Changeset 6649 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 31, 2008 11:11:03 AM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r6645 r6649 464 464 465 465 #include <Carbon/Carbon.h> 466 466 467 class VBoxQuartz2DFrameBuffer : public VBoxFrameBuffer 467 468 { … … 476 477 STDMETHOD (SetVisibleRegion) (BYTE *aRectangles, ULONG aCount); 477 478 478 uchar *address 479 ulong bitsPerPixel 480 ulong bytesPerLine 481 ulong pixelFormat 482 bool usesGuestVRAM 483 484 const CGImageRef imageRef 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; } 485 486 486 487 void paintEvent (QPaintEvent *pe); … … 488 489 489 490 private: 491 490 492 inline CGRect QRectToCGRect (const QRect &aRect) const 491 493 { 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 494 497 inline QRect mapYOrigin (const QRect &aRect, int aHeight) const 495 498 { 496 /* The cgcontext has a fliped y-coord relative to the 499 /* The cgcontext has a fliped y-coord relative to the 497 500 * 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; 503 508 void *mBitmapData; 504 509 ulong mPixelFormat; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r6645 r6649 721 721 722 722 #if defined (VBOX_GUI_USE_DDRAW) 723 if (!mFrameBuf || mFrameBuf->address 723 if (!mFrameBuf || mFrameBuf->address() == NULL) 724 724 { 725 725 if (mFrameBuf) … … 1208 1208 * destroyed widgets. 1209 1209 */ 1210 QWidgetList *list = QApplication::topLevelWidgets 1210 QWidgetList *list = QApplication::topLevelWidgets(); 1211 1211 bool destroyed = list->find (mMainWnd) < 0; 1212 1212 delete list; … … 1769 1769 case XFocusOut: 1770 1770 case XFocusIn: 1771 if (isRunning 1771 if (isRunning()) 1772 1772 focusEvent (event->type == XFocusIn); 1773 1773 return false; … … 1966 1966 else 1967 1967 { 1968 ::DarwinReleaseKeyboard 1968 ::DarwinReleaseKeyboard(); 1969 1969 #ifndef VBOX_WITH_HACKED_QT 1970 1970 if (mDarwinEventHandlerRef) … … 2812 2812 #ifdef Q_WS_MAC 2813 2813 /* Update the dock icon if we are in the running state */ 2814 if (isRunning 2814 if (isRunning()) 2815 2815 { 2816 2816 # if defined (VBOX_GUI_USE_QUARTZ2D) 2817 2817 if (mode == VBoxDefs::Quartz2DMode) 2818 2818 { 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 2824 2828 # endif 2825 SetApplicationDockTileImage (::DarwinCreateDockPreview (mFrameBuf, mMainWnd->dockImageState ())); 2829 SetApplicationDockTileImage ( 2830 ::DarwinCreateDockPreview (mFrameBuf, mMainWnd->dockImageState())); 2826 2831 } 2827 2832 #endif … … 2897 2902 2898 2903 if (aEmitSignal) 2899 emitKeyboardStateChanged 2904 emitKeyboardStateChanged(); 2900 2905 } 2901 2906 … … 2949 2954 2950 2955 if (aEmitSignal) 2951 emitMouseStateChanged 2956 emitMouseStateChanged(); 2952 2957 } 2953 2958 … … 3068 3073 #endif 3069 3074 3070 emitKeyboardStateChanged 3075 emitKeyboardStateChanged(); 3071 3076 } 3072 3077 … … 3132 3137 void VBoxConsoleView::setPointerShape (MousePointerChangeEvent *me) 3133 3138 { 3134 if (me->shapeData 3139 if (me->shapeData() != NULL) 3135 3140 { 3136 3141 bool ok = false; … … 3368 3373 * We did not get any shape data 3369 3374 */ 3370 if (me->isVisible 3375 if (me->isVisible()) 3371 3376 { 3372 3377 /* -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r6645 r6649 1909 1909 vmDisableMouseIntegrAction->setEnabled (false); 1910 1910 } 1911 1911 1912 #ifdef Q_WS_MAC 1912 1913 CGImageRef img = dockImageState();1914 1915 1913 SetApplicationDockTileImage (dockImgOS); 1914 CGImageRef img = dockImageState(); 1915 if (img) 1916 OverlayApplicationDockTileImage (img); 1916 1917 #endif 1917 1918 } … … 2103 2104 Assert (status == noErr); 2104 2105 /* 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. 2106 2107 * todo: Search for an option to enable this again. A shadow on every 2107 2108 * window has a big coolness factor. */ … … 2186 2187 2187 2188 #ifdef Q_WS_MAC 2188 CGImageRef VBoxConsoleWnd::dockImageState 2189 CGImageRef VBoxConsoleWnd::dockImageState() const 2189 2190 { 2190 2191 CGImageRef img; … … 2201 2202 return img; 2202 2203 } 2203 #endif 2204 #endif 2204 2205 2205 2206 // … … 2213 2214 * we requested. So after all the resizing stuff set the clipping 2214 2215 * mask and the spacing shifter to the corresponding values. */ 2215 QDesktopWidget *dtw = QApplication::desktop 2216 QDesktopWidget *dtw = QApplication::desktop(); 2216 2217 QRect sRect = dtw->screenGeometry (this); 2217 2218 QRect aRect (aTargetRect); … … 2307 2308 CKeyboard keyboard = console->console().GetKeyboard(); 2308 2309 Assert (!keyboard.isNull()); 2309 static LONG cadSequence[] = { 2310 static LONG sSequence[] = 2311 { 2310 2312 0x1d, // Ctrl down 2311 2313 0x38, // Alt down … … 2315 2317 0x9d // Ctrl up 2316 2318 }; 2317 keyboard.PutScancodes ( cadSequence, ELEMENTS (cadSequence));2319 keyboard.PutScancodes (sSequence, ELEMENTS (sSequence)); 2318 2320 AssertWrapperOk (keyboard); 2319 2321 } … … 2636 2638 region.translate (mMaskShift.width(), mMaskShift.height()); 2637 2639 /* 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. 2640 2642 * This is necessary for the mac.) */ 2641 2643 region &= mStrictedRegion; … … 2674 2676 if (vboxGlobal().vmRenderMode() == VBoxDefs::Quartz2DMode) 2675 2677 { 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 2678 2680 * in the paint engine. */ 2679 repaint 2680 // qApp->processEvents 2681 repaint(); 2682 // qApp->processEvents(); 2681 2683 } 2682 2684 else 2683 2685 # endif 2684 2686 { 2685 /* This is necessary to avoid the flicker by an mask update. 2687 /* This is necessary to avoid the flicker by an mask update. 2686 2688 * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html 2687 2689 * for the hint. 2688 2690 * There *must* be a better solution. */ 2689 if (!region.isEmpty 2691 if (!region.isEmpty()) 2690 2692 region |= QRect (0, 0, 1, 1); 2691 2693 /* Save the current region for later processing in the darwin event handler. */ … … 2695 2697 * mask is set. This leads into a missplaced drawing of the content. Currently 2696 2698 * no alternative to this and also this is not 100% perfect. */ 2697 repaint 2698 qApp->processEvents 2699 repaint(); 2700 qApp->processEvents(); 2699 2701 /* Now force the reshaping of the window. This is definitly necessary. */ 2700 ReshapeCustomWindow (reinterpret_cast <WindowPtr>(winId()));2702 ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId())); 2701 2703 } 2702 2704 #else -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp
r6645 r6649 50 50 } 51 51 52 VBoxQuartz2DFrameBuffer::~VBoxQuartz2DFrameBuffer 52 VBoxQuartz2DFrameBuffer::~VBoxQuartz2DFrameBuffer() 53 53 { 54 54 Log (("Quartz2D: Deleting\n")); 55 clean 55 clean(); 56 56 } 57 57 … … 84 84 QRegion reg; 85 85 // printf ("Region rects follow...\n"); 86 QRect vmScreenRect (0, 0, width (), height());86 QRect vmScreenRect (0, 0, width(), height()); 87 87 for (ULONG ind = 0; ind < aCount; ++ ind) 88 88 { … … 100 100 /* todo: Test if the other framebuffer implementation have the same 101 101 * 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) 104 104 reg += rect; 105 105 else 106 106 continue; 107 107 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()); 113 113 ++mRegionCount; 114 114 } … … 146 146 { 147 147 /* 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 149 149 * 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 151 151 * 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. 155 155 * 156 156 * For debugging /Developer/Applications/Performance Tools/Quartz Debug.app … … 159 159 Assert (mImage); 160 160 161 QWidget *pMain = qApp->mainWidget 161 QWidget *pMain = qApp->mainWidget(); 162 162 Assert (pMain); 163 163 /* Calculate the view rect to draw in */ 164 164 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()); 166 166 /* 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)); 171 171 172 172 /* Create the context to draw on */ 173 WindowPtr window = static_cast<WindowPtr>(mView->viewport ()->handle());173 WindowPtr window = static_cast<WindowPtr>(mView->viewport()->handle()); 174 174 SetPortWindowPort (window); 175 175 CGContextRef ctx; 176 176 QDBeginCGContext (GetWindowPort (window), &ctx); 177 177 /* 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. 181 181 * So the background would be set transparently. */ 182 182 183 183 /* Create a subimage of the current view. 184 184 * 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())); 186 186 Assert (subImage); 187 187 /* Clear the background (Make the rect fully transparent) */ … … 195 195 /* Flip the y-coord */ 196 196 CGContextScaleCTM (ctx, 1.0, -1.0); 197 CGContextTranslateCTM (ctx, Q2DViewRect.x (), -Q2DViewRect.height () - Q2DViewRect.y());197 CGContextTranslateCTM (ctx, Q2DViewRect.x(), -Q2DViewRect.height() - Q2DViewRect.y()); 198 198 /* Add the clipping rects all at once. They are defined in 199 199 * SetVisibleRegion. */ … … 216 216 /* Create a subimage of the current view in the size 217 217 * 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()); 220 220 CGImageRef subImage = CGImageCreateWithImageInRect (mImage, QRectToCGRect (is)); 221 221 Assert (subImage); … … 223 223 /* Ok, for more performance we set a clipping path of the 224 224 * regions given by this paint event. */ 225 QMemArray<QRect> a = pe->region ().rects();226 if (a.size 225 QMemArray<QRect> a = pe->region().rects(); 226 if (a.size() > 0) 227 227 { 228 228 /* Save state for display fliping */ … … 230 230 /* Flip the y-coord */ 231 231 CGContextScaleCTM (ctx, 1.0, -1.0); 232 CGContextTranslateCTM (ctx, Q2DViewRect.x (), -Q2DViewRect.height () - Q2DViewRect.y());232 CGContextTranslateCTM (ctx, Q2DViewRect.x(), -Q2DViewRect.height() - Q2DViewRect.y()); 233 233 CGContextBeginPath (ctx); 234 234 /* Add all region rects to the current context as path components */ 235 for (unsigned int i = 0; i < a.size 235 for (unsigned int i = 0; i < a.size(); ++i) 236 236 CGContextAddRect (ctx, QRectToCGRect (a[i])); 237 237 CGContextRestoreGState (ctx); … … 243 243 CGContextClipToRect (ctx, QRectToCGRect (Q2DViewRect)); 244 244 /* 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()); 247 247 CGContextDrawImage (ctx, QRectToCGRect (cr), subImage); 248 248 } … … 254 254 // CGContextSetShadow (myContext, CGSizeMake (10, 5), 1); 255 255 // 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())); 258 258 // CGContextEndTransparencyLayer (myContext); 259 259 … … 262 262 #if 0 263 263 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()); 267 267 #endif 268 268 269 269 /* 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(); 274 274 275 275 /* 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. 278 278 * Mac OS X supports 16 bit also but not in the 565 mode. So we could use 279 279 * 32 bit only. */ 280 if (re->pixelFormat 281 re->bitsPerPixel 280 if (re->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB && 281 re->bitsPerPixel() == 32) 282 282 { 283 283 // printf ("VRAM\n"); 284 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB 284 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); 285 285 /* 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, 289 289 kCGRenderingIntentDefault); 290 mDataAddress = re->VRAM 290 mDataAddress = re->VRAM(); 291 291 CGDataProviderRelease (dp); 292 292 } … … 300 300 CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, mBitmapData, bitmapByteCount, NULL); 301 301 mImage = CGImageCreate (mWdt, mHgt, 8, 32, bitmapBytesPerRow, cs, 302 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 302 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 303 303 kCGRenderingIntentDefault); 304 304 mDataAddress = static_cast<uchar*>(mBitmapData); … … 308 308 } 309 309 310 void VBoxQuartz2DFrameBuffer::clean 310 void VBoxQuartz2DFrameBuffer::clean() 311 311 { 312 312 if (mImage) -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp
r6645 r6649 49 49 QImage *imageCopy = new QImage (*aImage); 50 50 /** @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 51 if (imageCopy->depth() != 32) 52 52 *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 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; 59 59 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, 61 61 bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */, 62 62 kCGRenderingIntentDefault); … … 76 76 CGImageRef DarwinQPixmapToCGImage (const QPixmap *aPixmap) 77 77 { 78 QImage qimg = aPixmap->convertToImage 79 Assert (!qimg.isNull 78 QImage qimg = aPixmap->convertToImage(); 79 Assert (!qimg.isNull()); 80 80 return DarwinQImageToCGImage (&qimg); 81 81 } … … 90 90 { 91 91 QPixmap qpm = QPixmap::fromMimeSource (aSource); 92 Assert (!qpm.isNull 92 Assert (!qpm.isNull()); 93 93 return DarwinQPixmapToCGImage (&qpm); 94 94 } … … 108 108 just created one that I can load. The Qt gurus can fix this if they like :-) */ 109 109 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); 112 112 113 113 /* load the badge */ 114 114 QPixmap badge = QPixmap::fromMimeSource (aSource); 115 Assert (!badge.isNull 115 Assert (!badge.isNull()); 116 116 117 117 /* resize it and copy it onto the background. */ 118 if (badge.width 119 badge = badge.convertToImage 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(), 121 121 &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); 125 125 126 126 /* Convert it to a CGImage. */ … … 142 142 Assert (aVMImage); 143 143 144 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB 144 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); 145 145 Assert (cs); 146 146 … … 150 150 int scaledWidth; 151 151 int scaledHeight; 152 float aspect = static_cast <float>(CGImageGetWidth (aVMImage)) / CGImageGetHeight (aVMImage);152 float aspect = static_cast <float> (CGImageGetWidth (aVMImage)) / CGImageGetHeight (aVMImage); 153 153 if (aspect > 1.0) 154 154 { … … 161 161 scaledHeight = targetHeight; 162 162 } 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, 165 165 scaledWidth, scaledHeight); 166 166 /* Create a bitmap context to draw on */ … … 218 218 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage) 219 219 { 220 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB 220 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); 221 221 Assert (cs); 222 222 /* 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); 224 224 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, 226 226 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false, 227 227 kCGRenderingIntentDefault); … … 241 241 242 242 OSStatus status = eventNotHandledErr; 243 243 244 244 switch (GetEventKind (aInEvent)) 245 245 { … … 248 248 WindowRegionCode code; 249 249 RgnHandle rgn; 250 250 251 251 /* which region code is being queried? */ 252 252 GetEventParameter (aInEvent, kEventParamWindowRegionCode, typeWindowRegionCode, NULL, sizeof (code), NULL, &code); … … 264 264 GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof (rgn), NULL, &rgn); 265 265 QRegion *pRegion = static_cast <QRegion*> (aInUserData); 266 if (!pRegion->isNull 266 if (!pRegion->isNull() && pRegion) 267 267 { 268 CopyRgn (pRegion->handle 268 CopyRgn (pRegion->handle(), rgn); 269 269 status = noErr; 270 270 } … … 273 273 } 274 274 } 275 275 276 276 return status; 277 277 }
Note:
See TracChangeset
for help on using the changeset viewer.