From a5e89005445ac8ca18ac046eaf55fe2230e47cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 23 Jun 2016 12:04:48 +0200 Subject: [PATCH] Cocoa: Make qt_mac_toCGImageMask be self contained Remove qt_mac_deleteImage and qt_mac_toCGImageMask which are not used elsewhere. Change-Id: Idd3177d4c521eea318b58dc664efe6907896d022 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 8601e222ec..6c6bc3e4eb 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -111,23 +111,13 @@ CGImageRef qt_mac_toCGImage(const QImage &inImage) return inImage.convertToFormat(QImage::Format_ARGB32_Premultiplied).toCGImage(); } -static void qt_mac_deleteImage(void *image, const void *, size_t) -{ - delete static_cast(image); -} - -// Creates a CGDataProvider with the data from the given image. -// The data provider retains a copy of the image. -CGDataProviderRef qt_mac_CGDataProvider(const QImage &image) -{ - return CGDataProviderCreateWithData(new QImage(image), image.bits(), - image.byteCount(), qt_mac_deleteImage); -} - - CGImageRef qt_mac_toCGImageMask(const QImage &image) { - QCFType dataProvider = qt_mac_CGDataProvider(image); + static const auto deleter = [](void *image, const void *, size_t) { delete static_cast(image); }; + QCFType dataProvider = + CGDataProviderCreateWithData(new QImage(image), image.bits(), + image.byteCount(), deleter); + return CGImageMaskCreate(image.width(), image.height(), 8, image.depth(), image.bytesPerLine(), dataProvider, NULL, false); }