Changeset 39568 in vbox for trunk/src/VBox/Additions/common/crOpenGL
- Timestamp:
- Dec 9, 2011 1:52:31 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75322
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/context.c
r37986 r39568 309 309 } 310 310 311 static void stubWindowCheckOwnerCB(unsigned long key, void *data1, void *data2); 312 313 static void 314 stubDestroyContextLocked( 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 346 static DECLCALLBACK(void) stubContextDtor(void*pvContext) 347 { 348 crHashtableLock(stub.contextTable); 349 stubDestroyContextLocked((ContextInfo*)pvContext); 350 crHashtableUnlock(stub.contextTable); 351 } 352 #endif 311 353 312 354 /** … … 353 395 crStrncpy(context->dpyName, dpyName, MAX_DPY_NAME); 354 396 context->dpyName[MAX_DPY_NAME-1] = 0; 397 398 #ifdef CHROMIUM_THREADSAFE 399 crTSDRefInit(context, stubContextDtor); 400 #endif 355 401 356 402 #if defined(GLX) || defined(DARWIN) … … 925 971 926 972 if (!context || !window) { 927 if (stub.currentContext) 928 stub.currentContext->currentDrawable = NULL; 973 ContextInfo * currentContext = stubGetCurrentContext(); 974 if (currentContext) 975 currentContext->currentDrawable = NULL; 929 976 if (context) 930 977 context->currentDrawable = NULL; 931 stub .currentContext = NULL;978 stubSetCurrentContext(NULL); 932 979 return GL_TRUE; /* OK */ 933 980 } … … 1062 1109 window->pOwner = context; 1063 1110 context->currentDrawable = window; 1064 stub .currentContext = context;1111 stubSetCurrentContext(context); 1065 1112 1066 1113 if (retVal) { … … 1140 1187 CRASSERT(context); 1141 1188 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 1173 1202 crHashtableUnlock(stub.contextTable); 1174 1203 } -
trunk/src/VBox/Additions/common/crOpenGL/glx.c
r37986 r39568 1043 1043 DECLEXPORT(GLXContext) VBOXGLXTAG(glXGetCurrentContext)( void ) 1044 1044 { 1045 if (stub.currentContext) 1046 return (GLXContext) stub.currentContext->id; 1045 ContextInfo *context = stubGetCurrentContext(); 1046 if (context) 1047 return (GLXContext) context->id; 1047 1048 else 1048 1049 return (GLXContext) NULL; … … 1182 1183 DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase ) 1183 1184 { 1184 if (stub.currentContext->type == CHROMIUM) 1185 ContextInfo *context = stubGetCurrentContext(); 1186 if (context->type == CHROMIUM) 1185 1187 { 1186 1188 Display *dpy = stub.wsInterface.glXGetCurrentDisplay(); … … 1201 1203 DECLEXPORT(void) VBOXGLXTAG(glXUseXFont)( Font font, int first, int count, int listBase ) 1202 1204 { 1203 Display *dpy = stub.currentContext->dpy; 1205 ContextInfo *context = stubGetCurrentContext(); 1206 Display *dpy = context->dpy; 1204 1207 if (dpy) { 1205 1208 stubUseXFont( dpy, font, first, count, listBase ); … … 2479 2482 if (event->type==damage_evb+XDamageNotify) 2480 2483 { 2484 ContextInfo *context = stubGetCurrentContext(); 2481 2485 XDamageNotifyEvent *e = (XDamageNotifyEvent *) event; 2482 2486 /* we're interested in pixmaps only...and those have e->drawable set to 0 or other strange value for some odd reason … … 2486 2490 (unsigned int) e->drawable, (unsigned int) e->damage, (int) e->level, 2487 2491 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); 2490 2494 } 2491 2495 return False; … … 2498 2502 static int cnt=0; 2499 2503 XImage dummyimg; 2504 ContextInfo *context = stubGetCurrentContext(); 2500 2505 2501 2506 GLX_Pixmap_t *pGlxPixmap; 2502 2507 2503 if (! stub.currentContext)2508 if (!context) 2504 2509 { 2505 2510 crWarning("glXBindTexImageEXT called without current context"); … … 2507 2512 } 2508 2513 2509 pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch( stub.currentContext->pGLXPixmapsHash, (unsigned int) draw);2514 pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(context->pGLXPixmapsHash, (unsigned int) draw); 2510 2515 if (!pGlxPixmap) 2511 2516 { … … 2516 2521 return; 2517 2522 } 2518 pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, stub.currentContext);2523 pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, context); 2519 2524 if (!pGlxPixmap) 2520 2525 { … … 2525 2530 2526 2531 /* 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) 2528 2533 { 2529 2534 /* Sync connections, note that order of syncs is important here. … … 2532 2537 XSync(dpy, False); 2533 2538 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)) 2537 2542 { 2538 2543 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) 2541 2546 { 2542 crHashtableWalk( stub.currentContext->pGLXPixmapsHash, stubCheckXDamageCB, &event);2547 crHashtableWalk(contextt->pGLXPixmapsHash, stubCheckXDamageCB, &event); 2543 2548 } 2544 2549 } … … 2590 2595 { 2591 2596 /* Check if we have damage extension */ 2592 if ( stub.currentContext->damageDpy)2597 if (context->damageDpy) 2593 2598 { 2594 2599 if (pGlxPixmap->bPixmapImageDirty) -
trunk/src/VBox/Additions/common/crOpenGL/load.c
r39485 r39568 68 68 /* NOTE: 'SPUDispatchTable stubThreadsafeDispatch' is declared in tsfuncs.c */ 69 69 Stub stub; 70 #ifdef CHROMIUM_THREADSAFE 71 CRtsd g_stubCurrentContextTSD; 72 #endif 70 73 71 74 … … 201 204 static void stubCheckWindowsState(void) 202 205 { 206 ContextInfo *context = stubGetCurrentContext(); 207 203 208 CRASSERT(stub.trackWindowSize || stub.trackWindowPos); 204 209 205 if (! stub.currentContext)210 if (!context) 206 211 return; 207 212 … … 215 220 #endif 216 221 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); 219 224 220 225 #if defined(CR_NEWWINTRACK) && !defined(WINDOWS) … … 250 255 else 251 256 { 257 ContextInfo *context = stubGetCurrentContext(); 252 258 int winX, winY; 253 259 unsigned int winW, winH; 254 260 WindowInfo *pWindow; 255 pWindow = stub.currentContext->currentDrawable;261 pWindow = context->currentDrawable; 256 262 stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH); 257 263 origViewport(0, 0, winW, winH); … … 276 282 unsigned int winW, winH; 277 283 WindowInfo *pWindow; 278 pWindow = stub.currentContext->currentDrawable; 284 ContextInfo *context = stubGetCurrentContext(); 285 pWindow = context->currentDrawable; 279 286 stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH); 280 287 origScissor(0, 0, winW, winH); … … 538 545 stub.freeContextNumber = MAGIC_CONTEXT_BASE; 539 546 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); 541 553 542 554 stub.windowTable = crAllocHashtable(); … … 1367 1379 CRNetServer ns; 1368 1380 1381 #ifdef CHROMIUM_THREADSAFE 1382 crInitTSD(&g_stubCurrentContextTSD); 1383 #endif 1384 1369 1385 crInitMutex(&stub_init_mutex); 1370 1386 … … 1402 1418 } 1403 1419 1420 case DLL_THREAD_ATTACH: 1421 { 1404 1422 #if 0 1405 case DLL_THREAD_ATTACH:1406 {1407 1423 if (stub_initialized) 1408 1424 { … … 1410 1426 stub.spu->dispatch_table.VBoxPackAttachThread(); 1411 1427 } 1428 #endif 1412 1429 break; 1413 1430 } … … 1415 1432 case DLL_THREAD_DETACH: 1416 1433 { 1434 stubSetCurrentContext(NULL); 1435 #if 0 1417 1436 if (stub_initialized) 1418 1437 { … … 1420 1439 stub.spu->dispatch_table.VBoxPackDetachThread(); 1421 1440 } 1441 #endif 1422 1442 break; 1423 1443 } 1424 #endif1425 1444 1426 1445 default: -
trunk/src/VBox/Additions/common/crOpenGL/stub.c
r37986 r39568 88 88 GLint APIENTRY crGetCurrentContext( void ) 89 89 { 90 ContextInfo *context; 90 91 stubInit(); 91 if (stub.currentContext) 92 return (GLint) stub.currentContext->id; 92 context = stubGetCurrentContext(); 93 if (context) 94 return (GLint) context->id; 93 95 else 94 96 return 0; … … 97 99 GLint APIENTRY crGetCurrentWindow( void ) 98 100 { 101 ContextInfo *context; 99 102 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; 102 106 else 103 107 return -1; -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r34295 r39568 111 111 GLint visBits; 112 112 WindowInfo *currentDrawable; 113 114 #ifdef CHROMIUM_THREADSAFE 115 CRTSDREFDATA 116 #endif 113 117 114 118 #ifdef WINDOWS … … 225 229 int freeContextNumber; 226 230 CRHashTable *contextTable; 231 #ifndef CHROMIUM_THREADSAFE 227 232 ContextInfo *currentContext; /* may be NULL */ 233 #endif 228 234 229 235 /* windows */ … … 258 264 } Stub; 259 265 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 260 273 261 274 extern 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 287 extern CRtsd g_stubCurrentContextTSD; 288 #endif 262 289 extern DECLEXPORT(SPUDispatchTable) glim; 263 290 extern SPUDispatchTable stubThreadsafeDispatch; -
trunk/src/VBox/Additions/common/crOpenGL/wgl.c
r38244 r39568 186 186 HGLRC WINAPI wglGetCurrentContext_prox( void ) 187 187 { 188 return (HGLRC) (stub.currentContext ? stub.currentContext->id : 0); 188 ContextInfo *context = stubGetCurrentContext(); 189 return (HGLRC) (context ? context->id : 0); 189 190 } 190 191 191 192 HDC WINAPI wglGetCurrentDC_prox( void ) 192 193 { 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; 195 197 else 196 198 return (HDC) NULL;
Note:
See TracChangeset
for help on using the changeset viewer.