From 857cba59ee166358e175c43ac3cfbad7e04a6924 Mon Sep 17 00:00:00 2001 From: Tim Sylvester Date: Mon, 15 May 2023 15:36:04 -0700 Subject: [PATCH] Drawable Renderer (#1570), warnings --- include/mbgl/gfx/vertex_attribute.hpp | 15 +++++++++++++-- include/mbgl/gl/vertex_attribute_gl.hpp | 7 ++++--- src/mbgl/gfx/vertex_attribute.cpp | 4 ---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/mbgl/gfx/vertex_attribute.hpp b/include/mbgl/gfx/vertex_attribute.hpp index de5d288d6..7122c6f2c 100644 --- a/include/mbgl/gfx/vertex_attribute.hpp +++ b/include/mbgl/gfx/vertex_attribute.hpp @@ -137,7 +137,7 @@ public: VertexAttributeArray(int initCapacity = 10); VertexAttributeArray(VertexAttributeArray&&); // Would need to use the virtual assignment operator - VertexAttributeArray(const VertexAttributeArray&); + VertexAttributeArray(const VertexAttributeArray&) = delete; virtual ~VertexAttributeArray() = default; /// Number of elements @@ -214,7 +214,9 @@ public: VertexAttributeArray& operator=(const VertexAttributeArray&); virtual std::unique_ptr clone() const { - return std::make_unique(*this); + auto newAttrs = std::make_unique(); + newAttrs->copy(*this); + return newAttrs; } protected: @@ -234,6 +236,15 @@ protected: std::size_t count) const { return std::make_unique(index, dataType, size, count, size * count); } + + virtual void copy(const VertexAttributeArray& other) { + for (const auto& kv : other.attrs) { + if (kv.second) { + attrs.insert(std::make_pair(kv.first, copy(*kv.second))); + } + } + } + virtual std::unique_ptr copy(const gfx::VertexAttribute& attr) const { return std::make_unique(attr); } diff --git a/include/mbgl/gl/vertex_attribute_gl.hpp b/include/mbgl/gl/vertex_attribute_gl.hpp index 8a1ce70ea..fc84caf59 100644 --- a/include/mbgl/gl/vertex_attribute_gl.hpp +++ b/include/mbgl/gl/vertex_attribute_gl.hpp @@ -51,8 +51,6 @@ public: : VertexAttributeArray(initCapacity) {} VertexAttributeArrayGL(VertexAttributeArrayGL&& other) : VertexAttributeArray(std::move(other)) {} - VertexAttributeArrayGL(const VertexAttributeArrayGL& other) - : VertexAttributeArray(other) {} VertexAttributeArrayGL& operator=(VertexAttributeArrayGL&& other) { VertexAttributeArray::operator=(std::move(other)); @@ -64,7 +62,9 @@ public: } std::unique_ptr clone() const override { - return std::make_unique(*this); + auto newAttrs = std::make_unique(); + newAttrs->copy(*this); + return newAttrs; } private: @@ -74,6 +74,7 @@ private: std::size_t count) const override { return std::unique_ptr(new VertexAttributeGL(index, dataType, size, count)); } + using gfx::VertexAttributeArray::copy; std::unique_ptr copy(const gfx::VertexAttribute& attr) const override { return std::unique_ptr( new VertexAttributeGL(static_cast(attr))); diff --git a/src/mbgl/gfx/vertex_attribute.cpp b/src/mbgl/gfx/vertex_attribute.cpp index a43aa230a..e3aefe756 100644 --- a/src/mbgl/gfx/vertex_attribute.cpp +++ b/src/mbgl/gfx/vertex_attribute.cpp @@ -12,10 +12,6 @@ std::unique_ptr VertexAttributeArray::nullref = nullptr; VertexAttributeArray::VertexAttributeArray(int initCapacity) : attrs(initCapacity) {} -VertexAttributeArray::VertexAttributeArray(const VertexAttributeArray& other) { - operator=(other); -} - VertexAttributeArray::VertexAttributeArray(VertexAttributeArray&& other) : attrs(std::move(other.attrs)) {}