diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qicon.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qnativeimage.cpp | 10 | ||||
-rw-r--r-- | src/gui/image/qnativeimage_p.h | 1 | ||||
-rw-r--r-- | src/gui/image/qpixmap_mac.cpp | 79 | ||||
-rw-r--r-- | src/gui/image/qpixmap_win.cpp | 12 |
5 files changed, 21 insertions, 87 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index edae29a..fa407c7 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -54,7 +54,7 @@ #ifdef Q_WS_MAC #include <private/qt_mac_p.h> -#include <Carbon/Carbon.h> +#include <private/qt_cocoa_helpers_mac_p.h> #endif QT_BEGIN_NAMESPACE @@ -178,8 +178,8 @@ QPixmapIconEngine::~QPixmapIconEngine() void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { QSize pixmapSize = rect.size(); -#if defined(Q_WS_MAC) && !defined(Q_WS_MAC64) - pixmapSize *= (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) ? HIGetScaleFactor() : 1; +#if defined(Q_WS_MAC) + pixmapSize *= qt_mac_get_scalefactor(); #endif painter->drawPixmap(rect, pixmap(pixmapSize, mode, state)); } diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index bfe5dfe..a716eb1 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -232,15 +232,16 @@ QImage::Format QNativeImage::systemFormat() QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *widget) : image(width, height, format) { - cgColorSpace = QCoreGraphicsPaintEngine::macDisplayColorSpace(widget); + + uint cgflags = kCGImageAlphaNoneSkipFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version - if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) - cgflags |= kCGBitmapByteOrder32Host; + cgflags |= kCGBitmapByteOrder32Host; #endif - cg = CGBitmapContextCreate(image.bits(), width, height, 8, image.bytesPerLine(), cgColorSpace, cgflags); + cg = CGBitmapContextCreate(image.bits(), width, height, 8, image.bytesPerLine(), + QCoreGraphicsPaintEngine::macDisplayColorSpace(widget), cgflags); CGContextTranslateCTM(cg, 0, height); CGContextScaleCTM(cg, 1, -1); @@ -252,7 +253,6 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* QNativeImage::~QNativeImage() { CGContextRelease(cg); - CGColorSpaceRelease(cgColorSpace); } QImage::Format QNativeImage::systemFormat() diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/image/qnativeimage_p.h index f0c3688..268fe49 100644 --- a/src/gui/image/qnativeimage_p.h +++ b/src/gui/image/qnativeimage_p.h @@ -95,7 +95,6 @@ public: #elif defined(Q_WS_MAC) CGContextRef cg; - CGColorSpaceRef cgColorSpace; #endif private: diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index b40694a..c281fe9 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -119,14 +119,9 @@ CGImageRef qt_mac_image_to_cgimage(const QImage &image) CGDataProviderCreateWithData(0, image.bits(), image.bytesPerLine() * image.height(), 0); -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) uint cgflags = kCGImageAlphaPremultipliedFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version - if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) - cgflags |= kCGBitmapByteOrder32Host; -#endif -#else - CGImageAlphaInfo cgflags = kCGImageAlphaPremultipliedFirst; + cgflags |= kCGBitmapByteOrder32Host; #endif CGImageRef cgImage = CGImageCreate(image.width(), image.height(), bitsPerColor, bitsPerPixel, @@ -645,14 +640,9 @@ void QMacPixmapData::macCreateCGImageRef() pixels, bytesPerRow * h, qt_mac_cgimage_data_free); validDataPointers.insert(this); -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) uint cgflags = kCGImageAlphaPremultipliedFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version - if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) - cgflags |= kCGBitmapByteOrder32Host; -#endif -#else - CGImageAlphaInfo cgflags = kCGImageAlphaPremultipliedFirst; + cgflags |= kCGBitmapByteOrder32Host; #endif cg_data = CGImageCreate(w, h, 8, 32, bytesPerRow, colorspace, cgflags, provider, 0, 0, kCGRenderingIntentDefault); @@ -893,38 +883,6 @@ static void qt_mac_grabDisplayRect(CGDirectDisplayID display, const QRect &displ ptrCGLDestroyContext(glContextObj); // and destroy the context } -static CGImageRef qt_mac_createImageFromBitmapContext(CGContextRef c) -{ - void *rasterData = CGBitmapContextGetData(c); - const int width = CGBitmapContextGetBytesPerRow(c), - height = CGBitmapContextGetHeight(c); - size_t imageDataSize = width*height; - - if(!rasterData) - return 0; - - // Create the data provider from the image data, using - // the image releaser function releaseBitmapContextImageData. - CGDataProviderRef dataProvider = CGDataProviderCreateWithData(0, rasterData, - imageDataSize, - qt_mac_cgimage_data_free); - - if(!dataProvider) - return 0; - - uint bitmapInfo = 0; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - if(CGBitmapContextGetBitmapInfo) - bitmapInfo = CGBitmapContextGetBitmapInfo(c); - else -#endif - bitmapInfo = CGBitmapContextGetAlphaInfo(c); - return CGImageCreate(width, height, CGBitmapContextGetBitsPerComponent(c), - CGBitmapContextGetBitsPerPixel(c), CGBitmapContextGetBytesPerRow(c), - CGBitmapContextGetColorSpace(c), bitmapInfo, dataProvider, - 0, true, kCGRenderingIntentDefault); -} - // Returns a pixmap containing the screen contents at rect. static QPixmap qt_mac_grabScreenRect(const QRect &rect) { @@ -958,19 +916,8 @@ static QPixmap qt_mac_grabScreenRect(const QRect &rect) rect.height(), 8, bytewidth, QCoreGraphicsPaintEngine::macGenericColorSpace(), kCGImageAlphaNoneSkipFirst); - -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { - QCFType<CGImageRef> image = CGBitmapContextCreateImage(bitmap); - return QPixmap::fromMacCGImageRef(image); - } else -#endif - { - QCFType<CGImageRef> image = qt_mac_createImageFromBitmapContext(bitmap); - if (!image) - return QPixmap(); - return QPixmap::fromMacCGImageRef(image); - } + QCFType<CGImageRef> image = CGBitmapContextCreateImage(bitmap); + return QPixmap::fromMacCGImageRef(image); } #ifndef QT_MAC_USE_COCOA // no QuickDraw in 64-bit mode @@ -1043,18 +990,12 @@ Qt::HANDLE QPixmap::macQDHandle() const SetRect(&rect, 0, 0, d->w, d->h); unsigned long qdformat = k32ARGBPixelFormat; GWorldFlags qdflags = 0; -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { - //we play such games so we can use the same buffer in CG as QD this - //makes our merge much simpler, at some point the hacks will go away - //because QD will be removed, but until that day this keeps them coexisting - if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) - qdformat = k32BGRAPixelFormat; -#if 0 - qdflags |= kNativeEndianPixMap; -#endif - } -#endif + //we play such games so we can use the same buffer in CG as QD this + //makes our merge much simpler, at some point the hacks will go away + //because QD will be removed, but until that day this keeps them coexisting + if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) + qdformat = k32BGRAPixelFormat; + if(NewGWorldFromPtr(&d->qd_data, qdformat, &rect, 0, 0, qdflags, (char*)d->pixels, d->bytesPerRow) != noErr) qWarning("Qt: internal: QPixmap::init error (%d %d %d %d)", rect.left, rect.top, rect.right, rect.bottom); diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index 2c84ce7..56b53bd 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -179,13 +179,7 @@ QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format) BITMAP bitmap_info; memset(&bitmap_info, 0, sizeof(BITMAP)); - int res; - QT_WA({ - res = GetObjectW(bitmap, sizeof(BITMAP), &bitmap_info); - } , { - res = GetObjectA(bitmap, sizeof(BITMAP), &bitmap_info); - }); - + int res = GetObject(bitmap, sizeof(BITMAP), &bitmap_info); if (!res) { qErrnoWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap info"); return QPixmap(); @@ -417,9 +411,9 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large) QPixmap loadIconFromShell32( int resourceId, int size ) { #ifdef Q_OS_WINCE - HMODULE hmod = LoadLibrary((const wchar_t *) QString::fromLatin1("ceshell.dll").utf16()); + HMODULE hmod = LoadLibrary(L"ceshell.dll"); #else - HMODULE hmod = LoadLibraryA("shell32.dll"); + HMODULE hmod = LoadLibrary(L"shell32.dll"); #endif if( hmod ) { HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0); |