summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/fill_layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/layers/fill_layer.cpp')
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp57
1 files changed, 16 insertions, 41 deletions
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index ad1f0ae847..9a43037871 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -293,101 +293,84 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"fill-pattern-transition", toUint8(Property::FillPatternTransition)},
{"fill-translate-transition", toUint8(Property::FillTranslateTransition)},
{"fill-translate-anchor-transition", toUint8(Property::FillTranslateAnchorTransition)}});
-
-constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::FillTranslateAnchorTransition);
} // namespace
-optional<Error> FillLayer::setPaintProperty(const std::string& name, const Convertible& value) {
+optional<Error> FillLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
+ if (it == layerProperties.end()) {
+ if (name == "visibility") return setVisibility(value);
return Error{"layer doesn't support this property"};
}
auto property = static_cast<Property>(it->second);
-
if (property == Property::FillAntialias) {
Error error;
- optional<PropertyValue<bool>> typedValue = convert<PropertyValue<bool>>(value, error, false, false);
+ const auto& typedValue = convert<PropertyValue<bool>>(value, error, false, false);
if (!typedValue) {
return error;
}
-
+
setFillAntialias(*typedValue);
return nullopt;
-
}
-
if (property == Property::FillColor || property == Property::FillOutlineColor) {
Error error;
- optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
+ const auto& typedValue = convert<PropertyValue<Color>>(value, error, true, false);
if (!typedValue) {
return error;
}
-
+
if (property == Property::FillColor) {
setFillColor(*typedValue);
return nullopt;
}
-
+
if (property == Property::FillOutlineColor) {
setFillOutlineColor(*typedValue);
return nullopt;
}
-
}
-
if (property == Property::FillOpacity) {
Error error;
- optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
+ const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
if (!typedValue) {
return error;
}
-
+
setFillOpacity(*typedValue);
return nullopt;
-
}
-
if (property == Property::FillPattern) {
Error error;
- optional<PropertyValue<expression::Image>> typedValue =
- convert<PropertyValue<expression::Image>>(value, error, true, false);
+ const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, true, false);
if (!typedValue) {
return error;
}
-
+
setFillPattern(*typedValue);
return nullopt;
-
}
-
if (property == Property::FillTranslate) {
Error error;
- optional<PropertyValue<std::array<float, 2>>> typedValue =
- convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
+ const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
if (!typedValue) {
return error;
}
-
+
setFillTranslate(*typedValue);
return nullopt;
-
}
-
if (property == Property::FillTranslateAnchor) {
Error error;
- optional<PropertyValue<TranslateAnchorType>> typedValue =
- convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
+ const auto& typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
if (!typedValue) {
return error;
}
-
+
setFillTranslateAnchor(*typedValue);
return nullopt;
-
}
-
Error error;
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
@@ -472,14 +455,6 @@ StyleProperty FillLayer::getProperty(const std::string& name) const {
return {};
}
-optional<Error> FillLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
- if (name == "visibility") {
- return Layer::setVisibility(value);
- }
-
- return Error { "layer doesn't support this property" };
-}
-
Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}