VirtualBox

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


Ignore:
Timestamp:
Mar 15, 2015 11:49:44 PM (10 years ago)
Author:
vboxsync
Message:

VMSVGA3d: Eliminated WindowsInfo leak; dropping the CR compositor dependencies, we don't need it (at the moment at least).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r54638 r54767  
    213213#define VBOX_WITH_CONFIGURABLE_HIDPI_SCALING    1
    214214
     215
    215216#ifdef IN_VMSVGA3D
    216217
     
    218219 * VMSVGA3D compatibility glue.
    219220 */
     221typedef struct WindowInfo WindowInfo;
    220222
    221223# define CR_RGB_BIT             RT_BIT_32(0)
     
    233235# define VMSVGA3D_NON_DEFAULT_PROFILE_BIT RT_BIT_32(31)
    234236# define CR_ALL_BITS            UINT32_C(0x800003ff)
    235 
    236 typedef struct WindowInfo
    237 {
    238     uint32_t volatile           cRefs;
    239     RTCRITSECT                  CompositorLock;
    240     PCVBOXVR_SCR_COMPOSITOR     pCompositor;
    241 
    242     //NativeNSViewRef window;
    243     //NativeNSViewRef nativeWindow; /**< for render_to_app_window */
    244     NativeNSOpenGLContextRef   *currentCtx;
    245 } WindowInfo;
    246 
    247 static void vmsvga3DWinInfoDestroy(WindowInfo *pWinInfo)
    248 {
    249     /** @todo */
    250 }
    251 
    252 DECLINLINE(void) renderspuWinRetain(WindowInfo *pWinInfo)
    253 {
    254     ASMAtomicIncU32(&pWinInfo->cRefs);
    255 }
    256 
    257 DECLINLINE(void) renderspuWinRelease(WindowInfo *pWinInfo)
    258 {
    259     uint32_t cRefs = ASMAtomicDecU32(&pWinInfo->cRefs);
    260     if (!cRefs)
    261         vmsvga3DWinInfoDestroy(pWinInfo);
    262 }     
    263 
    264 static int renderspuVBoxCompositorLock(WindowInfo *pWinInfo, PCVBOXVR_SCR_COMPOSITOR *ppCompositor)
    265 {
    266     int rc = RTCritSectEnter(&pWinInfo->CompositorLock);
    267     AssertRCReturn(rc, rc);
    268     if (ppCompositor)
    269         *ppCompositor = pWinInfo->pCompositor;
    270     return VINF_SUCCESS;
    271 }
    272 
    273 static int renderspuVBoxCompositorUnlock(WindowInfo *pWinInfo)
    274 {
    275     int rc = RTCritSectLeave(&pWinInfo->CompositorLock);
    276     AssertRC(rc);
    277     return rc;
    278 }
    279 
    280 static PCVBOXVR_SCR_COMPOSITOR renderspuVBoxCompositorAcquire(WindowInfo *pWinInfo)
    281 {
    282     int rc = RTCritSectEnter(&pWinInfo->CompositorLock);
    283     AssertRCReturn(rc, NULL);
    284 
    285     PCVBOXVR_SCR_COMPOSITOR pCompositor = pWinInfo->pCompositor;
    286     if (pCompositor)
    287     {
    288         Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));
    289         return pCompositor;
    290     }
    291 
    292     /* if no compositor is set, release the lock and return */
    293     RTCritSectLeave(&pWinInfo->CompositorLock);
    294     return NULL;
    295 }
    296 
    297 static void renderspuVBoxCompositorRelease(WindowInfo *pWinInfo)
    298 {
    299     Assert(pWinInfo->pCompositor);
    300     Assert(!CrVrScrCompositorIsEmpty(pWinInfo->pCompositor));
    301     int rc = RTCritSectLeave(&pWinInfo->CompositorLock);
    302     AssertRC(rc);
    303 }
    304 
    305237
    306238#endif /* IN_VMSVGA3D */
     
    862794   
    863795    CR_BLITTER         *m_pBlitter;
     796#ifndef IN_VMSVGA3D
    864797    WindowInfo         *m_pWinInfo;
     798#endif
    865799    bool                m_fNeedViewportUpdate;
    866800    bool                m_fNeedCtxUpdate;
     
    912846- (void)vboxPresent:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
    913847- (void)vboxPresentCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
     848#ifndef IN_VMSVGA3D
    914849- (void)vboxPresentToDockTileCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
     850#endif
    915851- (void)vboxPresentToViewCS:(const VBOXVR_SCR_COMPOSITOR *)pCompositor;
    916852- (void)presentComposition:(const VBOXVR_SCR_COMPOSITOR_ENTRY *)pChangedEntry;
     
    14181354    m_yInvRootOffset          = 0;
    14191355    m_pBlitter                = nil;
     1356#ifndef IN_VMSVGA3D
    14201357    m_pWinInfo                = pWinInfo;
     1358#endif
    14211359    m_fNeedViewportUpdate     = true;
    14221360    m_fNeedCtxUpdate          = true;
     
    16361574    }
    16371575   
     1576#ifndef IN_VMSVGA3D
    16381577    renderspuWinRelease(m_pWinInfo);
     1578#endif
    16391579   
    16401580    COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__));
     
    22202160#endif
    22212161   
    2222     const VBOXVR_SCR_COMPOSITOR *pCompositor;
     2162    const VBOXVR_SCR_COMPOSITOR *pCompositor = NULL;
     2163#ifndef IN_VMSVGA3D
    22232164    int rc = renderspuVBoxCompositorLock(m_pWinInfo, &pCompositor);
    22242165    if (RT_FAILURE(rc))
     
    22282169    }
    22292170
    2230 #ifndef IN_VMSVGA3D
    22312171    if (!pCompositor && !m_fCleanupNeeded)
    22322172    {
     
    22352175        return;
    22362176    }
    2237 #endif
    22382177
    22392178    VBOXVR_SCR_COMPOSITOR TmpCompositor;
    2240    
    22412179    if (pCompositor)
    22422180    {
     
    22672205    {
    22682206        DEBUG_MSG(("%s: NeedCleanup\n", __PRETTY_FUNCTION__));
    2269 #ifndef IN_VMSVGA3D /** @todo VMSVGA3 */
    22702207        Assert(m_fCleanupNeeded);
    2271 #endif
    22722208        CrVrScrCompositorInit(&TmpCompositor, NULL);
    22732209        pCompositor = &TmpCompositor;
    22742210    }
     2211#endif /* !IN_VMSVGA3D */
     2212
    22752213   
    22762214    if ([self lockFocusIfCanDraw])
     
    22932231    }
    22942232   
     2233#ifndef IN_VMSVGA3D
    22952234    renderspuVBoxCompositorUnlock(m_pWinInfo);
     2235#endif
    22962236    COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__));
    22972237}
     
    23082248    COCOA_LOG_FLOW(("%s: self=%p pCompositor=%p\n", __PRETTY_FUNCTION__, (void *)self, (void *)pCompositor));
    23092249    /*DEBUG_MSG(("OVIW(%p): renderFBOToView\n", (void *)self));*/
     2250#ifndef IN_VMSVGA3D
    23102251    AssertPtr(pCompositor);
     2252#endif
    23112253
    23122254    VBOX_CR_RENDER_CTX_INFO CtxInfo;   
     
    23382280    m_fCleanupNeeded = false;
    23392281   
     2282#ifndef IN_VMSVGA3D
    23402283    /* Render FBO content to the dock tile when necessary. */
    23412284    [self vboxPresentToDockTileCS:pCompositor];
     2285#endif
    23422286
    23432287    /* change to #if 0 to see thumbnail image */           
     
    23832327
    23842328#if 1 /* Set to 0 to see the docktile instead of the real output */
    2385     VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
    2386     const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
    2387 
    2388     CrVrScrCompositorConstIterInit(pCompositor, &CIter);
    2389 
    23902329    float backingStretchFactor = 1.;
    2391 #if defined(VBOX_WITH_CONFIGURABLE_HIDPI_SCALING) && !defined(IN_VMSVGA3D)
     2330#  if defined(VBOX_WITH_CONFIGURABLE_HIDPI_SCALING) && !defined(IN_VMSVGA3D)
    23922331    /* Adjust viewport according to current NSView's backing store parameters. */
    23932332    if (render_spu.fUnscaledHiDPI)
     
    24032342    crDebug("HiDPI: vboxPresentToViewCS: up-scaling is %s (backingStretchFactor=%d).",
    24042343        render_spu.fUnscaledHiDPI ? "OFF" : "ON", (int)backingStretchFactor);
    2405 #endif
     2344#  endif
    24062345
    24072346    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
     
    24132352    m_fDataVisible = false;
    24142353   
     2354# ifndef IN_VMSVGA3D
    24152355    float xStretch;
    24162356    float yStretch;
    24172357    CrVrScrCompositorGetStretching(pCompositor, &xStretch, &yStretch);
    24182358       
     2359    VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
     2360    const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
     2361    CrVrScrCompositorConstIterInit(pCompositor, &CIter);
     2362
    24192363    while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
    24202364    {
     
    24682412            {
    24692413                DEBUG_WARN(("CrBltEnter failed rc %d", rc));
    2470 # ifndef DEBUG_VERBOSE
     2414#  ifndef DEBUG_VERBOSE
    24712415                AssertMsgFailed(("CrBltEnter failed rc %Rrc", rc));
    2472 # endif
     2416#  endif
    24732417            }
    24742418        }
     
    24792423        }
    24802424    }
     2425# endif /* !IN_VMSVGA3D */
    24812426#endif
    24822427
     
    25202465}
    25212466
    2522 #ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
     2467#ifndef IN_VMSVGA3D
     2468# ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
    25232469static int g_cVBoxTgaCtr = 0;
    2524 #endif
     2470# endif
    25252471- (void)vboxPresentToDockTileCS:(PCVBOXVR_SCR_COMPOSITOR)pCompositor
    25262472{
     
    25452491        {
    25462492            m_msDockUpdateTS = msTS;
    2547 #if 0
     2493# if 0
    25482494            /* todo: check this for optimization */
    25492495            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, myTextureName);
     
    25602506            glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
    25612507                          GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
    2562 #endif
     2508# endif
    25632509            glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
    25642510            glDrawBuffer(GL_BACK);
     
    26242570                    {
    26252571                        DEBUG_WARN(("CrBltEnter failed rc %d", rc));
    2626 #ifndef DEBUG_VERBOSE
     2572# ifndef DEBUG_VERBOSE
    26272573                        AssertMsgFailed(("CrBltEnter failed rc %Rrc", rc));
    2628 #endif
     2574# endif
    26292575                    }
    26302576                }
     
    26512597            [m_DockTileView unlock];
    26522598           
    2653 #ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
     2599# ifdef VBOX_WITH_CRDUMPER_THUMBNAIL
    26542600            ++g_cVBoxTgaCtr;
    26552601            crDumpNamedTGAF((GLint)rr.size.width, (GLint)rr.size.height,
    26562602                [[m_DockTileView thumbBitmap] bitmapData], "/Users/leo/vboxdumps/dump%d.tga", g_cVBoxTgaCtr);
    2657 #endif               
     2603# endif               
    26582604
    26592605            pDT = [[NSApplication sharedApplication] dockTile];
     
    26652611    }
    26662612}
     2613#endif /* !IN_VMSVGA3D */
    26672614
    26682615- (void)clearVisibleRegions
     
    29452892    [pRunner runTasksSyncIfPossible];
    29462893   
     2894#ifndef IN_VMSVGA3D
    29472895    renderspuWinRetain(pWinInfo);
    29482896
    2949 #ifndef IN_VMSVGA3D
    29502897    if (renderspuCalloutAvailable())
    29512898    {
     
    29712918    }
    29722919   
     2920#ifndef IN_VMSVGA3D
    29732921    if (!*ppView)
    29742922        renderspuWinRelease(pWinInfo);
     2923#endif
    29752924   
    29762925    [pPool release];
     
    32123161VMSVGA3D_DECL(void) vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView)
    32133162{
    3214     /** @todo share WinInfo with caller and maintain it better. */
    3215     WindowInfo *pWinInfo = (WindowInfo *)RTMemAllocZ(sizeof(WindowInfo));
    3216     AssertLogRelReturnVoid(pWinInfo);
    3217     pWinInfo->cRefs = 1;
    3218     RTCritSectInit(&pWinInfo->CompositorLock);
    3219 
    3220     cocoaViewCreate(ppView, pWinInfo, pParentView, 0 /* fVisParams - ignored */);
     3163    cocoaViewCreate(ppView, NULL, pParentView, 0 /* fVisParams - ignored */);
    32213164}
    32223165
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