diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-05 15:05:43 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-12 13:03:14 -0800 |
commit | 1e350b7ea485117cadc413d4d41062cf3c3c43a1 (patch) | |
tree | 8dde92582eda347a7c88c0e655270cef82e44744 /src/mbgl/sprite/sprite_store.hpp | |
parent | 0dc1519a1891dac6272f69dd1d1768f15908003c (diff) | |
download | qtlocation-mapboxgl-1e350b7ea485117cadc413d4d41062cf3c3c43a1.tar.gz |
[core] Reorganize sprite related files
Diffstat (limited to 'src/mbgl/sprite/sprite_store.hpp')
-rw-r--r-- | src/mbgl/sprite/sprite_store.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/mbgl/sprite/sprite_store.hpp b/src/mbgl/sprite/sprite_store.hpp new file mode 100644 index 0000000000..ed903f074b --- /dev/null +++ b/src/mbgl/sprite/sprite_store.hpp @@ -0,0 +1,53 @@ +#ifndef MBGL_SPRITE_STORE +#define MBGL_SPRITE_STORE + +#include <mbgl/sprite/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: + // Adds/replaces a Sprite image. + void setSprite(const std::string&, std::shared_ptr<const SpriteImage> = nullptr); + + // Adds/replaces mutliple Sprite images. + void setSprites(const Sprites& sprites); + + // 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: + void _setSprite(const std::string&, const std::shared_ptr<const SpriteImage>& = nullptr); + + // 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 |