Refactor clipping mask rendering (#1209)

This commit is contained in:
Tim Sylvester
2023-06-06 14:15:40 -07:00
committed by Bart Louwers
parent 172cc0a43f
commit 00d6bdd2ae
19 changed files with 180 additions and 88 deletions

View File

@@ -108,6 +108,10 @@ public:
bool getEnabled() const { return enabled; }
void setEnabled(bool value) { enabled = value; }
/// Whether to do stenciling (based on the Tile ID)
bool getNeedsStencil() const { return needsStencil; }
void setNeedsStencil(bool value) { needsStencil = value; }
/// not used for anything yet
DrawPriority getDrawPriority() const { return drawPriority; }
void setDrawPriority(DrawPriority value) { drawPriority = value; }
@@ -155,6 +159,7 @@ public:
protected:
bool enabled = true;
bool needsStencil = false;
std::string name;
util::SimpleIdentity uniqueID;
gfx::ShaderProgramBasePtr shader;

View File

@@ -84,6 +84,10 @@ public:
float getLineWidth() const { return lineWidth; }
void setLineWidth(float value) { lineWidth = value; }
/// Whether to do stenciling (based on the Tile ID)
bool getNeedsStencil() const { return needsStencil; }
void setNeedsStencil(bool value) { needsStencil = value; }
DepthMaskType getDepthType() const { return depthType; }
void setDepthType(DepthMaskType value) { depthType = value; }
@@ -156,6 +160,7 @@ protected:
std::string vertexAttrName;
std::string colorAttrName;
mbgl::RenderPass renderPass;
bool needsStencil = false;
float lineWidth = 1.0f;
DrawPriority drawPriority = 0;
int32_t subLayerIndex = 0;

View File

@@ -10,7 +10,7 @@ namespace gl {
*/
class TileLayerGroupGL : public TileLayerGroup {
public:
TileLayerGroupGL(int32_t layerIndex, std::size_t initialCapacity);
TileLayerGroupGL(int32_t layerIndex, std::size_t initialCapacity, std::string name);
~TileLayerGroupGL() override {}
void upload(gfx::UploadPass&) override;

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace mbgl {
@@ -33,7 +34,7 @@ using LayerTweakerPtr = std::shared_ptr<LayerTweaker>;
*/
class LayerGroup : public util::SimpleIdentifiable {
protected:
LayerGroup(int32_t layerIndex);
LayerGroup(int32_t layerIndex, std::string name = std::string());
public:
LayerGroup(const LayerGroup&) = delete;
@@ -43,8 +44,14 @@ public:
bool getEnabled() const { return enabled; }
void setEnabled(bool value) { enabled = value; }
const std::string& getName() const { return name; }
void setName(std::string value) { name = std::move(value); }
int32_t getLayerIndex() const { return layerIndex; }
virtual std::size_t getDrawableCount() const = 0;
bool empty() const { return getDrawableCount() == 0; }
/// Called before starting each frame
virtual void preRender(RenderOrchestrator&, PaintParameters&) {}
/// Called during the upload pass
@@ -71,6 +78,7 @@ protected:
bool enabled = true;
int32_t layerIndex;
LayerTweakerPtr layerTweaker;
std::string name;
};
/**
@@ -78,12 +86,12 @@ protected:
*/
class TileLayerGroup : public LayerGroup {
public:
TileLayerGroup(int32_t layerIndex, std::size_t initialCapacity);
TileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name);
~TileLayerGroup() override;
void updateLayerIndex(int32_t newLayerIndex);
std::size_t getDrawableCount() const;
std::size_t getDrawableCount() const override;
std::size_t getDrawableCount(mbgl::RenderPass, const OverscaledTileID&) const;
std::vector<gfx::UniqueDrawable> removeDrawables(mbgl::RenderPass, const OverscaledTileID&);