diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-07-02 17:36:27 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-07-08 19:46:01 +0200 |
commit | 70d0a26f98da50b348433a772cf02b025a70c5be (patch) | |
tree | 17c2bf6078a396d75d86c9704992c8457e692852 /src/mbgl/geometry | |
parent | a0e391c0cb485c3be5e99ddc9af57e3c1d27b8db (diff) | |
download | qtlocation-mapboxgl-70d0a26f98da50b348433a772cf02b025a70c5be.tar.gz |
key sprites in sprite atlas by name and wrap value
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r-- | src/mbgl/geometry/sprite_atlas.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/geometry/sprite_atlas.hpp | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/mbgl/geometry/sprite_atlas.cpp b/src/mbgl/geometry/sprite_atlas.cpp index c546463559..779afe2884 100644 --- a/src/mbgl/geometry/sprite_atlas.cpp +++ b/src/mbgl/geometry/sprite_atlas.cpp @@ -51,7 +51,7 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(const size_t pixel_width SpriteAtlasElement SpriteAtlas::getImage(const std::string& name, const bool wrap) { std::lock_guard<std::recursive_mutex> lock(mtx); - auto rect_it = images.find(name); + auto rect_it = images.find({ name, wrap }); if (rect_it != images.end()) { return { rect_it->second.pos, rect_it->second.texture }; } @@ -69,7 +69,7 @@ SpriteAtlasElement SpriteAtlas::getImage(const std::string& name, const bool wra return { Rect<dimension> { 0, 0, 0, 0 }, nullptr }; } - const Holder& holder = images.emplace(name, Holder{ sprite, rect }).first->second; + const Holder& holder = images.emplace(Key{ name, wrap }, Holder{ sprite, rect }).first->second; copy(holder, wrap); return { rect, sprite }; diff --git a/src/mbgl/geometry/sprite_atlas.hpp b/src/mbgl/geometry/sprite_atlas.hpp index 237ff0c7a2..c595d2ab76 100644 --- a/src/mbgl/geometry/sprite_atlas.hpp +++ b/src/mbgl/geometry/sprite_atlas.hpp @@ -75,6 +75,8 @@ private: const Rect<dimension> pos; }; + using Key = std::pair<std::string, bool>; + void allocate(); Rect<SpriteAtlas::dimension> allocateImage(size_t width, size_t height); void copy(const Holder& holder, const bool wrap); @@ -83,7 +85,7 @@ private: SpriteStore& store; const float pixelRatio; BinPack<dimension> bin; - std::map<std::string, Holder> images; + std::map<Key, Holder> images; std::set<std::string> uninitialized; std::unique_ptr<uint32_t[]> data; std::atomic<bool> dirty; |