[core] Move CrossFadedPropertyEvaluator to its own file

This commit is contained in:
John Firebaugh
2016-11-30 10:31:55 -08:00
parent 05b0dcd0f8
commit cc6e5c9df9
6 changed files with 53 additions and 41 deletions

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View 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

View File

@@ -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>

View File

@@ -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