summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoahelpers.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm54
1 files changed, 4 insertions, 50 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 7480d99d19..b7d5378674 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -202,15 +202,9 @@ NSImage *qt_mac_create_nsimage(const QIcon &icon)
HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region)
{
HIMutableShapeRef shape = HIShapeCreateMutable();
- QVector<QRect> rects = region.rects();
- if (!rects.isEmpty()) {
- int n = rects.count();
- const QRect *qt_r = rects.constData();
- while (n--) {
- CGRect cgRect = CGRectMake(qt_r->x(), qt_r->y(), qt_r->width(), qt_r->height());
- HIShapeUnionWithRect(shape, &cgRect);
- ++qt_r;
- }
+ for (const QRect &rect : region) {
+ CGRect cgRect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
+ HIShapeUnionWithRect(shape, &cgRect);
}
return shape;
}
@@ -220,16 +214,6 @@ NSSize qt_mac_toNSSize(const QSize &qtSize)
return NSMakeSize(qtSize.width(), qtSize.height());
}
-NSRect qt_mac_toNSRect(const QRect &rect)
-{
- return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-QRect qt_mac_toQRect(const NSRect &rect)
-{
- return QRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
QColor qt_mac_toQColor(const NSColor *color)
{
QColor qtColor;
@@ -340,38 +324,8 @@ QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup)
// (and providing no public API to get the underlying color without this insanity)
if (qt_mac_isSystemColorOrInstance(color, @"controlColor", @"NSGradientPatternColor") ||
qt_mac_isSystemColorOrInstance(color, @"windowBackgroundColor", @"NSGradientPatternColor")) {
- static QColor newColor;
- if (!newColor.isValid()) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- newColor = qt_mac_toQColor(color.CGColor);
- } else
-#endif
- {
- NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
- pixelsWide:1
- pixelsHigh:1
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:4
- bitsPerPixel:32];
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep]];
- NSEraseRect(NSMakeRect(0, 0, 1, 1));
- [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)];
- [NSGraphicsContext restoreGraphicsState];
- NSUInteger pixel[4];
- [offscreenRep getPixel:pixel atX:0 y:0];
- [offscreenRep release];
- newColor = QColor(pixel[0], pixel[1], pixel[2], pixel[3]);
- }
- }
-
qtBrush.setStyle(Qt::SolidPattern);
- qtBrush.setColor(newColor);
+ qtBrush.setColor(qt_mac_toQColor(color.CGColor));
return qtBrush;
}