diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-15 15:40:35 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-19 09:40:43 -0700 |
commit | 940124ff713a960d7f70071779dd37d07010fa80 (patch) | |
tree | a89c129b9e972946ab29f05587381c45649a5d99 /src/mbgl/annotation | |
parent | 1014a503a22dc47e4e6ec3c37d034fd729873345 (diff) | |
download | qtlocation-mapboxgl-940124ff713a960d7f70071779dd37d07010fa80.tar.gz |
[core] Merge SpriteStore and SpriteAtlas
Diffstat (limited to 'src/mbgl/annotation')
-rw-r--r-- | src/mbgl/annotation/annotation_manager.cpp | 23 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_manager.hpp | 3 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index fac494f223..28a97d292e 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -8,6 +8,7 @@ #include <mbgl/style/style.hpp> #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/style/layers/symbol_layer_impl.hpp> +#include <mbgl/storage/file_source.hpp> #include <boost/function_output_iterator.hpp> @@ -19,8 +20,20 @@ const std::string AnnotationManager::SourceID = "com.mapbox.annotations"; const std::string AnnotationManager::PointLayerID = "com.mapbox.annotations.points"; AnnotationManager::AnnotationManager(float pixelRatio) - : spriteStore(pixelRatio), - spriteAtlas(1024, 1024, pixelRatio, spriteStore) { + : spriteAtlas(1024, 1024, pixelRatio) { + + struct NullFileSource : public FileSource { + std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override { + assert(false); + return nullptr; + } + }; + + NullFileSource nullFileSource; + + // This is a special atlas, holding only images added via addIcon. But we need its isLoaded() + // method to return true. + spriteAtlas.load("", nullFileSource); } AnnotationManager::~AnnotationManager() = default; @@ -187,17 +200,17 @@ void AnnotationManager::removeTile(AnnotationTile& tile) { } void AnnotationManager::addIcon(const std::string& name, std::shared_ptr<const SpriteImage> sprite) { - spriteStore.setSprite(name, sprite); + spriteAtlas.setSprite(name, sprite); spriteAtlas.updateDirty(); } void AnnotationManager::removeIcon(const std::string& name) { - spriteStore.removeSprite(name); + spriteAtlas.removeSprite(name); spriteAtlas.updateDirty(); } double AnnotationManager::getTopOffsetPixelsForIcon(const std::string& name) { - auto sprite = spriteStore.getSprite(name); + auto sprite = spriteAtlas.getSprite(name); return sprite ? -(sprite->image.height / sprite->pixelRatio) / 2 : 0; } diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index a9afa0d52d..b4959964f6 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -2,7 +2,6 @@ #include <mbgl/annotation/annotation.hpp> #include <mbgl/annotation/symbol_annotation_impl.hpp> -#include <mbgl/sprite/sprite_store.hpp> #include <mbgl/sprite/sprite_atlas.hpp> #include <mbgl/map/update.hpp> #include <mbgl/util/noncopyable.hpp> @@ -75,8 +74,6 @@ private: ShapeAnnotationMap shapeAnnotations; std::set<std::string> obsoleteShapeAnnotationLayers; std::set<AnnotationTile*> tiles; - - SpriteStore spriteStore; SpriteAtlas spriteAtlas; }; |