diff options
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 29 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 20 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_symbol_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/paint_property_binder.hpp | 36 |
4 files changed, 56 insertions, 31 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; }; diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index e523a869b2..43e3068ff0 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -411,7 +411,7 @@ void RenderSymbolLayer::sortRenderTiles(const TransformState& state) { void RenderSymbolLayer::updateBucketPaintProperties(Bucket* bucket) const { assert(bucket->supportsLayer(*baseImpl)); - static_cast<SymbolBucket*>(bucket)->paintProperties.at(getID()).evaluated = evaluated; + static_cast<SymbolBucket*>(bucket)->updatePaintProperties(getID(), evaluated); } } // namespace mbgl diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index 34600508af..dc5ab6ae22 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -95,7 +95,10 @@ public: virtual ~PaintPropertyBinder() = default; - virtual void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, const ImagePositions&, const optional<PatternDependency>&) = 0; + virtual void populateVertexVector(const GeometryTileFeature& feature, + std::size_t length, const ImagePositions&, + const optional<PatternDependency>&, + const style::expression::Value&) = 0; virtual void upload(gfx::Context& context) = 0; virtual void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, CrossfadeParameters&) = 0; virtual std::tuple<ExpandToType<As, optional<gl::AttributeBinding>>...> attributeBinding(const PossiblyEvaluatedType& currentValue) const = 0; @@ -114,7 +117,7 @@ public: : constant(std::move(constant_)) { } - void populateVertexVector(const GeometryTileFeature&, std::size_t, const ImagePositions&, const optional<PatternDependency>&) override {} + void populateVertexVector(const GeometryTileFeature&, std::size_t, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value&) override {} void upload(gfx::Context&) override {} void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, CrossfadeParameters&) override {}; @@ -135,13 +138,13 @@ private: }; template <class T, class... As> -class ConstantCrossFadedPaintPropertyBinder : public PaintPropertyBinder<T, std::array<uint16_t, 4>,PossiblyEvaluatedPropertyValue<Faded<T>>, As...> { +class ConstantCrossFadedPaintPropertyBinder final : public PaintPropertyBinder<T, std::array<uint16_t, 4>,PossiblyEvaluatedPropertyValue<Faded<T>>, As...> { public: ConstantCrossFadedPaintPropertyBinder(Faded<T> constant_) : constant(std::move(constant_)), constantPatternPositions({}) { } - void populateVertexVector(const GeometryTileFeature&, std::size_t, const ImagePositions&, const optional<PatternDependency>&) override {} + void populateVertexVector(const GeometryTileFeature&, std::size_t, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value&) override {} void upload(gfx::Context&) override {} void setPatternParameters(const optional<ImagePosition>& posA, const optional<ImagePosition>& posB, CrossfadeParameters&) override { @@ -171,7 +174,7 @@ private: }; template <class T, class A> -class SourceFunctionPaintPropertyBinder : public PaintPropertyBinder<T, T, PossiblyEvaluatedPropertyValue<T>, A> { +class SourceFunctionPaintPropertyBinder final : public PaintPropertyBinder<T, T, PossiblyEvaluatedPropertyValue<T>, A> { public: using BaseAttributeType = A; using BaseVertex = gfx::Vertex<BaseAttributeType>; @@ -183,8 +186,9 @@ public: defaultValue(std::move(defaultValue_)) { } void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, CrossfadeParameters&) override {}; - void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, const ImagePositions&, const optional<PatternDependency>&) override { - auto evaluated = expression.evaluate(feature, defaultValue); + void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value& formattedSection) override { + using style::expression::EvaluationContext; + auto evaluated = expression.evaluate(EvaluationContext(&feature).withFormattedSection(&formattedSection), defaultValue); this->statistics.add(evaluated); auto value = attributeValue(evaluated); for (std::size_t i = vertexVector.elements(); i < length; ++i) { @@ -227,7 +231,7 @@ private: }; template <class T, class A> -class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder<T, T, PossiblyEvaluatedPropertyValue<T>, A> { +class CompositeFunctionPaintPropertyBinder final : public PaintPropertyBinder<T, T, PossiblyEvaluatedPropertyValue<T>, A> { public: using AttributeType = ZoomInterpolatedAttributeType<A>; @@ -240,8 +244,12 @@ public: zoomRange({zoom, zoom + 1}) { } void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, CrossfadeParameters&) override {}; - void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, const ImagePositions&, const optional<PatternDependency>&) override { - Range<T> range = expression.evaluate(zoomRange, feature, defaultValue); + void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value& formattedSection) override { + using style::expression::EvaluationContext; + Range<T> range = { + expression.evaluate(EvaluationContext(zoomRange.min, &feature).withFormattedSection(&formattedSection), defaultValue), + expression.evaluate(EvaluationContext(zoomRange.max, &feature).withFormattedSection(&formattedSection), defaultValue), + }; this->statistics.add(range.min); this->statistics.add(range.max); AttributeValue value = zoomInterpolatedAttributeValue( @@ -292,7 +300,7 @@ private: }; template <class T, class A1, class A2> -class CompositeCrossFadedPaintPropertyBinder : public PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2> { +class CompositeCrossFadedPaintPropertyBinder final : public PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2> { public: using AttributeType = ZoomInterpolatedAttributeType<A1>; using AttributeType2 = ZoomInterpolatedAttributeType<A2>; @@ -313,7 +321,7 @@ public: crossfade = crossfade_; }; - void populateVertexVector(const GeometryTileFeature&, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies) override { + void populateVertexVector(const GeometryTileFeature&, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies, const style::expression::Value&) override { if (patternDependencies->mid.empty()) { // Unlike other propperties with expressions that evaluate to null, the default value for `*-pattern` properties is an empty @@ -474,9 +482,9 @@ public: PaintPropertyBinders(PaintPropertyBinders&&) = default; PaintPropertyBinders(const PaintPropertyBinders&) = delete; - void populateVertexVectors(const GeometryTileFeature& feature, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies) { + void populateVertexVectors(const GeometryTileFeature& feature, std::size_t length, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies, const style::expression::Value& formattedSection = {}) { util::ignore({ - (binders.template get<Ps>()->populateVertexVector(feature, length, patternPositions, patternDependencies), 0)... + (binders.template get<Ps>()->populateVertexVector(feature, length, patternPositions, patternDependencies, formattedSection), 0)... }); } |