diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-21 14:52:19 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-24 15:52:28 -0700 |
commit | 5dd98df50ba1210b1eef0d8d6655713a725f2995 (patch) | |
tree | b289bb3cbad5d1c3076816f4891a057d6089fc93 /platform/macos/src | |
parent | 6f708ac5458fe332e25ca398431928b7ff5ba404 (diff) | |
download | qtlocation-mapboxgl-5dd98df50ba1210b1eef0d8d6655713a725f2995.tar.gz |
[all] Rationalize style::Image
A style has a collection of images, just as it has collections of sources and layers.
* Name things appropriately
* Use std::unique_ptr
Diffstat (limited to 'platform/macos/src')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 5 | ||||
-rw-r--r-- | platform/macos/src/NSImage+MGLAdditions.h | 6 | ||||
-rw-r--r-- | platform/macos/src/NSImage+MGLAdditions.mm | 12 |
3 files changed, 11 insertions, 12 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index cf3a5afe7f..a36766b745 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -28,7 +28,7 @@ #import <mbgl/util/default_thread_pool.hpp> #import <mbgl/map/backend.hpp> #import <mbgl/map/backend_scope.hpp> -#import <mbgl/sprite/sprite_image.hpp> +#import <mbgl/style/image.hpp> #import <mbgl/storage/default_file_source.hpp> #import <mbgl/storage/network_status.hpp> #import <mbgl/math/wrap.hpp> @@ -1949,8 +1949,7 @@ public: return; } - std::shared_ptr<mbgl::SpriteImage> sprite(annotationImage.image.mgl_spriteImage); - _mbglMap->addAnnotationIcon(iconIdentifier.UTF8String, sprite); + _mbglMap->addAnnotationImage(iconIdentifier.UTF8String, annotationImage.image.mgl_styleImage); // Create a slop area with a “radius” equal to the annotation image’s entire // size, allowing the eventual click to be on any point within this image. diff --git a/platform/macos/src/NSImage+MGLAdditions.h b/platform/macos/src/NSImage+MGLAdditions.h index c6a80e372d..d3cc80615b 100644 --- a/platform/macos/src/NSImage+MGLAdditions.h +++ b/platform/macos/src/NSImage+MGLAdditions.h @@ -1,6 +1,6 @@ #import <Cocoa/Cocoa.h> -#include <mbgl/sprite/sprite_image.hpp> +#include <mbgl/style/image.hpp> NS_ASSUME_NONNULL_BEGIN @@ -8,9 +8,9 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithMGLPremultipliedImage:(mbgl::PremultipliedImage&&)image; -- (nullable instancetype)initWithMGLSpriteImage:(const mbgl::SpriteImage *)spriteImage; +- (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)image; -- (std::unique_ptr<mbgl::SpriteImage>)mgl_spriteImage; +- (std::unique_ptr<mbgl::style::Image>)mgl_styleImage; @end diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm index 397e291431..91c4f7bf66 100644 --- a/platform/macos/src/NSImage+MGLAdditions.mm +++ b/platform/macos/src/NSImage+MGLAdditions.mm @@ -15,22 +15,22 @@ return self; } -- (nullable instancetype)initWithMGLSpriteImage:(const mbgl::SpriteImage *)spriteImage { - CGImageRef image = CGImageFromMGLPremultipliedImage(spriteImage->image.clone()); +- (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage { + CGImageRef image = CGImageFromMGLPremultipliedImage(styleImage->image.clone()); if (!image) { return nil; } NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:image]; CGImageRelease(image); - if (self = [self initWithSize:NSMakeSize(spriteImage->getWidth(), spriteImage->getHeight())]) { + if (self = [self initWithSize:NSMakeSize(styleImage->getWidth(), styleImage->getHeight())]) { [self addRepresentation:rep]; - [self setTemplate:spriteImage->sdf]; + [self setTemplate:styleImage->sdf]; } return self; } -- (std::unique_ptr<mbgl::SpriteImage>)mgl_spriteImage { +- (std::unique_ptr<mbgl::style::Image>)mgl_styleImage { // 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 @@ -40,7 +40,7 @@ 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 std::make_unique<mbgl::SpriteImage>(std::move(cPremultipliedImage), + return std::make_unique<mbgl::style::Image>(std::move(cPremultipliedImage), (float)(rep.pixelsWide / self.size.width), [self isTemplate]); } |