From 8be135231d9efe41a3b12037518d02b36104e8cf Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Mon, 11 Mar 2019 10:26:19 +0200 Subject: [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 --- src/mbgl/style/layers/symbol_layer_impl.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/mbgl/style/layers/symbol_layer_impl.cpp') diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index 3dd1da1136..e35e7b0b9f 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -1,17 +1,24 @@ #include - #include namespace mbgl { namespace style { +bool SymbolLayer::Impl::hasFormatSectionOverrides() const { + if (!hasFormatSectionOverrides_) { + hasFormatSectionOverrides_ = SymbolLayerPaintPropertyOverrides::hasOverrides(layout.get()); + } + return *hasFormatSectionOverrides_; +} + bool SymbolLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const { assert(other.getTypeInfo() == getTypeInfo()); const auto& impl = static_cast(other); return filter != impl.filter || visibility != impl.visibility || layout != impl.layout || - paint.hasDataDrivenPropertyDifference(impl.paint); + paint.hasDataDrivenPropertyDifference(impl.paint) || + (hasFormatSectionOverrides() && SymbolLayerPaintPropertyOverrides::hasPaintPropertyDifference(paint, impl.paint)); } void SymbolLayer::Impl::populateFontStack(std::set& fontStack) const { @@ -20,10 +27,10 @@ void SymbolLayer::Impl::populateFontStack(std::set& fontStack) const } layout.get().match( - [&] (Undefined) { + [&fontStack] (Undefined) { fontStack.insert({"Open Sans Regular", "Arial Unicode MS Regular"}); }, - [&] (const FontStack& constant) { + [&fontStack] (const FontStack& constant) { fontStack.insert(constant); }, [&] (const auto& function) { -- cgit v1.2.1