VirtualBox

Changeset 44910 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 4, 2013 11:40:29 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84081
Message:

FE/Qt: Multi-screen support: Reworking Quartz2D frame-buffer paint-engine to make sure zero-region is not painted as fullscreen in seamless mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp

    r44528 r44910  
    194194    if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless)
    195195    {
    196         /* Here we paint the windows without any wallpaper.
    197          * So the background would be set transparently. */
    198 
    199         /* Create a subimage of the current view.
    200          * Currently this subimage is the whole screen. */
    201         CGImageRef subImage;
    202         if (!m_pMachineView->pauseShot().isNull())
    203         {
    204             CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot());
    205             subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
    206             CGImageRelease(pauseImg);
    207         }
    208         else
    209         {
    210 #ifdef RT_ARCH_AMD64
    211             /* Not sure who to blame, but it seems on 64bit there goes
    212              * something terrible wrong (on a second monitor) when directly
    213              * using CGImageCreateWithImageInRect without making a copy. We saw
    214              * something like this already with the scale mode. */
    215             CGImageRef tmpImage = CGImageCreateWithImageInRect(m_image, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
    216             subImage = CGImageCreateCopy(tmpImage);
    217             CGImageRelease(tmpImage);
    218 #else
    219             subImage = CGImageCreateWithImageInRect(m_image, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
    220 #endif
    221         }
    222         Assert(VALID_PTR(subImage));
    223         /* Clear the background (Make the rect fully transparent) */
     196        /* Clear the background (make the rect fully transparent): */
    224197        CGContextClearRect(ctx, viewRect);
     198
    225199#ifdef OVERLAY_CLIPRECTS
     200        /* Enable overlay above the seamless mask: */
    226201        CGContextSetRGBFillColor(ctx, 0.0, 0.0, 5.0, 0.7);
    227202        CGContextFillRect(ctx, viewRect);
    228 #endif
     203#endif /* OVERLAY_CLIPRECTS */
    229204#ifdef COMP_WITH_SHADOW
    230         /* Enable shadows */
     205        /* Enable shadows: */
    231206        CGContextSetShadow(ctx, CGSizeMake (10, -10), 10);
    232207        CGContextBeginTransparencyLayer(ctx, NULL);
    233 #endif
    234         /* Grab the current visible region. */
    235         RegionRects *rgnRcts = ASMAtomicXchgPtrT(&mRegion, NULL, RegionRects *);
    236         if (rgnRcts)
    237         {
    238             if (rgnRcts->used > 0)
     208#endif /* COMP_WITH_SHADOW */
     209
     210        /* Determine current visible region: */
     211        RegionRects *pRgnRcts = ASMAtomicXchgPtrT(&mRegion, NULL, RegionRects*);
     212        if (pRgnRcts)
     213        {
     214            /* If visible region is determined: */
     215            if (pRgnRcts->used > 0)
    239216            {
    240                 /* Add the clipping rects all at once. They are defined in
    241                  * SetVisibleRegion. */
     217                /* Add the clipping rects all at once (they are defined in SetVisibleRegion): */
    242218                CGContextBeginPath(ctx);
    243                 CGContextAddRects(ctx, rgnRcts->rcts, rgnRcts->used);
    244                 /* Now convert the path to a clipping path. */
     219                CGContextAddRects(ctx, pRgnRcts->rcts, pRgnRcts->used);
     220                /* Now convert the path to a clipping path: */
    245221                CGContextClip(ctx);
    246222            }
    247             /* Put back the visible region, free if we cannot (2+ SetVisibleRegion calls). */
    248             if (    !ASMAtomicCmpXchgPtr(&mRegion, rgnRcts, NULL)
    249                 &&  !ASMAtomicCmpXchgPtr(&mRegionUnused, rgnRcts, NULL))
    250                 RTMemFree(rgnRcts);
    251         }
    252         /* In any case clip the drawing to the view window */
    253         CGContextClipToRect(ctx, viewRect);
    254         /* At this point draw the real vm image */
    255         CGContextDrawImage(ctx, ::darwinFlipCGRect (viewRect, viewRect.size.height), subImage);
     223
     224            /* Put back the visible region, free if we cannot (2+ SetVisibleRegion calls): */
     225            if (   !ASMAtomicCmpXchgPtr(&mRegion, pRgnRcts, NULL)
     226                && !ASMAtomicCmpXchgPtr(&mRegionUnused, pRgnRcts, NULL))
     227            {
     228                RTMemFree(pRgnRcts);
     229                pRgnRcts = NULL;
     230            }
     231        }
     232
     233        /* If visible region is still determined: */
     234        if (pRgnRcts && pRgnRcts->used > 0)
     235        {
     236            /* Create a subimage of the current view.
     237             * Currently this subimage is the whole screen. */
     238            CGImageRef subImage;
     239            if (!m_pMachineView->pauseShot().isNull())
     240            {
     241                CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot());
     242                subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
     243                CGImageRelease(pauseImg);
     244            }
     245            else
     246            {
     247#ifdef RT_ARCH_AMD64
     248                /* Not sure who to blame, but it seems on 64bit there goes
     249                 * something terrible wrong (on a second monitor) when directly
     250                 * using CGImageCreateWithImageInRect without making a copy. We saw
     251                 * something like this already with the scale mode. */
     252                CGImageRef tmpImage = CGImageCreateWithImageInRect(m_image, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
     253                subImage = CGImageCreateCopy(tmpImage);
     254                CGImageRelease(tmpImage);
     255#else /* RT_ARCH_AMD64 */
     256                subImage = CGImageCreateWithImageInRect(m_image, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
     257#endif /* !RT_ARCH_AMD64 */
     258            }
     259            Assert(VALID_PTR(subImage));
     260
     261            /* In any case clip the drawing to the view window: */
     262            CGContextClipToRect(ctx, viewRect);
     263            /* At this point draw the real vm image: */
     264            CGContextDrawImage(ctx, ::darwinFlipCGRect(viewRect, viewRect.size.height), subImage);
     265
     266            /* Release the subimage: */
     267            CGImageRelease(subImage);
     268        }
     269
    256270#ifdef COMP_WITH_SHADOW
    257271        CGContextEndTransparencyLayer(ctx);
    258 #endif
    259         CGImageRelease(subImage);
     272#endif /* COMP_WITH_SHADOW */
    260273#ifdef OVERLAY_CLIPRECTS
    261         if (rgnRcts && rgnRcts->used > 0)
     274        if (pRgnRcts && pRgnRcts->used > 0)
    262275        {
    263276            CGContextBeginPath(ctx);
    264             CGContextAddRects(ctx, rgnRcts->rcts, rgnRcts->used);
     277            CGContextAddRects(ctx, pRgnRcts->rcts, pRgnRcts->used);
    265278            CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 0.7);
    266279            CGContextDrawPath(ctx, kCGPathStroke);
     
    268281        CGContextSetRGBStrokeColor(ctx, 0.0, 1.0, 0.0, 0.7);
    269282        CGContextStrokeRect(ctx, viewRect);
    270 #endif
     283#endif /* OVERLAY_CLIPRECTS */
    271284    }
    272285    else if (   m_pMachineLogic->visualStateType() == UIVisualStateType_Scale
Note: See TracChangeset for help on using the changeset viewer.

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