diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-06-11 11:07:28 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-07-08 19:45:59 +0200 |
commit | 7f705da5644092d48b48aaacbe3dc232ff5149fc (patch) | |
tree | ea5612d580d0cafe4144175505c55c379d8e7e7e /src/mbgl/annotation/sprite_store.hpp | |
parent | 03c4ed75a2684b9866a00eebf0392c96cceb8d34 (diff) | |
download | qtlocation-mapboxgl-7f705da5644092d48b48aaacbe3dc232ff5149fc.tar.gz |
Sprite store API
Diffstat (limited to 'src/mbgl/annotation/sprite_store.hpp')
-rw-r--r-- | src/mbgl/annotation/sprite_store.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mbgl/annotation/sprite_store.hpp b/src/mbgl/annotation/sprite_store.hpp new file mode 100644 index 0000000000..3e81a4daf0 --- /dev/null +++ b/src/mbgl/annotation/sprite_store.hpp @@ -0,0 +1,52 @@ +#ifndef MBGL_ANNOTATION_SPRITE_STORE +#define MBGL_ANNOTATION_SPRITE_STORE + +#include <mbgl/annotation/sprite_image.hpp> + +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/geo.hpp> + +#include <map> +#include <set> +#include <vector> +#include <memory> +#include <mutex> +#include <cstdint> + +namespace mbgl { + +// The SpriteStore object holds Sprite images. +class SpriteStore : private util::noncopyable { + using Sprites = std::map<std::string, std::shared_ptr<const SpriteImage>>; + +public: + SpriteStore(const float ratio); + + // Adds/replaces a Sprite image. + void setSprite(const std::string&, std::shared_ptr<const SpriteImage> = nullptr); + + // Removes a Sprite. + void removeSprite(const std::string&); + + // Obtains a Sprite image. + std::shared_ptr<const SpriteImage> getSprite(const std::string&); + + // Returns Sprite images that changed since the last invocation of this function. + Sprites getDirty(); + +private: + const float ratio; + + // Lock for sprites and dirty maps. + std::mutex mutex; + + // Stores all current sprites. + Sprites sprites; + + // Stores all Sprite IDs that changed since the last invocation. + Sprites dirty; +}; + +} // namespace mbgl + +#endif |