diff options
Diffstat (limited to 'src/widgets/platforms/mac/qpaintdevice_mac.cpp')
-rw-r--r-- | src/widgets/platforms/mac/qpaintdevice_mac.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/widgets/platforms/mac/qpaintdevice_mac.cpp b/src/widgets/platforms/mac/qpaintdevice_mac.cpp index 50bd4b8490..4bdb5d8733 100644 --- a/src/widgets/platforms/mac/qpaintdevice_mac.cpp +++ b/src/widgets/platforms/mac/qpaintdevice_mac.cpp @@ -100,53 +100,4 @@ Q_WIDGETS_EXPORT GrafPtr qt_mac_qd_context(const QPaintDevice *device) extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *pdev); -/*! \internal - - Returns the CoreGraphics CGContextRef of the paint device. 0 is - returned if it can't be obtained. It is the caller's responsiblity to - CGContextRelease the context when finished using it. - - \warning This function is only available on Mac OS X. -*/ - -Q_WIDGETS_EXPORT CGContextRef qt_mac_cg_context(const QPaintDevice *pdev) -{ - if (pdev->devType() == QInternal::Pixmap) { - const QPixmap *pm = static_cast<const QPixmap*>(pdev); - CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev); - uint flags = kCGImageAlphaPremultipliedFirst; -#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version - flags |= kCGBitmapByteOrder32Host; -#endif - CGContextRef ret = 0; - - // It would make sense to put this into a mac #ifdef'ed - // virtual function in the QPlatformPixmap at some point - if (pm->data->classId() == QPlatformPixmap::MacClass) { - const QMacPlatformPixmap *pmData = static_cast<const QMacPlatformPixmap*>(pm->data.data()); - ret = CGBitmapContextCreate(pmData->pixels, pmData->w, pmData->h, - 8, pmData->bytesPerRow, colorspace, - flags); - if(!ret) - qWarning("QPaintDevice: Unable to create context for pixmap (%d/%d/%d)", - pmData->w, pmData->h, (pmData->bytesPerRow * pmData->h)); - } else if (pm->data->classId() == QPlatformPixmap::RasterClass) { - QImage *image = pm->data->buffer(); - ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(), - 8, image->bytesPerLine(), colorspace, flags); - } - - CGContextTranslateCTM(ret, 0, pm->height()); - CGContextScaleCTM(ret, 1, -1); - return ret; - } else if (pdev->devType() == QInternal::Widget) { - CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle()); - CGContextRetain(ret); - return ret; - } else if (pdev->devType() == QInternal::MacQuartz) { - return static_cast<const QMacQuartzPaintDevice *>(pdev)->cgContext(); - } - return 0; -} - QT_END_NAMESPACE |