Files
MapLibreParticleLab/src/mbgl/renderer/pattern_atlas.hpp
mwilsnd 642903fdb4 Merge branch 'topic/drawable-fixes' into topic/drawable (#1560)
Co-authored-by: Stefan Karschti <stefan.karschti@gmail.com>
Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
Co-authored-by: Tim Sylvester <tim@wetdogweather.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-08-31 15:36:19 +02:00

65 lines
1.5 KiB
C++

#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 <unordered_map>
#include <string>
#include <optional>
namespace mbgl {
template <class T>
class Actor;
namespace gfx {
#if MLN_DRAWABLE_RENDERER
class Texture2D;
#endif
class UploadPass;
} // namespace gfx
class PatternAtlas {
public:
PatternAtlas();
PatternAtlas(const PatternAtlas&) = delete;
PatternAtlas& operator=(const PatternAtlas&) = delete;
~PatternAtlas();
std::optional<ImagePosition> getPattern(const std::string&) const;
std::optional<ImagePosition> addPattern(const style::Image::Impl&);
void removePattern(const std::string&);
#if MLN_DRAWABLE_RENDERER
const std::shared_ptr<gfx::Texture2D>& texture() const;
#else
gfx::TextureBinding textureBinding() const; // @TODO: Migrate
#endif
void upload(gfx::UploadPass&);
Size getPixelSize() const;
const PremultipliedImage& getAtlasImageForTests() const { return atlasImage; }
bool isEmpty() const { return patterns.empty(); }
private:
struct Pattern {
mapbox::Bin* bin;
ImagePosition position;
};
mapbox::ShelfPack shelfPack;
std::unordered_map<std::string, Pattern> patterns;
PremultipliedImage atlasImage;
#if MLN_DRAWABLE_RENDERER
std::shared_ptr<gfx::Texture2D> atlasTexture2D{nullptr};
#else
std::optional<gfx::Texture> atlasTexture;
#endif
bool dirty = true;
};
} // namespace mbgl