diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-19 19:25:33 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-07-02 17:21:59 +0300 |
commit | 3bf85cc55d662c218e371a03040c4cd5c3cca771 (patch) | |
tree | bc14ad9a75826aa68eceb0cf0f64d4b9104f02f2 /src | |
parent | d8a10ac509d5f56120eb878b5e330dcb4c7abf1b (diff) | |
download | qtlocation-mapboxgl-3bf85cc55d662c218e371a03040c4cd5c3cca771.tar.gz |
[core] Added StaticRasterVertexBuffer
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/geometry/static_vertex_buffer.cpp | 18 | ||||
-rw-r--r-- | src/mbgl/geometry/static_vertex_buffer.hpp | 17 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.hpp | 33 |
4 files changed, 47 insertions, 22 deletions
diff --git a/src/mbgl/geometry/static_vertex_buffer.cpp b/src/mbgl/geometry/static_vertex_buffer.cpp index 254b01b6b6..c66b194748 100644 --- a/src/mbgl/geometry/static_vertex_buffer.cpp +++ b/src/mbgl/geometry/static_vertex_buffer.cpp @@ -3,11 +3,21 @@ namespace mbgl { -StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> init) { +StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>> init) { for (const auto& vertex : init) { - vertex_type *vertices = static_cast<vertex_type *>(addElement()); - vertices[0] = vertex.first; - vertices[1] = vertex.second; + VertexType* vertices = static_cast<VertexType*>(addElement()); + vertices[0] = std::get<0>(vertex); + vertices[1] = std::get<1>(vertex); + } +} + +StaticRasterVertexBuffer::StaticRasterVertexBuffer(std::initializer_list<std::array<VertexType, 4>> init) { + for (const auto& vertex : init) { + VertexType* vertices = static_cast<VertexType*>(addElement()); + vertices[0] = std::get<0>(vertex); + vertices[1] = std::get<1>(vertex); + vertices[2] = std::get<2>(vertex); + vertices[3] = std::get<3>(vertex); } } diff --git a/src/mbgl/geometry/static_vertex_buffer.hpp b/src/mbgl/geometry/static_vertex_buffer.hpp index 79f6117cbc..2e738afc98 100644 --- a/src/mbgl/geometry/static_vertex_buffer.hpp +++ b/src/mbgl/geometry/static_vertex_buffer.hpp @@ -2,10 +2,8 @@ #include <mbgl/geometry/buffer.hpp> -#include <vector> -#include <cstddef> +#include <array> #include <cstdint> -#include <cmath> namespace mbgl { @@ -15,9 +13,18 @@ class StaticVertexBuffer : public Buffer< 32 // default length > { public: - typedef int16_t vertex_type; + using VertexType = int16_t; + StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>>); +}; - StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> init); +class StaticRasterVertexBuffer : public Buffer< + 8, // bytes per vertex (4 * signed short == 8 bytes) + GL_ARRAY_BUFFER, + 32 // default length +> { +public: + using VertexType = int16_t; + StaticRasterVertexBuffer(std::initializer_list<std::array<VertexType, 4>>); }; } // namespace mbgl diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 7661d80e9c..0e2cfc30b4 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -133,6 +133,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a MBGL_DEBUG_GROUP("upload"); tileStencilBuffer.upload(store); + rasterBoundsBuffer.upload(store); tileBorderBuffer.upload(store); spriteAtlas->upload(store); lineAtlas->upload(store); diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 0ea3596775..304132595c 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -225,16 +225,23 @@ private: std::unique_ptr<CircleShader> circleOverdrawShader; // Set up the stencil quad we're using to generate the stencil mask. - StaticVertexBuffer tileStencilBuffer = { + StaticVertexBuffer tileStencilBuffer { // top left triangle - { 0, 0 }, - { util::EXTENT, 0 }, - { 0, util::EXTENT }, + {{ 0, 0 }}, + {{ util::EXTENT, 0 }}, + {{ 0, util::EXTENT }}, // bottom right triangle - { util::EXTENT, 0 }, - { 0, util::EXTENT }, - { util::EXTENT, util::EXTENT }, + {{ util::EXTENT, 0 }}, + {{ 0, util::EXTENT }}, + {{ util::EXTENT, util::EXTENT }}, + }; + + StaticRasterVertexBuffer rasterBoundsBuffer { + {{ 0, 0, 0, 0 }}, + {{ util::EXTENT, 0, 32767, 0 }}, + {{ 0, util::EXTENT, 0, 32767 }}, + {{ util::EXTENT, util::EXTENT, 32767, 32767 }}, }; VertexArrayObject coveringPlainArray; @@ -248,12 +255,12 @@ private: VertexArrayObject backgroundOverdrawArray; // Set up the tile boundary lines we're using to draw the tile outlines. - StaticVertexBuffer tileBorderBuffer = { - { 0, 0 }, - { util::EXTENT, 0 }, - { util::EXTENT, util::EXTENT }, - { 0, util::EXTENT }, - { 0, 0 }, + StaticVertexBuffer tileBorderBuffer { + {{ 0, 0 }}, + {{ util::EXTENT, 0 }}, + {{ util::EXTENT, util::EXTENT }}, + {{ 0, util::EXTENT }}, + {{ 0, 0 }}, }; VertexArrayObject tileBorderArray; |