diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-05-29 16:06:56 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-05-29 16:13:10 +0300 |
commit | c212d9aeda273c6a820eafa87ed1bede22e89919 (patch) | |
tree | 4b86c49dc5171f6482421a0c00f14c7691c903b5 /src/mbgl/renderer/pattern_atlas.hpp | |
parent | 967e466448bf2ce7070c66c8565c7d68c052ea97 (diff) | |
download | qtlocation-mapboxgl-c212d9aeda273c6a820eafa87ed1bede22e89919.tar.gz |
[core] Introduce PatternAtlasupstream/mikhail_image_manager
Diffstat (limited to 'src/mbgl/renderer/pattern_atlas.hpp')
-rw-r--r-- | src/mbgl/renderer/pattern_atlas.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/mbgl/renderer/pattern_atlas.hpp b/src/mbgl/renderer/pattern_atlas.hpp new file mode 100644 index 0000000000..f39ba25233 --- /dev/null +++ b/src/mbgl/renderer/pattern_atlas.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include <mapbox/shelf-pack.hpp> +#include <mbgl/gfx/texture.hpp> +#include <mbgl/renderer/image_atlas.hpp> +#include <mbgl/style/image_impl.hpp> +#include <mbgl/util/optional.hpp> + +#include <unordered_map> +#include <string> + +namespace mbgl { + +template <class T> +class Actor; + +namespace gfx { +class UploadPass; +} // namespace gfx + +class PatternAtlas { +public: + PatternAtlas(); + PatternAtlas(const PatternAtlas&) = delete; + PatternAtlas& operator=(const PatternAtlas&) = delete; + ~PatternAtlas(); + + optional<ImagePosition> getPattern(const std::string&) const; + optional<ImagePosition> addPattern(const style::Image::Impl&); + void removePattern(const std::string&); + + gfx::TextureBinding textureBinding() const; + + void upload(gfx::UploadPass&); + Size getPixelSize() const; + + const PremultipliedImage& getAtlasImageForTests() const { + return atlasImage; + } + +private: + struct Pattern { + mapbox::Bin* bin; + ImagePosition position; + }; + mapbox::ShelfPack shelfPack; + std::unordered_map<std::string, Pattern> patterns; + PremultipliedImage atlasImage; + mbgl::optional<gfx::Texture> atlasTexture; + bool dirty = true; +}; + +} // namespace mbgl |