summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-04-27 14:33:00 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-03 08:30:17 -0700
commitd5f4d0f05fcb8490984649d78d6c026f87a77f4e (patch)
treedea3b08a7c1d6f29a0f75d37cb2ee54a2429e6b4 /src/mbgl/style
parent6c7730ee7c2d9e63df526965bb511b2f43ee82b7 (diff)
downloadqtlocation-mapboxgl-d5f4d0f05fcb8490984649d78d6c026f87a77f4e.tar.gz
[core] Move render-related sources out of style directory/namespace
Moves the following to the renderer directory and out of the style namespace: * CascadeParameters * PropertyEvaluationParameters * UpdateParameters * PropertyEvaluator * DataDrivenPropertyEvaluator * CrossFadedPropertyEvaluator * PaintPropertyBinder * PaintProperyStatistics * PossiblyEvaluatedPropertyValue * TransitioningLight * EvaluatedLight
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/cascade_parameters.hpp20
-rw-r--r--src/mbgl/style/cross_faded_property_evaluator.cpp42
-rw-r--r--src/mbgl/style/cross_faded_property_evaluator.hpp48
-rw-r--r--src/mbgl/style/data_driven_property_evaluator.hpp42
-rw-r--r--src/mbgl/style/layout_property.hpp7
-rw-r--r--src/mbgl/style/light_impl.hpp74
-rw-r--r--src/mbgl/style/paint_property.hpp14
-rw-r--r--src/mbgl/style/paint_property_binder.hpp332
-rw-r--r--src/mbgl/style/paint_property_statistics.hpp31
-rw-r--r--src/mbgl/style/possibly_evaluated_property_value.hpp78
-rw-r--r--src/mbgl/style/property_evaluation_parameters.hpp30
-rw-r--r--src/mbgl/style/property_evaluator.hpp28
-rw-r--r--src/mbgl/style/style.cpp6
-rw-r--r--src/mbgl/style/style.hpp4
-rw-r--r--src/mbgl/style/transitioning_property.hpp77
-rw-r--r--src/mbgl/style/update_parameters.hpp48
16 files changed, 16 insertions, 865 deletions
diff --git a/src/mbgl/style/cascade_parameters.hpp b/src/mbgl/style/cascade_parameters.hpp
deleted file mode 100644
index e0333741dd..0000000000
--- a/src/mbgl/style/cascade_parameters.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/util/chrono.hpp>
-#include <mbgl/style/class_dictionary.hpp>
-#include <mbgl/style/transition_options.hpp>
-
-#include <vector>
-
-namespace mbgl {
-namespace style {
-
-class CascadeParameters {
-public:
- std::vector<ClassID> classes;
- TimePoint now;
- TransitionOptions transition;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/cross_faded_property_evaluator.cpp b/src/mbgl/style/cross_faded_property_evaluator.cpp
deleted file mode 100644
index 796ca00bbf..0000000000
--- a/src/mbgl/style/cross_faded_property_evaluator.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <mbgl/style/cross_faded_property_evaluator.hpp>
-#include <mbgl/util/chrono.hpp>
-
-#include <cmath>
-
-namespace mbgl {
-namespace style {
-
-template <typename T>
-Faded<T> CrossFadedPropertyEvaluator<T>::operator()(const Undefined&) const {
- return calculate(defaultValue, defaultValue, defaultValue);
-}
-
-template <typename T>
-Faded<T> CrossFadedPropertyEvaluator<T>::operator()(const T& constant) const {
- return calculate(constant, constant, constant);
-}
-
-template <typename T>
-Faded<T> CrossFadedPropertyEvaluator<T>::operator()(const CameraFunction<T>& function) const {
- return calculate(function.evaluate(parameters.z - 1.0f),
- function.evaluate(parameters.z),
- function.evaluate(parameters.z + 1.0f));
-}
-
-template <typename T>
-Faded<T> CrossFadedPropertyEvaluator<T>::calculate(const T& min, const T& mid, const T& max) const {
- const float z = parameters.z;
- const float fraction = z - std::floor(z);
- const std::chrono::duration<float> d = parameters.defaultFadeDuration;
- const float t = std::min((parameters.now - parameters.zoomHistory.lastIntegerZoomTime) / d, 1.0f);
-
- return z > parameters.zoomHistory.lastIntegerZoom
- ? Faded<T> { min, mid, 2.0f, 1.0f, fraction + (1.0f - fraction) * t }
- : Faded<T> { max, mid, 0.5f, 1.0f, 1 - (1 - t) * fraction };
-}
-
-template class CrossFadedPropertyEvaluator<std::string>;
-template class CrossFadedPropertyEvaluator<std::vector<float>>;
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/cross_faded_property_evaluator.hpp b/src/mbgl/style/cross_faded_property_evaluator.hpp
deleted file mode 100644
index c5642f5cfb..0000000000
--- a/src/mbgl/style/cross_faded_property_evaluator.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#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 CameraFunction<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
diff --git a/src/mbgl/style/data_driven_property_evaluator.hpp b/src/mbgl/style/data_driven_property_evaluator.hpp
deleted file mode 100644
index 7a0ff9a094..0000000000
--- a/src/mbgl/style/data_driven_property_evaluator.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-
-#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/property_evaluation_parameters.hpp>
-#include <mbgl/style/possibly_evaluated_property_value.hpp>
-
-namespace mbgl {
-namespace style {
-
-template <typename T>
-class DataDrivenPropertyEvaluator {
-public:
- using ResultType = PossiblyEvaluatedPropertyValue<T>;
-
- DataDrivenPropertyEvaluator(const PropertyEvaluationParameters& parameters_, T defaultValue_)
- : parameters(parameters_),
- defaultValue(std::move(defaultValue_)) {}
-
- ResultType operator()(const Undefined&) const {
- return ResultType(defaultValue);
- }
-
- ResultType operator()(const T& constant) const {
- return ResultType(constant);
- }
-
- ResultType operator()(const CameraFunction<T>& function) const {
- return ResultType(function.evaluate(parameters.z));
- }
-
- template <class Function>
- ResultType operator()(const Function& function) const {
- return ResultType(function);
- }
-
-private:
- const PropertyEvaluationParameters& parameters;
- T defaultValue;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp
index e2137deb9f..3b9d6114c0 100644
--- a/src/mbgl/style/layout_property.hpp
+++ b/src/mbgl/style/layout_property.hpp
@@ -2,15 +2,16 @@
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/data_driven_property_value.hpp>
-#include <mbgl/style/property_evaluator.hpp>
-#include <mbgl/style/data_driven_property_evaluator.hpp>
+#include <mbgl/renderer/property_evaluator.hpp>
+#include <mbgl/renderer/data_driven_property_evaluator.hpp>
#include <mbgl/util/indexed_tuple.hpp>
namespace mbgl {
-namespace style {
class PropertyEvaluationParameters;
+namespace style {
+
template <class T>
class LayoutProperty {
public:
diff --git a/src/mbgl/style/light_impl.hpp b/src/mbgl/style/light_impl.hpp
deleted file mode 100644
index d1825090fc..0000000000
--- a/src/mbgl/style/light_impl.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#pragma once
-
-#include <mbgl/style/light.hpp>
-#include <mbgl/style/transitioning_property.hpp>
-#include <mbgl/style/cascade_parameters.hpp>
-#include <mbgl/style/property_evaluator.hpp>
-#include <mbgl/style/property_evaluation_parameters.hpp>
-#include <mbgl/util/ignore.hpp>
-
-namespace mbgl {
-namespace style {
-
-template <class TypeList>
-class Transitioning;
-
-template <class... Ps>
-class Transitioning<TypeList<Ps...>> : public IndexedTuple<
- TypeList<Ps...>,
- TypeList<TransitioningProperty<typename Ps::ValueType>...>>
-{
-private:
- using Properties = TypeList<Ps...>;
- using Raw = IndexedTuple<Properties, Properties>;
- using Super = IndexedTuple<
- TypeList<Ps...>,
- TypeList<TransitioningProperty<typename Ps::ValueType>...>>;
-
-public:
- Transitioning() = default;
- Transitioning(const Raw& raw, Transitioning&& prior, const CascadeParameters& params)
- : Super {
- TransitioningProperty<typename Ps::ValueType>(
- raw.template get<Ps>().value,
- std::move(prior.template get<Ps>()),
- raw.template get<Ps>().transition.reverseMerge(params.transition),
- params.now)...
- } {}
-
- bool hasTransition() const {
- bool result = false;
- util::ignore({ result |= this->template get<Ps>().hasTransition()... });
- return result;
- }
-};
-
-template <class TypeList>
-class Evaluated;
-
-template <class... Ps>
-class Evaluated<TypeList<Ps...>> : public IndexedTuple<
- TypeList<Ps...>,
- TypeList<typename Ps::Type...>>
-{
-private:
- using Properties = TypeList<Ps...>;
- using TransitioningPs = Transitioning<Properties>;
- using Super = IndexedTuple<
- TypeList<Ps...>,
- TypeList<typename Ps::Type...>>;
-
-public:
- Evaluated() = default;
- Evaluated(TransitioningPs& transitioning, const PropertyEvaluationParameters& params)
- : Super {
- transitioning.template get<Ps>()
- .evaluate(PropertyEvaluator<typename Ps::Type>(params, Ps::defaultValue()), params.now)...
- } {}
-};
-
-using TransitioningLight = Transitioning<LightProperties>;
-using EvaluatedLight = Evaluated<LightProperties>;
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index dd8d6c0b50..f1752e69d9 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -1,16 +1,16 @@
#pragma once
-#include <mbgl/style/transitioning_property.hpp>
#include <mbgl/style/class_dictionary.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/data_driven_property_value.hpp>
-#include <mbgl/style/property_evaluator.hpp>
-#include <mbgl/style/cross_faded_property_evaluator.hpp>
-#include <mbgl/style/data_driven_property_evaluator.hpp>
-#include <mbgl/style/property_evaluation_parameters.hpp>
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/cascade_parameters.hpp>
-#include <mbgl/style/paint_property_binder.hpp>
+#include <mbgl/renderer/property_evaluator.hpp>
+#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
+#include <mbgl/renderer/data_driven_property_evaluator.hpp>
+#include <mbgl/renderer/property_evaluation_parameters.hpp>
+#include <mbgl/renderer/cascade_parameters.hpp>
+#include <mbgl/renderer/transitioning_property.hpp>
+#include <mbgl/renderer/paint_property_binder.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/interpolate.hpp>
#include <mbgl/util/indexed_tuple.hpp>
diff --git a/src/mbgl/style/paint_property_binder.hpp b/src/mbgl/style/paint_property_binder.hpp
deleted file mode 100644
index 3915ee588b..0000000000
--- a/src/mbgl/style/paint_property_binder.hpp
+++ /dev/null
@@ -1,332 +0,0 @@
-#pragma once
-
-#include <mbgl/programs/attributes.hpp>
-#include <mbgl/gl/attribute.hpp>
-#include <mbgl/gl/uniform.hpp>
-#include <mbgl/util/type_list.hpp>
-#include <mbgl/style/paint_property_statistics.hpp>
-
-namespace mbgl {
-namespace style {
-
-/*
- ZoomInterpolatedAttribute<Attr> is a 'compound' attribute, representing two values of the
- the base attribute Attr. These two values are provided to the shader to allow interpolation
- between zoom levels, without the need to repopulate vertex buffers each frame as the map is
- being zoomed.
-*/
-template <class A>
-using ZoomInterpolatedAttributeType = gl::Attribute<typename A::ValueType, A::Dimensions * 2>;
-
-inline std::array<float, 1> attributeValue(float v) {
- return {{ v }};
-}
-
-/*
- Encode a four-component color value into a pair of floats. Since csscolorparser
- uses 8-bit precision for each color component, for each float we use the upper 8
- bits for one component (e.g. (color.r * 255) * 256), and the lower 8 for another.
-
- Also note that colors come in as floats 0..1, so we scale by 255.
-*/
-inline std::array<float, 2> attributeValue(const Color& color) {
- return {{
- static_cast<float>(mbgl::attributes::packUint8Pair(255 * color.r, 255 * color.g)),
- static_cast<float>(mbgl::attributes::packUint8Pair(255 * color.b, 255 * color.a))
- }};
-}
-
-template <size_t N>
-std::array<float, N*2> zoomInterpolatedAttributeValue(const std::array<float, N>& min, const std::array<float, N>& max) {
- std::array<float, N*2> result;
- for (size_t i = 0; i < N; i++) {
- result[i] = min[i];
- result[i+N] = max[i];
- }
- return result;
-}
-
-/*
- PaintPropertyBinder is an abstract class serving as the interface definition for
- the strategy used for constructing, uploading, and binding paint property data as
- GLSL attributes.
-
- It has three concrete subclasses, one for each of the three strategies we use:
-
- * For _constant_ properties -- those whose value is a constant, or the constant
- result of evaluating a camera function at a particular camera position -- we
- don't need a vertex buffer, and can instead use a constant attribute binding
- via the `glVertexAttrib*` family of functions.
- * For source functions, we use a vertex buffer with a single attribute value,
- the evaluated result of the source function for the given feature.
- * For composite functions, we use a vertex buffer with two attributes: min and
- max values covering the range of zooms at which we expect the tile to be
- displayed. These values are calculated by evaluating the composite function for
- the given feature at strategically chosen zoom levels. In addition to this
- attribute data, we also use a uniform value which the shader uses to interpolate
- between the min and max value at the final displayed zoom level. The use of a
- uniform allows us to cheaply update the value on every frame.
-
- Note that the shader source is the same regardless of the strategy used to bind
- the attribute -- in all cases the attribute is declared as a vec2, in order to
- support composite min and max values (color attributes use a vec4 with special
- packing). When the constant or source function strategies are used, the
- interpolation uniform value is set to zero, and the second attribute element is
- unused. This differs from the GL JS implementation, which dynamically generates
- shader source based on the strategy used. We found that in WebGL, using
- `glVertexAttrib*` was unnacceptably slow. Additionally, in GL Native we have
- implemented binary shader caching, which works better if the shaders are constant.
-*/
-template <class T, class A>
-class PaintPropertyBinder {
-public:
- using Attribute = ZoomInterpolatedAttributeType<A>;
- using AttributeBinding = typename Attribute::Binding;
-
- virtual ~PaintPropertyBinder() = default;
-
- virtual void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) = 0;
- virtual void upload(gl::Context& context) = 0;
- virtual AttributeBinding attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const = 0;
- virtual float interpolationFactor(float currentZoom) const = 0;
-
- static std::unique_ptr<PaintPropertyBinder> create(const PossiblyEvaluatedPropertyValue<T>& value, float zoom, T defaultValue);
-
- PaintPropertyStatistics<T> statistics;
-};
-
-template <class T, class A>
-class ConstantPaintPropertyBinder : public PaintPropertyBinder<T, A> {
-public:
- using Attribute = ZoomInterpolatedAttributeType<A>;
- using AttributeBinding = typename Attribute::Binding;
-
- ConstantPaintPropertyBinder(T constant_)
- : constant(std::move(constant_)) {
- }
-
- void populateVertexVector(const GeometryTileFeature&, std::size_t) override {}
- void upload(gl::Context&) override {}
-
- AttributeBinding attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
- auto value = attributeValue(currentValue.constantOr(constant));
- return typename Attribute::ConstantBinding {
- zoomInterpolatedAttributeValue(value, value)
- };
- }
-
- float interpolationFactor(float) const override {
- return 0.0f;
- }
-
-private:
- T constant;
-};
-
-template <class T, class A>
-class SourceFunctionPaintPropertyBinder : public PaintPropertyBinder<T, A> {
-public:
- using BaseAttribute = A;
- using BaseAttributeValue = typename BaseAttribute::Value;
- using BaseVertex = gl::detail::Vertex<BaseAttribute>;
-
- using Attribute = ZoomInterpolatedAttributeType<A>;
- using AttributeBinding = typename Attribute::Binding;
-
- SourceFunctionPaintPropertyBinder(SourceFunction<T> function_, T defaultValue_)
- : function(std::move(function_)),
- defaultValue(std::move(defaultValue_)) {
- }
-
- void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) override {
- auto evaluated = function.evaluate(feature, defaultValue);
- this->statistics.add(evaluated);
- auto value = attributeValue(evaluated);
- for (std::size_t i = vertexVector.vertexSize(); i < length; ++i) {
- vertexVector.emplace_back(BaseVertex { value });
- }
- }
-
- void upload(gl::Context& context) override {
- vertexBuffer = context.createVertexBuffer(std::move(vertexVector));
- }
-
- AttributeBinding attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
- if (currentValue.isConstant()) {
- BaseAttributeValue value = attributeValue(*currentValue.constant());
- return typename Attribute::ConstantBinding {
- zoomInterpolatedAttributeValue(value, value)
- };
- } else {
- return Attribute::variableBinding(*vertexBuffer, 0, BaseAttribute::Dimensions);
- }
- }
-
- float interpolationFactor(float) const override {
- return 0.0f;
- }
-
-private:
- SourceFunction<T> function;
- T defaultValue;
- gl::VertexVector<BaseVertex> vertexVector;
- optional<gl::VertexBuffer<BaseVertex>> vertexBuffer;
-};
-
-template <class T, class A>
-class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder<T, A> {
-public:
- using BaseAttribute = A;
- using BaseAttributeValue = typename BaseAttribute::Value;
-
- using Attribute = ZoomInterpolatedAttributeType<A>;
- using AttributeValue = typename Attribute::Value;
- using AttributeBinding = typename Attribute::Binding;
- using Vertex = gl::detail::Vertex<Attribute>;
-
- CompositeFunctionPaintPropertyBinder(CompositeFunction<T> function_, float zoom, T defaultValue_)
- : function(std::move(function_)),
- defaultValue(std::move(defaultValue_)),
- coveringRanges(function.coveringRanges(zoom)) {
- }
-
- void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) override {
- Range<T> range = function.evaluate(std::get<1>(coveringRanges), feature, defaultValue);
- this->statistics.add(range.min);
- this->statistics.add(range.max);
- AttributeValue value = zoomInterpolatedAttributeValue(
- attributeValue(range.min),
- attributeValue(range.max));
- for (std::size_t i = vertexVector.vertexSize(); i < length; ++i) {
- vertexVector.emplace_back(Vertex { value });
- }
- }
-
- void upload(gl::Context& context) override {
- vertexBuffer = context.createVertexBuffer(std::move(vertexVector));
- }
-
- AttributeBinding attributeBinding(const PossiblyEvaluatedPropertyValue<T>& currentValue) const override {
- if (currentValue.isConstant()) {
- BaseAttributeValue value = attributeValue(*currentValue.constant());
- return typename Attribute::ConstantBinding {
- zoomInterpolatedAttributeValue(value, value)
- };
- } else {
- return Attribute::variableBinding(*vertexBuffer, 0);
- }
- }
-
- float interpolationFactor(float currentZoom) const override {
- return util::interpolationFactor(1.0f, std::get<0>(coveringRanges), currentZoom);
- }
-
-private:
- using InnerStops = typename CompositeFunction<T>::InnerStops;
- CompositeFunction<T> function;
- T defaultValue;
- std::tuple<Range<float>, Range<InnerStops>> coveringRanges;
- gl::VertexVector<Vertex> vertexVector;
- optional<gl::VertexBuffer<Vertex>> vertexBuffer;
-};
-
-template <class T, class A>
-std::unique_ptr<PaintPropertyBinder<T, A>>
-PaintPropertyBinder<T, A>::create(const PossiblyEvaluatedPropertyValue<T>& value, float zoom, T defaultValue) {
- return value.match(
- [&] (const T& constant) -> std::unique_ptr<PaintPropertyBinder<T, A>> {
- return std::make_unique<ConstantPaintPropertyBinder<T, A>>(constant);
- },
- [&] (const SourceFunction<T>& function) {
- return std::make_unique<SourceFunctionPaintPropertyBinder<T, A>>(function, defaultValue);
- },
- [&] (const CompositeFunction<T>& function) {
- return std::make_unique<CompositeFunctionPaintPropertyBinder<T, A>>(function, zoom, defaultValue);
- }
- );
-}
-
-template <class Attr>
-struct ZoomInterpolatedAttribute {
- static auto name() { return Attr::name(); }
- using Type = ZoomInterpolatedAttributeType<typename Attr::Type>;
-};
-
-template <class Attr>
-struct InterpolationUniform : gl::UniformScalar<InterpolationUniform<Attr>, float> {
- static auto name() {
- static const std::string name = Attr::name() + std::string("_t");
- return name.c_str();
- }
-};
-
-template <class Ps>
-class PaintPropertyBinders;
-
-template <class... Ps>
-class PaintPropertyBinders<TypeList<Ps...>> {
-public:
- template <class P>
- using Binder = PaintPropertyBinder<typename P::Type, typename P::Attribute::Type>;
-
- using Binders = IndexedTuple<
- TypeList<Ps...>,
- TypeList<std::unique_ptr<Binder<Ps>>...>>;
-
- template <class EvaluatedProperties>
- PaintPropertyBinders(const EvaluatedProperties& properties, float z)
- : binders(Binder<Ps>::create(properties.template get<Ps>(), z, Ps::defaultValue())...) {
- (void)z; // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56958
- }
-
- PaintPropertyBinders(PaintPropertyBinders&&) = default;
- PaintPropertyBinders(const PaintPropertyBinders&) = delete;
-
- void populateVertexVectors(const GeometryTileFeature& feature, std::size_t length) {
- util::ignore({
- (binders.template get<Ps>()->populateVertexVector(feature, length), 0)...
- });
- }
-
- void upload(gl::Context& context) {
- util::ignore({
- (binders.template get<Ps>()->upload(context), 0)...
- });
- }
-
- template <class P>
- using Attribute = ZoomInterpolatedAttribute<typename P::Attribute>;
-
- using Attributes = gl::Attributes<Attribute<Ps>...>;
- using AttributeBindings = typename Attributes::Bindings;
-
- template <class EvaluatedProperties>
- AttributeBindings attributeBindings(const EvaluatedProperties& currentProperties) const {
- return AttributeBindings {
- binders.template get<Ps>()->attributeBinding(currentProperties.template get<Ps>())...
- };
- }
-
- using Uniforms = gl::Uniforms<InterpolationUniform<typename Ps::Attribute>...>;
- using UniformValues = typename Uniforms::Values;
-
- UniformValues uniformValues(float currentZoom) const {
- (void)currentZoom; // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56958
- return UniformValues {
- typename InterpolationUniform<typename Ps::Attribute>::Value {
- binders.template get<Ps>()->interpolationFactor(currentZoom)
- }...
- };
- }
-
- template <class P>
- const auto& statistics() const {
- return binders.template get<P>()->statistics;
- }
-
-private:
- Binders binders;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/paint_property_statistics.hpp b/src/mbgl/style/paint_property_statistics.hpp
deleted file mode 100644
index 01d634dd6f..0000000000
--- a/src/mbgl/style/paint_property_statistics.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#pragma once
-
-#include <mbgl/util/optional.hpp>
-
-namespace mbgl {
-namespace style {
-
-template <class T>
-class PaintPropertyStatistics {
-public:
- optional<T> max() const { return {}; }
- void add(const T&) {}
-};
-
-template <>
-class PaintPropertyStatistics<float> {
-public:
- optional<float> max() const {
- return _max;
- }
-
- void add(float value) {
- _max = _max ? std::max(*_max, value) : value;
- }
-
-private:
- optional<float> _max;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/possibly_evaluated_property_value.hpp b/src/mbgl/style/possibly_evaluated_property_value.hpp
deleted file mode 100644
index 9cb5f6e81b..0000000000
--- a/src/mbgl/style/possibly_evaluated_property_value.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#pragma once
-
-#include <mbgl/style/function/source_function.hpp>
-#include <mbgl/style/function/composite_function.hpp>
-#include <mbgl/util/interpolate.hpp>
-#include <mbgl/util/variant.hpp>
-
-namespace mbgl {
-
-namespace style {
-
-template <class T>
-class PossiblyEvaluatedPropertyValue {
-private:
- using Value = variant<
- T,
- SourceFunction<T>,
- CompositeFunction<T>>;
-
- Value value;
-
-public:
- PossiblyEvaluatedPropertyValue() = default;
- PossiblyEvaluatedPropertyValue(Value v) : value(std::move(v)) {}
-
- bool isConstant() const {
- return value.template is<T>();
- }
-
- optional<T> constant() const {
- return value.match(
- [&] (const T& t) { return optional<T>(t); },
- [&] (const auto&) { return optional<T>(); });
- }
-
- T constantOr(const T& t) const {
- return constant().value_or(t);
- }
-
- template <class... Ts>
- auto match(Ts&&... ts) const {
- return value.match(std::forward<Ts>(ts)...);
- }
-
- template <class Feature>
- T evaluate(const Feature& feature, float zoom, T defaultValue) const {
- return this->match(
- [&] (const T& constant) { return constant; },
- [&] (const SourceFunction<T>& function) {
- return function.evaluate(feature, defaultValue);
- },
- [&] (const CompositeFunction<T>& function) {
- return function.evaluate(zoom, feature, defaultValue);
- }
- );
- }
-};
-
-} // namespace style
-
-namespace util {
-
-template <typename T>
-struct Interpolator<style::PossiblyEvaluatedPropertyValue<T>> {
- style::PossiblyEvaluatedPropertyValue<T> operator()(const style::PossiblyEvaluatedPropertyValue<T>& a,
- const style::PossiblyEvaluatedPropertyValue<T>& b,
- const double t) const {
- if (a.isConstant() && b.isConstant()) {
- return { interpolate(*a.constant(), *b.constant(), t) };
- } else {
- return { a };
- }
- }
-};
-
-} // namespace util
-
-} // namespace mbgl
diff --git a/src/mbgl/style/property_evaluation_parameters.hpp b/src/mbgl/style/property_evaluation_parameters.hpp
deleted file mode 100644
index 2591fc07a1..0000000000
--- a/src/mbgl/style/property_evaluation_parameters.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-#include <mbgl/map/zoom_history.hpp>
-#include <mbgl/util/chrono.hpp>
-
-namespace mbgl {
-namespace style {
-
-class PropertyEvaluationParameters {
-public:
- explicit PropertyEvaluationParameters(float z_)
- : z(z_) {}
-
- PropertyEvaluationParameters(float z_,
- TimePoint now_,
- ZoomHistory zoomHistory_,
- Duration defaultFadeDuration_)
- : z(z_),
- now(std::move(now_)),
- zoomHistory(std::move(zoomHistory_)),
- defaultFadeDuration(std::move(defaultFadeDuration_)) {}
-
- float z;
- TimePoint now;
- ZoomHistory zoomHistory;
- Duration defaultFadeDuration;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/property_evaluator.hpp b/src/mbgl/style/property_evaluator.hpp
deleted file mode 100644
index 3f629ada4f..0000000000
--- a/src/mbgl/style/property_evaluator.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/property_evaluation_parameters.hpp>
-
-namespace mbgl {
-namespace style {
-
-template <typename T>
-class PropertyEvaluator {
-public:
- using ResultType = T;
-
- PropertyEvaluator(const PropertyEvaluationParameters& parameters_, T defaultValue_)
- : parameters(parameters_),
- defaultValue(std::move(defaultValue_)) {}
-
- T operator()(const Undefined&) const { return defaultValue; }
- T operator()(const T& constant) const { return constant; }
- T operator()(const CameraFunction<T>& fn) const { return fn.evaluate(parameters.z); }
-
-private:
- const PropertyEvaluationParameters& parameters;
- T defaultValue;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 5fc9c40eba..23536e0e3e 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -16,13 +16,13 @@
#include <mbgl/style/parser.hpp>
#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/class_dictionary.hpp>
-#include <mbgl/style/update_parameters.hpp>
-#include <mbgl/style/cascade_parameters.hpp>
-#include <mbgl/style/property_evaluation_parameters.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
#include <mbgl/text/glyph_atlas.hpp>
#include <mbgl/geometry/line_atlas.hpp>
#include <mbgl/renderer/render_source.hpp>
+#include <mbgl/renderer/update_parameters.hpp>
+#include <mbgl/renderer/cascade_parameters.hpp>
+#include <mbgl/renderer/property_evaluation_parameters.hpp>
#include <mbgl/renderer/render_item.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/renderer/render_background_layer.hpp>
diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp
index 6c80a2ef59..fe588c3ce5 100644
--- a/src/mbgl/style/style.hpp
+++ b/src/mbgl/style/style.hpp
@@ -7,7 +7,7 @@
#include <mbgl/style/layer_observer.hpp>
#include <mbgl/style/update_batch.hpp>
#include <mbgl/renderer/render_layer.hpp>
-#include <mbgl/style/light_impl.hpp>
+#include <mbgl/renderer/render_light.hpp>
#include <mbgl/text/glyph_atlas_observer.hpp>
#include <mbgl/sprite/sprite_atlas_observer.hpp>
#include <mbgl/map/mode.hpp>
@@ -36,11 +36,11 @@ class RenderedQueryOptions;
class Scheduler;
class RenderLayer;
class RenderSource;
+class UpdateParameters;
namespace style {
class Layer;
-class UpdateParameters;
class QueryParameters;
class Style : public GlyphAtlasObserver,
diff --git a/src/mbgl/style/transitioning_property.hpp b/src/mbgl/style/transitioning_property.hpp
deleted file mode 100644
index 5456322b33..0000000000
--- a/src/mbgl/style/transitioning_property.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#pragma once
-
-#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/util/interpolate.hpp>
-
-#include <utility>
-
-namespace mbgl {
-namespace style {
-
-template <class Value>
-class TransitioningProperty {
-public:
- TransitioningProperty() = default;
-
- TransitioningProperty(Value value_,
- TransitioningProperty<Value> 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 <class Evaluator>
- 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<float>(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<mapbox::util::recursive_wrapper<TransitioningProperty<Value>>> prior;
- TimePoint begin;
- TimePoint end;
- Value value;
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/src/mbgl/style/update_parameters.hpp b/src/mbgl/style/update_parameters.hpp
deleted file mode 100644
index 900f4b5183..0000000000
--- a/src/mbgl/style/update_parameters.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#pragma once
-
-#include <mbgl/map/mode.hpp>
-
-namespace mbgl {
-
-class TransformState;
-class Scheduler;
-class FileSource;
-class AnnotationManager;
-
-namespace style {
-
-class Style;
-
-class UpdateParameters {
-public:
- UpdateParameters(float pixelRatio_,
- MapDebugOptions debugOptions_,
- const TransformState& transformState_,
- Scheduler& workerScheduler_,
- FileSource& fileSource_,
- const MapMode mode_,
- AnnotationManager& annotationManager_,
- Style& style_)
- : pixelRatio(pixelRatio_),
- debugOptions(debugOptions_),
- transformState(transformState_),
- workerScheduler(workerScheduler_),
- fileSource(fileSource_),
- mode(mode_),
- annotationManager(annotationManager_),
- style(style_) {}
-
- float pixelRatio;
- MapDebugOptions debugOptions;
- const TransformState& transformState;
- Scheduler& workerScheduler;
- FileSource& fileSource;
- const MapMode mode;
- AnnotationManager& annotationManager;
-
- // TODO: remove
- Style& style;
-};
-
-} // namespace style
-} // namespace mbgl