From 434d90d9395a5dd24a686ce5888f9cb7d752a94d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 20:55:07 +0000 Subject: [PATCH] Drawable Renderer (#1570), [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- include/mbgl/gfx/drawable.hpp | 40 ++++++++++++----------- src/mbgl/renderer/render_orchestrator.cpp | 4 +-- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/mbgl/gfx/drawable.hpp b/include/mbgl/gfx/drawable.hpp index cff718fad..9a91b2df0 100644 --- a/include/mbgl/gfx/drawable.hpp +++ b/include/mbgl/gfx/drawable.hpp @@ -28,63 +28,63 @@ using DrawableTweakerPtr = std::shared_ptr; class Drawable { protected: Drawable(std::string name); - + public: virtual ~Drawable() = default; - + const util::SimpleIdentity& getId() const { return uniqueID; } - + /// Draw the drawable virtual void draw(const PaintParameters&) const = 0; - + /// Drawable name is used for debugging and troubleshooting const std::string& getName() const { return name; } void setName(std::string value) { name = std::move(value); } - + /// Which shader to use when rendering this drawable const gfx::ShaderProgramBasePtr& getShader() const { return shader; } void setShader(gfx::ShaderProgramBasePtr value) { shader = std::move(value); } - + /// not used for anything yet DrawPriority getDrawPriority() const { return drawPriority; } void setDrawPriority(DrawPriority value) { drawPriority = value; } - + /// The layer index determines the drawing order int32_t getLayerIndex() const { return layerIndex; } void setLayerIndex(int32_t value) { layerIndex = value; } - + std::optional getTileID() const { return tileID; } void setTileID(OverscaledTileID value) { tileID = value; } - + mat4 getMatrix() const { return matrix; } void setMatrix(mat4 value) { matrix = value; } - + DepthMaskType getDepthType() const { return depthType; } void setDepthType(DepthMaskType value) { depthType = value; } - + /// Get the number of vertexes std::size_t getVertexCount() const { return getVertexAttributes().getMaxCount(); } - + /// Get the vertex attributes that override default values in the shader program virtual const gfx::VertexAttributeArray& getVertexAttributes() const = 0; virtual void setVertexAttributes(const gfx::VertexAttributeArray&) = 0; virtual void setVertexAttributes(gfx::VertexAttributeArray&&) = 0; - + virtual std::vector& getIndexData() const = 0; - + /// Attach a tweaker to be run on this drawable for each frame void addTweaker(DrawableTweakerPtr tweaker) { tweakers.emplace_back(std::move(tweaker)); } template void addTweakers(TIter beg, TIter end) { tweakers.insert(tweakers.end(), beg, end); } - + /// Get the tweakers attached to this drawable const std::vector& getTweakers() const { return tweakers; } - + // Reset a single color attribute for all vertexes virtual void resetColor(const Color&) = 0; - + protected: std::string name; util::SimpleIdentity uniqueID; @@ -94,7 +94,7 @@ protected: DrawPriority drawPriority = 0; int32_t layerIndex = -1; DepthMaskType depthType; // = DepthMaskType::ReadOnly; - + std::vector tweakers; }; @@ -102,7 +102,8 @@ using DrawablePtr = std::shared_ptr; /// Comparator for sorting drawable pointers primarily by layer index struct DrawablePtrLessByLayer { - DrawablePtrLessByLayer(bool descending) : desc(descending) { } + DrawablePtrLessByLayer(bool descending) + : desc(descending) {} bool operator()(const DrawablePtr& left, const DrawablePtr& right) const { const auto& a = desc ? right : left; const auto& b = desc ? left : right; @@ -118,6 +119,7 @@ struct DrawablePtrLessByLayer { } return a->getId() < b->getId(); } + private: bool desc; }; diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index 596e21bf0..95d1ce046 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -798,8 +798,8 @@ void RenderOrchestrator::updateLayers(gfx::ShaderRegistry& shaders, } // Layer index, similar but not identical to `layerRenderItems` index in render_impl - //int32_t i = static_cast(layerRenderItems.size()) - 1; - //for (auto it = layerRenderItems.begin(); it != layerRenderItems.end() && i >= 0; ++it, --i) { + // int32_t i = static_cast(layerRenderItems.size()) - 1; + // for (auto it = layerRenderItems.begin(); it != layerRenderItems.end() && i >= 0; ++it, --i) { auto index = static_cast(layerImpls->size()) - 1; for (auto& impl : *layerImpls) {