diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-01 10:00:43 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-06 16:12:51 +0100 |
commit | 63e81b9aa8ad1a96e47a296db57e33c866315bee (patch) | |
tree | 5af815b305e67ef229984a5c2214da2985e9a2df /src/mbgl/gfx | |
parent | 500080ea6489bf7208859ed9bcfeefff16b301ad (diff) | |
download | qtlocation-mapboxgl-63e81b9aa8ad1a96e47a296db57e33c866315bee.tar.gz |
[core] move VertexVector/IndexVector to gfx namespace
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r-- | src/mbgl/gfx/index_vector.hpp | 50 | ||||
-rw-r--r-- | src/mbgl/gfx/vertex_vector.hpp | 50 |
2 files changed, 100 insertions, 0 deletions
diff --git a/src/mbgl/gfx/index_vector.hpp b/src/mbgl/gfx/index_vector.hpp new file mode 100644 index 0000000000..b477c29782 --- /dev/null +++ b/src/mbgl/gfx/index_vector.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include <mbgl/util/ignore.hpp> + +#include <vector> + +namespace mbgl { +namespace gfx { + +template <class DrawMode> +class IndexVector { +public: + static constexpr std::size_t groupSize = DrawMode::bufferGroupSize; + + template <class... Args> + void emplace_back(Args&&... args) { + static_assert(sizeof...(args) == groupSize, "wrong buffer element count"); + util::ignore({ (v.emplace_back(std::forward<Args>(args)), 0)... }); + } + + std::size_t indexSize() const { + return v.size(); + } + + std::size_t byteSize() const { + return v.size() * sizeof(uint16_t); + } + + bool empty() const { + return v.empty(); + } + + void clear() { + v.clear(); + } + + const uint16_t* data() const { + return v.data(); + } + + const std::vector<uint16_t>& vector() const { + return v; + } + +private: + std::vector<uint16_t> v; +}; + +} // namespace gfx +} // namespace mbgl diff --git a/src/mbgl/gfx/vertex_vector.hpp b/src/mbgl/gfx/vertex_vector.hpp new file mode 100644 index 0000000000..5d892e9136 --- /dev/null +++ b/src/mbgl/gfx/vertex_vector.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include <mbgl/util/ignore.hpp> + +#include <vector> + +namespace mbgl { +namespace gfx { + +template <class V> +class VertexVector { +public: + using Vertex = V; + + template <class... Args> + void emplace_back(Args&&... args) { + static_assert(sizeof...(args) == 1, "wrong buffer element count"); + util::ignore({ (v.emplace_back(std::forward<Args>(args)), 0)... }); + } + + std::size_t vertexSize() const { + return v.size(); + } + + std::size_t byteSize() const { + return v.size() * sizeof(Vertex); + } + + bool empty() const { + return v.empty(); + } + + void clear() { + v.clear(); + } + + const Vertex* data() const { + return v.data(); + } + + const std::vector<Vertex>& vector() const { + return v; + } + +private: + std::vector<Vertex> v; +}; + +} // namespace gfx +} // namespace mbgl |