diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-03-11 10:26:19 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-03-13 17:14:53 +0200 |
commit | 8be135231d9efe41a3b12037518d02b36104e8cf (patch) | |
tree | efecd5380232f899aed2cd5824dc16f057f0469a /src/mbgl/renderer/buckets | |
parent | 8a51362bccbd6487dd1ed8518443b16ba6114fd8 (diff) | |
download | qtlocation-mapboxgl-8be135231d9efe41a3b12037518d02b36104e8cf.tar.gz |
[core] Add possibility of overriding paint properties inside format expression #14062
* [core] Add format override expression and formatted section to evaluation context
* [core] Add textColor to TaggedString's formatted section
* [core] Add FormatSectionOverrides and introduce overridable properties
* [core] Populate symbol layer paint properties for text sections
* [core] Add benchmark for style that uses text-color override
* [core] Add unit test for FormatOverrideExpression
* [core] Add unit test for FormatSectionOverrides
Diffstat (limited to 'src/mbgl/renderer/buckets')
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 29 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 20 |
2 files changed, 33 insertions, 16 deletions
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 3a3688a60b..9220235f1d 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -28,13 +28,17 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo iconSizeBinder(SymbolSizeBinder::create(zoom, iconSize, IconSize::defaultValue())) { for (const auto& pair : paintProperties_) { + auto layerPaintProperties = pair.second; + if (hasFormatSectionOverrides()) { + setPaintPropertyOverrides(layerPaintProperties); + } paintProperties.emplace( std::piecewise_construct, std::forward_as_tuple(pair.first), std::forward_as_tuple(PaintProperties { - pair.second, - { RenderSymbolLayer::iconPaintProperties(pair.second), zoom }, - { RenderSymbolLayer::textPaintProperties(pair.second), zoom } + layerPaintProperties, + { RenderSymbolLayer::iconPaintProperties(layerPaintProperties), zoom }, + { RenderSymbolLayer::textPaintProperties(layerPaintProperties), zoom } })); } } @@ -226,4 +230,23 @@ void SymbolBucket::sortFeatures(const float angle) { } } +void SymbolBucket::updatePaintProperties(const std::string& layerID, + style::SymbolPaintProperties::PossiblyEvaluated updated) { + if (hasFormatSectionOverrides()) { + SymbolLayerPaintPropertyOverrides::updateOverrides(paintProperties.at(layerID).evaluated, updated); + } + paintProperties.at(layerID).evaluated = updated; +} + +void SymbolBucket::setPaintPropertyOverrides(style::SymbolPaintProperties::PossiblyEvaluated& paint) { + SymbolLayerPaintPropertyOverrides::setOverrides(layout, paint); +} + +bool SymbolBucket::hasFormatSectionOverrides() { + if (!hasFormatSectionOverrides_) { + hasFormatSectionOverrides_= SymbolLayerPaintPropertyOverrides::hasOverrides(layout.get<TextField>()); + } + return *hasFormatSectionOverrides_; +} + } // namespace mbgl diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index 709e48dd2e..9764d870da 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -58,6 +58,10 @@ public: bool hasIconData() const; bool hasCollisionBoxData() const; bool hasCollisionCircleData() const; + bool hasFormatSectionOverrides(); + void updatePaintProperties(const std::string& layerID, + style::SymbolPaintProperties::PossiblyEvaluated); + void setPaintPropertyOverrides(style::SymbolPaintProperties::PossiblyEvaluated&); void updateOpacity(); void sortFeatures(const float angle); @@ -87,7 +91,7 @@ public: std::unique_ptr<SymbolSizeBinder> textSizeBinder; - struct TextBuffer { + struct Buffer { gfx::VertexVector<SymbolLayoutVertex> vertices; gfx::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>> dynamicVertices; gfx::VertexVector<gfx::Vertex<SymbolOpacityAttributes>> opacityVertices; @@ -103,19 +107,8 @@ public: std::unique_ptr<SymbolSizeBinder> iconSizeBinder; - struct IconBuffer { - gfx::VertexVector<SymbolLayoutVertex> vertices; - gfx::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>> dynamicVertices; - gfx::VertexVector<gfx::Vertex<SymbolOpacityAttributes>> opacityVertices; - gfx::IndexVector<gfx::Triangles> triangles; - SegmentVector<SymbolIconAttributes> segments; - std::vector<PlacedSymbol> placedSymbols; + struct IconBuffer : public Buffer { PremultipliedImage atlasImage; - - optional<gfx::VertexBuffer<SymbolLayoutVertex>> vertexBuffer; - optional<gfx::VertexBuffer<gfx::Vertex<SymbolDynamicLayoutAttributes>>> dynamicVertexBuffer; - optional<gfx::VertexBuffer<gfx::Vertex<SymbolOpacityAttributes>>> opacityVertexBuffer; - optional<gfx::IndexBuffer> indexBuffer; } icon; struct CollisionBuffer { @@ -139,6 +132,7 @@ public: uint32_t bucketInstanceId = 0; bool justReloaded = false; + optional<bool> hasFormatSectionOverrides_; std::shared_ptr<std::vector<size_t>> featureSortOrder; }; |