summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-07-11 14:31:05 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-07-17 12:20:03 -0700
commitb69f8338bbd18573b2a2a4282c4736f257526d03 (patch)
tree059004664afdcc26b1cf9114fed71afbe039c16e /platform
parent544d875445d80ae34317c13e31a33d9e80385b8f (diff)
downloadqtlocation-mapboxgl-b69f8338bbd18573b2a2a4282c4736f257526d03.tar.gz
[macos] Use [NSImage CGImageForProposedRect:context:hints:] instead of drawing into a bitmap representation
Diffstat (limited to 'platform')
-rw-r--r--platform/macos/src/NSImage+MGLAdditions.mm13
1 files changed, 3 insertions, 10 deletions
diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm
index 6abe53e9ae..7500a8a207 100644
--- a/platform/macos/src/NSImage+MGLAdditions.mm
+++ b/platform/macos/src/NSImage+MGLAdditions.mm
@@ -42,15 +42,8 @@
}
- (mbgl::PremultipliedImage)mgl_premultipliedImage {
- // Create a bitmap image representation from the image, respecting backing
- // scale factor and any resizing done on the image at runtime.
- // http://www.cocoabuilder.com/archive/cocoa/82430-nsimage-getting-raw-bitmap-data.html#82431
- [self lockFocus];
- NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:{ NSZeroPoint, self.size }];
- [self unlockFocus];
-
- mbgl::PremultipliedImage cPremultipliedImage({ static_cast<uint32_t>(rep.pixelsWide), static_cast<uint32_t>(rep.pixelsHigh) });
- std::copy(rep.bitmapData, rep.bitmapData + cPremultipliedImage.bytes(), cPremultipliedImage.data.get());
- return cPremultipliedImage;
+ CGImageRef ref = [self CGImageForProposedRect:nullptr context:nullptr hints:nullptr];
+ return MGLPremultipliedImageFromCGImage(ref);
}
+
@end