VirtualBox

Changeset 27022 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 4, 2010 1:01:56 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: new core: more cleanup

File:
1 edited

Legend:

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

    r27021 r27022  
    163163     * updated.*/
    164164
    165     Assert (m_image);
    166 
    167 //    VBoxConsoleWnd *main = qobject_cast <VBoxConsoleWnd *> (vboxGlobal().mainWindow());
    168 //    Assert (VALID_PTR (main));
     165    Assert(m_image);
     166
    169167    QWidget* viewport = m_pMachineView->viewport();
    170     Assert(VALID_PTR (viewport));
     168    Assert(VALID_PTR(viewport));
    171169    /* Get the dimensions of the viewport */
    172170    CGRect viewRect = ::darwinToCGRect(viewport->geometry());
     
    176174
    177175    /* Flip the context */
    178     CGContextTranslateCTM (ctx, 0, viewRect.size.height);
    179     CGContextScaleCTM (ctx, 1.0, -1.0);
     176    CGContextTranslateCTM(ctx, 0, viewRect.size.height);
     177    CGContextScaleCTM(ctx, 1.0, -1.0);
    180178
    181179    /* We handle the seamless mode as a special case. */
     
    190188        if (!m_pMachineView->pauseShot().isNull())
    191189        {
    192             CGImageRef pauseImg = ::darwinToCGImageRef (&m_pMachineView->pauseShot());
    193             subImage = CGImageCreateWithImageInRect (pauseImg, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
    194             CGImageRelease (pauseImg);
     190            CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot());
     191            subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
     192            CGImageRelease(pauseImg);
    195193        }
    196194        else
    197             subImage = CGImageCreateWithImageInRect (m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
    198         Assert (VALID_PTR (subImage));
     195            subImage = CGImageCreateWithImageInRect(m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
     196        Assert(VALID_PTR(subImage));
    199197        /* Clear the background (Make the rect fully transparent) */
    200         CGContextClearRect (ctx, viewRect);
     198        CGContextClearRect(ctx, viewRect);
    201199#ifdef OVERLAY_CLIPRECTS
    202         CGContextSetRGBFillColor (ctx, 0.0, 0.0, 5.0, 0.7);
    203         CGContextFillRect (ctx, viewRect);
     200        CGContextSetRGBFillColor(ctx, 0.0, 0.0, 5.0, 0.7);
     201        CGContextFillRect(ctx, viewRect);
    204202#endif
    205203#ifdef COMP_WITH_SHADOW
    206204        /* Enable shadows */
    207         CGContextSetShadow (ctx, CGSizeMake (10, -10), 10);
    208         CGContextBeginTransparencyLayer (ctx, NULL);
     205        CGContextSetShadow(ctx, CGSizeMake (10, -10), 10);
     206        CGContextBeginTransparencyLayer(ctx, NULL);
    209207#endif
    210208        /* Grab the current visible region. */
    211         RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr ((void * volatile *) &mRegion, NULL);
     209        RegionRects *rgnRcts = (RegionRects *)ASMAtomicXchgPtr((void * volatile *)&mRegion, NULL);
    212210        if (rgnRcts)
    213211        {
     
    216214                /* Add the clipping rects all at once. They are defined in
    217215                 * SetVisibleRegion. */
    218                 CGContextBeginPath (ctx);
    219                 CGContextAddRects (ctx, rgnRcts->rcts, rgnRcts->used);
     216                CGContextBeginPath(ctx);
     217                CGContextAddRects(ctx, rgnRcts->rcts, rgnRcts->used);
    220218                /* Now convert the path to a clipping path. */
    221                 CGContextClip (ctx);
     219                CGContextClip(ctx);
    222220            }
    223221            /* Put back the visible region, free if we cannot (2+ SetVisibleRegion calls). */
    224             if (    !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegion, rgnRcts, NULL)
    225                 &&  !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegionUnused, rgnRcts, NULL))
    226                 RTMemFree (rgnRcts);
     222            if (    !ASMAtomicCmpXchgPtr((void * volatile *)&mRegion, rgnRcts, NULL)
     223                &&  !ASMAtomicCmpXchgPtr((void * volatile *)&mRegionUnused, rgnRcts, NULL))
     224                RTMemFree(rgnRcts);
    227225        }
    228226        /* In any case clip the drawing to the view window */
    229         CGContextClipToRect (ctx, viewRect);
     227        CGContextClipToRect(ctx, viewRect);
    230228        /* At this point draw the real vm image */
    231         CGContextDrawImage (ctx, ::darwinFlipCGRect (viewRect, viewRect.size.height), subImage);
     229        CGContextDrawImage(ctx, ::darwinFlipCGRect (viewRect, viewRect.size.height), subImage);
    232230#ifdef COMP_WITH_SHADOW
    233         CGContextEndTransparencyLayer (ctx);
    234 #endif
    235         CGImageRelease (subImage);
     231        CGContextEndTransparencyLayer(ctx);
     232#endif
     233        CGImageRelease(subImage);
    236234#ifdef OVERLAY_CLIPRECTS
    237235        if (rgnRcts && rgnRcts->used > 0)
    238236        {
    239             CGContextBeginPath (ctx);
    240             CGContextAddRects (ctx, rgnRcts->rcts, rgnRcts->used);
    241             CGContextSetRGBStrokeColor (ctx, 1.0, 0.0, 0.0, 0.7);
    242             CGContextDrawPath (ctx, kCGPathStroke);
    243         }
    244         CGContextSetRGBStrokeColor (ctx, 0.0, 1.0, 0.0, 0.7);
    245         CGContextStrokeRect (ctx, viewRect);
     237            CGContextBeginPath(ctx);
     238            CGContextAddRects(ctx, rgnRcts->rcts, rgnRcts->used);
     239            CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 0.7);
     240            CGContextDrawPath(ctx, kCGPathStroke);
     241        }
     242        CGContextSetRGBStrokeColor(ctx, 0.0, 1.0, 0.0, 0.7);
     243        CGContextStrokeRect(ctx, viewRect);
    246244#endif
    247245    }
     
    257255        if (!m_pMachineView->pauseShot().isNull())
    258256        {
    259             CGImageRef pauseImg = ::darwinToCGImageRef (&m_pMachineView->pauseShot());
    260             subImage = CGImageCreateWithImageInRect (pauseImg, ::darwinToCGRect (is));
    261             CGImageRelease (pauseImg);
     257            CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot());
     258            subImage = CGImageCreateWithImageInRect(pauseImg, ::darwinToCGRect(is));
     259            CGImageRelease(pauseImg);
    262260        }
    263261        else
    264             subImage = CGImageCreateWithImageInRect (m_image, ::darwinToCGRect (is));
    265         Assert (VALID_PTR (subImage));
     262            subImage = CGImageCreateWithImageInRect(m_image, ::darwinToCGRect(is));
     263        Assert(VALID_PTR(subImage));
    266264        /* Ok, for more performance we set a clipping path of the
    267265         * regions given by this paint event. */
     
    272270            /* Add all region rects to the current context as path components */
    273271            for (int i = 0; i < a.size(); ++i)
    274                 CGContextAddRect (ctx, ::darwinFlipCGRect (::darwinToCGRect (a[i]), viewRect.size.height));
     272                CGContextAddRect(ctx, ::darwinFlipCGRect(::darwinToCGRect(a[i]), viewRect.size.height));
    275273            /* Now convert the path to a clipping path. */
    276             CGContextClip (ctx);
     274            CGContextClip(ctx);
    277275        }
    278276
    279277        /* In any case clip the drawing to the view window */
    280         CGContextClipToRect (ctx, viewRect);
     278        CGContextClipToRect(ctx, viewRect);
    281279        /* At this point draw the real vm image */
    282         CGContextDrawImage (ctx, ::darwinFlipCGRect (::darwinToCGRect (ir), viewRect.size.height), subImage);
    283 
    284         CGImageRelease (subImage);
    285     }
    286 }
    287 
    288 void UIFrameBufferQuartz2D::resizeEvent (UIResizeEvent *aEvent)
     280        CGContextDrawImage(ctx, ::darwinFlipCGRect(::darwinToCGRect (ir), viewRect.size.height), subImage);
     281
     282        CGImageRelease(subImage);
     283    }
     284}
     285
     286void UIFrameBufferQuartz2D::resizeEvent(UIResizeEvent *aEvent)
    289287{
    290288#if 0
     
    313311//        printf ("VRAM\n");
    314312        /* Create the image copy of the framebuffer */
    315         CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * m_width * m_height, NULL);
    316         m_image = CGImageCreate (m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs,
     313        CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * m_width * m_height, NULL);
     314        m_image = CGImageCreate(m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs,
    317315                                kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
    318316                                kCGRenderingIntentDefault);
     
    330328        int bitmapBytesPerRow = m_width * 4;
    331329        int bitmapByteCount = (bitmapBytesPerRow * m_height);
    332         m_pBitmapData = RTMemAlloc (bitmapByteCount);
    333         CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, m_pBitmapData, bitmapByteCount, NULL);
    334         m_image = CGImageCreate (m_width, m_height, 8, 32, bitmapBytesPerRow, cs,
    335                                kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
    336                                kCGRenderingIntentDefault);
    337         m_pDataAddress = static_cast <uchar*> (m_pBitmapData);
    338         CGDataProviderRelease (dp);
    339     }
    340     CGColorSpaceRelease (cs);
     330        m_pBitmapData = RTMemAlloc(bitmapByteCount);
     331        CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, m_pBitmapData, bitmapByteCount, NULL);
     332        m_image = CGImageCreate(m_width, m_height, 8, 32, bitmapBytesPerRow, cs,
     333                                kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
     334                                kCGRenderingIntentDefault);
     335        m_pDataAddress = static_cast<uchar*>(m_pBitmapData);
     336        CGDataProviderRelease(dp);
     337    }
     338    CGColorSpaceRelease(cs);
    341339#ifdef VBOX_WITH_ICHAT_THEATER
    342     setImageRef (m_image);
     340    setImageRef(m_image);
    343341#endif
    344342
     
    364362    if (m_image)
    365363    {
    366         CGImageRelease (m_image);
     364        CGImageRelease(m_image);
    367365        m_image = NULL;
    368366    }
    369367    if (m_pBitmapData)
    370368    {
    371         RTMemFree (m_pBitmapData);
     369        RTMemFree(m_pBitmapData);
    372370        m_pBitmapData = NULL;
    373371    }
    374372    if (mRegion)
    375373    {
    376         RTMemFree ((void *) mRegion);
     374        RTMemFree((void *)mRegion);
    377375        mRegion = NULL;
    378376    }
    379377    if (mRegionUnused)
    380378    {
    381         RTMemFree ((void *) mRegionUnused);
     379        RTMemFree((void *)mRegionUnused);
    382380        mRegionUnused = NULL;
    383381    }
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