diff options
Diffstat (limited to 'src/mbgl/style/layers/background_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/background_layer.cpp | 70 |
1 files changed, 16 insertions, 54 deletions
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index eb3c7a2666..89b367b632 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -9,7 +9,8 @@ #include <mbgl/style/conversion/transition_options.hpp> #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion_impl.hpp> -#include <mbgl/util/fnv_hash.hpp> + +#include <mapbox/eternal.hpp> namespace mbgl { namespace style { @@ -145,8 +146,7 @@ TransitionOptions BackgroundLayer::getBackgroundOpacityTransition() const { using namespace conversion; optional<Error> BackgroundLayer::setPaintProperty(const std::string& name, const Convertible& value) { - enum class Property { - Unknown, + enum class Property : uint8_t { BackgroundColor, BackgroundPattern, BackgroundOpacity, @@ -155,45 +155,22 @@ optional<Error> BackgroundLayer::setPaintProperty(const std::string& name, const BackgroundOpacityTransition, }; - Property property = Property::Unknown; - switch (util::hashFNV1a(name.c_str())) { - case util::hashFNV1a("background-color"): - if (name == "background-color") { - property = Property::BackgroundColor; - } - break; - case util::hashFNV1a("background-color-transition"): - if (name == "background-color-transition") { - property = Property::BackgroundColorTransition; - } - break; - case util::hashFNV1a("background-pattern"): - if (name == "background-pattern") { - property = Property::BackgroundPattern; - } - break; - case util::hashFNV1a("background-pattern-transition"): - if (name == "background-pattern-transition") { - property = Property::BackgroundPatternTransition; - } - break; - case util::hashFNV1a("background-opacity"): - if (name == "background-opacity") { - property = Property::BackgroundOpacity; - } - break; - case util::hashFNV1a("background-opacity-transition"): - if (name == "background-opacity-transition") { - property = Property::BackgroundOpacityTransition; - } - break; - - } - - if (property == Property::Unknown) { + MAPBOX_ETERNAL_CONSTEXPR const auto properties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>({ + { "background-color", static_cast<uint8_t>(Property::BackgroundColor) }, + { "background-pattern", static_cast<uint8_t>(Property::BackgroundPattern) }, + { "background-opacity", static_cast<uint8_t>(Property::BackgroundOpacity) }, + { "background-color-transition", static_cast<uint8_t>(Property::BackgroundColorTransition) }, + { "background-pattern-transition", static_cast<uint8_t>(Property::BackgroundPatternTransition) }, + { "background-opacity-transition", static_cast<uint8_t>(Property::BackgroundOpacityTransition) } + }); + + const auto it = properties.find(name.c_str()); + if (it == properties.end()) { return Error { "layer doesn't support this property" }; } + Property property = static_cast<Property>(it->second); + if (property == Property::BackgroundColor) { Error error; @@ -262,21 +239,6 @@ optional<Error> BackgroundLayer::setLayoutProperty(const std::string& name, cons return Layer::setVisibility(value); } - enum class Property { - Unknown, - }; - - Property property = Property::Unknown; - switch (util::hashFNV1a(name.c_str())) { - - } - - if (property == Property::Unknown) { - return Error { "layer doesn't support this property" }; - } - - - return Error { "layer doesn't support this property" }; } |