diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-04 13:21:47 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-06 10:39:06 -0800 |
commit | 10858ab382b006476d2c9b8f8f68910ec086068f (patch) | |
tree | 86febb46ded4eb26d02e0048f551a0fa8ce6caeb /src | |
parent | 9b537fab29735bd7969c8781c4c54df3d5786d15 (diff) | |
download | qtlocation-mapboxgl-10858ab382b006476d2c9b8f8f68910ec086068f.tar.gz |
[core] Remove the ability to change cross-fade durations via transition
We shouldn't overload transition duration to mean the duration of the
cross-fade when moving between stops. If we want to allow styles to
override the default 300ms fade duration, it should be a dedicated
property like raster-fade-duration.
I don't think any styles use this functionality -- if they did, they
were broken for MapMode::Still rendering.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/layer/background_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/layer/fill_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/layer/line_layer.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/function.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/function.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/property_parsing.cpp | 17 | ||||
-rw-r--r-- | src/mbgl/style/property_parsing.hpp | 20 |
7 files changed, 13 insertions, 40 deletions
diff --git a/src/mbgl/layer/background_layer.cpp b/src/mbgl/layer/background_layer.cpp index d52905708b..d7986d757a 100644 --- a/src/mbgl/layer/background_layer.cpp +++ b/src/mbgl/layer/background_layer.cpp @@ -7,7 +7,7 @@ void BackgroundLayer::parsePaints(const JSVal& layer) { paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) { parseProperty<Function<float>>("background-opacity", PropertyKey::BackgroundOpacity, paint, value); parseProperty<Function<Color>>("background-color", PropertyKey::BackgroundColor, paint, value); - parseProperty<Function<Faded<std::string>>>("background-pattern", PropertyKey::BackgroundImage, paint, value, "background-pattern-transition"); + parseProperty<Function<Faded<std::string>>>("background-pattern", PropertyKey::BackgroundImage, paint, value); }); } diff --git a/src/mbgl/layer/fill_layer.cpp b/src/mbgl/layer/fill_layer.cpp index 7d53fa97cb..b5e0727559 100644 --- a/src/mbgl/layer/fill_layer.cpp +++ b/src/mbgl/layer/fill_layer.cpp @@ -17,7 +17,7 @@ void FillLayer::parsePaints(const JSVal& layer) { parseProperty<Function<std::array<float, 2>>>("fill-translate", PropertyKey::FillTranslate, paint, value); parseProperty<PropertyTransition>("fill-translate-transition", PropertyKey::FillTranslate, paint, value); parseProperty<Function<TranslateAnchorType>>("fill-translate-anchor", PropertyKey::FillTranslateAnchor, paint, value); - parseProperty<Function<Faded<std::string>>>("fill-pattern", PropertyKey::FillImage, paint, value, "fill-pattern-transition"); + parseProperty<Function<Faded<std::string>>>("fill-pattern", PropertyKey::FillImage, paint, value); }); } diff --git a/src/mbgl/layer/line_layer.cpp b/src/mbgl/layer/line_layer.cpp index a0b216bda1..d404c593cb 100644 --- a/src/mbgl/layer/line_layer.cpp +++ b/src/mbgl/layer/line_layer.cpp @@ -28,8 +28,8 @@ void LineLayer::parsePaints(const JSVal& layer) { parseProperty<PropertyTransition>("line-gap-width-transition", PropertyKey::LineGapWidth, paint, value); parseProperty<Function<float>>("line-blur", PropertyKey::LineBlur, paint, value); parseProperty<PropertyTransition>("line-blur-transition", PropertyKey::LineBlur, paint, value); - parseProperty<Function<Faded<std::vector<float>>>>("line-dasharray", PropertyKey::LineDashArray, paint, value, "line-dasharray-transition"); - parseProperty<Function<Faded<std::string>>>("line-pattern", PropertyKey::LineImage, paint, value, "line-pattern-transition"); + parseProperty<Function<Faded<std::vector<float>>>>("line-dasharray", PropertyKey::LineDashArray, paint, value); + parseProperty<Function<Faded<std::string>>>("line-pattern", PropertyKey::LineImage, paint, value); }); } diff --git a/src/mbgl/style/function.cpp b/src/mbgl/style/function.cpp index f6f67d9531..c656f86888 100644 --- a/src/mbgl/style/function.cpp +++ b/src/mbgl/style/function.cpp @@ -107,7 +107,7 @@ Faded<T> Function<Faded<T>>::evaluate(const StyleCalculationParameters& paramete float z = parameters.z; float fraction = std::fmod(z, 1.0f); - std::chrono::duration<float> d = duration ? *duration : parameters.defaultFadeDuration; + std::chrono::duration<float> d = parameters.defaultFadeDuration; float t = std::min((parameters.now - parameters.zoomHistory.lastIntegerZoomTime) / d, 1.0f); float fromScale = 1.0f; float toScale = 1.0f; diff --git a/src/mbgl/style/function.hpp b/src/mbgl/style/function.hpp index e28b0efdd9..c6ee9a229b 100644 --- a/src/mbgl/style/function.hpp +++ b/src/mbgl/style/function.hpp @@ -44,15 +44,13 @@ public: /* explicit */ Function(const T& constant) : stops({{ 0, constant }}) {} - explicit Function(const Stops& stops_, - mapbox::util::optional<Duration> duration_) - : stops(stops_), duration(duration_) {} + explicit Function(const Stops& stops_) + : stops(stops_) {} Faded<T> evaluate(const StyleCalculationParameters&) const; private: const std::vector<std::pair<float, T>> stops; - const mapbox::util::optional<Duration> duration = {}; }; } diff --git a/src/mbgl/style/property_parsing.cpp b/src/mbgl/style/property_parsing.cpp index 73345fcc62..00b3db8918 100644 --- a/src/mbgl/style/property_parsing.cpp +++ b/src/mbgl/style/property_parsing.cpp @@ -360,12 +360,7 @@ template<> optional<Function<Color>> parseProperty(const char* name, const JSVal } template <typename T> -optional<Function<Faded<T>>> parseFadedFunction(const JSVal& value, const JSVal& transition) { - mapbox::util::optional<Duration> duration; - if (transition.HasMember("duration")) { - duration = std::chrono::milliseconds(transition["duration"].GetUint()); - } - +optional<Function<Faded<T>>> parseFadedFunction(const JSVal& value) { if (!value.HasMember("stops")) { Log::Warning(Event::ParseStyle, "function must specify a function type"); return {}; @@ -377,13 +372,13 @@ optional<Function<Faded<T>>> parseFadedFunction(const JSVal& value, const JSVal& return {}; } - return Function<Faded<T>>(*stops, duration); + return Function<Faded<T>>(*stops); } template <> -optional<Function<Faded<std::vector<float>>>> parseProperty(const char* name, const JSVal& value, const JSVal& transition) { +optional<Function<Faded<std::vector<float>>>> parseProperty(const char* name, const JSVal& value) { if (value.IsObject()) { - return parseFadedFunction<std::vector<float>>(value, transition); + return parseFadedFunction<std::vector<float>>(value); } auto constant = parseProperty<std::vector<float>>(name, value); @@ -394,9 +389,9 @@ optional<Function<Faded<std::vector<float>>>> parseProperty(const char* name, co } template <> -optional<Function<Faded<std::string>>> parseProperty(const char* name, const JSVal& value, const JSVal& transition) { +optional<Function<Faded<std::string>>> parseProperty(const char* name, const JSVal& value) { if (value.IsObject()) { - return parseFadedFunction<std::string>(value, transition); + return parseFadedFunction<std::string>(value); } auto constant = parseProperty<std::string>(name, value); diff --git a/src/mbgl/style/property_parsing.hpp b/src/mbgl/style/property_parsing.hpp index 478e192898..182636df5c 100644 --- a/src/mbgl/style/property_parsing.hpp +++ b/src/mbgl/style/property_parsing.hpp @@ -18,9 +18,6 @@ namespace detail { template <typename T> optional<T> parseProperty(const char* name, const JSVal&); -template <typename T> -optional<T> parseProperty(const char* name, const JSVal&, const JSVal& transition); - } template <typename T> @@ -35,23 +32,6 @@ void parseProperty(const char* name, PropertyKey key, ClassProperties& propertie } } -template <typename T> -void parseProperty(const char* name, PropertyKey key, ClassProperties& properties, const JSVal& value, const char* transitionName) { - if (!value.HasMember(name)) - return; - - const JSVal& noTransition = JSVal { rapidjson::kObjectType }; - - const optional<T> res = detail::parseProperty<T>(name, value[name], - value.HasMember(transitionName) - ? value[transitionName] - : noTransition); - - if (res) { - properties.set(key, *res); - } -} - } #endif |