VirtualBox

Changeset 51442 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
May 28, 2014 11:09:30 AM (11 years ago)
Author:
vboxsync
Message:

crOpenGL: fix flickering on osx

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r51432 r51442  
    25012501            {
    25022502                mFlags.fForcePresentOnReenable = false;
    2503                 cr_server.head_spu->dispatch_table.VBoxPresentComposition(mSpuWindow, mpCompositor, NULL);
     2503                if (mpCompositor)
     2504                    cr_server.head_spu->dispatch_table.VBoxPresentComposition(mSpuWindow, mpCompositor, NULL);
     2505                else
     2506                {
     2507                    VBOXVR_SCR_COMPOSITOR TmpCompositor;
     2508                    RTRECT Rect;
     2509                    Rect.xLeft = 0;
     2510                    Rect.yTop = 0;
     2511                    Rect.xRight = mWidth;
     2512                    Rect.yBottom = mHeight;
     2513                    CrVrScrCompositorInit(&TmpCompositor, &Rect);
     2514                    /* this is a cleanup operation
     2515                     * empty compositor is guarantid to be released on VBoxPresentComposition return */
     2516                    cr_server.head_spu->dispatch_table.VBoxPresentComposition(mSpuWindow, mpCompositor, NULL);
     2517                }
    25042518                g_pLed->Asserted.s.fWriting = 1;
    25052519            }
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c

    r51349 r51442  
    450450    crMemset(window, 0, sizeof (*window));
    451451    RTCritSectInit(&window->CompositorLock);
    452     window->fCompositorPresentEmpty = GL_FALSE;
    453452    window->pCompositor = NULL;
    454453
     
    777776    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
    778777    if (window) {
    779         if (pCompositor && CrVrScrCompositorIsEmpty(pCompositor) && !window->fCompositorPresentEmpty)
    780             pCompositor = NULL;
    781 
    782         if (pCompositor)
    783             window->fCompositorPresentEmpty = GL_FALSE;
    784 
    785         renderspuVBoxCompositorSet( window, pCompositor);
    786         if (pCompositor)
     778        if (renderspuVBoxCompositorSet(window, pCompositor))
    787779        {
    788780            renderspu_SystemVBoxPresentComposition(window, pChangedEntry);
     
    10161008}
    10171009
    1018 void renderspuVBoxCompositorSet( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor)
     1010GLboolean renderspuVBoxCompositorSet( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor)
    10191011{
    10201012    int rc;
     1013    GLboolean fEmpty = pCompositor && CrVrScrCompositorIsEmpty(pCompositor);
     1014    GLboolean fNeedPresent;
     1015
    10211016    /* renderspuVBoxCompositorSet can be invoked from the chromium thread only and is not reentrant,
    10221017     * no need to synch here
    10231018     * the lock is actually needed to ensure we're in synch with the redraw thread */
    1024     if (window->pCompositor == pCompositor)
    1025         return;
     1019    if (window->pCompositor == pCompositor && ! fEmpty)
     1020        return !!pCompositor;
     1021
    10261022    rc = RTCritSectEnter(&window->CompositorLock);
    10271023    if (RT_SUCCESS(rc))
    10281024    {
     1025        if (!fEmpty)
     1026            fNeedPresent = !!pCompositor;
     1027        else
     1028        {
     1029            fNeedPresent = renderspu_SystemWindowNeedEmptyPresent(window);
     1030            pCompositor = NULL;
     1031        }
     1032
    10291033        window->pCompositor = pCompositor;
    10301034        RTCritSectLeave(&window->CompositorLock);
    1031         return;
     1035        return fNeedPresent;
    10321036    }
    10331037    else
    10341038    {
    1035         crWarning("RTCritSectEnter failed rc %d", rc);
    1036     }
     1039        WARN(("RTCritSectEnter failed rc %d", rc));
     1040    }
     1041
     1042    return GL_FALSE;
    10371043}
    10381044
     
    10601066        const VBOXVR_SCR_COMPOSITOR * pCompositor = window->pCompositor;
    10611067        if (pCompositor)
     1068        {
     1069            Assert(!CrVrScrCompositorIsEmpty(window->pCompositor));
    10621070            return pCompositor;
     1071        }
    10631072
    10641073        /* if no compositor is set, release the lock and return */
     
    10721081}
    10731082
    1074 int renderspuVBoxCompositorLock(WindowInfo *window)
     1083int renderspuVBoxCompositorLock(WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR **ppCompositor)
    10751084{
    10761085    int rc = RTCritSectEnter(&window->CompositorLock);
    1077     AssertRC(rc);
     1086    if (RT_SUCCESS(rc))
     1087    {
     1088        if (ppCompositor)
     1089            *ppCompositor = window->pCompositor;
     1090    }
     1091    else
     1092        WARN(("RTCritSectEnter failed %d", rc));
    10781093    return rc;
    10791094}
     
    10931108        *ppCompositor = window->pCompositor;
    10941109        if (*ppCompositor)
     1110        {
     1111            Assert(!CrVrScrCompositorIsEmpty(window->pCompositor));
    10951112            return VINF_SUCCESS;
     1113        }
    10961114
    10971115        /* if no compositor is set, release the lock and return */
     
    11101128    int rc;
    11111129    Assert(window->pCompositor);
    1112     if (CrVrScrCompositorIsEmpty(window->pCompositor) && RTCritSectGetRecursion(&window->CompositorLock) == 1)
    1113         window->pCompositor = NULL;
     1130    Assert(!CrVrScrCompositorIsEmpty(window->pCompositor));
    11141131    rc = RTCritSectLeave(&window->CompositorLock);
    11151132    if (!RT_SUCCESS(rc))
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r51349 r51442  
    101101    GLboolean visible;
    102102    GLboolean everCurrent; /**< has this window ever been bound? */
    103     GLboolean fCompositorPresentEmpty;
    104103    char *title;
    105104
     
    400399extern void renderspu_SystemWindowPosition( WindowInfo *window, GLint x, GLint y );
    401400extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects);
     401extern GLboolean renderspu_SystemWindowNeedEmptyPresent(WindowInfo *window);
    402402extern int renderspu_SystemInit();
    403403extern int renderspu_SystemTerm();
     
    411411extern void renderspu_GCWindow(void);
    412412extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] );
    413 extern void renderspuVBoxCompositorSet( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor);
     413extern GLboolean renderspuVBoxCompositorSet( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor);
    414414extern void renderspuVBoxCompositorClearAll();
    415 extern int renderspuVBoxCompositorLock(WindowInfo *window);
     415extern int renderspuVBoxCompositorLock(WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR **ppCompositor);
    416416extern int renderspuVBoxCompositorUnlock(WindowInfo *window);
    417417extern const struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window);
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c

    r51349 r51442  
    704704}
    705705
     706GLboolean renderspu_SystemWindowNeedEmptyPresent(WindowInfo *window)
     707{
     708    return GL_FALSE;
     709}
     710
    706711void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects)
    707712{
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c

    r51082 r51442  
    180180}
    181181
     182GLboolean renderspu_SystemWindowNeedEmptyPresent(WindowInfo *pWinInfo)
     183{
     184    return cocoaViewNeedsEmptyPresent(pWinInfo->window);
     185}
     186
    182187void renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, const GLint* paRects)
    183188{
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h

    r50095 r51442  
    4949void cocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    5050void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects);
     51GLboolean cocoaViewNeedsEmptyPresent(NativeNSViewRef pView);
    5152void cocoaViewPresentComposition(NativeNSViewRef pView, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry);
    5253
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r51360 r51442  
    349349    bool m_fNeedCtxUpdate;
    350350    bool m_fDataVisible;
     351    bool m_fCleanupNeeded;
    351352    bool m_fEverSized;
    352353}
     
    386387- (void)clearVisibleRegions;
    387388- (void)setVisibleRegions:(GLint)cRects paRects:(const GLint*)paRects;
     389- (GLboolean)vboxNeedsEmptyPresent;
    388390
    389391- (NSView*)dockTileScreen;
     
    796798    m_fNeedCtxUpdate          = true;
    797799    m_fDataVisible            = false;
     800    m_fCleanupNeeded          = false;
    798801    m_fEverSized              = false;
    799802   
     
    900903    if (m_fEverSized)
    901904        [self performSelectorOnMainThread:@selector(vboxReshapePerform) withObject:nil waitUntilDone:NO];
    902    
    903     /* we need to redwar on regions change, however the compositor now is cleared
    904      * because all compositor&window data-related modifications are performed with compositor cleared
    905      * the renderspu client will re-set the compositor after modifications are complete
    906      * this way we indicate renderspu generic code not to ignore the empty compositor */
    907      /* generally this should not be needed for setPos because compositor should not be zeroed with it,
    908       * in any way setting this flag here should not hurt as it will be re-set on next present */
    909     m_pWinInfo->fCompositorPresentEmpty = GL_TRUE;
    910905}
    911906
     
    930925    DEBUG_MSG(("OVIW(%p): setSize: new size: %dx%d\n", (void*)self, (int)size.width, (int)size.height));
    931926    [self performSelectorOnMainThread:@selector(vboxReshapeOnResizePerform) withObject:nil waitUntilDone:NO];
    932 
    933     /* we need to redwar on regions change, however the compositor now is cleared
    934      * because all compositor&window data-related modifications are performed with compositor cleared
    935      * the renderspu client will re-set the compositor after modifications are complete
    936      * this way we indicate renderspu generic code not to ignore the empty compositor */
    937      /* generally this should not be needed for setSize because compositor should not be zeroed with it,
    938       * in any way setting this flag here should not hurt as it will be re-set on next present */
    939     m_pWinInfo->fCompositorPresentEmpty = GL_TRUE;
    940927}
    941928
     
    11931180- (void)vboxTryDrawUI
    11941181{
    1195     const VBOXVR_SCR_COMPOSITOR *pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
    1196     if (!m_fDataVisible && !pCompositor)
     1182    const VBOXVR_SCR_COMPOSITOR *pCompositor;
     1183    int rc = renderspuVBoxCompositorLock(m_pWinInfo, &pCompositor);
     1184    if (RT_FAILURE(rc))
     1185    {
     1186        DEBUG_WARN(("renderspuVBoxCompositorLock failed\n"));
    11971187        return;
     1188    }
     1189
     1190    if (!pCompositor && !m_fCleanupNeeded)
     1191    {
     1192        renderspuVBoxCompositorUnlock(m_pWinInfo);
     1193        return;
     1194    }
    11981195
    11991196    VBOXVR_SCR_COMPOSITOR TmpCompositor;
     
    12041201        {
    12051202            Assert(!m_fDataVisible);
     1203            Assert(!m_fCleanupNeeded);
    12061204            renderspuVBoxCompositorRelease(m_pWinInfo);
    12071205            if (![self vboxSharedCtxCreate])
     
    12151213            pCompositor = renderspuVBoxCompositorAcquire(m_pWinInfo);
    12161214            Assert(!m_fDataVisible);
     1215            Assert(!m_fCleanupNeeded);
    12171216            if (!pCompositor)
    12181217                return;
     
    12211220    else
    12221221    {
     1222        Assert(m_fCleanupNeeded);
    12231223        CrVrScrCompositorInit(&TmpCompositor, NULL);
    12241224        pCompositor = &TmpCompositor;
     
    12351235    }
    12361236   
    1237     if (pCompositor != &TmpCompositor)
    1238         renderspuVBoxCompositorRelease(m_pWinInfo);
     1237    renderspuVBoxCompositorUnlock(m_pWinInfo);
    12391238}
    12401239
     
    15691568}
    15701569
     1570- (GLboolean)vboxNeedsEmptyPresent
     1571{
     1572    if (m_fDataVisible)
     1573    {
     1574        m_fCleanupNeeded = true;
     1575        return GL_TRUE;
     1576    }
     1577   
     1578    return GL_FALSE;
     1579}
     1580
    15711581- (void)setVisibleRegions:(GLint)cRects paRects:(const GLint*)paRects
    15721582{
     
    15891599        memcpy(m_paClipRects, paRects, sizeof(GLint) * 4 * cRects);
    15901600    }
    1591 
    1592     /* we need to redwar on regions change, however the compositor now is cleared
    1593      * because all compositor&window data-related modifications are performed with compositor cleared
    1594      * the renderspu client will re-set the compositor after modifications are complete
    1595      * this way we indicate renderspu generic code not to ignore the empty compositor */
    1596     m_pWinInfo->fCompositorPresentEmpty = GL_TRUE;
    15971601}
    15981602
     
    19381942}
    19391943
     1944GLboolean cocoaViewNeedsEmptyPresent(NativeNSViewRef pView)
     1945{
     1946    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
     1947
     1948    [(OverlayView*)pView vboxNeedsEmptyPresent];
     1949
     1950    [pPool release];
     1951}
     1952
    19401953void cocoaViewSetVisibleRegion(NativeNSViewRef pView, GLint cRects, const GLint* paRects)
    19411954{
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c

    r51349 r51442  
    18891889}
    18901890
     1891GLboolean renderspu_SystemWindowNeedEmptyPresent(WindowInfo *window)
     1892{
     1893    return GL_FALSE;
     1894}
     1895
    18911896void
    18921897renderspu_SystemWindowVisibleRegion( WindowInfo *window, GLint cRects, const GLint *pRects )
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c

    r51349 r51442  
    15801580}
    15811581
     1582GLboolean renderspu_SystemWindowNeedEmptyPresent(WindowInfo *window)
     1583{
     1584    return GL_FALSE;
     1585}
     1586
    15821587void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects)
    15831588{
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