diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-18 16:31:16 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-26 11:21:56 -0700 |
commit | d766af44c80ca41adbd988eeb681f90fb52ec817 (patch) | |
tree | de0adcd07c2c4b6057256009bd70458fa21cb0d9 /src/mbgl/sprite/sprite_atlas.hpp | |
parent | e4e08aca7910d1a8d75791db61de39fa03673fde (diff) | |
download | qtlocation-mapboxgl-d766af44c80ca41adbd988eeb681f90fb52ec817.tar.gz |
[core] Auto-growable SpriteAtlas using shelf-pack
Diffstat (limited to 'src/mbgl/sprite/sprite_atlas.hpp')
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.hpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 3629ed6eb1..f5c7fd114a 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -1,11 +1,13 @@ #pragma once -#include <mbgl/geometry/binpack.hpp> #include <mbgl/gl/texture.hpp> #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/optional.hpp> +#include <mbgl/util/rect.hpp> #include <mbgl/style/image.hpp> +#include <mapbox/shelf-pack.hpp> + #include <string> #include <set> #include <unordered_map> @@ -20,7 +22,7 @@ class Context; class SpriteAtlasElement { public: - SpriteAtlasElement(Rect<uint16_t>, const style::Image::Impl&); + SpriteAtlasElement(const mapbox::Bin&, const style::Image::Impl&); bool sdf; float pixelRatio; @@ -59,7 +61,7 @@ public: class SpriteAtlas : public util::noncopyable { public: - SpriteAtlas(Size, float pixelRatio); + SpriteAtlas(); ~SpriteAtlas(); void onSpriteLoaded(); @@ -106,7 +108,6 @@ public: } private: - const Size pixelSize; bool loaded = false; struct Entry { @@ -116,20 +117,20 @@ private: // it must have two distinct entries in the texture. The one for the icon image has // a single pixel transparent border, and the one for the pattern image has a single // pixel border wrapped from the opposite side. - optional<Rect<uint16_t>> iconRect; - optional<Rect<uint16_t>> patternRect; + mapbox::Bin* iconBin = nullptr; + mapbox::Bin* patternBin = nullptr; }; - optional<SpriteAtlasElement> getImage(const std::string& name, optional<Rect<uint16_t>> Entry::*rect); - void copy(const Entry&, optional<Rect<uint16_t>> Entry::*rect); + optional<SpriteAtlasElement> getImage(const std::string& name, mapbox::Bin* Entry::*bin); + void copy(const Entry&, mapbox::Bin* Entry::*bin); IconMap buildIconMap(); std::unordered_map<std::string, Entry> entries; - BinPack<uint16_t> bin; + mapbox::ShelfPack shelfPack; PremultipliedImage image; mbgl::optional<gl::Texture> texture; - bool dirty; + bool dirty = true; std::set<IconRequestor*> requestors; IconMap icons; |