summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation
diff options
context:
space:
mode:
authorIvo van Dongen <ivovandongen@users.noreply.github.com>2017-05-12 23:19:00 +0300
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-12 13:19:00 -0700
commitcc9f040a2d35293c51dcc5be9c7affea7f1263bd (patch)
treede62a5610e719f5bfe07226c3382d4d2a5e17530 /src/mbgl/annotation
parentc80f3e9d29d1c26ccc88ef30f8f17329c9bfb1b7 (diff)
downloadqtlocation-mapboxgl-cc9f040a2d35293c51dcc5be9c7affea7f1263bd.tar.gz
[core] Split style image collection from SpriteAtlas
Diffstat (limited to 'src/mbgl/annotation')
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp13
-rw-r--r--src/mbgl/annotation/annotation_manager.hpp3
2 files changed, 12 insertions, 4 deletions
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 <mbgl/annotation/symbol_annotation_impl.hpp>
#include <mbgl/annotation/line_annotation_impl.hpp>
#include <mbgl/annotation/fill_annotation_impl.hpp>
+#include <mbgl/sprite/sprite_image_collection.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>
@@ -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<style::Image> image) {
- spriteAtlas.addImage(id, std::move(image));
+ addSpriteImage(spriteImages, id, std::move(image), [&](style::Image& added) {
+ spriteAtlas.addImage(id, std::make_unique<style::Image>(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
diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp
index de213c830d..69232677f9 100644
--- a/src/mbgl/annotation/annotation_manager.hpp
+++ b/src/mbgl/annotation/annotation_manager.hpp
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include <unordered_set>
+#include <unordered_map>
namespace mbgl {
@@ -72,6 +73,8 @@ private:
ShapeAnnotationMap shapeAnnotations;
std::unordered_set<std::string> obsoleteShapeAnnotationLayers;
std::unordered_set<AnnotationTile*> tiles;
+
+ std::unordered_map<std::string, std::unique_ptr<style::Image>> spriteImages;
SpriteAtlas spriteAtlas;
friend class AnnotationTile;