[core] Move CrossFadedPropertyEvaluator to its own file
This commit is contained in:
@@ -218,6 +218,8 @@ set(MBGL_CORE_FILES
|
||||
src/mbgl/style/cascade_parameters.hpp
|
||||
src/mbgl/style/class_dictionary.cpp
|
||||
src/mbgl/style/class_dictionary.hpp
|
||||
src/mbgl/style/cross_faded_property_evaluator.cpp
|
||||
src/mbgl/style/cross_faded_property_evaluator.hpp
|
||||
src/mbgl/style/function.cpp
|
||||
src/mbgl/style/layer.cpp
|
||||
src/mbgl/style/layer_impl.cpp
|
||||
@@ -229,7 +231,6 @@ set(MBGL_CORE_FILES
|
||||
src/mbgl/style/parser.cpp
|
||||
src/mbgl/style/parser.hpp
|
||||
src/mbgl/style/property_evaluation_parameters.hpp
|
||||
src/mbgl/style/property_evaluator.cpp
|
||||
src/mbgl/style/property_evaluator.hpp
|
||||
src/mbgl/style/property_parsing.cpp
|
||||
src/mbgl/style/property_parsing.hpp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/sprite/sprite_atlas.hpp>
|
||||
#include <mbgl/style/property_evaluator.hpp>
|
||||
#include <mbgl/style/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <mbgl/style/property_evaluator.hpp>
|
||||
#include <mbgl/style/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
|
||||
#include <cmath>
|
||||
48
src/mbgl/style/cross_faded_property_evaluator.hpp
Normal file
48
src/mbgl/style/cross_faded_property_evaluator.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/style/property_value.hpp>
|
||||
#include <mbgl/style/property_evaluation_parameters.hpp>
|
||||
#include <mbgl/util/interpolate.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
template <typename T>
|
||||
class Faded {
|
||||
public:
|
||||
T from;
|
||||
T to;
|
||||
float fromScale;
|
||||
float toScale;
|
||||
float t;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class CrossFadedPropertyEvaluator {
|
||||
public:
|
||||
using ResultType = Faded<T>;
|
||||
|
||||
CrossFadedPropertyEvaluator(const PropertyEvaluationParameters& parameters_, T defaultValue_)
|
||||
: parameters(parameters_),
|
||||
defaultValue(std::move(defaultValue_)) {}
|
||||
|
||||
Faded<T> operator()(const Undefined&) const;
|
||||
Faded<T> operator()(const T& constant) const;
|
||||
Faded<T> operator()(const Function<T>&) const;
|
||||
|
||||
private:
|
||||
Faded<T> calculate(const T& min, const T& mid, const T& max) const;
|
||||
|
||||
const PropertyEvaluationParameters& parameters;
|
||||
T defaultValue;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
namespace util {
|
||||
template <typename T>
|
||||
struct Interpolator<style::Faded<T>>
|
||||
: Uninterpolated {};
|
||||
} // namespace util
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/style/class_dictionary.hpp>
|
||||
#include <mbgl/style/property_evaluator.hpp>
|
||||
#include <mbgl/style/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/cascade_parameters.hpp>
|
||||
#include <mbgl/style/property_evaluation_parameters.hpp>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/style/property_value.hpp>
|
||||
#include <mbgl/style/property_evaluation_parameters.hpp>
|
||||
#include <mbgl/util/interpolate.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -25,42 +24,5 @@ private:
|
||||
T defaultValue;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class Faded {
|
||||
public:
|
||||
T from;
|
||||
T to;
|
||||
float fromScale;
|
||||
float toScale;
|
||||
float t;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class CrossFadedPropertyEvaluator {
|
||||
public:
|
||||
using ResultType = Faded<T>;
|
||||
|
||||
CrossFadedPropertyEvaluator(const PropertyEvaluationParameters& parameters_, T defaultValue_)
|
||||
: parameters(parameters_),
|
||||
defaultValue(std::move(defaultValue_)) {}
|
||||
|
||||
Faded<T> operator()(const Undefined&) const;
|
||||
Faded<T> operator()(const T& constant) const;
|
||||
Faded<T> operator()(const Function<T>&) const;
|
||||
|
||||
private:
|
||||
Faded<T> calculate(const T& min, const T& mid, const T& max) const;
|
||||
|
||||
const PropertyEvaluationParameters& parameters;
|
||||
T defaultValue;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
namespace util {
|
||||
template <typename T>
|
||||
struct Interpolator<style::Faded<T>>
|
||||
: Uninterpolated {};
|
||||
} // namespace util
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user