From cc9f040a2d35293c51dcc5be9c7affea7f1263bd Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Fri, 12 May 2017 23:19:00 +0300 Subject: [core] Split style image collection from SpriteAtlas --- src/mbgl/annotation/annotation_manager.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/mbgl/annotation/annotation_manager.cpp') diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index e11ecff30c..96cdd96750 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,7 @@ const std::string AnnotationManager::SourceID = "com.mapbox.annotations"; const std::string AnnotationManager::PointLayerID = "com.mapbox.annotations.points"; AnnotationManager::AnnotationManager(float pixelRatio) - : spriteAtlas({ 1024, 1024 }, pixelRatio) { + : spriteAtlas({ 1024, 1024 }, pixelRatio){ // This is a special atlas, holding only images added via addIcon, so we always treat it as // loaded. spriteAtlas.markAsLoaded(); @@ -190,16 +191,20 @@ void AnnotationManager::removeTile(AnnotationTile& tile) { } void AnnotationManager::addImage(const std::string& id, std::unique_ptr image) { - spriteAtlas.addImage(id, std::move(image)); + addSpriteImage(spriteImages, id, std::move(image), [&](style::Image& added) { + spriteAtlas.addImage(id, std::make_unique(added)); + }); } void AnnotationManager::removeImage(const std::string& id) { - spriteAtlas.removeImage(id); + removeSpriteImage(spriteImages, id, [&] () { + spriteAtlas.removeImage(id); + }); } double AnnotationManager::getTopOffsetPixelsForImage(const std::string& id) { const style::Image* image = spriteAtlas.getImage(id); - return image ? -(image->image.size.height / image->pixelRatio) / 2 : 0; + return image ? -(image->getImage().size.height / image->getPixelRatio()) / 2 : 0; } } // namespace mbgl -- cgit v1.2.1