From f6e79d70735361438655f279c8699a786d25458c Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Thu, 27 Apr 2017 15:56:55 -0700 Subject: [core] Render fill-extrusion layers (#8431) --- src/mbgl/style/paint_property.hpp | 75 ++++----------------------------------- 1 file changed, 7 insertions(+), 68 deletions(-) (limited to 'src/mbgl/style/paint_property.hpp') diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index 7f7018748c..dd8d6c0b50 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -23,68 +24,6 @@ class GeometryTileFeature; namespace style { -template -class UnevaluatedPaintProperty { -public: - UnevaluatedPaintProperty() = default; - - UnevaluatedPaintProperty(Value value_, - UnevaluatedPaintProperty prior_, - TransitionOptions transition, - TimePoint now) - : begin(now + transition.delay.value_or(Duration::zero())), - end(begin + transition.duration.value_or(Duration::zero())), - value(std::move(value_)) { - if (transition.isDefined()) { - prior = { std::move(prior_) }; - } - } - - template - auto evaluate(const Evaluator& evaluator, TimePoint now) { - auto finalValue = value.evaluate(evaluator); - if (!prior) { - // No prior value. - return finalValue; - } else if (now >= end) { - // Transition from prior value is now complete. - prior = {}; - return finalValue; - } else if (value.isDataDriven()) { - // Transitions to data-driven properties are not supported. - // We snap immediately to the data-driven value so that, when we perform layout, - // we see the data-driven function and can use it to populate vertex buffers. - prior = {}; - return finalValue; - } else if (now < begin) { - // Transition hasn't started yet. - return prior->get().evaluate(evaluator, now); - } else { - // Interpolate between recursively-calculated prior value and final. - float t = std::chrono::duration(now - begin) / (end - begin); - return util::interpolate(prior->get().evaluate(evaluator, now), finalValue, util::DEFAULT_TRANSITION_EASE.solve(t, 0.001)); - } - } - - bool hasTransition() const { - return bool(prior); - } - - bool isUndefined() const { - return value.isUndefined(); - } - - const Value& getValue() const { - return value; - } - -private: - optional>> prior; - TimePoint begin; - TimePoint end; - Value value; -}; - template class CascadingPaintProperty { public: @@ -112,8 +51,8 @@ public: transitions[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = transition; } - template - UnevaluatedPaintProperty cascade(const CascadeParameters& params, UnevaluatedPaintProperty prior) const { + template + TransitioningProperty cascade(const CascadeParameters& params, TransitioningProperty prior) const { TransitionOptions transition; Value value; @@ -131,7 +70,7 @@ public: } } - return UnevaluatedPaintProperty(std::move(value), + return TransitioningProperty(std::move(value), std::move(prior), transition.reverseMerge(params.transition), params.now); @@ -147,7 +86,7 @@ class PaintProperty { public: using ValueType = PropertyValue; using CascadingType = CascadingPaintProperty; - using UnevaluatedType = UnevaluatedPaintProperty; + using UnevaluatedType = TransitioningProperty; using EvaluatorType = PropertyEvaluator; using EvaluatedType = T; static constexpr bool IsDataDriven = false; @@ -158,7 +97,7 @@ class DataDrivenPaintProperty { public: using ValueType = DataDrivenPropertyValue; using CascadingType = CascadingPaintProperty; - using UnevaluatedType = UnevaluatedPaintProperty; + using UnevaluatedType = TransitioningProperty; using EvaluatorType = DataDrivenPropertyEvaluator; using EvaluatedType = PossiblyEvaluatedPropertyValue; static constexpr bool IsDataDriven = true; @@ -172,7 +111,7 @@ class CrossFadedPaintProperty { public: using ValueType = PropertyValue; using CascadingType = CascadingPaintProperty; - using UnevaluatedType = UnevaluatedPaintProperty; + using UnevaluatedType = TransitioningProperty; using EvaluatorType = CrossFadedPropertyEvaluator; using EvaluatedType = Faded; static constexpr bool IsDataDriven = false; -- cgit v1.2.1