From 38fcbe21d48186c4630a3b8a76d1b20e156faadd Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sun, 30 Oct 2016 11:06:59 -0700 Subject: [core] Convert style properties to a tuple-based approach This converts the style property classes (CirclePaintProperties and so on) to the same tuple-based approach as gl::Attribute and gl::Uniform. The approach is outlined in https://github.com/mapbox/cpp/blob/master/C%2B%2B%20Structural%20Metaprogramming.md. The main advantage of this approach is it allows writing algorithms that work on sets of style properties, without resorting to code generation or manually repetitive code. This lets us iterate on approaches to data-driven properties more easily. Another advantage is that the cascading, unevaluated, and evaluated states of a set of properties exist as independent structures, instead of individual properties holding their own state. This is a more functional approach that makes data flow clearer and reduces state. --- src/mbgl/style/layers/fill_layer_impl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mbgl/style/layers/fill_layer_impl.cpp') diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp index fc439f1cd1..6a690ba447 100644 --- a/src/mbgl/style/layers/fill_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_layer_impl.cpp @@ -12,22 +12,22 @@ void FillLayer::Impl::cascade(const CascadeParameters& parameters) { paint.cascade(parameters); } -bool FillLayer::Impl::recalculate(const CalculationParameters& parameters) { - bool hasTransitions = paint.recalculate(parameters); +bool FillLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { + paint.evaluate(parameters); passes = RenderPass::None; - if (paint.fillAntialias) { + if (paint.evaluated.get()) { passes |= RenderPass::Translucent; } - if (!paint.fillPattern.value.from.empty() || (paint.fillColor.value.a * paint.fillOpacity) < 1.0f) { + if (!paint.evaluated.get().from.empty() || (paint.evaluated.get().a * paint.evaluated.get()) < 1.0f) { passes |= RenderPass::Translucent; } else { passes |= RenderPass::Opaque; } - return hasTransitions; + return paint.hasTransition(); } std::unique_ptr FillLayer::Impl::createBucket(BucketParameters& parameters) const { @@ -44,7 +44,7 @@ std::unique_ptr FillLayer::Impl::createBucket(BucketParameters& paramete } float FillLayer::Impl::getQueryRadius() const { - const std::array& translate = paint.fillTranslate; + const std::array& translate = paint.evaluated.get(); return util::length(translate[0], translate[1]); } @@ -55,7 +55,7 @@ bool FillLayer::Impl::queryIntersectsGeometry( const float pixelsToTileUnits) const { auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry( - queryGeometry, paint.fillTranslate, paint.fillTranslateAnchor, bearing, pixelsToTileUnits); + queryGeometry, paint.evaluated.get(), paint.evaluated.get(), bearing, pixelsToTileUnits); return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), geometry); } -- cgit v1.2.1