summaryrefslogtreecommitdiff
path: root/platform/macos/src/NSImage+MGLAdditions.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/macos/src/NSImage+MGLAdditions.mm')
-rw-r--r--platform/macos/src/NSImage+MGLAdditions.mm49
1 files changed, 0 insertions, 49 deletions
diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm
deleted file mode 100644
index 2666dfe790..0000000000
--- a/platform/macos/src/NSImage+MGLAdditions.mm
+++ /dev/null
@@ -1,49 +0,0 @@
-#import "NSImage+MGLAdditions.h"
-
-#include <mbgl/util/image+MGLAdditions.hpp>
-
-@implementation NSImage (MGLAdditions)
-
-- (nullable instancetype)initWithMGLPremultipliedImage:(mbgl::PremultipliedImage&&)src {
- CGImageRef image = CGImageCreateWithMGLPremultipliedImage(std::move(src));
- if (!image) {
- return nil;
- }
-
- self = [self initWithCGImage:image size:NSZeroSize];
- CGImageRelease(image);
- return self;
-}
-
-- (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage {
- CGImageRef image = CGImageCreateWithMGLPremultipliedImage(styleImage->getImage().clone());
- if (!image) {
- return nil;
- }
-
- NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:image];
- CGImageRelease(image);
- CGFloat w = styleImage->getImage().size.width / styleImage->getPixelRatio();
- CGFloat h = styleImage->getImage().size.height / styleImage->getPixelRatio();
- if (self = [self initWithSize:NSMakeSize(w, h)]) {
- [self addRepresentation:rep];
- [self setTemplate:styleImage->isSdf()];
- }
- return self;
-}
-
-- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
- mbgl::PremultipliedImage cPremultipliedImage = self.mgl_premultipliedImage;
- auto imageWidth = cPremultipliedImage.size.width;
- return std::make_unique<mbgl::style::Image>([identifier UTF8String],
- std::move(cPremultipliedImage),
- (float)(imageWidth / self.size.width),
- [self isTemplate]);
-}
-
-- (mbgl::PremultipliedImage)mgl_premultipliedImage {
- CGImageRef ref = [self CGImageForProposedRect:nullptr context:nullptr hints:nullptr];
- return MGLPremultipliedImageFromCGImage(ref);
-}
-
-@end