Topic/fill pass (#1225)

This commit is contained in:
Tim Sylvester
2023-06-09 07:23:17 -07:00
committed by Bart Louwers
parent bffa77f98c
commit b060abeb92
15 changed files with 344 additions and 259 deletions

View File

@@ -29,6 +29,7 @@ class ShaderProgramBase;
using ShaderProgramBasePtr = std::shared_ptr<ShaderProgramBase>;
using DrawPriority = int64_t;
using DrawableTweakerPtr = std::shared_ptr<DrawableTweaker>;
using Texture2DPtr = std::shared_ptr<Texture2D>;
class Drawable {
public:
@@ -104,6 +105,15 @@ public:
/// @param location A sampler location in the shader being used with this drawable.
void setTexture(std::shared_ptr<gfx::Texture2D> texture, int32_t location);
using TexSourceFunc = std::function<gfx::Texture2DPtr()>;
/// @brief Provide a function to get the current texture
void setTextureSource(int32_t location, TexSourceFunc);
const TexSourceFunc& getTextureSource(int32_t location) const;
/// @brief Provide all texture sources at once
void setTextureSources(std::vector<TexSourceFunc>);
/// Whether the drawble should be drawn
bool getEnabled() const { return enabled; }
void setEnabled(bool value) { enabled = value; }
@@ -120,8 +130,8 @@ public:
int32_t getSubLayerIndex() const { return subLayerIndex; }
void setSubLayerIndex(int32_t value) { subLayerIndex = value; }
std::optional<OverscaledTileID> getTileID() const { return tileID; }
void setTileID(OverscaledTileID value) { tileID = value; }
const std::optional<OverscaledTileID>& getTileID() const { return tileID; }
void setTileID(const OverscaledTileID& value) { tileID = value; }
DepthMaskType getDepthType() const { return depthType; }
void setDepthType(DepthMaskType value) { depthType = value; }
@@ -174,6 +184,7 @@ protected:
std::unique_ptr<Impl> impl;
Textures textures;
std::vector<TexSourceFunc> textureSources;
std::vector<DrawableTweakerPtr> tweakers;
};

View File

@@ -21,6 +21,7 @@ class ShaderProgramBase;
using DrawableTweakerPtr = std::shared_ptr<DrawableTweaker>;
using ShaderProgramBasePtr = std::shared_ptr<ShaderProgramBase>;
using Texture2DPtr = std::shared_ptr<Texture2D>;
/**
Base class for drawable builders, which construct Drawables from primitives
@@ -111,7 +112,12 @@ public:
/// @brief Attach the given texture at the given sampler location.
/// @param texture Texture2D instance
/// @param location A sampler location in the shader being used.
void setTexture(const std::shared_ptr<gfx::Texture2D>& texture, int32_t location);
void setTexture(const gfx::Texture2DPtr&, int32_t location);
using TexSourceFunc = std::function<gfx::Texture2DPtr()>;
/// @brief Provide a function to get the current texture
void setTextureSource(int32_t location, TexSourceFunc);
/// Add a triangle
void addTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
@@ -171,6 +177,7 @@ protected:
ColorAttrMode colorAttrMode = ColorAttrMode::PerVertex;
VertexAttributeArray vertexAttrs;
gfx::Drawable::Textures textures;
std::vector<TexSourceFunc> textureSources;
struct Impl;
std::unique_ptr<Impl> impl;

View File

@@ -102,7 +102,8 @@ public:
void observeDrawables(std::function<void(gfx::UniqueDrawable&)>) override;
/// Call the provided function for each drawable for the given tile
void observeDrawables(mbgl::RenderPass, const OverscaledTileID&, std::function<void(const gfx::Drawable&)>) const;
void observeDrawables(mbgl::RenderPass, const OverscaledTileID&, std::function<void(gfx::Drawable&)>&&);
void observeDrawables(mbgl::RenderPass, const OverscaledTileID&, std::function<void(const gfx::Drawable&)>&&) const;
std::size_t clearDrawables();