From 5ae995867b6fbc0d2e14b696bae580eb8ba3e5ef Mon Sep 17 00:00:00 2001 From: Karim Naaji Date: Mon, 1 Jun 2020 17:35:09 -0700 Subject: WIP Save stash --- src/mbgl/renderer/paint_property_binder.hpp | 52 +++++++++++++--------- .../layers/fill_extrusion_layer_properties.hpp | 11 ++++- src/mbgl/style/layers/fill_layer_properties.hpp | 11 ++++- src/mbgl/style/layers/line_layer_properties.hpp | 11 ++++- src/mbgl/style/paint_property.hpp | 6 +-- 5 files changed, 64 insertions(+), 27 deletions(-) diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index 15dc535556..40efb753be 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -162,11 +162,16 @@ private: T constant; }; +struct FadedPaintPropertyData { + std::array patternPositions; + float pixelRatio; +}; + template -class ConstantCrossFadedPaintPropertyBinder final : public PaintPropertyBinder,PossiblyEvaluatedPropertyValue>, As...> { +class ConstantCrossFadedPaintPropertyBinder final : public PaintPropertyBinder>, As...> { public: ConstantCrossFadedPaintPropertyBinder(Faded constant_) - : constant(std::move(constant_)), constantPatternPositions({}) { + : constant(std::move(constant_)), constantUniforms({}) { } void populateVertexVector(const GeometryTileFeature&, @@ -183,7 +188,10 @@ public: if (!posA || !posB) { return; } else { - constantPatternPositions = std::tuple, std::array> { posB->tlbr(), posA->tlbr() }; + constantUniforms = std::tuple { + {posB->tlbr(), posB->pixelRatio}, + {posA->tlbr(), posA->pixelRatio}, + }; } } @@ -196,13 +204,13 @@ public: return std::tuple { 0.0f, 0.0f }; } - std::tuple, std::array> uniformValue(const PossiblyEvaluatedPropertyValue>&) const override { - return constantPatternPositions; + std::tuple uniformValue(const PossiblyEvaluatedPropertyValue>&) const override { + return constantUniforms; } private: Faded constant; - std::tuple, std::array> constantPatternPositions; + std::tuple constantUniforms; }; template @@ -424,8 +432,8 @@ private: FeatureVertexRangeMap featureMap; }; -template -class CompositeCrossFadedPaintPropertyBinder final : public PaintPropertyBinder, PossiblyEvaluatedPropertyValue>, A1, A2> { +template +class CompositeCrossFadedPaintPropertyBinder final : public PaintPropertyBinder>, A1, A2, A3, A4> { public: using AttributeType = ZoomInterpolatedAttributeType; using AttributeType2 = ZoomInterpolatedAttributeType; @@ -458,9 +466,10 @@ public: // string and will not have a valid entry in patternPositions. We still need to populate the attribute buffers to avoid crashes // when we try to draw the layer because we don't know at draw time if all features were evaluated to valid pattern dependencies. for (std::size_t i = zoomInVertexVector.elements(); i < length; ++i) { - patternToVertexVector.emplace_back(Vertex { std::array{{0, 0, 0, 0}} }); - zoomInVertexVector.emplace_back(Vertex2 { std::array{{0, 0, 0, 0}} } ); - zoomOutVertexVector.emplace_back(Vertex2 { std::array{{0, 0, 0, 0}} }); + // FIXME + //patternToVertexVector.emplace_back(Vertex { std::array{{0, 0, 0, 0}} }); + //zoomInVertexVector.emplace_back(Vertex2 { std::array{{0, 0, 0, 0}} } ); + //zoomOutVertexVector.emplace_back(Vertex2 { std::array{{0, 0, 0, 0}} }); } } else if (!patternPositions.empty()) { const auto min = patternPositions.find(patternDependencies->min); @@ -475,9 +484,10 @@ public: const ImagePosition imageMax = max->second; for (std::size_t i = zoomInVertexVector.elements(); i < length; ++i) { - patternToVertexVector.emplace_back(Vertex { imageMid.tlbr() }); - zoomInVertexVector.emplace_back(Vertex2 { imageMin.tlbr() }); - zoomOutVertexVector.emplace_back(Vertex2 { imageMax.tlbr() }); + // FIXME + //patternToVertexVector.emplace_back(Vertex { imageMid.tlbr() }); + //zoomInVertexVector.emplace_back(Vertex2 { imageMin.tlbr() }); + //zoomOutVertexVector.emplace_back(Vertex2 { imageMax.tlbr() }); } } } @@ -515,7 +525,7 @@ public: return std::tuple { 0.0f, 0.0f }; } - std::tuple, std::array> uniformValue(const PossiblyEvaluatedPropertyValue>& ) const override { + std::tuple uniformValue(const PossiblyEvaluatedPropertyValue>& ) const override { // Uniform values for vertex attribute arrays are unused. return {}; } @@ -554,14 +564,14 @@ struct CreateBinder { template struct CreateBinder>> { - template - static std::unique_ptr, PossiblyEvaluatedPropertyValue>, A1, A2>> create(const PossiblyEvaluatedPropertyValue>& value, float zoom, T defaultValue) { + template + static std::unique_ptr>, A1, A2, A3, A4>> create(const PossiblyEvaluatedPropertyValue>& value, float zoom, T defaultValue) { return value.match( - [&] (const Faded& constant) -> std::unique_ptr, PossiblyEvaluatedPropertyValue>, A1, A2>> { - return std::make_unique>(constant); + [&] (const Faded& constant) -> std::unique_ptr>, A1, A2, A3, A4>> { + return std::make_unique>(constant); }, - [&] (const style::PropertyExpression& expression) -> std::unique_ptr, PossiblyEvaluatedPropertyValue>, A1, A2>> { - return std::make_unique>(expression, zoom, defaultValue); + [&] (const style::PropertyExpression& expression) -> std::unique_ptr>, A1, A2, A3, A4>> { + return std::make_unique>(expression, zoom, defaultValue); } ); } diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp index 60a2340b0d..1f17f1ff32 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp @@ -32,7 +32,16 @@ struct FillExtrusionOpacity : PaintProperty { static float defaultValue() { return 1; } }; -struct FillExtrusionPattern : CrossFadedDataDrivenPaintProperty { +struct FillExtrusionPattern : CrossFadedDataDrivenPaintProperty< + expression::Image, + attributes::pattern_to, + uniforms::pattern_to, + attributes::pattern_from, + uniforms::pattern_from, + attributes::pixel_ratio_to, + uniforms::pixel_ratio_to, + attributes::pixel_ratio_from, + uniforms::pixel_ratio_from> { static expression::Image defaultValue() { return {}; } }; diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp index 7867fe8f0c..3890615275 100644 --- a/src/mbgl/style/layers/fill_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_layer_properties.hpp @@ -37,7 +37,16 @@ struct FillOutlineColor : DataDrivenPaintProperty { +struct FillPattern : CrossFadedDataDrivenPaintProperty< + expression::Image, + attributes::pattern_to, + uniforms::pattern_to, + attributes::pattern_from, + uniforms::pattern_from, + attributes::pixel_ratio_to, + uniforms::pixel_ratio_to, + attributes::pixel_ratio_from, + uniforms::pixel_ratio_from> { static expression::Image defaultValue() { return {}; } }; diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp index b2bd4aa401..2725e55158 100644 --- a/src/mbgl/style/layers/line_layer_properties.hpp +++ b/src/mbgl/style/layers/line_layer_properties.hpp @@ -73,7 +73,16 @@ struct LineOpacity : DataDrivenPaintProperty { +struct LinePattern : CrossFadedDataDrivenPaintProperty< + expression::Image, + attributes::pattern_to, + uniforms::pattern_to, + attributes::pattern_from, + uniforms::pattern_from, + attributes::pixel_ratio_to, + uniforms::pixel_ratio_to, + attributes::pixel_ratio_from, + uniforms::pixel_ratio_from> { static expression::Image defaultValue() { return {}; } }; diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index 7d398748f2..76a62f3946 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -41,7 +41,7 @@ public: using UniformList = TypeList; }; -template +template class CrossFadedDataDrivenPaintProperty { public: using TransitionableType = Transitionable>; @@ -53,9 +53,9 @@ public: static constexpr bool IsOverridable = false; using Attribute = A1; - using AttributeList = TypeList; + using AttributeList = TypeList; using Uniform = U1; - using UniformList = TypeList; + using UniformList = TypeList; }; template -- cgit v1.2.1