VirtualBox

Changeset 39568 in vbox


Ignore:
Timestamp:
Dec 9, 2011 1:52:31 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75322
Message:

crOpenGL: more threading fixes

Location:
trunk/src/VBox
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/context.c

    r37986 r39568  
    309309}
    310310
     311static void stubWindowCheckOwnerCB(unsigned long key, void *data1, void *data2);
     312
     313static void
     314stubDestroyContextLocked( ContextInfo *context )
     315{
     316    unsigned long contextId = context->id;
     317    if (context->type == NATIVE) {
     318#ifdef WINDOWS
     319        stub.wsInterface.wglDeleteContext( context->hglrc );
     320#elif defined(Darwin)
     321        stub.wsInterface.CGLDestroyContext( context->cglc );
     322#elif defined(GLX)
     323        stub.wsInterface.glXDestroyContext( context->dpy, context->glxContext );
     324#endif
     325    }
     326    else if (context->type == CHROMIUM) {
     327        /* Have pack SPU or tilesort SPU, etc. destroy the context */
     328        CRASSERT(context->spuContext >= 0);
     329        stub.spu->dispatch_table.DestroyContext( context->spuContext );
     330        crHashtableWalk(stub.windowTable, stubWindowCheckOwnerCB, context);
     331    }
     332
     333#ifdef GLX
     334    crFreeHashtable(context->pGLXPixmapsHash, crFree);
     335    if (context->damageDpy)
     336    {
     337        XCloseDisplay(context->damageDpy);
     338    }
     339#endif
     340
     341    crMemZero(context, sizeof(ContextInfo));  /* just to be safe */
     342    crHashtableDelete(stub.contextTable, contextId, crFree);
     343}
     344
     345#ifdef CHROMIUM_THREADSAFE
     346static DECLCALLBACK(void) stubContextDtor(void*pvContext)
     347{
     348    crHashtableLock(stub.contextTable);
     349    stubDestroyContextLocked((ContextInfo*)pvContext);
     350    crHashtableUnlock(stub.contextTable);
     351}
     352#endif
    311353
    312354/**
     
    353395    crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME);
    354396    context->dpyName[MAX_DPY_NAME-1] = 0;
     397
     398#ifdef CHROMIUM_THREADSAFE
     399    crTSDRefInit(context, stubContextDtor);
     400#endif
    355401
    356402#if defined(GLX) || defined(DARWIN)
     
    925971
    926972    if (!context || !window) {
    927         if (stub.currentContext)
    928             stub.currentContext->currentDrawable = NULL;
     973        ContextInfo * currentContext = stubGetCurrentContext();
     974        if (currentContext)
     975            currentContext->currentDrawable = NULL;
    929976        if (context)
    930977            context->currentDrawable = NULL;
    931         stub.currentContext = NULL;
     978        stubSetCurrentContext(NULL);
    932979        return GL_TRUE;  /* OK */
    933980    }
     
    10621109    window->pOwner = context;
    10631110    context->currentDrawable = window;
    1064     stub.currentContext = context;
     1111    stubSetCurrentContext(context);
    10651112
    10661113    if (retVal) {
     
    11401187    CRASSERT(context);
    11411188
    1142     if (context->type == NATIVE) {
    1143 #ifdef WINDOWS
    1144         stub.wsInterface.wglDeleteContext( context->hglrc );
    1145 #elif defined(Darwin)
    1146         stub.wsInterface.CGLDestroyContext( context->cglc );
    1147 #elif defined(GLX)
    1148         stub.wsInterface.glXDestroyContext( context->dpy, context->glxContext );
    1149 #endif
    1150     }
    1151     else if (context->type == CHROMIUM) {
    1152         /* Have pack SPU or tilesort SPU, etc. destroy the context */
    1153         CRASSERT(context->spuContext >= 0);
    1154         stub.spu->dispatch_table.DestroyContext( context->spuContext );
    1155         crHashtableWalk(stub.windowTable, stubWindowCheckOwnerCB, context);
    1156     }
    1157 
    1158     if (stub.currentContext == context) {
    1159         stub.currentContext = NULL;
    1160     }
    1161 
    1162 #ifdef GLX
    1163     crFreeHashtable(context->pGLXPixmapsHash, crFree);
    1164     if (context->damageDpy)
    1165     {
    1166         XCloseDisplay(context->damageDpy);
    1167     }
    1168 #endif
    1169 
    1170     crMemZero(context, sizeof(ContextInfo));  /* just to be safe */
    1171     crHashtableDelete(stub.contextTable, contextId, crFree);
    1172 
     1189#ifdef CHROMIUM_THREADSAFE
     1190    if (stubGetCurrentContext() == context) {
     1191        stubSetCurrentContext(NULL);
     1192    }
     1193
     1194    crTSDRefRelease(context);
     1195#else
     1196    stubDestroyContextLocked(context);
     1197
     1198    if (stubGetCurrentContext() == context) {
     1199        stubSetCurrentContext(NULL);
     1200    }
     1201#endif
    11731202    crHashtableUnlock(stub.contextTable);
    11741203}
  • trunk/src/VBox/Additions/common/crOpenGL/glx.c

    r37986 r39568  
    10431043DECLEXPORT(GLXContext) VBOXGLXTAG(glXGetCurrentContext)( void )
    10441044{
    1045     if (stub.currentContext)
    1046         return (GLXContext) stub.currentContext->id;
     1045    ContextInfo *context = stubGetCurrentContext();
     1046    if (context)
     1047        return (GLXContext) context->id;
    10471048    else
    10481049        return (GLXContext) NULL;
     
    11821183DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase )
    11831184{
    1184     if (stub.currentContext->type == CHROMIUM)
     1185    ContextInfo *context = stubGetCurrentContext();
     1186    if (context->type == CHROMIUM)
    11851187    {
    11861188        Display *dpy = stub.wsInterface.glXGetCurrentDisplay();
     
    12011203DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase )
    12021204{
    1203     Display *dpy = stub.currentContext->dpy;
     1205    ContextInfo *context = stubGetCurrentContext();
     1206    Display *dpy = context->dpy;
    12041207    if (dpy) {
    12051208        stubUseXFont( dpy, font, first, count, listBase );
     
    24792482    if (event->type==damage_evb+XDamageNotify)
    24802483    {
     2484        ContextInfo *context = stubGetCurrentContext();
    24812485        XDamageNotifyEvent *e = (XDamageNotifyEvent *) event;
    24822486        /* we're interested in pixmaps only...and those have e->drawable set to 0 or other strange value for some odd reason
     
    24862490                (unsigned int) e->drawable, (unsigned int) e->damage, (int) e->level,
    24872491                e->area.x, e->area.y, e->area.width, e->area.height);*/
    2488         CRASSERT(stub.currentContext);
    2489         crHashtableWalk(stub.currentContext->pGLXPixmapsHash, checkdamageCB, e);
     2492        CRASSERT(context);
     2493        crHashtableWalk(context->pGLXPixmapsHash, checkdamageCB, e);
    24902494    }
    24912495    return False;
     
    24982502    static int cnt=0;
    24992503    XImage dummyimg;
     2504    ContextInfo *context = stubGetCurrentContext();
    25002505
    25012506    GLX_Pixmap_t *pGlxPixmap;
    25022507
    2503     if (!stub.currentContext)
     2508    if (!context)
    25042509    {
    25052510        crWarning("glXBindTexImageEXT called without current context");
     
    25072512    }
    25082513
    2509     pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(stub.currentContext->pGLXPixmapsHash, (unsigned int) draw);
     2514    pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(context->pGLXPixmapsHash, (unsigned int) draw);
    25102515    if (!pGlxPixmap)
    25112516    {
     
    25162521            return;
    25172522        }
    2518         pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, stub.currentContext);
     2523        pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, context);
    25192524        if (!pGlxPixmap)
    25202525        {
     
    25252530
    25262531    /* If there's damage extension, then process incoming events as we need the information right now */
    2527     if (stub.currentContext->damageDpy)
     2532    if (context->damageDpy)
    25282533    {
    25292534        /* Sync connections, note that order of syncs is important here.
     
    25322537        XSync(dpy, False);
    25332538        XUNLOCK(dpy);
    2534         XSync(stub.currentContext->damageDpy, False);
    2535 
    2536         while (XPending(stub.currentContext->damageDpy))
     2539        XSync(context->damageDpy, False);
     2540
     2541        while (XPending(context->damageDpy))
    25372542        {
    25382543            XEvent event;
    2539             XNextEvent(stub.currentContext->damageDpy, &event);
    2540             if (event.type==stub.currentContext->damageEventsBase+XDamageNotify)
     2544            XNextEvent(context->damageDpy, &event);
     2545            if (event.type==contextt->damageEventsBase+XDamageNotify)
    25412546            {
    2542                 crHashtableWalk(stub.currentContext->pGLXPixmapsHash, stubCheckXDamageCB, &event);
     2547                crHashtableWalk(contextt->pGLXPixmapsHash, stubCheckXDamageCB, &event);
    25432548            }
    25442549        }
     
    25902595    {
    25912596        /* Check if we have damage extension */
    2592         if (stub.currentContext->damageDpy)
     2597        if (context->damageDpy)
    25932598        {
    25942599            if (pGlxPixmap->bPixmapImageDirty)
  • trunk/src/VBox/Additions/common/crOpenGL/load.c

    r39485 r39568  
    6868/* NOTE: 'SPUDispatchTable stubThreadsafeDispatch' is declared in tsfuncs.c */
    6969Stub stub;
     70#ifdef CHROMIUM_THREADSAFE
     71CRtsd g_stubCurrentContextTSD;
     72#endif
    7073
    7174
     
    201204static void stubCheckWindowsState(void)
    202205{
     206    ContextInfo *context = stubGetCurrentContext();
     207
    203208    CRASSERT(stub.trackWindowSize || stub.trackWindowPos);
    204209
    205     if (!stub.currentContext)
     210    if (!context)
    206211        return;
    207212
     
    215220#endif
    216221
    217     stubCheckWindowState(stub.currentContext->currentDrawable, GL_TRUE);
    218     crHashtableWalk(stub.windowTable, stubCheckWindowsCB, stub.currentContext);
     222    stubCheckWindowState(context->currentDrawable, GL_TRUE);
     223    crHashtableWalk(stub.windowTable, stubCheckWindowsCB, context);
    219224
    220225#if defined(CR_NEWWINTRACK) && !defined(WINDOWS)
     
    250255    else
    251256    {
     257        ContextInfo *context = stubGetCurrentContext();
    252258        int winX, winY;
    253259        unsigned int winW, winH;
    254260        WindowInfo *pWindow;
    255         pWindow = stub.currentContext->currentDrawable;
     261        pWindow = context->currentDrawable;
    256262        stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH);
    257263        origViewport(0, 0, winW, winH);
     
    276282    unsigned int winW, winH;
    277283    WindowInfo *pWindow;
    278     pWindow = stub.currentContext->currentDrawable;
     284    ContextInfo *context = stubGetCurrentContext();
     285    pWindow = context->currentDrawable;
    279286    stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH);
    280287    origScissor(0, 0, winW, winH);
     
    538545    stub.freeContextNumber = MAGIC_CONTEXT_BASE;
    539546    stub.contextTable = crAllocHashtable();
    540     stub.currentContext = NULL;
     547#ifndef RT_OS_WINDOWS
     548# ifdef CHROMIUM_THREADSAFE
     549    crInitTSD(&g_stubCurrentContextTSD);
     550# endif
     551#endif
     552    stubSetCurrentContext(NULL);
    541553
    542554    stub.windowTable = crAllocHashtable();
     
    13671379        CRNetServer ns;
    13681380
     1381#ifdef CHROMIUM_THREADSAFE
     1382        crInitTSD(&g_stubCurrentContextTSD);
     1383#endif
     1384
    13691385        crInitMutex(&stub_init_mutex);
    13701386
     
    14021418    }
    14031419
     1420    case DLL_THREAD_ATTACH:
     1421    {
    14041422#if 0
    1405     case DLL_THREAD_ATTACH:
    1406     {
    14071423        if (stub_initialized)
    14081424        {
     
    14101426            stub.spu->dispatch_table.VBoxPackAttachThread();
    14111427        }
     1428#endif
    14121429        break;
    14131430    }
     
    14151432    case DLL_THREAD_DETACH:
    14161433    {
     1434        stubSetCurrentContext(NULL);
     1435#if 0
    14171436        if (stub_initialized)
    14181437        {
     
    14201439            stub.spu->dispatch_table.VBoxPackDetachThread();
    14211440        }
     1441#endif
    14221442        break;
    14231443    }
    1424 #endif
    14251444
    14261445    default:
  • trunk/src/VBox/Additions/common/crOpenGL/stub.c

    r37986 r39568  
    8888GLint APIENTRY crGetCurrentContext( void )
    8989{
     90    ContextInfo *context;
    9091    stubInit();
    91     if (stub.currentContext)
    92       return (GLint) stub.currentContext->id;
     92    context = stubGetCurrentContext();
     93    if (context)
     94      return (GLint) context->id;
    9395    else
    9496      return 0;
     
    9799GLint APIENTRY crGetCurrentWindow( void )
    98100{
     101    ContextInfo *context;
    99102    stubInit();
    100     if (stub.currentContext && stub.currentContext->currentDrawable)
    101       return stub.currentContext->currentDrawable->spuWindow;
     103    context = stubGetCurrentContext();
     104    if (context && context->currentDrawable)
     105      return context->currentDrawable->spuWindow;
    102106    else
    103107      return -1;
  • trunk/src/VBox/Additions/common/crOpenGL/stub.h

    r34295 r39568  
    111111    GLint visBits;
    112112    WindowInfo *currentDrawable;
     113
     114#ifdef CHROMIUM_THREADSAFE
     115    CRTSDREFDATA
     116#endif
    113117
    114118#ifdef WINDOWS
     
    225229    int freeContextNumber;
    226230    CRHashTable *contextTable;
     231#ifndef CHROMIUM_THREADSAFE
    227232    ContextInfo *currentContext; /* may be NULL */
     233#endif
    228234
    229235    /* windows */
     
    258264} Stub;
    259265
     266#ifdef CHROMIUM_THREADSAFE
     267# define stubGetCurrentContext() crTSDRefGetCurrent(ContextInfo, &g_stubCurrentContextTSD)
     268# define stubSetCurrentContext(_ctx) crTSDRefSetCurrent(ContextInfo, &g_stubCurrentContextTSD, _ctx)
     269#else
     270# define stubGetCurrentContext() (stub.currentContext)
     271# define stubSetCurrentContext(_ctx) do { stub.currentContext = (_ctx); } while (0)
     272#endif
    260273
    261274extern Stub stub;
     275/* we place the __currentContextTSD outside the Stub data because Stub data is inited by the client's call,
     276 * while we need __currentContextTSD the __currentContextTSD to be valid at any time to be able to handle
     277 * THREAD_DETACH cleanup on windows.
     278 * Note that we can not do
     279 *  STUB_INIT_LOCK();
     280 *  if (stub_initialized) stubSetCurrentContext(NULL);
     281 *  STUB_INIT_UNLOCK();
     282 * on THREAD_DETACH since it may cause deadlock, i.e. in this situation loader lock is acquired first and then the init lock,
     283 * but since we use GetModuleFileName in crGetProcName called from stubInitLocked, the lock order might be the oposite.
     284 * Note that GetModuleFileName acquires the loader lock.
     285 * */
     286#ifdef CHROMIUM_THREADSAFE
     287extern CRtsd g_stubCurrentContextTSD;
     288#endif
    262289extern DECLEXPORT(SPUDispatchTable) glim;
    263290extern SPUDispatchTable stubThreadsafeDispatch;
  • trunk/src/VBox/Additions/common/crOpenGL/wgl.c

    r38244 r39568  
    186186HGLRC WINAPI wglGetCurrentContext_prox( void )
    187187{
    188     return (HGLRC) (stub.currentContext ? stub.currentContext->id : 0);
     188    ContextInfo *context = stubGetCurrentContext();
     189    return (HGLRC) (context ? context->id : 0);
    189190}
    190191
    191192HDC WINAPI wglGetCurrentDC_prox( void )
    192193{
    193     if (stub.currentContext && stub.currentContext->currentDrawable)
    194         return (HDC) stub.currentContext->currentDrawable->drawable;
     194    ContextInfo *context = stubGetCurrentContext();
     195    if (context && context->currentDrawable)
     196        return (HDC) context->currentDrawable->drawable;
    195197    else
    196198        return (HDC) NULL;
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h

    r39507 r39568  
    4646#include "spu_dispatch_table.h"
    4747
     48#ifdef CHROMIUM_THREADSAFE
     49#include "cr_threads.h"
     50#endif
     51
    4852#include <iprt/cdefs.h>
    4953
     
    129133     * => Thread2 still refers to destroyed ctx1
    130134     * */
    131     /* number of threads that have context set as current */
    132     volatile int cRefs;
     135    CRTSDREFDATA
    133136#endif
    134137
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_threads.h

    r15532 r39568  
    2525#endif
    2626
    27 
     27#include <iprt/asm.h>
    2828/*
    2929 * Handle for Thread-Specific Data
     
    101101extern DECLEXPORT(void) crSignalSemaphore(CRsemaphore *s);
    102102
     103typedef DECLCALLBACK(void) FNCRTSDREFDTOR(void*);
     104typedef FNCRTSDREFDTOR *PFNCRTSDREFDTOR;
    103105
     106typedef enum {
     107    CRTSDREFDATA_STATE_UNDEFINED = 0,
     108    CRTSDREFDATA_STATE_INITIALIZED,
     109    CRTSDREFDATA_STATE_TOBE_DESTROYED,
     110    CRTSDREFDATA_STATE_DESTROYING,
     111    CRTSDREFDATA_STATE_32BIT_HACK = 0x7fffffff
     112} CRTSDREFDATA_STATE;
     113
     114#define CRTSDREFDATA \
     115    volatile uint32_t cTsdRefs; \
     116    uint32_t enmTsdRefState; \
     117    PFNCRTSDREFDTOR pfnTsdRefDtor; \
     118
     119#define crTSDRefInit(_p, _pfnDtor) do { \
     120        (_p)->cTsdRefs = 1; \
     121        (_p)->enmTsdRefState = CRTSDREFDATA_STATE_INITIALIZED; \
     122        (_p)->pfnTsdRefDtor = (_pfnDtor); \
     123    } while (0)
     124
     125#define crTSDRefIsFunctional(_p) (!!((_p)->enmTsdRefState == CRTSDREFDATA_STATE_INITIALIZED))
     126
     127#define crTSDRefAddRef(_p) do { \
     128        int cRefs = ASMAtomicIncS32(&(_p)->cTsdRefs); \
     129        CRASSERT(cRefs > 1 || (_p)->enmTsdRefState == CRTSDREFDATA_STATE_DESTROYING); \
     130    } while (0)
     131
     132#define crTSDRefRelease(_p) do { \
     133        int cRefs = ASMAtomicDecS32(&(_p)->cTsdRefs); \
     134        CRASSERT(cRefs >= 0); \
     135        if (!cRefs && (_p)->enmTsdRefState != CRTSDREFDATA_STATE_DESTROYING /* <- avoid recursion if crTSDRefAddRef/Release is called from dtor */) { \
     136            (_p)->enmTsdRefState = CRTSDREFDATA_STATE_DESTROYING; \
     137            (_p)->pfnTsdRefDtor((_p)); \
     138        } \
     139    } while (0)
     140
     141#define crTSDRefReleaseMarkDestroy(_p) do { \
     142        (_p)->enmTsdRefState = CRTSDREFDATA_STATE_TOBE_DESTROYED; \
     143    } while (0)
     144
     145#define crTSDRefGetCurrent(_t, _pTsd) ((_t*) crGetTSD((_pTsd)))
     146
     147#define crTSDRefSetCurrent(_t, _pTsd, _p) do { \
     148        _t * oldCur = crTSDRefGetCurrent(_t, _pTsd); \
     149        if (oldCur != (_p)) { \
     150            crSetTSD((_pTsd), (_p)); \
     151            if (oldCur) { \
     152                crTSDRefRelease(oldCur); \
     153            } \
     154            if ((_p)) { \
     155                crTSDRefAddRef((_t*)(_p)); \
     156            } \
     157        } \
     158    } while (0)
    104159#ifdef __cplusplus
    105160}
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state.h

    r39507 r39568  
    1111#ifdef CHROMIUM_THREADSAFE
    1212#include "cr_threads.h"
    13 #include <iprt/asm.h>
    1413#endif
    1514
     
    2524#ifdef CHROMIUM_THREADSAFE
    2625extern CRtsd __contextTSD;
    27 #define GetCurrentContext() (CRContext *) crGetTSD(&__contextTSD)
     26#define GetCurrentContext() crTSDRefGetCurrent(CRContext, &__contextTSD)
    2827
    29 /* NOTE: below ref & SetCurrentContext stuff is supposed to be used only internally!!
     28/* NOTE: below SetCurrentContext stuff is supposed to be used only internally!!
    3029 * it is placed here only to simplify things since some code besides state_init.c
    3130 * (i.e. state_glsl.c) is using it */
    32 void crStateFreeContext(CRContext *ctx);
    33 #define CRCONTEXT_ADDREF(_ctx) do { \
    34         int cRefs = ASMAtomicIncS32(&((CRContext*)(_ctx))->cRefs); \
    35         CRASSERT(cRefs > 1); \
    36     } while (0)
    37 #define CRCONTEXT_RELEASE(_ctx) do { \
    38         int cRefs = ASMAtomicDecS32(&((CRContext*)(_ctx))->cRefs); \
    39         CRASSERT(cRefs >= 0); \
    40         if (!cRefs) { \
    41             crStateFreeContext((_ctx)); \
    42         } \
    43     } while (0)
    44 #define SetCurrentContext(_ctx) do { \
    45         CRContext * oldCur = GetCurrentContext(); \
    46         if (oldCur != (_ctx)) { \
    47             if (oldCur) { \
    48                 CRCONTEXT_RELEASE(oldCur); \
    49             } \
    50             if ((_ctx)) { \
    51                 CRCONTEXT_ADDREF(_ctx); \
    52             } \
    53             crSetTSD(&__contextTSD, _ctx); \
    54         } \
    55     } while (0)
     31#define SetCurrentContext(_ctx) crTSDRefSetCurrent(CRContext, &__contextTSD, _ctx)
    5632#else
    5733extern CRContext *__currentContext;
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c

    r39529 r39568  
    174174      as the current context isn't the one being destroyed*/
    175175#ifdef CHROMIUM_THREADSAFE
    176     CRASSERT(!ctx->cRefs);
    177     ++ctx->cRefs; /* <- this is a hack to avoid subsequent SetCurrentContext(g) do recursive Destroy for ctx */
     176    CRASSERT(g != ctx);
     177    crTSDRefAddRef(ctx); /* <- this is a hack to avoid subsequent SetCurrentContext(g) do recursive Destroy for ctx */
    178178    if (g)
    179         CRCONTEXT_ADDREF(g); /* <- ensure the g is not destroyed by the following SetCurrentContext call */
     179        crTSDRefAddRef(g); /* <- ensure the g is not destroyed by the following SetCurrentContext call */
    180180    SetCurrentContext(ctx);
    181181#else
     
    189189    SetCurrentContext(g);
    190190    if (g)
    191         CRCONTEXT_RELEASE(g);
    192     --ctx->cRefs; /* <- restore back the cRefs (see above) */
     191        crTSDRefRelease(g);
     192    crTSDRefRelease(ctx); /* <- restore back the cRefs (see above) */
    193193#else
    194194    __currentContext = g;
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c

    r39507 r39568  
    145145}
    146146
     147#ifdef CHROMIUM_THREADSAFE
     148static void
     149crStateFreeContext(CRContext *ctx);
     150static DECLCALLBACK(void) crStateContextDtor(void *pvCtx)
     151{
     152    crStateFreeContext((CRContext*)pvCtx);
     153}
     154#endif
     155
    147156/*
    148157 * Helper for crStateCreateContext, below.
     
    159168    ctx->id = i;
    160169#ifdef CHROMIUM_THREADSAFE
    161     ctx->cRefs = 1;
     170    crTSDRefInit(ctx, crStateContextDtor);
    162171#endif
    163172    ctx->flush_func = NULL;
     
    261270
    262271/*@todo crStateAttribDestroy*/
    263 void
     272static void
    264273crStateFreeContext(CRContext *ctx)
    265274{
     
    312321#ifdef CHROMIUM_THREADSAFE
    313322        SetCurrentContext(NULL);
    314         CRCONTEXT_RELEASE(defaultContext);
     323        crTSDRefRelease(defaultContext);
    315324#else
    316325        crStateFreeContext(defaultContext);
     
    448457
    449458#ifdef CHROMIUM_THREADSAFE
    450     CRCONTEXT_RELEASE(ctx);
     459    crTSDRefRelease(ctx);
    451460#else
    452461    crStateFreeContext(ctx);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette