VirtualBox

Ignore:
Timestamp:
Mar 18, 2013 5:08:39 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: misc bugfixes & cleanups

Location:
trunk/src/VBox/HostServices/SharedOpenGL
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r45053 r45066  
    142142void crServerMuralFBOSwapBuffers(CRMuralInfo *mural);
    143143
    144 void crServerVBoxCompositionReenable(CRMuralInfo *mural, bool fOnContentHide);
     144void crServerVBoxCompositionReenable(CRMuralInfo *mural, GLboolean fForcePresent);
    145145void crServerVBoxCompositionDisable(CRMuralInfo *mural);
    146 void crServerVBoxCompositionPresent(CRMuralInfo *mural, bool fOnContentHide);
     146void crServerVBoxCompositionPresent(CRMuralInfo *mural);
     147DECLINLINE(GLboolean) crServerVBoxCompositionPresentNeeded(CRMuralInfo *mural)
     148{
     149    return mural->bVisible
     150                && mural->width
     151                && mural->height
     152                && CrVrScrCompositorEntryIsInList(&mural->CEntry);
     153}
    147154
    148155#define CR_SERVER_FBO_BB_IDX(_mural) ((_mural)->iBbBuffer)
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r44956 r45066  
    18061806        crVBoxServerFBImageDataTerm(&Data.data);
    18071807
    1808         if (pMural->fUseFBO && pMural->bVisible)
     1808        if (pMural->fUseFBO && crServerVBoxCompositionPresentNeeded(pMural))
    18091809        {
    18101810            crServerPresentFBO(pMural);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r45053 r45066  
    251251    }
    252252
     253    crServerVBoxCompositionDisable(mural);
     254
    253255    if (redir)
    254256    {
     
    313315
    314316    mural->fUseFBO = redir;
     317    crServerVBoxCompositionReenable(mural, GL_FALSE);
    315318}
    316319
     
    513516}
    514517
    515 void crServerVBoxCompositionPresent(CRMuralInfo *mural, bool fOnContentHide)
     518static void crServerVBoxCompositionPresentPerform(CRMuralInfo *mural)
    516519{
    517520    CRMuralInfo *currentMural = cr_server.currentMural;
     
    522525    CRASSERT(curCtx == crStateGetCurrent());
    523526
    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 
    542527    if (currentMural)
    543528    {
     
    556541
    557542    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
     545void crServerVBoxCompositionPresent(CRMuralInfo *mural)
     546{
     547    if (!crServerVBoxCompositionPresentNeeded(mural))
     548        return;
     549    crServerVBoxCompositionPresentPerform(mural);
     550}
     551
     552void 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);
    568560}
    569561
    570562void crServerVBoxCompositionDisable(CRMuralInfo *mural)
    571563{
     564    if (mural->fUseFBO != CR_SERVER_REDIR_FBO_BLT)
     565        return;
    572566    cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, NULL, NULL);
    573567}
     
    585579    CRASSERT(cr_server.pfnPresentFBO || mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT);
    586580
    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 
    600581    if (mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT)
    601582    {
    602         crServerVBoxCompositionPresent(mural, false);
    603         return;
    604     }
     583        crServerVBoxCompositionPresent(mural);
     584        return;
     585    }
     586
     587    if (!crServerVBoxCompositionPresentNeeded(mural))
     588        return;
    605589
    606590    Tex.width = mural->width;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r45053 r45066  
    3131        return -1;
    3232    }
    33 
    34     mural->fCompositorPresented = GL_FALSE;
    3533
    3634    /*
     
    332330        Tex.hwid = 0;
    333331
    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);
    349343
    350344        /* 2. do necessary modifications (see above comment) */
     
    377371        /* 3. (so far not needed for resize, but in case it is in the future) re-set the compositor (see above comment) */
    378372        /* 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);
    384375        */
    385376    }
     
    423414//    if (mural->gX != x || mural->gY != y)
    424415    {
    425         if (mural->fUseFBO != CR_SERVER_REDIR_NONE)
    426         {
    427             /* since we're going to change the current compositor & the window we need to avoid
    428              * renderspu fron dealing with inconsistent data, i.e. modified compositor and
    429              * 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 used
    432              * 2. do necessary modifications
    433              * 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_APIENTRY
    464 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_WARN
    470          crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window);
    471 #endif
    472          return;
    473     }
    474 
    475     if (mural->fUseFBO != CR_SERVER_REDIR_NONE)
    476     {
    477416        /* since we're going to change the current compositor & the window we need to avoid
    478417         * renderspu fron dealing with inconsistent data, i.e. modified compositor and
     
    485424        /* 1. tell renderspu to stop using the current compositor (see above comment) */
    486425        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
     448void SERVER_DISPATCH_APIENTRY
     449crServerDispatchWindowVisibleRegion( 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
    490471    /* 2. do necessary modifications (see above comment) */
    491472    /* NOTE: we can do it even if mural->fUseFBO = CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */
     
    523504
    524505    /* 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}
    532508
    533509void SERVER_DISPATCH_APIENTRY
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r45053 r45066  
    367367GLboolean renderspuWindowInit( WindowInfo *window, VisualInfo *visual, GLboolean showIt, GLint id )
    368368{
     369    crMemset(window, 0, sizeof (*window));
    369370    RTCritSectInit(&window->CompositorLock);
     371    window->fCompositorPresentEmpty = GL_FALSE;
    370372    window->pCompositor = NULL;
    371373
     
    644646    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
    645647    if (window) {
    646 #if !defined(RT_OS_DARWIN) || !defined(VBOX_WITH_COCOA_QT)
    647         if (CrVrScrCompositorIsEmpty(pCompositor))
     648        if (pCompositor && CrVrScrCompositorIsEmpty(pCompositor) && !window->fCompositorPresentEmpty)
    648649            pCompositor = NULL;
    649 #endif
     650
     651        if (pCompositor)
     652            window->fCompositorPresentEmpty = GL_FALSE;
     653
    650654        renderspuVBoxCompositorSet( window, pCompositor);
    651655        if (pCompositor)
    652656        {
    653             renderspu_SystemVBoxPresentComposition(window, pCompositor, pChangedEntry);
    654 #if defined(RT_OS_DARWIN) && defined(VBOX_WITH_COCOA_QT)
     657            renderspu_SystemVBoxPresentComposition(window, pChangedEntry);
    655658            if (CrVrScrCompositorIsEmpty(pCompositor))
    656659                renderspuVBoxCompositorSet( window, NULL);
    657 #endif
    658660        }
    659661    }
     
    976978    int rc;
    977979    Assert(window->pCompositor);
     980    if (CrVrScrCompositorIsEmpty(window->pCompositor))
     981        window->pCompositor = NULL;
    978982    rc = RTCritSectLeave(&window->CompositorLock);
    979983    if (!RT_SUCCESS(rc))
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r44997 r45066  
    100100    GLboolean visible;
    101101    GLboolean everCurrent; /**< has this window ever been bound? */
     102    GLboolean fCompositorPresentEmpty;
    102103    char *title;
    103104
     
    391392extern void renderspu_SystemSwapBuffers( WindowInfo *window, GLint flags );
    392393extern void renderspu_SystemReparentWindow(WindowInfo *window);
    393 extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
     394extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
    394395extern void renderspu_GCWindow(void);
    395396extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] );
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c

    r44997 r45066  
    152152}
    153153
    154 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     154void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
    155155{
    156     cocoaViewPresentComposition(window->window, pCompositor, pChangedEntry);
     156    cocoaViewPresentComposition(window->window, pChangedEntry);
    157157}
    158158
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h

    r44784 r45066  
    4747void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    4848void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, GLint* paRects);
    49 void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
     49void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
    5050
    5151RT_C_DECLS_END
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r45048 r45066  
    192192}
    193193
     194typedef 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
     201static 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   
     228static 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
    194261/** Custom OpenGL context class.
    195262 *
     
    248315   
    249316    WindowInfo *m_pWinInfo;
    250     PVBOXVR_SCR_COMPOSITOR m_pCompositor;
    251317    bool m_fNeedViewportUpdate;
    252318    bool m_fNeedCtxUpdate;
     
    276342- (void)vboxTryDraw;
    277343- (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;
    284349
    285350- (void)clearVisibleRegions;
     
    677742    m_RootShift               = NSZeroPoint;
    678743    m_pWinInfo                    = pWinInfo;
    679     m_pCompositor             = nil;
    680744    m_fNeedViewportUpdate     = true;       
    681745    m_fNeedCtxUpdate          = true;
     
    776840    [self reshape];
    777841   
    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;
    779849}
    780850
     
    806876        m_fNeedCtxUpdate = true;
    807877    }
     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;
    808886}
    809887
     
    906984    if (m_pSharedGLCtx)
    907985    {
    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);
    909992    }
    910993}
     
    9871070    if ([self lockFocusIfCanDraw])
    9881071    {
    989         bool fCompositorAquired = false;
     1072        VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
    9901073        if (!m_pSharedGLCtx)
    9911074            {
    992                 m_pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
    993                 if (m_pCompositor)
     1075                pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
     1076                if (pCompositor)
    9941077                {
    995                     fCompositorAquired = true;
    9961078                        /* Create a shared context out of the main context. Use the same pixel format. */
    9971079                        m_pSharedGLCtx = [[NSOpenGLContext alloc] initWithFormat:[(OverlayOpenGLContext*)m_pGLCtx openGLPixelFormat] shareContext:m_pGLCtx];
     
    10041086#ifdef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    10051087                                renderspuVBoxCompositorRelease(m_pWinInfo);
    1006                                 fCompositorAquired = false;
    10071088#endif
    10081089                    }
     
    10111092                if (m_pSharedGLCtx)
    10121093                {
    1013                         if (!fCompositorAquired)
     1094                        if (!pCompositor)
    10141095                        {
    10151096#ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    10161097                                /* 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);
    10181099                                if (RT_SUCCESS(rc))
    10191100                                {
    1020                                         fCompositorAquired = true;
     1101                                        Assert(pCompositor);
    10211102                                }
    10221103                            else if (rc == VERR_SEM_BUSY)
     
    10371118               
    10381119#ifdef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1039                         Assert(!fCompositorAquired);
     1120                        Assert(!pCompositor);
    10401121#endif 
    1041                         if (fCompositorAquired)
     1122                        if (pCompositor)
    10421123                        {
    1043                                 Assert(m_pCompositor);
    1044                                 [self vboxPresent];
     1124                                [self vboxPresent:pCompositor];
    10451125                                renderspuVBoxCompositorRelease(m_pWinInfo);
    10461126                        }
     
    10481128                else
    10491129                {
    1050                         AssertRelease(!fCompositorAquired);
     1130                        AssertRelease(!pCompositor);
    10511131                }
    10521132        [self unlockFocus];
     
    10601140        if (m_pSharedGLCtx)
    10611141            {
    1062                 m_pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
    1063                 if (m_pCompositor)
     1142                VBOXVR_SCR_COMPOSITOR *pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
     1143                if (pCompositor)
    10641144                {
    1065                         [self vboxPresent];
     1145                        [self vboxPresent:pCompositor];
    10661146                                renderspuVBoxCompositorRelease(m_pWinInfo);
    10671147                        }
     
    10761156}
    10771157
    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;   
    10811161   
    1082     Assert(m_pCompositor);
     1162    DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void*)self));   
     1163   
     1164    Assert(pCompositor);
    10831165   
    10841166#if 0 //def DEBUG
     
    10901172            }
    10911173#endif
     1174
     1175    vboxCtxEnter(m_pSharedGLCtx, &CtxInfo);
    10921176   
    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
    10971183{
    10981184        {
     
    11111197           
    11121198            /* Render FBO content to the dock tile when necessary. */
    1113             [self vboxPresentToDockTileCS];
     1199            [self vboxPresentToDockTileCS:pCompositor];
    11141200           
    1115             [self vboxPresentToViewCS];
     1201            [self vboxPresentToViewCS:pCompositor];
    11161202        }
    11171203}
    11181204
    1119 - (void)vboxPresentToViewCS
     1205- (void)vboxPresentToViewCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor
    11201206{
    11211207    NSRect r = [self frame];
     
    11261212    PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
    11271213       
    1128     CrVrScrCompositorIterInit(m_pCompositor, &CIter);
     1214    CrVrScrCompositorIterInit(pCompositor, &CIter);
    11291215       
    11301216    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
     
    11381224        uint32_t cRegions;
    11391225        const RTRECT *paSrcRegions, *paDstRegions;
    1140         int rc = CrVrScrCompositorEntryRegionsGet(m_pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
     1226        int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
    11411227        if (RT_SUCCESS(rc))
    11421228        {
     
    11771263}
    11781264
    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
    12281266{
    12291267    [self vboxTryDraw];
    12301268}
    12311269
    1232 - (void)vboxPresentToDockTileCS
     1270- (void)vboxPresentToDockTileCS:(PVBOXVR_SCR_COMPOSITOR)pCompositor
    12331271{
    12341272    NSRect r        = [self frame];
     
    12721310            rr = [m_DockTileView frame];
    12731311           
    1274             CrVrScrCompositorIterInit(m_pCompositor, &CIter);
     1312            CrVrScrCompositorIterInit(pCompositor, &CIter);
    12751313            while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
    12761314            {
    12771315                uint32_t cRegions;
    12781316                const RTRECT *paSrcRegions, *paDstRegions;
    1279                 int rc = CrVrScrCompositorEntryRegionsGet(m_pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
     1317                int rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRegions, &paSrcRegions, &paDstRegions);
    12801318                if (RT_SUCCESS(rc))
    12811319                {
     
    13631401    }
    13641402
    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;
    13661408}
    13671409
     
    16591701}
    16601702
    1661 void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)
     1703void cocoaViewPresentComposition(NativeNSViewRef pView, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry)
    16621704{
    16631705    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
    16641706
    1665     [(OverlayView*)pView presentComposition:pCompositor withChangedEntry:pChangedEntry];
     1707    [(OverlayView*)pView presentComposition:pChangedEntry];
    16661708
    16671709    [pPool release];
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c

    r45039 r45066  
    19721972}
    19731973
    1974 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     1974void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
    19751975{
    19761976    /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl,
     
    19791979     * @todo: change to some more generic macro name */
    19801980#ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1981     struct VBOXVR_SCR_COMPOSITOR *pCurCompositor;
     1981    struct VBOXVR_SCR_COMPOSITOR *pCompositor;
    19821982    /* 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, &pCurCompositor);
     1983    int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
    19841984    if (RT_SUCCESS(rc))
    19851985    {
    1986         Assert(pCurCompositor == pCompositor);
    19871986        renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0);
    19881987        renderspuVBoxCompositorRelease(window);
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c

    r45043 r45066  
    12451245}
    12461246
    1247 void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
     1247void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
    12481248{
    12491249    /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl,
     
    12521252     * @todo: change to some more generic macro name */
    12531253#ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1254     struct VBOXVR_SCR_COMPOSITOR *pCurCompositor;
     1254    struct VBOXVR_SCR_COMPOSITOR *pCompositor;
    12551255    /* 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, &pCurCompositor);
     1256    int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
    12571257    if (RT_SUCCESS(rc))
    12581258    {
    1259         Assert(pCurCompositor == pCompositor);
    12601259        renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0);
    12611260        renderspuVBoxCompositorRelease(window);
Note: See TracChangeset for help on using the changeset viewer.

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