VirtualBox

Changeset 6649 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 31, 2008 11:11:03 AM (17 years ago)
Author:
vboxsync
Message:

FE/Qt: Minor style corrections.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h

    r6645 r6649  
    464464
    465465#include <Carbon/Carbon.h>
     466
    466467class VBoxQuartz2DFrameBuffer : public VBoxFrameBuffer
    467468{
     
    476477    STDMETHOD (SetVisibleRegion) (BYTE *aRectangles, ULONG aCount);
    477478
    478     uchar *address () { return mDataAddress; }
    479     ulong bitsPerPixel () { return CGImageGetBitsPerPixel (mImage); }
    480     ulong bytesPerLine () { return CGImageGetBytesPerRow (mImage); }
    481     ulong pixelFormat () { return mPixelFormat; };
    482     bool usesGuestVRAM () { return mBitmapData == NULL; }
    483 
    484     const CGImageRef imageRef () const { return mImage; }
     479    uchar *address() { return mDataAddress; }
     480    ulong bitsPerPixel() { return CGImageGetBitsPerPixel (mImage); }
     481    ulong bytesPerLine() { return CGImageGetBytesPerRow (mImage); }
     482    ulong pixelFormat() { return mPixelFormat; };
     483    bool usesGuestVRAM() { return mBitmapData == NULL; }
     484
     485    const CGImageRef imageRef() const { return mImage; }
    485486
    486487    void paintEvent (QPaintEvent *pe);
     
    488489
    489490private:
     491
    490492    inline CGRect QRectToCGRect (const QRect &aRect) const
    491493    {
    492         return CGRectMake (aRect.x (), aRect.y (), aRect.width (), aRect.height ());
    493     }
     494        return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height());
     495    }
     496
    494497    inline QRect mapYOrigin (const QRect &aRect, int aHeight) const
    495498    {
    496         /* The cgcontext has a fliped y-coord relative to the 
     499        /* The cgcontext has a fliped y-coord relative to the
    497500         * qt coord system. So we need some mapping here */
    498         return QRect (aRect.x (), aHeight - (aRect.y () + aRect.height ()), aRect.width (), aRect.height ());
    499     }
    500     void clean ();
    501 
    502     uchar *mDataAddress;
     501        return QRect (aRect.x(), aHeight - (aRect.y() + aRect.height()),
     502                      aRect.width(), aRect.height());
     503    }
     504
     505    void clean();
     506
     507    uchar *mDataAddress;
    503508    void *mBitmapData;
    504509    ulong mPixelFormat;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r6645 r6649  
    721721
    722722#if defined (VBOX_GUI_USE_DDRAW)
    723     if (!mFrameBuf || mFrameBuf->address () == NULL)
     723    if (!mFrameBuf || mFrameBuf->address() == NULL)
    724724    {
    725725        if (mFrameBuf)
     
    12081208                 *  destroyed widgets.
    12091209                 */
    1210                 QWidgetList *list = QApplication::topLevelWidgets ();
     1210                QWidgetList *list = QApplication::topLevelWidgets();
    12111211                bool destroyed = list->find (mMainWnd) < 0;
    12121212                delete list;
     
    17691769        case XFocusOut:
    17701770        case XFocusIn:
    1771             if (isRunning ())
     1771            if (isRunning())
    17721772                focusEvent (event->type == XFocusIn);
    17731773            return false;
     
    19661966    else
    19671967    {
    1968         ::DarwinReleaseKeyboard ();
     1968        ::DarwinReleaseKeyboard();
    19691969#ifndef VBOX_WITH_HACKED_QT
    19701970        if (mDarwinEventHandlerRef)
     
    28122812#ifdef Q_WS_MAC
    28132813            /* Update the dock icon if we are in the running state */
    2814             if (isRunning ())
     2814            if (isRunning())
    28152815            {
    28162816# if defined (VBOX_GUI_USE_QUARTZ2D)
    28172817                if (mode == VBoxDefs::Quartz2DMode)
    28182818                {
    2819                     /* If the render mode is Quartz2D we could use the CGImageRef of the framebuffer
    2820                      * for the dock icon creation. This saves some conversation time. */
    2821                     CGImageRef ir = static_cast<VBoxQuartz2DFrameBuffer*>(mFrameBuf)->imageRef ();
    2822                     SetApplicationDockTileImage (::DarwinCreateDockPreview (ir, mMainWnd->dockImageState ()));
    2823                 }else
     2819                    /* If the render mode is Quartz2D we could use the
     2820                     * CGImageRef of the framebuffer for the dock icon creation.
     2821                     * This saves some conversation time.*/
     2822                    CGImageRef ir =
     2823                        static_cast <VBoxQuartz2DFrameBuffer *> (mFrameBuf)->imageRef();
     2824                    SetApplicationDockTileImage (
     2825                        ::DarwinCreateDockPreview (ir, mMainWnd->dockImageState()));
     2826                }
     2827                else
    28242828# endif
    2825                     SetApplicationDockTileImage (::DarwinCreateDockPreview (mFrameBuf, mMainWnd->dockImageState ()));
     2829                    SetApplicationDockTileImage (
     2830                        ::DarwinCreateDockPreview (mFrameBuf, mMainWnd->dockImageState()));
    28262831            }
    28272832#endif
     
    28972902
    28982903    if (aEmitSignal)
    2899         emitKeyboardStateChanged ();
     2904        emitKeyboardStateChanged();
    29002905}
    29012906
     
    29492954
    29502955    if (aEmitSignal)
    2951         emitMouseStateChanged ();
     2956        emitMouseStateChanged();
    29522957}
    29532958
     
    30683073#endif
    30693074
    3070     emitKeyboardStateChanged ();
     3075    emitKeyboardStateChanged();
    30713076}
    30723077
     
    31323137void VBoxConsoleView::setPointerShape (MousePointerChangeEvent *me)
    31333138{
    3134     if (me->shapeData () != NULL)
     3139    if (me->shapeData() != NULL)
    31353140    {
    31363141        bool ok = false;
     
    33683373         * We did not get any shape data
    33693374         */
    3370         if (me->isVisible ())
     3375        if (me->isVisible())
    33713376        {
    33723377            /*
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r6645 r6649  
    19091909            vmDisableMouseIntegrAction->setEnabled (false);
    19101910    }
     1911
    19111912#ifdef Q_WS_MAC
    1912         SetApplicationDockTileImage (dockImgOS);
    1913         CGImageRef img = dockImageState ();
    1914         if (img)
    1915             OverlayApplicationDockTileImage (img);
     1913    SetApplicationDockTileImage (dockImgOS);
     1914    CGImageRef img = dockImageState();
     1915    if (img)
     1916        OverlayApplicationDockTileImage (img);
    19161917#endif
    19171918}
     
    21032104            Assert (status == noErr);
    21042105            /* For now disable the shadow of the window. This feature cause errors
    2105              * if a window in vbox looses focus, is reselected and than moved. 
     2106             * if a window in vbox looses focus, is reselected and than moved.
    21062107             * todo: Search for an option to enable this again. A shadow on every
    21072108             * window has a big coolness factor. */
     
    21862187
    21872188#ifdef Q_WS_MAC
    2188 CGImageRef VBoxConsoleWnd::dockImageState () const
     2189CGImageRef VBoxConsoleWnd::dockImageState() const
    21892190{
    21902191    CGImageRef img;
     
    22012202    return img;
    22022203}
    2203 #endif 
     2204#endif
    22042205
    22052206//
     
    22132214         * we requested. So after all the resizing stuff set the clipping
    22142215         * mask and the spacing shifter to the corresponding values. */
    2215         QDesktopWidget *dtw = QApplication::desktop ();
     2216        QDesktopWidget *dtw = QApplication::desktop();
    22162217        QRect sRect = dtw->screenGeometry (this);
    22172218        QRect aRect (aTargetRect);
     
    23072308        CKeyboard keyboard  = console->console().GetKeyboard();
    23082309        Assert (!keyboard.isNull());
    2309         static LONG cadSequence[] = {
     2310        static LONG sSequence[] =
     2311        {
    23102312            0x1d, // Ctrl down
    23112313            0x38, // Alt down
     
    23152317            0x9d  // Ctrl up
    23162318        };
    2317         keyboard.PutScancodes (cadSequence, ELEMENTS (cadSequence));
     2319        keyboard.PutScancodes (sSequence, ELEMENTS (sSequence));
    23182320        AssertWrapperOk (keyboard);
    23192321    }
     
    26362638    region.translate (mMaskShift.width(), mMaskShift.height());
    26372639    /* Restrict the drawing to the available space on the screen.
    2638      * (The &operator is better than the previous used -operator, 
    2639      * because this excludes space around the real screen also. 
     2640     * (The &operator is better than the previous used -operator,
     2641     * because this excludes space around the real screen also.
    26402642     * This is necessary for the mac.) */
    26412643    region &= mStrictedRegion;
     
    26742676    if (vboxGlobal().vmRenderMode() == VBoxDefs::Quartz2DMode)
    26752677    {
    2676         /* If we are using the Quartz2D backend we have to trigger 
    2677          * an repaint only. All the magic clipping stuff is done 
     2678        /* If we are using the Quartz2D backend we have to trigger
     2679         * an repaint only. All the magic clipping stuff is done
    26782680         * in the paint engine. */
    2679         repaint ();
    2680 //        qApp->processEvents ();
     2681        repaint();
     2682//        qApp->processEvents();
    26812683    }
    26822684    else
    26832685# endif
    26842686    {
    2685         /* This is necessary to avoid the flicker by an mask update. 
     2687        /* This is necessary to avoid the flicker by an mask update.
    26862688         * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html
    26872689         * for the hint.
    26882690         * There *must* be a better solution. */
    2689         if (!region.isEmpty ())
     2691        if (!region.isEmpty())
    26902692            region |= QRect (0, 0, 1, 1);
    26912693        /* Save the current region for later processing in the darwin event handler. */
     
    26952697         * mask is set. This leads into a missplaced drawing of the content. Currently
    26962698         * no alternative to this and also this is not 100% perfect. */
    2697         repaint ();
    2698         qApp->processEvents ();
     2699        repaint();
     2700        qApp->processEvents();
    26992701        /* Now force the reshaping of the window. This is definitly necessary. */
    2700         ReshapeCustomWindow (reinterpret_cast<WindowPtr>(winId()));
     2702        ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId()));
    27012703    }
    27022704#else
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp

    r6645 r6649  
    5050}
    5151
    52 VBoxQuartz2DFrameBuffer::~VBoxQuartz2DFrameBuffer ()
     52VBoxQuartz2DFrameBuffer::~VBoxQuartz2DFrameBuffer()
    5353{
    5454    Log (("Quartz2D: Deleting\n"));
    55     clean ();
     55    clean();
    5656}
    5757
     
    8484    QRegion reg;
    8585//    printf ("Region rects follow...\n");
    86     QRect vmScreenRect (0, 0, width (), height ());
     86    QRect vmScreenRect (0, 0, width(), height());
    8787    for (ULONG ind = 0; ind < aCount; ++ ind)
    8888    {
     
    100100        /* todo: Test if the other framebuffer implementation have the same
    101101         * problem with invalid rects (In Linux/Windows) */
    102         if (rect.isValid () &&
    103            rect.width () > 0 && rect.height () > 0)
     102        if (rect.isValid() &&
     103           rect.width() > 0 && rect.height() > 0)
    104104            reg += rect;
    105105        else
    106106            continue;
    107107
    108         mRegionRects[mRegionCount].origin.x = rect.x ();
    109         mRegionRects[mRegionCount].origin.y = rect.y ();
    110         mRegionRects[mRegionCount].size.width = rect.width ();
    111         mRegionRects[mRegionCount].size.height = rect.height ();
    112 //        printf ("Region rect[%d - %d]: %d %d %d %d\n", mRegionCount, aCount, rect.x (), rect.y (), rect.height (), rect.width ());
     108        mRegionRects[mRegionCount].origin.x = rect.x();
     109        mRegionRects[mRegionCount].origin.y = rect.y();
     110        mRegionRects[mRegionCount].size.width = rect.width();
     111        mRegionRects[mRegionCount].size.height = rect.height();
     112//        printf ("Region rect[%d - %d]: %d %d %d %d\n", mRegionCount, aCount, rect.x(), rect.y(), rect.height(), rect.width());
    113113        ++mRegionCount;
    114114    }
     
    146146{
    147147    /* Some general hints at the beginning:
    148      * The console is not a real sub window of the main window. There is 
     148     * The console is not a real sub window of the main window. There is
    149149     * one real mac window only. This means all the drawing on the context has
    150      * to pay attention to the statusbar, the scrollbars, the shifting spacers 
     150     * to pay attention to the statusbar, the scrollbars, the shifting spacers
    151151     * and any frame borders.
    152      * Secondly the origin of the coordinate system is differently defined in 
    153      * Qt and Quartz2D. In Qt the point (0, 0) means top/left where this is 
    154      * bottom/left in Quartz2D. Use mapYOrigin to map from Qt to Quartz2D. 
     152     * Secondly the origin of the coordinate system is differently defined in
     153     * Qt and Quartz2D. In Qt the point (0, 0) means top/left where this is
     154     * bottom/left in Quartz2D. Use mapYOrigin to map from Qt to Quartz2D.
    155155     *
    156156     * For debugging /Developer/Applications/Performance Tools/Quartz Debug.app
     
    159159    Assert (mImage);
    160160
    161     QWidget *pMain = qApp->mainWidget ();
     161    QWidget *pMain = qApp->mainWidget();
    162162    Assert (pMain);
    163163    /* Calculate the view rect to draw in */
    164164    QPoint p = mView->viewport()->mapTo (pMain, QPoint (0, 0));
    165     QRect Q2DViewRect = mapYOrigin (QRect (p.x (), p.y (), mView->width (), mView->height ()), pMain->height ());
     165    QRect Q2DViewRect = mapYOrigin (QRect (p.x(), p.y(), mView->width(), mView->height()), pMain->height());
    166166    /* We have to pay special attention to the scrollbars */
    167     if (mView->horizontalScrollBar ()->isVisible ())
    168         Q2DViewRect.setY (Q2DViewRect.y () + (mView->horizontalScrollBar ()->frameSize ().height () + 2));
    169     if (mView->verticalScrollBar ()->isVisible ())
    170         Q2DViewRect.setWidth (Q2DViewRect.width () - (mView->verticalScrollBar ()->frameSize ().width () + 2));
     167    if (mView->horizontalScrollBar()->isVisible())
     168        Q2DViewRect.setY (Q2DViewRect.y() + (mView->horizontalScrollBar()->frameSize().height() + 2));
     169    if (mView->verticalScrollBar()->isVisible())
     170        Q2DViewRect.setWidth (Q2DViewRect.width() - (mView->verticalScrollBar()->frameSize().width() + 2));
    171171
    172172    /* Create the context to draw on */
    173     WindowPtr window = static_cast<WindowPtr>(mView->viewport ()->handle ());
     173    WindowPtr window = static_cast<WindowPtr>(mView->viewport()->handle());
    174174    SetPortWindowPort (window);
    175175    CGContextRef ctx;
    176176    QDBeginCGContext (GetWindowPort (window), &ctx);
    177177    /* We handle the seamless mode as a special case. */
    178     if (static_cast<VBoxConsoleWnd*>(pMain)->isTrueSeamless ())
    179     {
    180         /* Here we paint the windows without any wallpaper. 
     178    if (static_cast<VBoxConsoleWnd*>(pMain)->isTrueSeamless())
     179    {
     180        /* Here we paint the windows without any wallpaper.
    181181         * So the background would be set transparently. */
    182182
    183183        /* Create a subimage of the current view.
    184184         * Currently this subimage is the whole screen. */
    185         CGImageRef subImage = CGImageCreateWithImageInRect (mImage, CGRectMake (mView->contentsX (), mView->contentsY (), mView->visibleWidth (), mView->visibleHeight ()));
     185        CGImageRef subImage = CGImageCreateWithImageInRect (mImage, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));
    186186        Assert (subImage);
    187187        /* Clear the background (Make the rect fully transparent) */
     
    195195            /* Flip the y-coord */
    196196            CGContextScaleCTM (ctx, 1.0, -1.0);
    197             CGContextTranslateCTM (ctx, Q2DViewRect.x (), -Q2DViewRect.height () - Q2DViewRect.y ());
     197            CGContextTranslateCTM (ctx, Q2DViewRect.x(), -Q2DViewRect.height() - Q2DViewRect.y());
    198198            /* Add the clipping rects all at once. They are defined in
    199199             * SetVisibleRegion. */
     
    216216        /* Create a subimage of the current view in the size
    217217         * of the bounding box of the current paint event */
    218         QRect ir = pe->rect ();
    219         QRect is = QRect (ir.x () + mView->contentsX (), ir.y () + mView->contentsY (), ir.width (), ir.height ());
     218        QRect ir = pe->rect();
     219        QRect is = QRect (ir.x() + mView->contentsX(), ir.y() + mView->contentsY(), ir.width(), ir.height());
    220220        CGImageRef subImage = CGImageCreateWithImageInRect (mImage, QRectToCGRect (is));
    221221        Assert (subImage);
     
    223223        /* Ok, for more performance we set a clipping path of the
    224224         * regions given by this paint event. */
    225         QMemArray<QRect> a = pe->region ().rects ();
    226         if (a.size () > 0)
     225        QMemArray<QRect> a = pe->region().rects();
     226        if (a.size() > 0)
    227227        {
    228228            /* Save state for display fliping */
     
    230230            /* Flip the y-coord */
    231231            CGContextScaleCTM (ctx, 1.0, -1.0);
    232             CGContextTranslateCTM (ctx, Q2DViewRect.x (), -Q2DViewRect.height () - Q2DViewRect.y ());
     232            CGContextTranslateCTM (ctx, Q2DViewRect.x(), -Q2DViewRect.height() - Q2DViewRect.y());
    233233            CGContextBeginPath (ctx);
    234234            /* Add all region rects to the current context as path components */
    235             for (unsigned int i = 0; i < a.size (); ++i)
     235            for (unsigned int i = 0; i < a.size(); ++i)
    236236                CGContextAddRect (ctx, QRectToCGRect (a[i]));
    237237            CGContextRestoreGState (ctx);
     
    243243        CGContextClipToRect (ctx, QRectToCGRect (Q2DViewRect));
    244244        /* Draw the sub image to the right position */
    245         QPoint p = mView->viewport ()->mapTo (pMain, QPoint (ir.x (), ir.y ()));
    246         QRect cr = mapYOrigin (QRect (p.x (), p.y (), ir.width (), ir.height ()), pMain->height ());
     245        QPoint p = mView->viewport()->mapTo (pMain, QPoint (ir.x(), ir.y()));
     246        QRect cr = mapYOrigin (QRect (p.x(), p.y(), ir.width(), ir.height()), pMain->height());
    247247        CGContextDrawImage (ctx, QRectToCGRect (cr), subImage);
    248248    }
     
    254254//        CGContextSetShadow (myContext, CGSizeMake (10, 5), 1);
    255255//        CGContextClipToRect (myContext, rect);
    256 //        QRect ir = pe->rect ();
    257 //        CGContextClipToRect (myContext, CGRectMake (ir.y (), ir.x (), ir.width (), ir.height ()));
     256//        QRect ir = pe->rect();
     257//        CGContextClipToRect (myContext, CGRectMake (ir.y(), ir.x(), ir.width(), ir.height()));
    258258//        CGContextEndTransparencyLayer (myContext);
    259259
     
    262262#if 0
    263263    printf ("fmt=%lu, vram=%X, bpp=%lu, bpl=%lu, width=%lu, height=%lu\n",
    264            re->pixelFormat (), (unsigned int)re->VRAM (),
    265            re->bitsPerPixel (), re->bytesPerLine (),
    266            re->width (), re->height ());
     264           re->pixelFormat(), (unsigned int)re->VRAM(),
     265           re->bitsPerPixel(), re->bytesPerLine(),
     266           re->width(), re->height());
    267267#endif
    268268
    269269    /* Clean out old stuff */
    270     clean ();
    271 
    272     mWdt = re->width ();
    273     mHgt = re->height ();
     270    clean();
     271
     272    mWdt = re->width();
     273    mHgt = re->height();
    274274
    275275    /* We need a color space in any case */
    276     CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
    277     /* Check if we support the pixel format/colordepth and can use the guest VRAM directly. 
     276    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
     277    /* Check if we support the pixel format/colordepth and can use the guest VRAM directly.
    278278     * Mac OS X supports 16 bit also but not in the 565 mode. So we could use
    279279     * 32 bit only. */
    280     if (re->pixelFormat () == FramebufferPixelFormat_FOURCC_RGB &&
    281         re->bitsPerPixel () == 32)
     280    if (re->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB &&
     281        re->bitsPerPixel() == 32)
    282282    {
    283283//        printf ("VRAM\n");
    284         CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
     284        CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    285285        /* Create the image copy of the framebuffer */
    286         CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, re->VRAM (), re->bitsPerPixel () / 8 * mWdt * mHgt, NULL);
    287         mImage = CGImageCreate (mWdt, mHgt, 8, re->bitsPerPixel (), re->bytesPerLine (), cs,
    288                                 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 
     286        CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, re->VRAM(), re->bitsPerPixel() / 8 * mWdt * mHgt, NULL);
     287        mImage = CGImageCreate (mWdt, mHgt, 8, re->bitsPerPixel(), re->bytesPerLine(), cs,
     288                                kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
    289289                                kCGRenderingIntentDefault);
    290         mDataAddress = re->VRAM ();
     290        mDataAddress = re->VRAM();
    291291        CGDataProviderRelease (dp);
    292292    }
     
    300300        CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, mBitmapData, bitmapByteCount, NULL);
    301301        mImage = CGImageCreate (mWdt, mHgt, 8, 32, bitmapBytesPerRow, cs,
    302                                kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 
     302                               kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
    303303                               kCGRenderingIntentDefault);
    304304        mDataAddress = static_cast<uchar*>(mBitmapData);
     
    308308}
    309309
    310 void VBoxQuartz2DFrameBuffer::clean ()
     310void VBoxQuartz2DFrameBuffer::clean()
    311311{
    312312    if (mImage)
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp

    r6645 r6649  
    4949    QImage *imageCopy = new QImage (*aImage);
    5050    /** @todo this code assumes 32-bit image input, the lazy bird convert image to 32-bit method is anything but optimal... */
    51     if (imageCopy->depth () != 32)
     51    if (imageCopy->depth() != 32)
    5252        *imageCopy = imageCopy->convertDepth (32);
    53     Assert (!imageCopy->isNull ());
    54 
    55     CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
    56     CGDataProviderRef dp = CGDataProviderCreateWithData (imageCopy, aImage->bits (), aImage->numBytes (), darwinDataProviderReleaseQImage);
    57 
    58     CGBitmapInfo bmpInfo = imageCopy->hasAlphaBuffer () ? kCGImageAlphaFirst : kCGImageAlphaNoneSkipFirst;
     53    Assert (!imageCopy->isNull());
     54
     55    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
     56    CGDataProviderRef dp = CGDataProviderCreateWithData (imageCopy, aImage->bits(), aImage->numBytes(), darwinDataProviderReleaseQImage);
     57
     58    CGBitmapInfo bmpInfo = imageCopy->hasAlphaBuffer() ? kCGImageAlphaFirst : kCGImageAlphaNoneSkipFirst;
    5959    bmpInfo |= kCGBitmapByteOrder32Host;
    60     CGImageRef ir = CGImageCreate (imageCopy->width (), imageCopy->height (), 8, 32, imageCopy->bytesPerLine (), cs,
     60    CGImageRef ir = CGImageCreate (imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
    6161                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
    6262                                   kCGRenderingIntentDefault);
     
    7676CGImageRef DarwinQPixmapToCGImage (const QPixmap *aPixmap)
    7777{
    78     QImage qimg = aPixmap->convertToImage ();
    79     Assert (!qimg.isNull ());
     78    QImage qimg = aPixmap->convertToImage();
     79    Assert (!qimg.isNull());
    8080    return DarwinQImageToCGImage (&qimg);
    8181}
     
    9090{
    9191    QPixmap qpm = QPixmap::fromMimeSource (aSource);
    92     Assert (!qpm.isNull ());
     92    Assert (!qpm.isNull());
    9393    return DarwinQPixmapToCGImage (&qpm);
    9494}
     
    108108       just created one that I can load. The Qt gurus can fix this if they like :-) */
    109109    QPixmap back (QPixmap::fromMimeSource ("dock_128x128_transparent.png"));
    110     Assert (!back.isNull ());
    111     Assert (back.width () == 128 && back.height () == 128);
     110    Assert (!back.isNull());
     111    Assert (back.width() == 128 && back.height() == 128);
    112112
    113113    /* load the badge */
    114114    QPixmap badge = QPixmap::fromMimeSource (aSource);
    115     Assert (!badge.isNull ());
     115    Assert (!badge.isNull());
    116116
    117117    /* resize it and copy it onto the background. */
    118     if (badge.width () < 32)
    119         badge = badge.convertToImage ().smoothScale (32, 32);
    120     copyBlt (&back, back.width () - badge.width (), back.height () - badge.height (),
     118    if (badge.width() < 32)
     119        badge = badge.convertToImage().smoothScale (32, 32);
     120    copyBlt (&back, back.width() - badge.width(), back.height() - badge.height(),
    121121             &badge, 0, 0,
    122              badge.width (), badge.height ());
    123     Assert (!back.isNull ());
    124     Assert (back.width () == 128 && back.height () == 128);
     122             badge.width(), badge.height());
     123    Assert (!back.isNull());
     124    Assert (back.width() == 128 && back.height() == 128);
    125125
    126126    /* Convert it to a CGImage. */
     
    142142    Assert (aVMImage);
    143143
    144     CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
     144    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    145145    Assert (cs);
    146146
     
    150150    int scaledWidth;
    151151    int scaledHeight;
    152     float aspect = static_cast<float>(CGImageGetWidth (aVMImage)) / CGImageGetHeight (aVMImage);
     152    float aspect = static_cast <float> (CGImageGetWidth (aVMImage)) / CGImageGetHeight (aVMImage);
    153153    if (aspect > 1.0)
    154154    {
     
    161161        scaledHeight = targetHeight;
    162162    }
    163     CGRect iconRect = CGRectMake ((targetWidth - scaledWidth) / 2.0, 
    164                                   (targetHeight - scaledHeight) / 2.0, 
     163    CGRect iconRect = CGRectMake ((targetWidth - scaledWidth) / 2.0,
     164                                  (targetHeight - scaledHeight) / 2.0,
    165165                                  scaledWidth, scaledHeight);
    166166    /* Create a bitmap context to draw on */
     
    218218CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage)
    219219{
    220     CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
     220    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    221221    Assert (cs);
    222222    /* Create the image copy of the framebuffer */
    223     CGDataProviderRef dp = CGDataProviderCreateWithData (aFrameBuffer, aFrameBuffer->address (), aFrameBuffer->bitsPerPixel () / 8 * aFrameBuffer->width () * aFrameBuffer->height (), NULL);
     223    CGDataProviderRef dp = CGDataProviderCreateWithData (aFrameBuffer, aFrameBuffer->address(), aFrameBuffer->bitsPerPixel() / 8 * aFrameBuffer->width() * aFrameBuffer->height(), NULL);
    224224    Assert (dp);
    225     CGImageRef ir = CGImageCreate (aFrameBuffer->width (), aFrameBuffer->height (), 8, 32, aFrameBuffer->bytesPerLine (), cs,
     225    CGImageRef ir = CGImageCreate (aFrameBuffer->width(), aFrameBuffer->height(), 8, 32, aFrameBuffer->bytesPerLine(), cs,
    226226                                   kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false,
    227227                                   kCGRenderingIntentDefault);
     
    241241
    242242    OSStatus status = eventNotHandledErr;
    243    
     243
    244244    switch (GetEventKind (aInEvent))
    245245    {
     
    248248            WindowRegionCode code;
    249249            RgnHandle rgn;
    250            
     250
    251251            /* which region code is being queried? */
    252252            GetEventParameter (aInEvent, kEventParamWindowRegionCode, typeWindowRegionCode, NULL, sizeof (code), NULL, &code);
     
    264264                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof (rgn), NULL, &rgn);
    265265                QRegion *pRegion = static_cast <QRegion*> (aInUserData);
    266                 if (!pRegion->isNull () && pRegion)
     266                if (!pRegion->isNull() && pRegion)
    267267                {
    268                     CopyRgn (pRegion->handle (), rgn);
     268                    CopyRgn (pRegion->handle(), rgn);
    269269                    status = noErr;
    270270                }
     
    273273        }
    274274    }
    275    
     275
    276276    return status;
    277277}
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