From c8edbb0500cbf4baf1d5fdb0e63679539e166585 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 13 Jul 2018 18:14:12 -0700 Subject: [core] Replace {Source,Camera,Composite}Function with PropertyExpression --- src/mbgl/renderer/paint_property_binder.hpp | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/mbgl/renderer/paint_property_binder.hpp') diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index 3a49882f12..aade672ae7 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -130,13 +130,13 @@ public: using Attribute = ZoomInterpolatedAttributeType; using AttributeBinding = typename Attribute::Binding; - SourceFunctionPaintPropertyBinder(style::SourceFunction function_, T defaultValue_) - : function(std::move(function_)), + SourceFunctionPaintPropertyBinder(style::PropertyExpression expression_, T defaultValue_) + : expression(std::move(expression_)), defaultValue(std::move(defaultValue_)) { } void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) override { - auto evaluated = function.evaluate(feature, defaultValue); + auto evaluated = expression.evaluate(feature, defaultValue); this->statistics.add(evaluated); auto value = attributeValue(evaluated); for (std::size_t i = vertexVector.vertexSize(); i < length; ++i) { @@ -170,7 +170,7 @@ public: } private: - style::SourceFunction function; + style::PropertyExpression expression; T defaultValue; gl::VertexVector vertexVector; optional> vertexBuffer; @@ -187,14 +187,14 @@ public: using AttributeBinding = typename Attribute::Binding; using Vertex = gl::detail::Vertex; - CompositeFunctionPaintPropertyBinder(style::CompositeFunction function_, float zoom, T defaultValue_) - : function(std::move(function_)), + CompositeFunctionPaintPropertyBinder(style::PropertyExpression expression_, float zoom, T defaultValue_) + : expression(std::move(expression_)), defaultValue(std::move(defaultValue_)), zoomRange({zoom, zoom + 1}) { } void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) override { - Range range = function.evaluate(zoomRange, feature, defaultValue); + Range range = expression.evaluate(zoomRange, feature, defaultValue); this->statistics.add(range.min); this->statistics.add(range.max); AttributeValue value = zoomInterpolatedAttributeValue( @@ -218,10 +218,10 @@ public: } float interpolationFactor(float currentZoom) const override { - if (function.useIntegerZoom) { - return function.interpolationFactor(zoomRange, std::floor(currentZoom)); + if (expression.useIntegerZoom) { + return expression.interpolationFactor(zoomRange, std::floor(currentZoom)); } else { - return function.interpolationFactor(zoomRange, currentZoom); + return expression.interpolationFactor(zoomRange, currentZoom); } } @@ -235,7 +235,7 @@ public: } private: - style::CompositeFunction function; + style::PropertyExpression expression; T defaultValue; Range zoomRange; gl::VertexVector vertexVector; @@ -249,11 +249,12 @@ PaintPropertyBinder::create(const PossiblyEvaluatedPropertyValue& value [&] (const T& constant) -> std::unique_ptr> { return std::make_unique>(constant); }, - [&] (const style::SourceFunction& function) { - return std::make_unique>(function, defaultValue); - }, - [&] (const style::CompositeFunction& function) { - return std::make_unique>(function, zoom, defaultValue); + [&] (const style::PropertyExpression& expression) -> std::unique_ptr> { + if (expression.isZoomConstant()) { + return std::make_unique>(expression, defaultValue); + } else { + return std::make_unique>(expression, zoom, defaultValue); + } } ); } -- cgit v1.2.1