Changeset 44766 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render
- Timestamp:
- Feb 20, 2013 3:43:52 PM (12 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL/render
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r44740 r44766 129 129 } 130 130 131 static ContextInfo * renderspuCreateContextInternal(const char *dpyName, GLint visBits, ContextInfo * sharedContext)131 static ContextInfo * renderspuCreateContextInternal(const char *dpyName, GLint visBits, GLint idCtx, ContextInfo * sharedContext) 132 132 { 133 133 ContextInfo *context; 134 134 VisualInfo *visual; 135 136 if (idCtx <= 0) 137 { 138 idCtx = (GLint)crHashtableAllocKeys(render_spu.contextTable, 1); 139 if (idCtx <= 0) 140 { 141 crWarning("failed to allocate context id"); 142 return NULL; 143 } 144 } 145 else 146 { 147 if (crHashtableIsKeyUsed(render_spu.contextTable, idCtx)) 148 { 149 crWarning("the specified ctx key %d is in use", idCtx); 150 return NULL; 151 } 152 } 153 135 154 136 155 if (!dpyName || crStrlen(render_spu.display_string)>0) … … 144 163 if (!context) 145 164 return NULL; 146 context->BltInfo.Base.id = render_spu.context_id;165 context->BltInfo.Base.id = idCtx; 147 166 context->shared = sharedContext; 148 167 if (!renderspu_SystemCreateContext(visual, context, sharedContext)) 149 168 return NULL; 150 169 151 crHashtableAdd(render_spu.contextTable, render_spu.context_id, context); 152 render_spu.context_id++; 170 crHashtableAdd(render_spu.contextTable, idCtx, context); 153 171 154 172 context->BltInfo.Base.visualBits = visual->visAttribs; … … 161 179 } 162 180 181 GLint renderspuCreateContextEx(const char *dpyName, GLint visBits, GLint id, GLint shareCtx) 182 { 183 ContextInfo *context, *sharedContext = NULL; 184 185 if (shareCtx) { 186 sharedContext 187 = (ContextInfo *) crHashtableSearch(render_spu.contextTable, shareCtx); 188 CRASSERT(sharedContext); 189 } 190 191 context = renderspuCreateContextInternal(dpyName, visBits, id, sharedContext); 192 if (context) 193 return context->BltInfo.Base.id; 194 return -1; 195 } 196 163 197 /* 164 198 * Context functions … … 168 202 renderspuCreateContext(const char *dpyName, GLint visBits, GLint shareCtx) 169 203 { 170 ContextInfo *context, *sharedContext = NULL; 171 bool fHasShared; 172 173 if (shareCtx > 0) 174 fHasShared = true; 175 else if (shareCtx == -1) 176 { 177 shareCtx = 0; 178 fHasShared = true; 179 } 180 else 181 fHasShared = false; 182 183 if (fHasShared) { 184 sharedContext 185 = (ContextInfo *) crHashtableSearch(render_spu.contextTable, shareCtx); 186 CRASSERT(sharedContext); 187 } 188 189 context = renderspuCreateContextInternal(dpyName, visBits, sharedContext); 190 if (context) 191 return context->BltInfo.Base.id; 192 return -1; 204 return renderspuCreateContextEx(dpyName, visBits, 0, shareCtx); 193 205 } 194 206 … … 200 212 CRASSERT(ctx); 201 213 202 if (ctx == 0)214 if (ctx == CR_RENDER_DEFAULT_CONTEXT_ID) 203 215 { 204 216 crWarning("request to destroy a default context, ignoring"); … … 213 225 if (curCtx == context) 214 226 { 215 renderspuMakeCurrent( 0, 0, 0);227 renderspuMakeCurrent( CR_RENDER_DEFAULT_WINDOW_ID, 0, CR_RENDER_DEFAULT_CONTEXT_ID ); 216 228 curCtx = GET_CONTEXT_VAL(); 217 229 Assert(curCtx); … … 277 289 context->everCurrent = GL_TRUE; 278 290 } 279 if (crWindow == 0&& window->mapPending &&291 if (crWindow == CR_RENDER_DEFAULT_WINDOW_ID && window->mapPending && 280 292 !render_spu.render_to_app_window && !render_spu.render_to_crut_window) { 281 /* Window[ 0] is special, it's the default window and normally hidden.293 /* Window[CR_RENDER_DEFAULT_CONTEXT_ID] is special, it's the default window and normally hidden. 282 294 * If the mapPending flag is set, then we should now make the window 283 295 * visible. … … 288 300 window->everCurrent = GL_TRUE; 289 301 } 290 else 302 else if (!crWindow && !ctx) 291 303 { 292 304 #ifdef CHROMIUM_THREADSAFE … … 295 307 render_spu.currentContext = NULL; 296 308 #endif 309 renderspu_SystemMakeCurrent( NULL, 0, NULL ); 310 } 311 else 312 { 313 crError("renderspuMakeCurrent invalid ids: crWindow(%d), ctx(%d)", crWindow, ctx); 297 314 } 298 315 } … … 303 320 */ 304 321 305 GLint RENDER_APIENTRY 306 renderspuWindowCreate( const char *dpyName, GLint visBits ) 322 GLint renderspuWindowCreateEx( const char *dpyName, GLint visBits, GLint id ) 307 323 { 308 324 WindowInfo *window; … … 310 326 GLboolean showIt; 311 327 328 if (id <= 0) 329 { 330 id = (GLint)crHashtableAllocKeys(render_spu.windowTable, 1); 331 if (id <= 0) 332 { 333 crWarning("failed to allocate window id"); 334 return -1; 335 } 336 } 337 else 338 { 339 if (crHashtableIsKeyUsed(render_spu.windowTable, id)) 340 { 341 crWarning("the specified window key %d is in use", id); 342 return -1; 343 } 344 } 345 346 312 347 if (!dpyName || crStrlen(render_spu.display_string) > 0) 313 348 dpyName = render_spu.display_string; … … 328 363 } 329 364 330 crHashtableAdd(render_spu.windowTable, render_spu.window_id, window); 331 window->BltInfo.Base.id = render_spu.window_id; 332 render_spu.window_id++; 365 RTCritSectInit(&window->CompositorLock); 366 window->pCompositor = NULL; 367 368 crHashtableAdd(render_spu.windowTable, id, window); 369 window->BltInfo.Base.id = id; 333 370 334 371 window->x = render_spu.defaultX; … … 341 378 showIt = 0; 342 379 else 343 showIt = window->BltInfo.Base.id > 0;380 showIt = window->BltInfo.Base.id != CR_RENDER_DEFAULT_WINDOW_ID; 344 381 345 382 /* Set window->title, replacing %i with the window ID number */ … … 381 418 } 382 419 420 GLint RENDER_APIENTRY 421 renderspuWindowCreate( const char *dpyName, GLint visBits ) 422 { 423 return renderspuWindowCreateEx( dpyName, visBits, 0 ); 424 } 425 383 426 static void renderspuCheckCurrentCtxWindowCB(unsigned long key, void *data1, void *data2) 384 427 { … … 389 432 if (pCtx->currentWindow==pWindow) 390 433 { 391 renderspuMakeCurrent( 0, 0, pCtx->BltInfo.Base.id);434 renderspuMakeCurrent(CR_RENDER_DEFAULT_WINDOW_ID, 0, pCtx->BltInfo.Base.id); 392 435 pCtx->currentWindow=0; 393 436 } … … 401 444 402 445 CRASSERT(win >= 0); 403 if (win == 0)446 if (win == CR_RENDER_DEFAULT_WINDOW_ID) 404 447 { 405 448 crWarning("request to destroy a default mural, ignoring"); … … 410 453 crDebug("Render SPU: Destroy window (%d)", win); 411 454 renderspu_SystemDestroyWindow( window ); 455 456 RTCritSectDelete(&window->CompositorLock); 457 window->pCompositor = NULL; 458 412 459 /* remove window info from hash table, and free it */ 413 460 crHashtableDelete(render_spu.windowTable, win, crFree); … … 421 468 if (pNewCtx!=pOldCtx) 422 469 { 423 renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id: 0, 0,424 pOldCtx ? pOldCtx->BltInfo.Base.id: 0);470 renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id:CR_RENDER_DEFAULT_WINDOW_ID, 0, 471 pOldCtx ? pOldCtx->BltInfo.Base.id:CR_RENDER_DEFAULT_CONTEXT_ID); 425 472 } 426 473 } … … 509 556 window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win); 510 557 if (window) { 558 renderspuVBoxCompositorSet( window, pCompositor); 559 /* renderspuVBoxPresentComposition can be invoked from the chromium thread only and is not reentrant, 560 * no need to acquire a compositor lock here */ 511 561 renderspu_SystemVBoxPresentComposition(window, pCompositor, pChangedEntry); 512 562 } … … 574 624 if (render_spu.blitterTable) 575 625 { 626 crHashtableLock(render_spu.blitterTable); 576 627 pBlitter = (PCR_BLITTER)crHashtableSearch(render_spu.blitterTable, window->visual->visAttribs); 577 628 } … … 599 650 return NULL; 600 651 } 601 } 652 653 if (render_spu.blitterTable) 654 { 655 crHashtableAdd( render_spu.blitterTable, window->visual->visAttribs, pBlitter ); 656 } 657 } 658 659 if (render_spu.blitterTable) 660 crHashtableUnlock(render_spu.blitterTable); 602 661 603 662 Assert(pBlitter); … … 612 671 { 613 672 int rc; 673 PCR_BLITTER_CONTEXT pCtxInfo = NULL; 674 PCR_BLITTER_WINDOW pWindowInfo = NULL; 614 675 GET_CONTEXT(pCtx); 615 676 616 if (!pCtx) 617 { 618 crWarning("renderspuVBoxPresentBlitterEnter: no current context!"); 619 return VERR_INVALID_STATE; 620 } 621 622 if (!pCtx->currentWindow) 623 { 624 crWarning("renderspuVBoxPresentBlitterEnter: no current window!"); 625 return VERR_INVALID_STATE; 626 } 627 628 rc = CrBltEnter(pBlitter, &pCtx->BltInfo, &pCtx->currentWindow->BltInfo); 677 if (pCtx) 678 { 679 if (pCtx->currentWindow) 680 { 681 pCtxInfo = &pCtx->BltInfo; 682 pWindowInfo = &pCtx->currentWindow->BltInfo; 683 } 684 } 685 686 rc = CrBltEnter(pBlitter, pCtxInfo, pWindowInfo); 629 687 if (!RT_SUCCESS(rc)) 630 688 { … … 647 705 } 648 706 return NULL; 707 } 708 709 PCR_BLITTER renderspuVBoxPresentBlitterEnsureCreated( WindowInfo *window ) 710 { 711 if (!window->pBlitter) 712 { 713 struct VBOXVR_SCR_COMPOSITOR * pTmpCompositor; 714 /* just use compositor lock to synchronize */ 715 pTmpCompositor = renderspuVBoxCompositorAcquire(window); 716 CRASSERT(pTmpCompositor); 717 if (pTmpCompositor) 718 { 719 PCR_BLITTER pBlitter = renderspuVBoxPresentBlitterGet( window ); 720 if (pBlitter) 721 { 722 if (!CrBltIsEverEntered(pBlitter)) 723 { 724 int rc = renderspuVBoxPresentBlitterEnter(pBlitter); 725 if (RT_SUCCESS(rc)) 726 { 727 CrBltLeave(pBlitter); 728 } 729 else 730 { 731 crWarning("renderspuVBoxPresentBlitterEnter failed rc %d", rc); 732 } 733 } 734 } 735 else 736 { 737 crWarning("renderspuVBoxPresentBlitterGet failed"); 738 } 739 740 renderspuVBoxCompositorRelease(window); 741 } 742 else 743 { 744 crWarning("renderspuVBoxCompositorAcquire failed"); 745 } 746 } 747 return window->pBlitter; 649 748 } 650 749 … … 657 756 renderspuVBoxCompositorBlit(pCompositor, pBlitter); 658 757 659 CrBltPresent(pBlitter);758 renderspu_SystemSwapBuffers(window, 0); 660 759 661 760 CrBltLeave(pBlitter); 662 761 } 762 763 void renderspuVBoxCompositorSet( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor) 764 { 765 int rc; 766 /* renderspuVBoxCompositorSet can be invoked from the chromium thread only and is not reentrant, 767 * no need to synch here 768 * the lock is actually needed to ensure we're in synch with the redraw thread */ 769 if (window->pCompositor == pCompositor) 770 return; 771 rc = RTCritSectEnter(&window->CompositorLock); 772 if (RT_SUCCESS(rc)) 773 { 774 window->pCompositor = pCompositor; 775 RTCritSectLeave(&window->CompositorLock); 776 return; 777 } 778 else 779 { 780 crWarning("RTCritSectEnter failed rc %d", rc); 781 } 782 } 783 784 struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window) 785 { 786 int rc = RTCritSectEnter(&window->CompositorLock); 787 if (RT_SUCCESS(rc)) 788 { 789 VBOXVR_SCR_COMPOSITOR * pCompositor = window->pCompositor; 790 if (pCompositor) 791 return pCompositor; 792 793 /* if no compositor is set, release the lock and return */ 794 RTCritSectLeave(&window->CompositorLock); 795 } 796 else 797 { 798 crWarning("RTCritSectEnter failed rc %d", rc); 799 } 800 return NULL; 801 } 802 803 int renderspuVBoxCompositorTryAcquire(WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR **ppCompositor) 804 { 805 int rc = RTCritSectTryEnter(&window->CompositorLock); 806 if (RT_SUCCESS(rc)) 807 { 808 *ppCompositor = window->pCompositor; 809 if (*ppCompositor) 810 return VINF_SUCCESS; 811 812 /* if no compositor is set, release the lock and return */ 813 RTCritSectLeave(&window->CompositorLock); 814 rc = VERR_INVALID_STATE; 815 } 816 else 817 { 818 *ppCompositor = NULL; 819 crWarning("RTCritSectTryEnter failed rc %d", rc); 820 } 821 return rc; 822 } 823 824 void renderspuVBoxCompositorRelease( WindowInfo *window) 825 { 826 int rc; 827 Assert(window->pCompositor); 828 rc = RTCritSectLeave(&window->CompositorLock); 829 if (!RT_SUCCESS(rc)) 830 { 831 crWarning("RTCritSectLeave failed rc %d", rc); 832 } 833 } 834 663 835 664 836 /* … … 1051 1223 case GL_WINDOW_SIZE_CR: 1052 1224 /* XXX this is old code that should be removed. 1053 * NOTE: we can only resize the default (id= 0) window!!!1225 * NOTE: we can only resize the default (id=CR_RENDER_DEFAULT_WINDOW_ID) window!!! 1054 1226 */ 1055 1227 { … … 1061 1233 w = ((GLint*)values)[0]; 1062 1234 h = ((GLint*)values)[1]; 1063 window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, 0);1235 window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, CR_RENDER_DEFAULT_WINDOW_ID); 1064 1236 if (window) 1065 1237 { -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
r44740 r44766 31 31 32 32 #include <iprt/cdefs.h> 33 #include <iprt/critsect.h> 33 34 34 35 #define MAX_VISUALS 32 … … 90 91 char *title; 91 92 93 PVBOXVR_SCR_COMPOSITOR pCompositor; 94 /* the composotor lock is used to synchronize the current compositor access, 95 * i.e. the compositor can be accessed by a gui refraw thread, 96 * while chromium thread might try to set a new compositor 97 * note that the compositor internally has its own lock to be used for accessing its data 98 * see CrVrScrCompositorLock/Unlock; renderspu and crserverlib would use it for compositor data access */ 99 RTCRITSECT CompositorLock; 92 100 PCR_BLITTER pBlitter; 93 101 #if defined(WINDOWS) … … 165 173 SPUDispatchTable self; 166 174 int id; 167 168 unsigned int window_id;169 unsigned int context_id;170 175 171 176 /** config options */ … … 330 335 extern void renderspu_GCWindow(void); 331 336 extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] ); 337 extern void renderspuVBoxCompositorSet( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor); 338 extern struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window); 339 extern int renderspuVBoxCompositorTryAcquire(WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR **ppCompositor); 340 extern void renderspuVBoxCompositorRelease( WindowInfo *window); 332 341 extern void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry ); 333 342 extern PCR_BLITTER renderspuVBoxPresentBlitterGet( WindowInfo *window ); 334 343 extern int renderspuVBoxPresentBlitterEnter( PCR_BLITTER pBlitter ); 335 344 extern PCR_BLITTER renderspuVBoxPresentBlitterGetAndEnter( WindowInfo *window ); 345 extern PCR_BLITTER renderspuVBoxPresentBlitterEnsureCreated( WindowInfo *window ); 336 346 extern void renderspuVBoxCompositorBlit ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter); 337 347 extern void renderspuVBoxCompositorBlitStretched ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY); 348 extern GLint renderspuCreateContextEx(const char *dpyName, GLint visBits, GLint id, GLint shareCtx); 349 extern GLint renderspuWindowCreateEx( const char *dpyName, GLint visBits, GLint id ); 338 350 339 351 extern GLint RENDER_APIENTRY renderspuWindowCreate( const char *dpyName, GLint visBits ); -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c
r44740 r44766 159 159 void renderspu_SystemMakeCurrent(WindowInfo *pWinInfo, GLint nativeWindow, ContextInfo *pCtxInfo) 160 160 { 161 CRASSERT(pWinInfo);162 CRASSERT(pCtxInfo);163 164 161 /* if(pWinInfo->visual != pCtxInfo->visual)*/ 165 162 /* printf ("visual mismatch .....................\n");*/ 166 163 167 cocoaViewMakeCurrentContext(pWinInfo->window, pCtxInfo->context); 164 if (pWinInfo && pCtxInfo) 165 cocoaViewMakeCurrentContext(pWinInfo->window, pCtxInfo->context); 166 else 167 cocoaViewMakeCurrentContext(NULL, NULL); 168 168 } 169 169 -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r44756 r44766 1593 1593 DEBUG_MSG(("cocoaViewMakeCurrentContext(%p, %p)\n", (void*)pView, (void*)pCtx)); 1594 1594 1595 [(OverlayView*)pView setGLCtx:pCtx]; 1596 [(OverlayView*)pView makeCurrentFBO]; 1595 if (pView) 1596 { 1597 [(OverlayView*)pView setGLCtx:pCtx]; 1598 [(OverlayView*)pView makeCurrentFBO]; 1599 } 1600 else 1601 { 1602 vboxCtxSetCurrent(NULL); 1603 } 1597 1604 1598 1605 [pPool release]; -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_config.c
r15532 r44766 322 322 void renderspuSetVBoxConfiguration( RenderSPU *render_spu ) 323 323 { 324 CRConnection *conn;325 324 int a; 326 325 -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c
r44740 r44766 1177 1177 1178 1178 CRASSERT(render_spu.ws.glXMakeCurrent); 1179 window->appWindow = nativeWindow;1180 1179 1181 1180 /*crDebug("%s nativeWindow=0x%x", __FUNCTION__, (int) nativeWindow);*/ … … 1192 1191 1193 1192 if (window && context) { 1193 window->appWindow = nativeWindow; 1194 1194 1195 if (window->visual != context->visual) { 1195 1196 crDebug("Render SPU: MakeCurrent visual mismatch (win(%d) bits:0x%x != ctx(%d) bits:0x%x); remaking window.", … … 1344 1345 } 1345 1346 #endif 1347 } 1348 else 1349 { 1350 GET_CONTEXT(pCurCtx); 1351 if (pCurCtx) 1352 { 1353 b = render_spu.ws.glXMakeCurrent( pCurCtx->currentWindow->visual->dpy, None, NULL); 1354 if (!b) { 1355 crWarning("glXMakeCurrent(%p, None, NULL) failed!", pCurCtx->currentWindow->visual->dpy); 1356 } 1357 } 1358 1346 1359 } 1347 1360 -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c
r44740 r44766 96 96 { 97 97 LPCREATESTRUCT pCS = (LPCREATESTRUCT) msg.lParam; 98 HWND *phWnd; 98 HWND hWnd; 99 WindowInfo *pWindow = (WindowInfo *)pCS->lpCreateParams; 99 100 100 101 CRASSERT(msg.lParam && !msg.wParam && pCS->lpCreateParams); 101 102 102 phWnd = pCS->lpCreateParams; 103 104 *phWnd = CreateWindowEx(pCS->dwExStyle, pCS->lpszName, pCS->lpszClass, pCS->style, 103 hWnd = CreateWindowEx(pCS->dwExStyle, pCS->lpszName, pCS->lpszClass, pCS->style, 105 104 pCS->x, pCS->y, pCS->cx, pCS->cy, 106 105 pCS->hwndParent, pCS->hMenu, pCS->hInstance, &render_spu); 106 107 pWindow->hWnd = hWnd; 107 108 108 109 SetEvent(render_spu.hWinThreadReadyEvent); … … 198 199 #endif 199 200 200 render_spu.window_id = 0; 201 render_spu.context_id = 0; 202 render_spu.contextTable = crAllocHashtable(); 203 render_spu.windowTable = crAllocHashtable(); 201 render_spu.contextTable = crAllocHashtableEx(1, INT32_MAX); 202 render_spu.windowTable = crAllocHashtableEx(1, INT32_MAX); 204 203 205 204 pcpwSetting = crGetenv("CR_RENDER_ENABLE_PRESENT_CONTEXT_PER_WINDOW"); … … 212 211 { 213 212 /* default is enable for OSX */ 214 #if defined(DARWIN) && defined(VBOX_WITH_COCOA_QT)213 #if 0 //defined(DARWIN) && defined(VBOX_WITH_COCOA_QT) 215 214 pcpwSetting = (char*)1; 216 215 #endif 217 216 218 217 } 218 219 219 220 220 if (pcpwSetting) … … 275 275 crDebug("Render SPU: Creating default window (visBits=0x%x, id=0)", 276 276 render_spu.default_visual); 277 defaultWin = renderspuWindowCreate ( NULL, render_spu.default_visual);278 if (defaultWin != 0) {277 defaultWin = renderspuWindowCreateEx( NULL, render_spu.default_visual, CR_RENDER_DEFAULT_WINDOW_ID ); 278 if (defaultWin != CR_RENDER_DEFAULT_WINDOW_ID) { 279 279 crError("Render SPU: Couldn't get a double-buffered, RGB visual with Z!"); 280 280 return NULL; … … 284 284 crDebug("Render SPU: Creating default context, visBits=0x%x", 285 285 render_spu.default_visual ); 286 defaultCtx = renderspuCreateContext( NULL, render_spu.default_visual, 0 ); 287 CRASSERT(defaultCtx == 0); 286 defaultCtx = renderspuCreateContextEx( NULL, render_spu.default_visual, CR_RENDER_DEFAULT_CONTEXT_ID, 0 ); 287 if (defaultCtx != CR_RENDER_DEFAULT_CONTEXT_ID) { 288 crError("Render SPU: failed to create default context!"); 289 return NULL; 290 } 288 291 289 292 renderspuMakeCurrent( defaultWin, 0, defaultCtx ); 290 293 291 294 /* Get windowInfo for the default window */ 292 windowInfo = (WindowInfo *) crHashtableSearch(render_spu.windowTable, 0);295 windowInfo = (WindowInfo *) crHashtableSearch(render_spu.windowTable, CR_RENDER_DEFAULT_WINDOW_ID); 293 296 CRASSERT(windowInfo); 294 297 windowInfo->mapPending = GL_TRUE; -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c
r44740 r44766 426 426 427 427 switch ( uMsg ) { 428 428 case WM_PAINT: 429 { 430 WindowInfo *pWindow = (WindowInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 431 if (pWindow) 432 { 433 struct VBOXVR_SCR_COMPOSITOR * pCompositor; 434 435 pCompositor = renderspuVBoxCompositorAcquire(pWindow); 436 if (pCompositor) 437 { 438 HDC hDC, hOldDC = pWindow->device_context; 439 PAINTSTRUCT Paint; 440 441 Assert(pWindow->device_context); 442 hDC = BeginPaint(pWindow->hWnd, &Paint); 443 if (hDC) 444 { 445 BOOL bRc; 446 pWindow->device_context = hDC; 447 448 renderspuVBoxPresentCompositionGeneric(pWindow, pCompositor, NULL); 449 renderspuVBoxCompositorRelease(pWindow); 450 451 bRc = EndPaint(pWindow->hWnd, &Paint); 452 if (!bRc) 453 { 454 DWORD winEr = GetLastError(); 455 crWarning("EndPaint failed, winEr %d", winEr); 456 } 457 458 pWindow->device_context = hOldDC; 459 } 460 else 461 { 462 DWORD winEr = GetLastError(); 463 crWarning("BeginPaint failed, winEr %d", winEr); 464 } 465 } 466 } 467 break; 468 } 429 469 case WM_SIZE: 430 470 /* w = LOWORD( lParam ); … … 558 598 crDebug("Render SPU: wglChoosePixelFormatEXT (vis 0x%x, LastError 0x%x, pixelFormat 0x%x", vis, GetLastError(), pixelFormat); 559 599 600 #ifdef VBOX_CR_SERVER_FORCE_WGL 560 601 render_spu.ws.wglSetPixelFormat( hdc, pixelFormat, &ppfd ); 602 #else 603 SetPixelFormat( hdc, pixelFormat, &ppfd ); 604 #endif 561 605 562 606 crDebug("Render SPU: wglSetPixelFormat (Last error 0x%x)", GetLastError()); … … 617 661 * versions. 618 662 */ 663 #ifdef VBOX_CR_SERVER_FORCE_WGL 619 664 if (crGetenv( "CR_WGL_DO_NOT_USE_GDI" ) != NULL) 620 665 { … … 634 679 } 635 680 else 681 #endif 636 682 { 637 683 /* Okay, we were loaded manually. Call the GDI functions. */ … … 879 925 880 926 window->device_context = GetDC( window->hWnd ); 927 if (!window->device_context) 928 { 929 DWORD winEr = GetLastError(); 930 crWarning("GetDC failed, winEr %d", winEr); 931 } 881 932 882 933 crDebug( "Render SPU: Got the DC: 0x%x", window->device_context ); … … 1053 1104 CREATESTRUCT cs; 1054 1105 1055 cs.lpCreateParams = &window->hWnd;1106 cs.lpCreateParams = window; 1056 1107 1057 1108 cs.dwExStyle = WS_EX_NOACTIVATE | WS_EX_NOPARENTNOTIFY; … … 1152 1203 1153 1204 window->device_context = GetDC( window->hWnd ); 1205 if (!window->device_context) 1206 { 1207 DWORD winEr = GetLastError(); 1208 crWarning("GetDC failed, winEr %d", winEr); 1209 } 1154 1210 1155 1211 crDebug( "Render SPU: Got the DC: 0x%x", window->device_context ); … … 1159 1215 crError( "Render SPU: Couldn't set up the device context! Yikes!" ); 1160 1216 return GL_FALSE; 1217 } 1218 1219 /* set the window pointer data at the last step to ensure our WM_PAINT callback does not do anything until we are fully initialized */ 1220 { 1221 LONG_PTR oldVal = SetWindowLongPtr(window->hWnd, GWLP_USERDATA, (LONG_PTR)window); 1222 Assert(!oldVal && GetLastError() == NO_ERROR); 1161 1223 } 1162 1224 … … 1185 1247 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry ) 1186 1248 { 1187 renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry); 1249 struct VBOXVR_SCR_COMPOSITOR *pCurCompositor; 1250 /* we do not want to be blocked with the GUI thread here, so only draw her eif we are really able to do that w/o bllocking */ 1251 int rc = renderspuVBoxCompositorTryAcquire(window, &pCurCompositor); 1252 if (RT_SUCCESS(rc)) 1253 { 1254 Assert(pCurCompositor == pCompositor); 1255 renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry); 1256 renderspuVBoxCompositorRelease(window); 1257 } 1258 else if (rc != VERR_SEM_BUSY) 1259 { 1260 render_spu.self.Flush(); 1261 renderspuVBoxPresentBlitterEnsureCreated(window); 1262 RedrawWindow(window->hWnd, NULL, NULL, RDW_INTERNALPAINT); 1263 } 1264 else 1265 { 1266 /* this is somewhat we do not expect */ 1267 crWarning("renderspuVBoxCompositorTryAcquire failed rc %d", rc); 1268 } 1188 1269 } 1189 1270 … … 1341 1422 { 1342 1423 /* share lists */ 1343 render_spu.ws.wglShareLists(context->shared->hRC, context->hRC); 1424 BOOL bRc = render_spu.ws.wglShareLists(context->shared->hRC, context->hRC); 1425 if (!bRc) 1426 { 1427 DWORD winEr = GetLastError(); 1428 crWarning("wglShareLists failed, winEr %d", winEr); 1429 } 1344 1430 } 1345 1431 … … 1506 1592 1507 1593 /* peek at the windows message queue */ 1508 renderspuHandleWindowMessages( w->hWnd );1594 // renderspuHandleWindowMessages( w->hWnd ); 1509 1595 1510 1596 /* render_to_app_window: … … 1515 1601 */ 1516 1602 if (render_spu.render_to_app_window && w->nativeWindow) { 1603 #ifdef VBOX_CR_SERVER_FORCE_WGL 1517 1604 return_value = render_spu.ws.wglSwapBuffers( w->nativeWindow ); 1605 #else 1606 return_value = SwapBuffers( w->nativeWindow ); 1607 #endif 1518 1608 } else { 1519 1609 /* … … 1558 1648 crDebug("rcClip(%d, %d, %d, %d)", rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); 1559 1649 */ 1650 #ifdef VBOX_CR_SERVER_FORCE_WGL 1560 1651 return_value = render_spu.ws.wglSwapBuffers( w->device_context ); 1652 #else 1653 return_value = SwapBuffers( w->device_context ); 1654 #endif 1561 1655 } 1562 1656 if (!return_value)
Note:
See TracChangeset
for help on using the changeset viewer.