Changeset 45066 in vbox for trunk/src/VBox/HostServices/SharedOpenGL
- Timestamp:
- Mar 18, 2013 5:08:39 PM (12 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
r45053 r45066 142 142 void crServerMuralFBOSwapBuffers(CRMuralInfo *mural); 143 143 144 void crServerVBoxCompositionReenable(CRMuralInfo *mural, bool fOnContentHide);144 void crServerVBoxCompositionReenable(CRMuralInfo *mural, GLboolean fForcePresent); 145 145 void crServerVBoxCompositionDisable(CRMuralInfo *mural); 146 void crServerVBoxCompositionPresent(CRMuralInfo *mural, bool fOnContentHide); 146 void crServerVBoxCompositionPresent(CRMuralInfo *mural); 147 DECLINLINE(GLboolean) crServerVBoxCompositionPresentNeeded(CRMuralInfo *mural) 148 { 149 return mural->bVisible 150 && mural->width 151 && mural->height 152 && CrVrScrCompositorEntryIsInList(&mural->CEntry); 153 } 147 154 148 155 #define CR_SERVER_FBO_BB_IDX(_mural) ((_mural)->iBbBuffer) -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r44956 r45066 1806 1806 crVBoxServerFBImageDataTerm(&Data.data); 1807 1807 1808 if (pMural->fUseFBO && pMural->bVisible)1808 if (pMural->fUseFBO && crServerVBoxCompositionPresentNeeded(pMural)) 1809 1809 { 1810 1810 crServerPresentFBO(pMural); -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c
r45053 r45066 251 251 } 252 252 253 crServerVBoxCompositionDisable(mural); 254 253 255 if (redir) 254 256 { … … 313 315 314 316 mural->fUseFBO = redir; 317 crServerVBoxCompositionReenable(mural, GL_FALSE); 315 318 } 316 319 … … 513 516 } 514 517 515 void crServerVBoxCompositionPresent(CRMuralInfo *mural, bool fOnContentHide)518 static void crServerVBoxCompositionPresentPerform(CRMuralInfo *mural) 516 519 { 517 520 CRMuralInfo *currentMural = cr_server.currentMural; … … 522 525 CRASSERT(curCtx == crStateGetCurrent()); 523 526 524 Assert(!CrVrScrCompositorIsEmpty(&mural->Compositor) == !fOnContentHide);525 526 if (!fOnContentHide)527 {528 if (!mural->bVisible)529 {530 return;531 }532 533 if (!mural->width || !mural->height)534 {535 return;536 }537 538 if (!CrVrScrCompositorEntryIsInList(&mural->CEntry))539 return;540 }541 542 527 if (currentMural) 543 528 { … … 556 541 557 542 crStateSwitchPostprocess(curCtx, NULL, idDrawFBO, idReadFBO); 558 559 mural->fCompositorPresented = !fOnContentHide; 560 } 561 562 void crServerVBoxCompositionReenable(CRMuralInfo *mural, bool fOnContentHide) 563 { 564 if (!mural->fCompositorPresented) 565 return; 566 567 crServerVBoxCompositionPresent(mural, fOnContentHide); 543 } 544 545 void crServerVBoxCompositionPresent(CRMuralInfo *mural) 546 { 547 if (!crServerVBoxCompositionPresentNeeded(mural)) 548 return; 549 crServerVBoxCompositionPresentPerform(mural); 550 } 551 552 void crServerVBoxCompositionReenable(CRMuralInfo *mural, GLboolean fForcePresent) 553 { 554 if (mural->fUseFBO != CR_SERVER_REDIR_FBO_BLT || 555 (!fForcePresent 556 && !crServerVBoxCompositionPresentNeeded(mural))) 557 return; 558 559 crServerVBoxCompositionPresentPerform(mural); 568 560 } 569 561 570 562 void crServerVBoxCompositionDisable(CRMuralInfo *mural) 571 563 { 564 if (mural->fUseFBO != CR_SERVER_REDIR_FBO_BLT) 565 return; 572 566 cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, NULL, NULL); 573 567 } … … 585 579 CRASSERT(cr_server.pfnPresentFBO || mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT); 586 580 587 if (!mural->bVisible)588 {589 return;590 }591 592 if (!mural->width || !mural->height)593 {594 return;595 }596 597 if (!CrVrScrCompositorEntryIsInList(&mural->CEntry))598 return;599 600 581 if (mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT) 601 582 { 602 crServerVBoxCompositionPresent(mural, false); 603 return; 604 } 583 crServerVBoxCompositionPresent(mural); 584 return; 585 } 586 587 if (!crServerVBoxCompositionPresentNeeded(mural)) 588 return; 605 589 606 590 Tex.width = mural->width; -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c
r45053 r45066 31 31 return -1; 32 32 } 33 34 mural->fCompositorPresented = GL_FALSE;35 33 36 34 /* … … 332 330 Tex.hwid = 0; 333 331 334 if (mural->fUseFBO != CR_SERVER_REDIR_NONE) 335 { 336 /* since we're going to change the current compositor & the window we need to avoid 337 * renderspu fron dealing with inconsistent data, i.e. modified compositor and 338 * still unmodified window. 339 * So what we do is: 340 * 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used 341 * 2. do necessary modifications 342 * 3. (so far not needed for resize, but in case it is in the future) re-set the compositor */ 343 344 /* 1. tell renderspu to stop using the current compositor (see above comment) */ 345 crServerVBoxCompositionDisable(mural); 346 } 347 348 mural->fCompositorPresented = GL_FALSE; 332 333 /* since we're going to change the current compositor & the window we need to avoid 334 * renderspu fron dealing with inconsistent data, i.e. modified compositor and 335 * still unmodified window. 336 * So what we do is: 337 * 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used 338 * 2. do necessary modifications 339 * 3. (so far not needed for resize, but in case it is in the future) re-set the compositor */ 340 341 /* 1. tell renderspu to stop using the current compositor (see above comment) */ 342 crServerVBoxCompositionDisable(mural); 349 343 350 344 /* 2. do necessary modifications (see above comment) */ … … 377 371 /* 3. (so far not needed for resize, but in case it is in the future) re-set the compositor (see above comment) */ 378 372 /* uncomment when needed */ 379 /* NOTE: !!! we have mural->fCompositorPresented set to GL_FALSE above, so crServerVBoxCompositionReenable will have no effect in any way 380 if (mural->fUseFBO != CR_SERVER_REDIR_NONE) 381 { 382 crServerVBoxCompositionReenable(mural); 383 } 373 /* NOTE: !!! we have mural->fHasPresentationData set to GL_FALSE above, so crServerVBoxCompositionReenable will have no effect in any way 374 crServerVBoxCompositionReenable(mural); 384 375 */ 385 376 } … … 423 414 // if (mural->gX != x || mural->gY != y) 424 415 { 425 if (mural->fUseFBO != CR_SERVER_REDIR_NONE)426 {427 /* since we're going to change the current compositor & the window we need to avoid428 * renderspu fron dealing with inconsistent data, i.e. modified compositor and429 * still unmodified window.430 * So what we do is:431 * 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used432 * 2. do necessary modifications433 * 3. re-set the compositor */434 435 /* 1. tell renderspu to stop using the current compositor (see above comment) */436 crServerVBoxCompositionDisable(mural);437 }438 439 /* 2. do necessary modifications (see above comment) */440 /* NOTE: we can do it even if mural->fUseFBO == CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */441 Pos.x = x;442 Pos.y = y;443 444 /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */445 /* CrVrScrCompositorLock(&mural->Compositor); */446 /* no need to set position because the position is relative to window */447 /*CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);*/448 /*CrVrScrCompositorUnlock(&mural->Compositor);*/449 450 mural->gX = x;451 mural->gY = y;452 453 crServerCheckMuralGeometry(mural);454 455 /* 3. re-set the compositor (see above comment) */456 if (mural->fUseFBO != CR_SERVER_REDIR_NONE)457 {458 crServerVBoxCompositionReenable(mural, false);459 }460 }461 }462 463 void SERVER_DISPATCH_APIENTRY464 crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, GLint *pRects )465 {466 CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);467 bool fContainedRegions;468 if (!mural) {469 #if EXTRA_WARN470 crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window);471 #endif472 return;473 }474 475 if (mural->fUseFBO != CR_SERVER_REDIR_NONE)476 {477 416 /* since we're going to change the current compositor & the window we need to avoid 478 417 * renderspu fron dealing with inconsistent data, i.e. modified compositor and … … 485 424 /* 1. tell renderspu to stop using the current compositor (see above comment) */ 486 425 crServerVBoxCompositionDisable(mural); 487 } 488 489 fContainedRegions = !CrVrScrCompositorIsEmpty(&mural->Compositor); 426 427 /* 2. do necessary modifications (see above comment) */ 428 /* NOTE: we can do it even if mural->fUseFBO == CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */ 429 Pos.x = x; 430 Pos.y = y; 431 432 /* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */ 433 /* CrVrScrCompositorLock(&mural->Compositor); */ 434 /* no need to set position because the position is relative to window */ 435 /*CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);*/ 436 /*CrVrScrCompositorUnlock(&mural->Compositor);*/ 437 438 mural->gX = x; 439 mural->gY = y; 440 441 crServerCheckMuralGeometry(mural); 442 443 /* 3. re-set the compositor (see above comment) */ 444 crServerVBoxCompositionReenable(mural, GL_FALSE); 445 } 446 } 447 448 void SERVER_DISPATCH_APIENTRY 449 crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, GLint *pRects ) 450 { 451 CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window); 452 GLboolean fForcePresent = crServerVBoxCompositionPresentNeeded(mural); 453 if (!mural) { 454 #if EXTRA_WARN 455 crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window); 456 #endif 457 return; 458 } 459 460 /* since we're going to change the current compositor & the window we need to avoid 461 * renderspu fron dealing with inconsistent data, i.e. modified compositor and 462 * still unmodified window. 463 * So what we do is: 464 * 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used 465 * 2. do necessary modifications 466 * 3. re-set the compositor */ 467 468 /* 1. tell renderspu to stop using the current compositor (see above comment) */ 469 crServerVBoxCompositionDisable(mural); 470 490 471 /* 2. do necessary modifications (see above comment) */ 491 472 /* NOTE: we can do it even if mural->fUseFBO = CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */ … … 523 504 524 505 /* 3. re-set the compositor (see above comment) */ 525 if (mural->fUseFBO != CR_SERVER_REDIR_NONE) 526 { 527 crServerVBoxCompositionReenable(mural, fContainedRegions && CrVrScrCompositorIsEmpty(&mural->Compositor)); 528 } 529 } 530 531 506 crServerVBoxCompositionReenable(mural, fForcePresent); 507 } 532 508 533 509 void SERVER_DISPATCH_APIENTRY -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r45053 r45066 367 367 GLboolean renderspuWindowInit( WindowInfo *window, VisualInfo *visual, GLboolean showIt, GLint id ) 368 368 { 369 crMemset(window, 0, sizeof (*window)); 369 370 RTCritSectInit(&window->CompositorLock); 371 window->fCompositorPresentEmpty = GL_FALSE; 370 372 window->pCompositor = NULL; 371 373 … … 644 646 window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win); 645 647 if (window) { 646 #if !defined(RT_OS_DARWIN) || !defined(VBOX_WITH_COCOA_QT) 647 if (CrVrScrCompositorIsEmpty(pCompositor)) 648 if (pCompositor && CrVrScrCompositorIsEmpty(pCompositor) && !window->fCompositorPresentEmpty) 648 649 pCompositor = NULL; 649 #endif 650 651 if (pCompositor) 652 window->fCompositorPresentEmpty = GL_FALSE; 653 650 654 renderspuVBoxCompositorSet( window, pCompositor); 651 655 if (pCompositor) 652 656 { 653 renderspu_SystemVBoxPresentComposition(window, pCompositor, pChangedEntry); 654 #if defined(RT_OS_DARWIN) && defined(VBOX_WITH_COCOA_QT) 657 renderspu_SystemVBoxPresentComposition(window, pChangedEntry); 655 658 if (CrVrScrCompositorIsEmpty(pCompositor)) 656 659 renderspuVBoxCompositorSet( window, NULL); 657 #endif658 660 } 659 661 } … … 976 978 int rc; 977 979 Assert(window->pCompositor); 980 if (CrVrScrCompositorIsEmpty(window->pCompositor)) 981 window->pCompositor = NULL; 978 982 rc = RTCritSectLeave(&window->CompositorLock); 979 983 if (!RT_SUCCESS(rc)) -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
r44997 r45066 100 100 GLboolean visible; 101 101 GLboolean everCurrent; /**< has this window ever been bound? */ 102 GLboolean fCompositorPresentEmpty; 102 103 char *title; 103 104 … … 391 392 extern void renderspu_SystemSwapBuffers( WindowInfo *window, GLint flags ); 392 393 extern void renderspu_SystemReparentWindow(WindowInfo *window); 393 extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );394 extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry ); 394 395 extern void renderspu_GCWindow(void); 395 396 extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] ); -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c
r44997 r45066 152 152 } 153 153 154 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )154 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry ) 155 155 { 156 cocoaViewPresentComposition(window->window, pC ompositor, pChangedEntry);156 cocoaViewPresentComposition(window->window, pChangedEntry); 157 157 } 158 158 -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h
r44784 r45066 47 47 void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx); 48 48 void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, GLint* paRects); 49 void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);49 void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry); 50 50 51 51 RT_C_DECLS_END -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r45048 r45066 192 192 } 193 193 194 typedef struct VBOX_CR_RENDER_CTX_INFO 195 { 196 bool fIsValid; 197 NSOpenGLContext *pCtx; 198 NSView *pView; 199 } VBOX_CR_RENDER_CTX_INFO, *PVBOX_CR_RENDER_CTX_INFO; 200 201 static void vboxCtxEnter(NSOpenGLContext*pCtx, PVBOX_CR_RENDER_CTX_INFO pCtxInfo) 202 { 203 NSOpenGLContext *pOldCtx = vboxCtxGetCurrent(); 204 NSView *pOldView = (pOldCtx ? [pOldCtx view] : nil); 205 NSView *pView = [pCtx view]; 206 bool fNeedCtxSwitch = (pOldCtx != pCtx || pOldView != pView); 207 Assert(pCtx); 208 // Assert(pOldCtx == m_pGLCtx); 209 // Assert(pOldView == self); 210 // Assert(fNeedCtxSwitch); 211 if (fNeedCtxSwitch) 212 { 213 if(pOldCtx != nil) 214 glFlush(); 215 216 [pCtx makeCurrentContext]; 217 218 pCtxInfo->fIsValid = true; 219 pCtxInfo->pCtx = pOldCtx; 220 pCtxInfo->pView = pView; 221 } 222 else 223 { 224 pCtxInfo->fIsValid = false; 225 } 226 } 227 228 static void vboxCtxLeave(PVBOX_CR_RENDER_CTX_INFO pCtxInfo) 229 { 230 if (pCtxInfo->fIsValid) 231 { 232 NSOpenGLContext *pOldCtx = pCtxInfo->pCtx; 233 NSView *pOldView = pCtxInfo->pView; 234 235 glFlush(); 236 if (pOldCtx != nil) 237 { 238 if ([pOldCtx view] != pOldView) 239 { 240 [pOldCtx setView: pOldView]; 241 } 242 243 [pOldCtx makeCurrentContext]; 244 245 #ifdef DEBUG 246 { 247 NSOpenGLContext *pTstOldCtx = [NSOpenGLContext currentContext]; 248 NSView *pTstOldView = (pTstOldCtx ? [pTstOldCtx view] : nil); 249 Assert(pTstOldCtx == pOldCtx); 250 Assert(pTstOldView == pOldView); 251 } 252 #endif 253 } 254 else 255 { 256 [NSOpenGLContext clearCurrentContext]; 257 } 258 } 259 } 260 194 261 /** Custom OpenGL context class. 195 262 * … … 248 315 249 316 WindowInfo *m_pWinInfo; 250 PVBOXVR_SCR_COMPOSITOR m_pCompositor;251 317 bool m_fNeedViewportUpdate; 252 318 bool m_fNeedCtxUpdate; … … 276 342 - (void)vboxTryDraw; 277 343 - (void)vboxTryDrawUI; 278 - (void)vboxPresent; 279 - (void)vboxPresentCS; 280 - (void)vboxPresentToDockTileCS; 281 - (void)vboxPresentToViewCS; 282 - (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR)pCompositor withChangedEntry:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry; 283 - (void)performSelectorMakingCurrent:(NSOpenGLContext*)pCtx idSel:(SEL)selector; 344 - (void)vboxPresent:(PVBOXVR_SCR_COMPOSITOR)pCompositor; 345 - (void)vboxPresentCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor; 346 - (void)vboxPresentToDockTileCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor; 347 - (void)vboxPresentToViewCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor; 348 - (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry; 284 349 285 350 - (void)clearVisibleRegions; … … 677 742 m_RootShift = NSZeroPoint; 678 743 m_pWinInfo = pWinInfo; 679 m_pCompositor = nil;680 744 m_fNeedViewportUpdate = true; 681 745 m_fNeedCtxUpdate = true; … … 776 840 [self reshape]; 777 841 778 [self vboxTryDraw]; 842 /* we need to redwar on regions change, however the compositor now is cleared 843 * because all compositor&window data-related modifications are performed with compositor cleared 844 * the renderspu client will re-set the compositor after modifications are complete 845 * this way we indicate renderspu generic code not to ignore the empty compositor */ 846 /* generally this should not be needed for setPos because compositor should not be zeroed with it, 847 * in any way setting this flag here should not hurt as it will be re-set on next present */ 848 m_pWinInfo->fCompositorPresentEmpty = GL_TRUE; 779 849 } 780 850 … … 806 876 m_fNeedCtxUpdate = true; 807 877 } 878 879 /* we need to redwar on regions change, however the compositor now is cleared 880 * because all compositor&window data-related modifications are performed with compositor cleared 881 * the renderspu client will re-set the compositor after modifications are complete 882 * this way we indicate renderspu generic code not to ignore the empty compositor */ 883 /* generally this should not be needed for setSize because compositor should not be zeroed with it, 884 * in any way setting this flag here should not hurt as it will be re-set on next present */ 885 m_pWinInfo->fCompositorPresentEmpty = GL_TRUE; 808 886 } 809 887 … … 906 984 if (m_pSharedGLCtx) 907 985 { 908 [self performSelectorMakingCurrent:m_pSharedGLCtx idSel:@selector(updateViewportCS)]; 986 VBOX_CR_RENDER_CTX_INFO CtxInfo; 987 vboxCtxEnter(m_pSharedGLCtx, &CtxInfo); 988 989 [self updateViewportCS]; 990 991 vboxCtxLeave(&CtxInfo); 909 992 } 910 993 } … … 987 1070 if ([self lockFocusIfCanDraw]) 988 1071 { 989 bool fCompositorAquired = false;1072 VBOXVR_SCR_COMPOSITOR *pCompositor = NULL; 990 1073 if (!m_pSharedGLCtx) 991 1074 { 992 m_pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);993 if ( m_pCompositor)1075 pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo); 1076 if (pCompositor) 994 1077 { 995 fCompositorAquired = true;996 1078 /* Create a shared context out of the main context. Use the same pixel format. */ 997 1079 m_pSharedGLCtx = [[NSOpenGLContext alloc] initWithFormat:[(OverlayOpenGLContext*)m_pGLCtx openGLPixelFormat] shareContext:m_pGLCtx]; … … 1004 1086 #ifdef CR_RENDER_FORCE_PRESENT_MAIN_THREAD 1005 1087 renderspuVBoxCompositorRelease(m_pWinInfo); 1006 fCompositorAquired = false;1007 1088 #endif 1008 1089 } … … 1011 1092 if (m_pSharedGLCtx) 1012 1093 { 1013 if (! fCompositorAquired)1094 if (!pCompositor) 1014 1095 { 1015 1096 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD 1016 1097 /* 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 */ 1017 int rc = renderspuVBoxCompositorTryAcquire(m_pWinInfo, & m_pCompositor);1098 int rc = renderspuVBoxCompositorTryAcquire(m_pWinInfo, &pCompositor); 1018 1099 if (RT_SUCCESS(rc)) 1019 1100 { 1020 fCompositorAquired = true;1101 Assert(pCompositor); 1021 1102 } 1022 1103 else if (rc == VERR_SEM_BUSY) … … 1037 1118 1038 1119 #ifdef CR_RENDER_FORCE_PRESENT_MAIN_THREAD 1039 Assert(! fCompositorAquired);1120 Assert(!pCompositor); 1040 1121 #endif 1041 if ( fCompositorAquired)1122 if (pCompositor) 1042 1123 { 1043 Assert(m_pCompositor); 1044 [self vboxPresent]; 1124 [self vboxPresent:pCompositor]; 1045 1125 renderspuVBoxCompositorRelease(m_pWinInfo); 1046 1126 } … … 1048 1128 else 1049 1129 { 1050 AssertRelease(! fCompositorAquired);1130 AssertRelease(!pCompositor); 1051 1131 } 1052 1132 [self unlockFocus]; … … 1060 1140 if (m_pSharedGLCtx) 1061 1141 { 1062 m_pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);1063 if ( m_pCompositor)1142 VBOXVR_SCR_COMPOSITOR *pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo); 1143 if (pCompositor) 1064 1144 { 1065 [self vboxPresent ];1145 [self vboxPresent:pCompositor]; 1066 1146 renderspuVBoxCompositorRelease(m_pWinInfo); 1067 1147 } … … 1076 1156 } 1077 1157 1078 - (void)vboxPresent 1079 { 1080 DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void*)self));1158 - (void)vboxPresent:(PVBOXVR_SCR_COMPOSITOR)pCompositor 1159 { 1160 VBOX_CR_RENDER_CTX_INFO CtxInfo; 1081 1161 1082 Assert(m_pCompositor); 1162 DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void*)self)); 1163 1164 Assert(pCompositor); 1083 1165 1084 1166 #if 0 //def DEBUG … … 1090 1172 } 1091 1173 #endif 1174 1175 vboxCtxEnter(m_pSharedGLCtx, &CtxInfo); 1092 1176 1093 [self performSelectorMakingCurrent:m_pSharedGLCtx idSel:@selector(vboxPresentCS)]; 1094 } 1095 1096 - (void)vboxPresentCS 1177 [self vboxPresentCS:pCompositor]; 1178 1179 vboxCtxLeave(&CtxInfo); 1180 } 1181 1182 - (void)vboxPresentCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor 1097 1183 { 1098 1184 { … … 1111 1197 1112 1198 /* Render FBO content to the dock tile when necessary. */ 1113 [self vboxPresentToDockTileCS ];1199 [self vboxPresentToDockTileCS:pCompositor]; 1114 1200 1115 [self vboxPresentToViewCS ];1201 [self vboxPresentToViewCS:pCompositor]; 1116 1202 } 1117 1203 } 1118 1204 1119 - (void)vboxPresentToViewCS 1205 - (void)vboxPresentToViewCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor 1120 1206 { 1121 1207 NSRect r = [self frame]; … … 1126 1212 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry; 1127 1213 1128 CrVrScrCompositorIterInit( m_pCompositor, &CIter);1214 CrVrScrCompositorIterInit(pCompositor, &CIter); 1129 1215 1130 1216 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); … … 1138 1224 uint32_t cRegions; 1139 1225 const RTRECT *paSrcRegions, *paDstRegions; 1140 int rc = CrVrScrCompositorEntryRegionsGet( m_pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);1226 int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions); 1141 1227 if (RT_SUCCESS(rc)) 1142 1228 { … … 1177 1263 } 1178 1264 1179 - (void)performSelectorMakingCurrent:(NSOpenGLContext*)pCtx idSel:(SEL)selector 1180 { 1181 NSOpenGLContext *pOldCtx = vboxCtxGetCurrent(); 1182 NSView *pOldView = (pOldCtx ? [pOldCtx view] : nil); 1183 NSView *pView = [pCtx view]; 1184 bool fNeedCtxSwitch = (pOldCtx != pCtx || pOldView != pView); 1185 Assert(pCtx); 1186 // Assert(pOldCtx == m_pGLCtx); 1187 // Assert(pOldView == self); 1188 // Assert(fNeedCtxSwitch); 1189 if (fNeedCtxSwitch) 1190 { 1191 if(pOldCtx != nil) 1192 glFlush(); 1193 1194 [pCtx makeCurrentContext]; 1195 } 1196 1197 [self performSelector:selector]; 1198 1199 if (fNeedCtxSwitch) 1200 { 1201 glFlush(); 1202 if (pOldCtx != nil) 1203 { 1204 if ([pOldCtx view] != pOldView) 1205 { 1206 [pOldCtx setView: pOldView]; 1207 } 1208 1209 [pOldCtx makeCurrentContext]; 1210 1211 #ifdef DEBUG 1212 { 1213 NSOpenGLContext *pTstOldCtx = [NSOpenGLContext currentContext]; 1214 NSView *pTstOldView = (pTstOldCtx ? [pTstOldCtx view] : nil); 1215 Assert(pTstOldCtx == pOldCtx); 1216 Assert(pTstOldView == pOldView); 1217 } 1218 #endif 1219 } 1220 else 1221 { 1222 [NSOpenGLContext clearCurrentContext]; 1223 } 1224 } 1225 } 1226 1227 - (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR)pCompositor withChangedEntry:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry 1265 - (void)presentComposition:(PVBOXVR_SCR_COMPOSITOR_ENTRY)pChangedEntry 1228 1266 { 1229 1267 [self vboxTryDraw]; 1230 1268 } 1231 1269 1232 - (void)vboxPresentToDockTileCS 1270 - (void)vboxPresentToDockTileCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor 1233 1271 { 1234 1272 NSRect r = [self frame]; … … 1272 1310 rr = [m_DockTileView frame]; 1273 1311 1274 CrVrScrCompositorIterInit( m_pCompositor, &CIter);1312 CrVrScrCompositorIterInit(pCompositor, &CIter); 1275 1313 while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL) 1276 1314 { 1277 1315 uint32_t cRegions; 1278 1316 const RTRECT *paSrcRegions, *paDstRegions; 1279 int rc = CrVrScrCompositorEntryRegionsGet( m_pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);1317 int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions); 1280 1318 if (RT_SUCCESS(rc)) 1281 1319 { … … 1363 1401 } 1364 1402 1365 [self vboxTryDraw]; 1403 /* we need to redwar on regions change, however the compositor now is cleared 1404 * because all compositor&window data-related modifications are performed with compositor cleared 1405 * the renderspu client will re-set the compositor after modifications are complete 1406 * this way we indicate renderspu generic code not to ignore the empty compositor */ 1407 m_pWinInfo->fCompositorPresentEmpty = GL_TRUE; 1366 1408 } 1367 1409 … … 1659 1701 } 1660 1702 1661 void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)1703 void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry) 1662 1704 { 1663 1705 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1664 1706 1665 [(OverlayView*)pView presentComposition:pC ompositor withChangedEntry:pChangedEntry];1707 [(OverlayView*)pView presentComposition:pChangedEntry]; 1666 1708 1667 1709 [pPool release]; -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c
r45039 r45066 1972 1972 } 1973 1973 1974 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )1974 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry ) 1975 1975 { 1976 1976 /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl, … … 1979 1979 * @todo: change to some more generic macro name */ 1980 1980 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD 1981 struct VBOXVR_SCR_COMPOSITOR *pC urCompositor;1981 struct VBOXVR_SCR_COMPOSITOR *pCompositor; 1982 1982 /* 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 */ 1983 int rc = renderspuVBoxCompositorTryAcquire(window, &pC urCompositor);1983 int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor); 1984 1984 if (RT_SUCCESS(rc)) 1985 1985 { 1986 Assert(pCurCompositor == pCompositor);1987 1986 renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0); 1988 1987 renderspuVBoxCompositorRelease(window); -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c
r45043 r45066 1245 1245 } 1246 1246 1247 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )1247 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry ) 1248 1248 { 1249 1249 /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl, … … 1252 1252 * @todo: change to some more generic macro name */ 1253 1253 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD 1254 struct VBOXVR_SCR_COMPOSITOR *pC urCompositor;1254 struct VBOXVR_SCR_COMPOSITOR *pCompositor; 1255 1255 /* 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 */ 1256 int rc = renderspuVBoxCompositorTryAcquire(window, &pC urCompositor);1256 int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor); 1257 1257 if (RT_SUCCESS(rc)) 1258 1258 { 1259 Assert(pCurCompositor == pCompositor);1260 1259 renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0); 1261 1260 renderspuVBoxCompositorRelease(window);
Note:
See TracChangeset
for help on using the changeset viewer.