diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-03 15:04:25 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-06 10:38:48 -0800 |
commit | b81243daa9ec5a16594fa280236e2ee903540f64 (patch) | |
tree | 024376bc2a72890d6c77eb1581d2e716f661ea87 /src/mbgl/style/function.hpp | |
parent | 7de4ce5bcbd8a3081f364bef3249d99f3fad60cc (diff) | |
download | qtlocation-mapboxgl-b81243daa9ec5a16594fa280236e2ee903540f64.tar.gz |
[core] Merge PiecewiseConstantFunction into Function
Diffstat (limited to 'src/mbgl/style/function.hpp')
-rw-r--r-- | src/mbgl/style/function.hpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/mbgl/style/function.hpp b/src/mbgl/style/function.hpp index 6ef4fcf5da..e28b0efdd9 100644 --- a/src/mbgl/style/function.hpp +++ b/src/mbgl/style/function.hpp @@ -1,11 +1,18 @@ #ifndef MBGL_STYLE_FUNCTION #define MBGL_STYLE_FUNCTION +#include <mbgl/style/types.hpp> +#include <mbgl/util/chrono.hpp> + +#include <mapbox/optional.hpp> + #include <vector> #include <utility> namespace mbgl { +class StyleCalculationParameters; + template <typename T> class Function { public: @@ -19,13 +26,35 @@ public: explicit Function(const Stops& stops_, float base_) : base(base_), stops(stops_) {} - T evaluate(float z) const; + T evaluate(const StyleCalculationParameters&) const; private: const float base = 1; const std::vector<std::pair<float, T>> stops; }; +// Partial specialization for cross-faded properties (*-pattern, line-dasharray). +template <typename T> +class Function<Faded<T>> { +public: + using Stop = std::pair<float, T>; + using Stops = std::vector<Stop>; + + // TODO: make explicit + /* explicit */ Function(const T& constant) + : stops({{ 0, constant }}) {} + + explicit Function(const Stops& stops_, + mapbox::util::optional<Duration> duration_) + : stops(stops_), duration(duration_) {} + + Faded<T> evaluate(const StyleCalculationParameters&) const; + +private: + const std::vector<std::pair<float, T>> stops; + const mapbox::util::optional<Duration> duration = {}; +}; + } #endif |