diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-21 15:30:13 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-21 16:23:44 +0100 |
commit | f0f65a3331713873b2c54900c7ee3f9e8a76f745 (patch) | |
tree | b96b04c640df9af19e821297677432748e7f0520 /src/mbgl/gfx | |
parent | 58a5aa0141915f4501d58d68bdba1b0adba37ccf (diff) | |
download | qtlocation-mapboxgl-f0f65a3331713873b2c54900c7ee3f9e8a76f745.tar.gz |
[xxx] remove Primitive classes
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r-- | src/mbgl/gfx/draw_mode.hpp | 66 | ||||
-rw-r--r-- | src/mbgl/gfx/primitives.hpp | 24 | ||||
-rw-r--r-- | src/mbgl/gfx/types.hpp | 6 |
3 files changed, 41 insertions, 55 deletions
diff --git a/src/mbgl/gfx/draw_mode.hpp b/src/mbgl/gfx/draw_mode.hpp index a0a9b6c575..586f41cb13 100644 --- a/src/mbgl/gfx/draw_mode.hpp +++ b/src/mbgl/gfx/draw_mode.hpp @@ -1,71 +1,75 @@ #pragma once #include <mbgl/gfx/types.hpp> -#include <mbgl/gfx/primitives.hpp> #include <cassert> namespace mbgl { namespace gfx { -class Points { -public: - using Primitive = Point; +class DrawMode { +protected: + DrawMode(DrawModeType type_, float) + : type(type_) { + } - static constexpr std::size_t bufferGroupSize = 1; - static constexpr PrimitiveType primitiveType = PrimitiveType::Points; +public: + const DrawModeType type; +}; - explicit Points(float pointSize_) : pointSize(pointSize_) {} +class Points : public DrawMode { +public: + explicit Points(float pointSize_) : DrawMode(DrawModeType::Points, pointSize_), pointSize(pointSize_) { + assert(size > 0); + } + static constexpr PrimitiveType primitive = PrimitiveType::Point; + static constexpr std::size_t bufferGroupSize = 1; float pointSize; }; -class Lines { +class Lines : public DrawMode { public: - using Primitive = Line; - - static constexpr std::size_t bufferGroupSize = 2; - static constexpr PrimitiveType primitiveType = PrimitiveType::Lines; - - explicit Lines(float lineWidth_) : lineWidth(lineWidth_) { - assert(lineWidth > 0); + explicit Lines(float lineWidth_) : DrawMode(DrawModeType::Lines, lineWidth_), lineWidth(lineWidth_) { + assert(size > 0); } + static constexpr PrimitiveType primitive = PrimitiveType::Line; + static constexpr std::size_t bufferGroupSize = 2; float lineWidth; }; -class LineStrip { +class LineStrip : public DrawMode { public: + explicit LineStrip(float lineWidth_) : DrawMode(DrawModeType::LineStrip, lineWidth_), lineWidth(lineWidth_) { + assert(size > 0); + } + // LineStrip is a form of "Line" rendering, but the element buffer // cannot be grouped into logical elements beyond a single Point. - using Primitive = Line; - + static constexpr PrimitiveType primitive = PrimitiveType::Line; static constexpr std::size_t bufferGroupSize = 1; - static constexpr PrimitiveType primitiveType = PrimitiveType::LineStrip; - - explicit LineStrip(float lineWidth_) : lineWidth(lineWidth_) { - assert(lineWidth > 0); - } - float lineWidth; }; -class Triangles { +class Triangles : public DrawMode { public: - using Primitive = Triangle; + explicit Triangles() : DrawMode(DrawModeType::Triangles, 0) { + } + static constexpr PrimitiveType primitive = PrimitiveType::Triangle; static constexpr std::size_t bufferGroupSize = 3; - static constexpr PrimitiveType primitiveType = PrimitiveType::Triangles; }; -class TriangleStrip { +class TriangleStrip : public DrawMode { public: + explicit TriangleStrip() : DrawMode(DrawModeType::TriangleStrip, 0) { + } + // TriangleStrip is a form of "Triangle" rendering, but the element buffer // cannot be grouped into logical elements beyond a single Point. - using Primitive = Triangle; - + static constexpr PrimitiveType primitive = PrimitiveType::Triangle; static constexpr std::size_t bufferGroupSize = 1; - static constexpr PrimitiveType primitiveType = PrimitiveType::TriangleStrip; }; } // namespace gfx diff --git a/src/mbgl/gfx/primitives.hpp b/src/mbgl/gfx/primitives.hpp deleted file mode 100644 index f92b1ec525..0000000000 --- a/src/mbgl/gfx/primitives.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include <cstddef> - -namespace mbgl { -namespace gfx { - -class Point { -public: - static constexpr std::size_t vertexCount = 1; -}; - -class Line { -public: - static constexpr std::size_t vertexCount = 2; -}; - -class Triangle { -public: - static constexpr std::size_t vertexCount = 3; -}; - -} // namespace gfx -} // namespace mbgl diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp index 4c6a040b1f..42647eb9a8 100644 --- a/src/mbgl/gfx/types.hpp +++ b/src/mbgl/gfx/types.hpp @@ -6,6 +6,12 @@ namespace mbgl { namespace gfx { enum class PrimitiveType : uint8_t { + Point, + Line, + Triangle, +}; + +enum class DrawModeType : uint8_t { Points, Lines, LineLoop, |