diff options
author | Andrew Hay Kurtz <andrew.hay.kurtz@gmail.com> | 2019-09-17 17:35:08 -0700 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-12-17 14:25:19 +0200 |
commit | da4eb01bc7b74b09405f9911ef506c190b426f9d (patch) | |
tree | 11d2d2549150ebb0fbd1db14bc575f628113da5d /src/mbgl/style/layers/fill_layer.cpp | |
parent | c3854cedc2b1b7e0fb9b5cb5744d6c9495c1730e (diff) | |
download | qtlocation-mapboxgl-da4eb01bc7b74b09405f9911ef506c190b426f9d.tar.gz |
[core] Enable 'line-sort-key' and 'fill-sort-key' layout properties (#15839)
- Generate style code for 'line-sort-key' and 'symbol-sort-key'
- Add new layout properties to FillLayer::Impl, FillBucket, and FillLayerFactory
- Fix consistency of paint and layout properties type alias usage in FillBucket, LineBucket
- Add optional feature sorting to fill and line Layout creation
- Enable node render tests for fill-sort-key and line-sort-key
- Fix FillBucket test construction
- Prefer emplace_back to push_back for PatternFeature container
- Fix buggy static_cast for PatternFeature indices
- Maintain sort of features as they are created
- Switch pattern layout features container to list from vector for better insert performance
- Fix formatting expected by sanity check
- Use subclass PatternLayoutSorted to work around lack of template functions
- Fix to retain source order for features with equivalent sort keys during sorting
- [core] Fix clang-format
- [core] Address review comments
- [core] Pass inserting strategy class at compile time
- [core] Use sorted strategy only if sort key is defined in layout
- [core] Update style generator
- [core] Merge PatternLayout and PatternLayoutSorted classes
- Use static methods for inserter strategies
- Merge PatternLayout and PatternLayoutSorted classes
Diffstat (limited to 'src/mbgl/style/layers/fill_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/fill_layer.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index 9a43037871..757738dfef 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -55,11 +55,27 @@ std::unique_ptr<Layer> FillLayer::cloneRef(const std::string& id_) const { return std::make_unique<FillLayer>(std::move(impl_)); } -void FillLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const { +void FillLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>& writer) const { + layout.stringify(writer); } // Layout properties +PropertyValue<float> FillLayer::getDefaultFillSortKey() { + return FillSortKey::defaultValue(); +} + +const PropertyValue<float>& FillLayer::getFillSortKey() const { + return impl().layout.get<FillSortKey>(); +} + +void FillLayer::setFillSortKey(const PropertyValue<float>& value) { + if (value == getFillSortKey()) return; + auto impl_ = mutableImpl(); + impl_->layout.get<FillSortKey>() = value; + baseImpl = std::move(impl_); + observer->onLayerChanged(*this); +} // Paint properties @@ -271,6 +287,7 @@ enum class Property : uint8_t { FillPatternTransition, FillTranslateTransition, FillTranslateAnchorTransition, + FillSortKey, }; template <typename T> @@ -292,7 +309,8 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map< {"fill-outline-color-transition", toUint8(Property::FillOutlineColorTransition)}, {"fill-pattern-transition", toUint8(Property::FillPatternTransition)}, {"fill-translate-transition", toUint8(Property::FillTranslateTransition)}, - {"fill-translate-anchor-transition", toUint8(Property::FillTranslateAnchorTransition)}}); + {"fill-translate-anchor-transition", toUint8(Property::FillTranslateAnchorTransition)}, + {"fill-sort-key", toUint8(Property::FillSortKey)}}); } // namespace optional<Error> FillLayer::setProperty(const std::string& name, const Convertible& value) { @@ -331,15 +349,22 @@ optional<Error> FillLayer::setProperty(const std::string& name, const Convertibl return nullopt; } } - if (property == Property::FillOpacity) { + if (property == Property::FillOpacity || property == Property::FillSortKey) { Error error; const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false); if (!typedValue) { return error; } - setFillOpacity(*typedValue); - return nullopt; + if (property == Property::FillOpacity) { + setFillOpacity(*typedValue); + return nullopt; + } + + if (property == Property::FillSortKey) { + setFillSortKey(*typedValue); + return nullopt; + } } if (property == Property::FillPattern) { Error error; @@ -451,6 +476,8 @@ StyleProperty FillLayer::getProperty(const std::string& name) const { return makeStyleProperty(getFillTranslateTransition()); case Property::FillTranslateAnchorTransition: return makeStyleProperty(getFillTranslateAnchorTransition()); + case Property::FillSortKey: + return makeStyleProperty(getFillSortKey()); } return {}; } |