diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2017-06-16 10:42:33 -0400 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2017-07-11 09:10:24 -0700 |
commit | e514138b691615be24f484986c40f486223df82a (patch) | |
tree | 4cab221d92f66feefd132818a700c47cc67ef245 /src/mbgl/renderer/buckets/symbol_bucket.hpp | |
parent | 77734cfe1b9e77a0058fa3e0db79e3c20a264165 (diff) | |
download | qtlocation-mapboxgl-e514138b691615be24f484986c40f486223df82a.tar.gz |
[core] improve legibility of labels that follow lines
port https://github.com/mapbox/mapbox-gl-js/pull/4781
This improves legibility of labels that follow lines in pitched views.
The previous approach used the limited information in the shader to
calculate put the glyph in approximatelyright place. The new approach
does this more accurately by doing it on the cpu where we have access to
the entire line geometry.
Diffstat (limited to 'src/mbgl/renderer/buckets/symbol_bucket.hpp')
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index 002b6e28b3..ffa22e9021 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -15,6 +15,23 @@ namespace mbgl { +class PlacedSymbol { +public: + PlacedSymbol(Point<float> anchorPoint_, uint16_t segment_, float lowerSize_, float upperSize_, + std::array<float, 2> lineOffset_, float placementZoom_, bool useVerticalMode_, GeometryCoordinates line_) : + anchorPoint(anchorPoint_), segment(segment_), lowerSize(lowerSize_), upperSize(upperSize_), + lineOffset(lineOffset_), placementZoom(placementZoom_), useVerticalMode(useVerticalMode_), line(std::move(line_)) {} + Point<float> anchorPoint; + uint16_t segment; + float lowerSize; + float upperSize; + std::array<float, 2> lineOffset; + float placementZoom; + bool useVerticalMode; + GeometryCoordinates line; + std::vector<float> glyphOffsets; +}; + class SymbolBucket : public Bucket { public: SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated, @@ -44,10 +61,13 @@ public: struct TextBuffer { gl::VertexVector<SymbolLayoutVertex> vertices; + gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex> dynamicVertices; gl::IndexVector<gl::Triangles> triangles; gl::SegmentVector<SymbolTextAttributes> segments; + std::vector<PlacedSymbol> placedSymbols; optional<gl::VertexBuffer<SymbolLayoutVertex>> vertexBuffer; + optional<gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>> dynamicVertexBuffer; optional<gl::IndexBuffer<gl::Triangles>> indexBuffer; } text; @@ -55,11 +75,14 @@ public: struct IconBuffer { gl::VertexVector<SymbolLayoutVertex> vertices; + gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex> dynamicVertices; gl::IndexVector<gl::Triangles> triangles; gl::SegmentVector<SymbolIconAttributes> segments; + std::vector<PlacedSymbol> placedSymbols; PremultipliedImage atlasImage; optional<gl::VertexBuffer<SymbolLayoutVertex>> vertexBuffer; + optional<gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>> dynamicVertexBuffer; optional<gl::IndexBuffer<gl::Triangles>> indexBuffer; } icon; @@ -69,6 +92,7 @@ public: gl::SegmentVector<CollisionBoxAttributes> segments; optional<gl::VertexBuffer<CollisionBoxVertex>> vertexBuffer; + optional<gl::VertexBuffer<SymbolDynamicLayoutAttributes::Vertex>> dynamicVertexBuffer; optional<gl::IndexBuffer<gl::Lines>> indexBuffer; } collisionBox; }; |