summaryrefslogtreecommitdiff
path: root/src/mbgl/sprite/sprite_atlas.hpp
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-03-31 14:53:18 -0700
committerChris Loer <chris.loer@mapbox.com>2017-04-04 11:33:12 -0700
commit5cdf838a387cae446dba500ac49a1c5524bf7949 (patch)
tree3b438034a7842c36a7804096785fca1a6ad6fa80 /src/mbgl/sprite/sprite_atlas.hpp
parent64beba3accb0f2088b2e01fad710f915c81d99c7 (diff)
downloadqtlocation-mapboxgl-5cdf838a387cae446dba500ac49a1c5524bf7949.tar.gz
[core] De-mutex GlyphAtlas and SpriteAtlas
- Expose glyph and icon information to workers via message interface. - Glyph/SpriteAtlas track which tiles have outstanding requests and send messages to them when glyphs/icons become available. - Remove obsolete "updateSymbolDependentTiles" pathway - Symbol preparation for a tile now depends on all glyphs becoming available before it can start. - Start tracking individual icons needed for a tile, although we don't do anything with the information yet. - Introduce typedef for GlyphID
Diffstat (limited to 'src/mbgl/sprite/sprite_atlas.hpp')
-rw-r--r--src/mbgl/sprite/sprite_atlas.hpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp
index c7b266376b..3c37f57708 100644
--- a/src/mbgl/sprite/sprite_atlas.hpp
+++ b/src/mbgl/sprite/sprite_atlas.hpp
@@ -6,10 +6,9 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/sprite/sprite_image.hpp>
-#include <atomic>
#include <string>
#include <map>
-#include <mutex>
+#include <set>
#include <unordered_map>
#include <array>
#include <memory>
@@ -28,12 +27,26 @@ public:
SpriteAtlasElement(Rect<uint16_t>, std::shared_ptr<const SpriteImage>, Size size, float pixelRatio);
Rect<uint16_t> pos;
- std::shared_ptr<const SpriteImage> spriteImage;
+ bool sdf;
float relativePixelRatio;
std::array<float, 2> size;
std::array<float, 2> tl;
std::array<float, 2> br;
+ float width;
+ float height;
+};
+
+class SpriteAtlas;
+
+typedef std::map<std::string,SpriteAtlasElement> IconMap;
+typedef std::set<std::string> IconDependencies;
+typedef std::map<uintptr_t,IconMap> IconAtlasMap;
+typedef std::map<SpriteAtlas*,IconDependencies> IconDependencyMap;
+
+class IconRequestor {
+public:
+ virtual void onIconsAvailable(SpriteAtlas*, IconMap) = 0;
};
class SpriteAtlas : public util::noncopyable {
@@ -55,8 +68,11 @@ public:
void setSprite(const std::string&, std::shared_ptr<const SpriteImage>);
void removeSprite(const std::string&);
+
+ std::shared_ptr<const SpriteImage> getSprite(const std::string& name);
- std::shared_ptr<const SpriteImage> getSprite(const std::string&);
+ void getIcons(IconRequestor& requestor);
+ void removeRequestor(IconRequestor& requestor);
optional<SpriteAtlasElement> getIcon(const std::string& name);
optional<SpriteAtlasElement> getPattern(const std::string& name);
@@ -105,13 +121,17 @@ private:
optional<SpriteAtlasElement> getImage(const std::string& name, optional<Rect<uint16_t>> Entry::*rect);
void copy(const Entry&, optional<Rect<uint16_t>> Entry::*rect);
+
+ IconMap buildIconMap();
- std::mutex mutex;
std::unordered_map<std::string, Entry> entries;
BinPack<uint16_t> bin;
PremultipliedImage image;
mbgl::optional<gl::Texture> texture;
- std::atomic<bool> dirty;
+ bool dirty;
+
+ std::set<IconRequestor*> requestors;
+ IconMap icons;
};
} // namespace mbgl