diff options
author | Karim Naaji <karim.naaji@gmail.com> | 2020-06-01 17:35:09 -0700 |
---|---|---|
committer | Karim Naaji <karim.naaji@gmail.com> | 2020-06-01 17:35:09 -0700 |
commit | 5ae995867b6fbc0d2e14b696bae580eb8ba3e5ef (patch) | |
tree | 112e36f17a9b75d3b596426c234e93e7360126c8 | |
parent | 2dfd8ba452ce1528965ea6bef3355e0f970142ec (diff) | |
download | qtlocation-mapboxgl-5ae995867b6fbc0d2e14b696bae580eb8ba3e5ef.tar.gz |
WIP Save stashupstream/karim/gl-js-port
-rw-r--r-- | src/mbgl/renderer/paint_property_binder.hpp | 52 | ||||
-rw-r--r-- | src/mbgl/style/layers/fill_extrusion_layer_properties.hpp | 11 | ||||
-rw-r--r-- | src/mbgl/style/layers/fill_layer_properties.hpp | 11 | ||||
-rw-r--r-- | src/mbgl/style/layers/line_layer_properties.hpp | 11 | ||||
-rw-r--r-- | 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<uint16_t, 4> patternPositions; + float pixelRatio; +}; + template <class T, class... As> -class ConstantCrossFadedPaintPropertyBinder final : public PaintPropertyBinder<T, std::array<uint16_t, 4>,PossiblyEvaluatedPropertyValue<Faded<T>>, As...> { +class ConstantCrossFadedPaintPropertyBinder final : public PaintPropertyBinder<T, FadedPaintPropertyData, PossiblyEvaluatedPropertyValue<Faded<T>>, As...> { public: ConstantCrossFadedPaintPropertyBinder(Faded<T> 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<uint16_t, 4>, std::array<uint16_t, 4>> { posB->tlbr(), posA->tlbr() }; + constantUniforms = std::tuple<FadedPaintPropertyData, FadedPaintPropertyData> { + {posB->tlbr(), posB->pixelRatio}, + {posA->tlbr(), posA->pixelRatio}, + }; } } @@ -196,13 +204,13 @@ public: return std::tuple<float, float> { 0.0f, 0.0f }; } - std::tuple<std::array<uint16_t, 4>, std::array<uint16_t, 4>> uniformValue(const PossiblyEvaluatedPropertyValue<Faded<T>>&) const override { - return constantPatternPositions; + std::tuple<FadedPaintPropertyData, FadedPaintPropertyData> uniformValue(const PossiblyEvaluatedPropertyValue<Faded<T>>&) const override { + return constantUniforms; } private: Faded<T> constant; - std::tuple<std::array<uint16_t, 4>, std::array<uint16_t, 4>> constantPatternPositions; + std::tuple<FadedPaintPropertyData, FadedPaintPropertyData> constantUniforms; }; template <class T, class A> @@ -424,8 +432,8 @@ private: FeatureVertexRangeMap featureMap; }; -template <class T, class A1, class A2> -class CompositeCrossFadedPaintPropertyBinder final : public PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2> { +template <class T, class A1, class A2, class A3, class A4> +class CompositeCrossFadedPaintPropertyBinder final : public PaintPropertyBinder<T, FadedPaintPropertyData, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2, A3, A4> { public: using AttributeType = ZoomInterpolatedAttributeType<A1>; using AttributeType2 = ZoomInterpolatedAttributeType<A2>; @@ -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<uint16_t, 4>{{0, 0, 0, 0}} }); - zoomInVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} } ); - zoomOutVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} }); + // FIXME + //patternToVertexVector.emplace_back(Vertex { std::array<uint16_t, 4>{{0, 0, 0, 0}} }); + //zoomInVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{0, 0, 0, 0}} } ); + //zoomOutVertexVector.emplace_back(Vertex2 { std::array<uint16_t, 4>{{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<float, float> { 0.0f, 0.0f }; } - std::tuple<std::array<uint16_t, 4>, std::array<uint16_t, 4>> uniformValue(const PossiblyEvaluatedPropertyValue<Faded<T>>& ) const override { + std::tuple<FadedPaintPropertyData, FadedPaintPropertyData> uniformValue(const PossiblyEvaluatedPropertyValue<Faded<T>>& ) const override { // Uniform values for vertex attribute arrays are unused. return {}; } @@ -554,14 +564,14 @@ struct CreateBinder { template <class T> struct CreateBinder<T, PossiblyEvaluatedPropertyValue<Faded<T>>> { - template <class A1, class A2> - static std::unique_ptr<PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2>> create(const PossiblyEvaluatedPropertyValue<Faded<T>>& value, float zoom, T defaultValue) { + template <class A1, class A2, class A3, class A4> + static std::unique_ptr<PaintPropertyBinder<T, FadedPaintPropertyData, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2, A3, A4>> create(const PossiblyEvaluatedPropertyValue<Faded<T>>& value, float zoom, T defaultValue) { return value.match( - [&] (const Faded<T>& constant) -> std::unique_ptr<PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2>> { - return std::make_unique<ConstantCrossFadedPaintPropertyBinder<T, A1, A2>>(constant); + [&] (const Faded<T>& constant) -> std::unique_ptr<PaintPropertyBinder<T, FadedPaintPropertyData, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2, A3, A4>> { + return std::make_unique<ConstantCrossFadedPaintPropertyBinder<T, A1, A2, A3, A4>>(constant); }, - [&] (const style::PropertyExpression<T>& expression) -> std::unique_ptr<PaintPropertyBinder<T, std::array<uint16_t, 4>, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2>> { - return std::make_unique<CompositeCrossFadedPaintPropertyBinder<T, A1, A2>>(expression, zoom, defaultValue); + [&] (const style::PropertyExpression<T>& expression) -> std::unique_ptr<PaintPropertyBinder<T, FadedPaintPropertyData, PossiblyEvaluatedPropertyValue<Faded<T>>, A1, A2, A3, A4>> { + return std::make_unique<CompositeCrossFadedPaintPropertyBinder<T, A1, A2, A3, A4>>(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<float> { static float defaultValue() { return 1; } }; -struct FillExtrusionPattern : CrossFadedDataDrivenPaintProperty<expression::Image, attributes::pattern_to, uniforms::pattern_to, attributes::pattern_from, uniforms::pattern_from> { +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<Color, attributes::outline_col static Color defaultValue() { return {}; } }; -struct FillPattern : CrossFadedDataDrivenPaintProperty<expression::Image, attributes::pattern_to, uniforms::pattern_to, attributes::pattern_from, uniforms::pattern_from> { +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<float, attributes::opacity, uniform static float defaultValue() { return 1; } }; -struct LinePattern : CrossFadedDataDrivenPaintProperty<expression::Image, attributes::pattern_to, uniforms::pattern_to, attributes::pattern_from, uniforms::pattern_from> { +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<U>; }; -template <class T, class A1, class U1, class A2, class U2> +template <class T, class A1, class U1, class A2, class U2, class A3, class U3, class A4, class U4> class CrossFadedDataDrivenPaintProperty { public: using TransitionableType = Transitionable<PropertyValue<T>>; @@ -53,9 +53,9 @@ public: static constexpr bool IsOverridable = false; using Attribute = A1; - using AttributeList = TypeList<A1, A2>; + using AttributeList = TypeList<A1, A2, A3, A4>; using Uniform = U1; - using UniformList = TypeList<U1, U2>; + using UniformList = TypeList<U1, U2, U3, U4>; }; template <class T> |