diff options
Diffstat (limited to 'src/mbgl/style/layers')
30 files changed, 249 insertions, 211 deletions
diff --git a/src/mbgl/style/layers/background_layer_impl.cpp b/src/mbgl/style/layers/background_layer_impl.cpp index 4a8fe39c9a..f25ba9cfb4 100644 --- a/src/mbgl/style/layers/background_layer_impl.cpp +++ b/src/mbgl/style/layers/background_layer_impl.cpp @@ -16,7 +16,8 @@ bool BackgroundLayer::Impl::evaluate(const PropertyEvaluationParameters& paramet return paint.hasTransition(); } -std::unique_ptr<Bucket> BackgroundLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { +std::unique_ptr<Bucket> BackgroundLayer::Impl::createBucket(const BucketParameters&, const std::vector<const Layer*>&) const { + assert(false); return nullptr; } diff --git a/src/mbgl/style/layers/background_layer_impl.hpp b/src/mbgl/style/layers/background_layer_impl.hpp index 4629217e6d..02a8c423d6 100644 --- a/src/mbgl/style/layers/background_layer_impl.hpp +++ b/src/mbgl/style/layers/background_layer_impl.hpp @@ -16,7 +16,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; BackgroundPaintProperties paint; }; diff --git a/src/mbgl/style/layers/background_layer_properties.hpp b/src/mbgl/style/layers/background_layer_properties.hpp index 792bf3de94..fae6c26a4b 100644 --- a/src/mbgl/style/layers/background_layer_properties.hpp +++ b/src/mbgl/style/layers/background_layer_properties.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index 389ab93403..f8d06e2644 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -65,64 +65,80 @@ const Filter& CircleLayer::getFilter() const { // Paint properties -PropertyValue<float> CircleLayer::getDefaultCircleRadius() { +DataDrivenPropertyValue<float> CircleLayer::getDefaultCircleRadius() { return { 5 }; } -PropertyValue<float> CircleLayer::getCircleRadius(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> CircleLayer::getCircleRadius(const optional<std::string>& klass) const { return impl->paint.get<CircleRadius>(klass); } -void CircleLayer::setCircleRadius(PropertyValue<float> value, const optional<std::string>& klass) { +void CircleLayer::setCircleRadius(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getCircleRadius(klass)) return; impl->paint.set<CircleRadius>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<Color> CircleLayer::getDefaultCircleColor() { +DataDrivenPropertyValue<Color> CircleLayer::getDefaultCircleColor() { return { Color::black() }; } -PropertyValue<Color> CircleLayer::getCircleColor(const optional<std::string>& klass) const { +DataDrivenPropertyValue<Color> CircleLayer::getCircleColor(const optional<std::string>& klass) const { return impl->paint.get<CircleColor>(klass); } -void CircleLayer::setCircleColor(PropertyValue<Color> value, const optional<std::string>& klass) { +void CircleLayer::setCircleColor(DataDrivenPropertyValue<Color> value, const optional<std::string>& klass) { if (value == getCircleColor(klass)) return; impl->paint.set<CircleColor>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<float> CircleLayer::getDefaultCircleBlur() { +DataDrivenPropertyValue<float> CircleLayer::getDefaultCircleBlur() { return { 0 }; } -PropertyValue<float> CircleLayer::getCircleBlur(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> CircleLayer::getCircleBlur(const optional<std::string>& klass) const { return impl->paint.get<CircleBlur>(klass); } -void CircleLayer::setCircleBlur(PropertyValue<float> value, const optional<std::string>& klass) { +void CircleLayer::setCircleBlur(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getCircleBlur(klass)) return; impl->paint.set<CircleBlur>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<float> CircleLayer::getDefaultCircleOpacity() { +DataDrivenPropertyValue<float> CircleLayer::getDefaultCircleOpacity() { return { 1 }; } -PropertyValue<float> CircleLayer::getCircleOpacity(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> CircleLayer::getCircleOpacity(const optional<std::string>& klass) const { return impl->paint.get<CircleOpacity>(klass); } -void CircleLayer::setCircleOpacity(PropertyValue<float> value, const optional<std::string>& klass) { +void CircleLayer::setCircleOpacity(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getCircleOpacity(klass)) return; impl->paint.set<CircleOpacity>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } PropertyValue<std::array<float, 2>> CircleLayer::getDefaultCircleTranslate() { @@ -170,49 +186,61 @@ void CircleLayer::setCirclePitchScale(PropertyValue<CirclePitchScaleType> value, impl->observer->onLayerPaintPropertyChanged(*this); } -PropertyValue<float> CircleLayer::getDefaultCircleStrokeWidth() { +DataDrivenPropertyValue<float> CircleLayer::getDefaultCircleStrokeWidth() { return { 0 }; } -PropertyValue<float> CircleLayer::getCircleStrokeWidth(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> CircleLayer::getCircleStrokeWidth(const optional<std::string>& klass) const { return impl->paint.get<CircleStrokeWidth>(klass); } -void CircleLayer::setCircleStrokeWidth(PropertyValue<float> value, const optional<std::string>& klass) { +void CircleLayer::setCircleStrokeWidth(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getCircleStrokeWidth(klass)) return; impl->paint.set<CircleStrokeWidth>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<Color> CircleLayer::getDefaultCircleStrokeColor() { +DataDrivenPropertyValue<Color> CircleLayer::getDefaultCircleStrokeColor() { return { Color::black() }; } -PropertyValue<Color> CircleLayer::getCircleStrokeColor(const optional<std::string>& klass) const { +DataDrivenPropertyValue<Color> CircleLayer::getCircleStrokeColor(const optional<std::string>& klass) const { return impl->paint.get<CircleStrokeColor>(klass); } -void CircleLayer::setCircleStrokeColor(PropertyValue<Color> value, const optional<std::string>& klass) { +void CircleLayer::setCircleStrokeColor(DataDrivenPropertyValue<Color> value, const optional<std::string>& klass) { if (value == getCircleStrokeColor(klass)) return; impl->paint.set<CircleStrokeColor>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<float> CircleLayer::getDefaultCircleStrokeOpacity() { +DataDrivenPropertyValue<float> CircleLayer::getDefaultCircleStrokeOpacity() { return { 1 }; } -PropertyValue<float> CircleLayer::getCircleStrokeOpacity(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> CircleLayer::getCircleStrokeOpacity(const optional<std::string>& klass) const { return impl->paint.get<CircleStrokeOpacity>(klass); } -void CircleLayer::setCircleStrokeOpacity(PropertyValue<float> value, const optional<std::string>& klass) { +void CircleLayer::setCircleStrokeOpacity(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getCircleStrokeOpacity(klass)) return; impl->paint.set<CircleStrokeOpacity>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } } // namespace style diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp index 136522e41c..655ad9b5b9 100644 --- a/src/mbgl/style/layers/circle_layer_impl.cpp +++ b/src/mbgl/style/layers/circle_layer_impl.cpp @@ -1,5 +1,4 @@ #include <mbgl/style/layers/circle_layer_impl.hpp> -#include <mbgl/style/bucket_parameters.hpp> #include <mbgl/renderer/circle_bucket.hpp> #include <mbgl/geometry/feature_index.hpp> #include <mbgl/util/math.hpp> @@ -15,27 +14,22 @@ void CircleLayer::Impl::cascade(const CascadeParameters& parameters) { bool CircleLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { paint.evaluate(parameters); - passes = (paint.evaluated.get<CircleRadius>() > 0 && paint.evaluated.get<CircleColor>().a > 0 && paint.evaluated.get<CircleOpacity>() > 0) + passes = (paint.evaluated.get<CircleRadius>().constantOr(1) > 0 + && paint.evaluated.get<CircleColor>().constantOr(Color::black()).a > 0 + && paint.evaluated.get<CircleOpacity>().constantOr(1) > 0) ? RenderPass::Translucent : RenderPass::None; return paint.hasTransition(); } -std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const { - auto bucket = std::make_unique<CircleBucket>(parameters.mode); - - parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) { - auto geometries = feature.getGeometries(); - bucket->addGeometry(geometries); - parameters.featureIndex.insert(geometries, index, layerName, id); - }); - - return std::move(bucket); +std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(const BucketParameters& parameters, const std::vector<const Layer*>& layers) const { + return std::make_unique<CircleBucket>(parameters, layers); } float CircleLayer::Impl::getQueryRadius() const { const std::array<float, 2>& translate = paint.evaluated.get<CircleTranslate>(); - return paint.evaluated.get<CircleRadius>() + util::length(translate[0], translate[1]); + return paint.evaluated.get<CircleRadius>().constantOr(CircleRadius::defaultValue()) + + util::length(translate[0], translate[1]); } bool CircleLayer::Impl::queryIntersectsGeometry( @@ -47,7 +41,7 @@ bool CircleLayer::Impl::queryIntersectsGeometry( auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry( queryGeometry, paint.evaluated.get<CircleTranslate>(), paint.evaluated.get<CircleTranslateAnchor>(), bearing, pixelsToTileUnits); - auto circleRadius = paint.evaluated.get<CircleRadius>() * pixelsToTileUnits; + auto circleRadius = paint.evaluated.get<CircleRadius>().constantOr(CircleRadius::defaultValue()) * pixelsToTileUnits; return util::polygonIntersectsBufferedMultiPoint( translatedQueryGeometry.value_or(queryGeometry), geometry, circleRadius); diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp index 744a56898c..0f9611d589 100644 --- a/src/mbgl/style/layers/circle_layer_impl.hpp +++ b/src/mbgl/style/layers/circle_layer_impl.hpp @@ -16,7 +16,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; float getQueryRadius() const override; bool queryIntersectsGeometry( diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp index ea36b31949..1cb4f5a635 100644 --- a/src/mbgl/style/layers/circle_layer_properties.hpp +++ b/src/mbgl/style/layers/circle_layer_properties.hpp @@ -5,23 +5,24 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { -struct CircleRadius : PaintProperty<float> { +struct CircleRadius : DataDrivenPaintProperty<float, attributes::a_radius> { static float defaultValue() { return 5; } }; -struct CircleColor : PaintProperty<Color> { +struct CircleColor : DataDrivenPaintProperty<Color, attributes::a_color> { static Color defaultValue() { return Color::black(); } }; -struct CircleBlur : PaintProperty<float> { +struct CircleBlur : DataDrivenPaintProperty<float, attributes::a_blur> { static float defaultValue() { return 0; } }; -struct CircleOpacity : PaintProperty<float> { +struct CircleOpacity : DataDrivenPaintProperty<float, attributes::a_opacity> { static float defaultValue() { return 1; } }; @@ -37,15 +38,15 @@ struct CirclePitchScale : PaintProperty<CirclePitchScaleType> { static CirclePitchScaleType defaultValue() { return CirclePitchScaleType::Map; } }; -struct CircleStrokeWidth : PaintProperty<float> { +struct CircleStrokeWidth : DataDrivenPaintProperty<float, attributes::a_stroke_width> { static float defaultValue() { return 0; } }; -struct CircleStrokeColor : PaintProperty<Color> { +struct CircleStrokeColor : DataDrivenPaintProperty<Color, attributes::a_stroke_color> { static Color defaultValue() { return Color::black(); } }; -struct CircleStrokeOpacity : PaintProperty<float> { +struct CircleStrokeOpacity : DataDrivenPaintProperty<float, attributes::a_stroke_opacity> { static float defaultValue() { return 1; } }; diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp index cecd60a296..379de25e8f 100644 --- a/src/mbgl/style/layers/custom_layer_impl.cpp +++ b/src/mbgl/style/layers/custom_layer_impl.cpp @@ -70,7 +70,8 @@ bool CustomLayer::Impl::evaluate(const PropertyEvaluationParameters&) { return false; } -std::unique_ptr<Bucket> CustomLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { +std::unique_ptr<Bucket> CustomLayer::Impl::createBucket(const BucketParameters&, const std::vector<const Layer*>&) const { + assert(false); return nullptr; } diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp index 71fb46d0d9..33eb86828c 100644 --- a/src/mbgl/style/layers/custom_layer_impl.hpp +++ b/src/mbgl/style/layers/custom_layer_impl.hpp @@ -32,7 +32,7 @@ private: void cascade(const CascadeParameters&) final {} bool evaluate(const PropertyEvaluationParameters&) final; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const final; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const final; CustomLayerInitializeFunction initializeFn = nullptr; CustomLayerRenderFunction renderFn = nullptr; diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 34f0267d16..0ef5c9bcbc 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -80,19 +80,23 @@ void FillExtrusionLayer::setFillExtrusionOpacity(PropertyValue<float> value, con impl->observer->onLayerPaintPropertyChanged(*this); } -PropertyValue<Color> FillExtrusionLayer::getDefaultFillExtrusionColor() { +DataDrivenPropertyValue<Color> FillExtrusionLayer::getDefaultFillExtrusionColor() { return { Color::black() }; } -PropertyValue<Color> FillExtrusionLayer::getFillExtrusionColor(const optional<std::string>& klass) const { +DataDrivenPropertyValue<Color> FillExtrusionLayer::getFillExtrusionColor(const optional<std::string>& klass) const { return impl->paint.get<FillExtrusionColor>(klass); } -void FillExtrusionLayer::setFillExtrusionColor(PropertyValue<Color> value, const optional<std::string>& klass) { +void FillExtrusionLayer::setFillExtrusionColor(DataDrivenPropertyValue<Color> value, const optional<std::string>& klass) { if (value == getFillExtrusionColor(klass)) return; impl->paint.set<FillExtrusionColor>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } PropertyValue<std::array<float, 2>> FillExtrusionLayer::getDefaultFillExtrusionTranslate() { @@ -140,34 +144,42 @@ void FillExtrusionLayer::setFillExtrusionPattern(PropertyValue<std::string> valu impl->observer->onLayerPaintPropertyChanged(*this); } -PropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionHeight() { +DataDrivenPropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionHeight() { return { 0 }; } -PropertyValue<float> FillExtrusionLayer::getFillExtrusionHeight(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> FillExtrusionLayer::getFillExtrusionHeight(const optional<std::string>& klass) const { return impl->paint.get<FillExtrusionHeight>(klass); } -void FillExtrusionLayer::setFillExtrusionHeight(PropertyValue<float> value, const optional<std::string>& klass) { +void FillExtrusionLayer::setFillExtrusionHeight(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getFillExtrusionHeight(klass)) return; impl->paint.set<FillExtrusionHeight>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionBase() { +DataDrivenPropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionBase() { return { 0 }; } -PropertyValue<float> FillExtrusionLayer::getFillExtrusionBase(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> FillExtrusionLayer::getFillExtrusionBase(const optional<std::string>& klass) const { return impl->paint.get<FillExtrusionBase>(klass); } -void FillExtrusionLayer::setFillExtrusionBase(PropertyValue<float> value, const optional<std::string>& klass) { +void FillExtrusionLayer::setFillExtrusionBase(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getFillExtrusionBase(klass)) return; impl->paint.set<FillExtrusionBase>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } } // namespace style diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp index ebe9009312..a809820644 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp @@ -11,7 +11,7 @@ bool FillExtrusionLayer::Impl::evaluate(const PropertyEvaluationParameters&) { return false; } -std::unique_ptr<Bucket> FillExtrusionLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { +std::unique_ptr<Bucket> FillExtrusionLayer::Impl::createBucket(const BucketParameters&, const std::vector<const Layer*>&) const { return nullptr; } diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp index 3dd8bb270a..ed7ef747fb 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp @@ -16,7 +16,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; FillExtrusionPaintProperties paint; }; diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp index a2d01199a5..c1dd3b079d 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { @@ -13,7 +14,7 @@ struct FillExtrusionOpacity : PaintProperty<float> { static float defaultValue() { return 1; } }; -struct FillExtrusionColor : PaintProperty<Color> { +struct FillExtrusionColor : DataDrivenPaintProperty<Color, attributes::a_color> { static Color defaultValue() { return Color::black(); } }; @@ -29,11 +30,11 @@ struct FillExtrusionPattern : CrossFadedPaintProperty<std::string> { static std::string defaultValue() { return ""; } }; -struct FillExtrusionHeight : PaintProperty<float> { +struct FillExtrusionHeight : DataDrivenPaintProperty<float, attributes::a_height> { static float defaultValue() { return 0; } }; -struct FillExtrusionBase : PaintProperty<float> { +struct FillExtrusionBase : DataDrivenPaintProperty<float, attributes::a_base> { static float defaultValue() { return 0; } }; diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index b8fa8cad8b..e1c0d4d243 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -80,49 +80,61 @@ void FillLayer::setFillAntialias(PropertyValue<bool> value, const optional<std:: impl->observer->onLayerPaintPropertyChanged(*this); } -PropertyValue<float> FillLayer::getDefaultFillOpacity() { +DataDrivenPropertyValue<float> FillLayer::getDefaultFillOpacity() { return { 1 }; } -PropertyValue<float> FillLayer::getFillOpacity(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> FillLayer::getFillOpacity(const optional<std::string>& klass) const { return impl->paint.get<FillOpacity>(klass); } -void FillLayer::setFillOpacity(PropertyValue<float> value, const optional<std::string>& klass) { +void FillLayer::setFillOpacity(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getFillOpacity(klass)) return; impl->paint.set<FillOpacity>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<Color> FillLayer::getDefaultFillColor() { +DataDrivenPropertyValue<Color> FillLayer::getDefaultFillColor() { return { Color::black() }; } -PropertyValue<Color> FillLayer::getFillColor(const optional<std::string>& klass) const { +DataDrivenPropertyValue<Color> FillLayer::getFillColor(const optional<std::string>& klass) const { return impl->paint.get<FillColor>(klass); } -void FillLayer::setFillColor(PropertyValue<Color> value, const optional<std::string>& klass) { +void FillLayer::setFillColor(DataDrivenPropertyValue<Color> value, const optional<std::string>& klass) { if (value == getFillColor(klass)) return; impl->paint.set<FillColor>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<Color> FillLayer::getDefaultFillOutlineColor() { +DataDrivenPropertyValue<Color> FillLayer::getDefaultFillOutlineColor() { return { {} }; } -PropertyValue<Color> FillLayer::getFillOutlineColor(const optional<std::string>& klass) const { +DataDrivenPropertyValue<Color> FillLayer::getFillOutlineColor(const optional<std::string>& klass) const { return impl->paint.get<FillOutlineColor>(klass); } -void FillLayer::setFillOutlineColor(PropertyValue<Color> value, const optional<std::string>& klass) { +void FillLayer::setFillOutlineColor(DataDrivenPropertyValue<Color> value, const optional<std::string>& klass) { if (value == getFillOutlineColor(klass)) return; impl->paint.set<FillOutlineColor>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } PropertyValue<std::array<float, 2>> FillLayer::getDefaultFillTranslate() { diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp index 1ff26aa003..c7c89f8c20 100644 --- a/src/mbgl/style/layers/fill_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_layer_impl.cpp @@ -1,5 +1,4 @@ #include <mbgl/style/layers/fill_layer_impl.hpp> -#include <mbgl/style/bucket_parameters.hpp> #include <mbgl/renderer/fill_bucket.hpp> #include <mbgl/geometry/feature_index.hpp> #include <mbgl/util/math.hpp> @@ -25,7 +24,9 @@ bool FillLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { passes |= RenderPass::Translucent; } - if (!paint.evaluated.get<FillPattern>().from.empty() || (paint.evaluated.get<FillColor>().a * paint.evaluated.get<FillOpacity>()) < 1.0f) { + if (!paint.unevaluated.get<FillPattern>().isUndefined() + || paint.evaluated.get<FillColor>().constantOr(Color()).a < 1.0f + || paint.evaluated.get<FillOpacity>().constantOr(0) < 1.0f) { passes |= RenderPass::Translucent; } else { passes |= RenderPass::Opaque; @@ -34,16 +35,8 @@ bool FillLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { return paint.hasTransition(); } -std::unique_ptr<Bucket> FillLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const { - auto bucket = std::make_unique<FillBucket>(); - - parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) { - auto geometries = feature.getGeometries(); - bucket->addGeometry(geometries); - parameters.featureIndex.insert(geometries, index, layerName, id); - }); - - return std::move(bucket); +std::unique_ptr<Bucket> FillLayer::Impl::createBucket(const BucketParameters& parameters, const std::vector<const Layer*>& layers) const { + return std::make_unique<FillBucket>(parameters, layers); } float FillLayer::Impl::getQueryRadius() const { diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp index 28e2fa7edc..bd25a8bebf 100644 --- a/src/mbgl/style/layers/fill_layer_impl.hpp +++ b/src/mbgl/style/layers/fill_layer_impl.hpp @@ -16,7 +16,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; float getQueryRadius() const override; bool queryIntersectsGeometry( diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp index b2d926c31e..f44a18d0e0 100644 --- a/src/mbgl/style/layers/fill_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_layer_properties.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { @@ -13,15 +14,15 @@ struct FillAntialias : PaintProperty<bool> { static bool defaultValue() { return true; } }; -struct FillOpacity : PaintProperty<float> { +struct FillOpacity : DataDrivenPaintProperty<float, attributes::a_opacity> { static float defaultValue() { return 1; } }; -struct FillColor : PaintProperty<Color> { +struct FillColor : DataDrivenPaintProperty<Color, attributes::a_color> { static Color defaultValue() { return Color::black(); } }; -struct FillOutlineColor : PaintProperty<Color> { +struct FillOutlineColor : DataDrivenPaintProperty<Color, attributes::a_outline_color> { static Color defaultValue() { return {}; } }; diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index e730e3a29b..4a91a5c7e3 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -86,15 +86,15 @@ const Filter& <%- camelize(type) %>Layer::getFilter() const { // Layout properties <% for (const property of layoutProperties) { -%> -PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() { +<%- propertyValueType(property) %> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() { return <%- camelize(property.name) %>::defaultValue(); } -PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { +<%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { return impl->layout.unevaluated.get<<%- camelize(property.name) %>>(); } -void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) { +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value) { if (value == get<%- camelize(property.name) %>()) return; impl->layout.unevaluated.get<<%- camelize(property.name) %>>() = value; @@ -104,19 +104,27 @@ void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue // Paint properties <% for (const property of paintProperties) { %> -PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() { +<%- propertyValueType(property) %> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() { return { <%- defaultValue(property) %> }; } -PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(const optional<std::string>& klass) const { +<%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(const optional<std::string>& klass) const { return impl->paint.get<<%- camelize(property.name) %>>(klass); } -void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value, const optional<std::string>& klass) { +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value, const optional<std::string>& klass) { if (value == get<%- camelize(property.name) %>(klass)) return; impl->paint.set<<%- camelize(property.name) %>>(value, klass); +<% if (isDataDriven(property)) { -%> + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } +<% } else { -%> impl->observer->onLayerPaintPropertyChanged(*this); +<% } -%> } <% } -%> diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs index d18ad44efd..2a736ca388 100644 --- a/src/mbgl/style/layers/layer_properties.hpp.ejs +++ b/src/mbgl/style/layers/layer_properties.hpp.ejs @@ -10,22 +10,21 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { <% for (const property of layoutProperties) { -%> -struct <%- camelize(property.name) %> : LayoutProperty<<%- propertyType(property) %>> { +struct <%- camelize(property.name) %> : <%- layoutPropertyType(property, type) %> { static constexpr const char * key = "<%- property.name %>"; - static <%- propertyType(property) %> defaultValue() { return <%- defaultValue(property) %>; } + static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; } }; <% } -%> <% for (const property of paintProperties) { -%> -struct <%- camelize(property.name) %> : <% -if (/-pattern$/.test(property.name) || property.name === 'line-dasharray') { -%>CrossFaded<% } -%>PaintProperty<<%- propertyType(property) %>> { - static <%- propertyType(property) %> defaultValue() { return <%- defaultValue(property) %>; } +struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %> { + static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; } }; <% } -%> diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 7f6c148cd1..fcad1eacb6 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -122,34 +122,42 @@ void LineLayer::setLineRoundLimit(PropertyValue<float> value) { // Paint properties -PropertyValue<float> LineLayer::getDefaultLineOpacity() { +DataDrivenPropertyValue<float> LineLayer::getDefaultLineOpacity() { return { 1 }; } -PropertyValue<float> LineLayer::getLineOpacity(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> LineLayer::getLineOpacity(const optional<std::string>& klass) const { return impl->paint.get<LineOpacity>(klass); } -void LineLayer::setLineOpacity(PropertyValue<float> value, const optional<std::string>& klass) { +void LineLayer::setLineOpacity(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getLineOpacity(klass)) return; impl->paint.set<LineOpacity>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<Color> LineLayer::getDefaultLineColor() { +DataDrivenPropertyValue<Color> LineLayer::getDefaultLineColor() { return { Color::black() }; } -PropertyValue<Color> LineLayer::getLineColor(const optional<std::string>& klass) const { +DataDrivenPropertyValue<Color> LineLayer::getLineColor(const optional<std::string>& klass) const { return impl->paint.get<LineColor>(klass); } -void LineLayer::setLineColor(PropertyValue<Color> value, const optional<std::string>& klass) { +void LineLayer::setLineColor(DataDrivenPropertyValue<Color> value, const optional<std::string>& klass) { if (value == getLineColor(klass)) return; impl->paint.set<LineColor>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } PropertyValue<std::array<float, 2>> LineLayer::getDefaultLineTranslate() { @@ -197,49 +205,61 @@ void LineLayer::setLineWidth(PropertyValue<float> value, const optional<std::str impl->observer->onLayerPaintPropertyChanged(*this); } -PropertyValue<float> LineLayer::getDefaultLineGapWidth() { +DataDrivenPropertyValue<float> LineLayer::getDefaultLineGapWidth() { return { 0 }; } -PropertyValue<float> LineLayer::getLineGapWidth(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> LineLayer::getLineGapWidth(const optional<std::string>& klass) const { return impl->paint.get<LineGapWidth>(klass); } -void LineLayer::setLineGapWidth(PropertyValue<float> value, const optional<std::string>& klass) { +void LineLayer::setLineGapWidth(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getLineGapWidth(klass)) return; impl->paint.set<LineGapWidth>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<float> LineLayer::getDefaultLineOffset() { +DataDrivenPropertyValue<float> LineLayer::getDefaultLineOffset() { return { 0 }; } -PropertyValue<float> LineLayer::getLineOffset(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> LineLayer::getLineOffset(const optional<std::string>& klass) const { return impl->paint.get<LineOffset>(klass); } -void LineLayer::setLineOffset(PropertyValue<float> value, const optional<std::string>& klass) { +void LineLayer::setLineOffset(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getLineOffset(klass)) return; impl->paint.set<LineOffset>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } -PropertyValue<float> LineLayer::getDefaultLineBlur() { +DataDrivenPropertyValue<float> LineLayer::getDefaultLineBlur() { return { 0 }; } -PropertyValue<float> LineLayer::getLineBlur(const optional<std::string>& klass) const { +DataDrivenPropertyValue<float> LineLayer::getLineBlur(const optional<std::string>& klass) const { return impl->paint.get<LineBlur>(klass); } -void LineLayer::setLineBlur(PropertyValue<float> value, const optional<std::string>& klass) { +void LineLayer::setLineBlur(DataDrivenPropertyValue<float> value, const optional<std::string>& klass) { if (value == getLineBlur(klass)) return; impl->paint.set<LineBlur>(value, klass); - impl->observer->onLayerPaintPropertyChanged(*this); + if (value.isDataDriven()) { + impl->observer->onLayerDataDrivenPaintPropertyChanged(*this); + } else { + impl->observer->onLayerPaintPropertyChanged(*this); + } } PropertyValue<std::vector<float>> LineLayer::getDefaultLineDasharray() { diff --git a/src/mbgl/style/layers/line_layer_impl.cpp b/src/mbgl/style/layers/line_layer_impl.cpp index 477579a43c..ef0131e3d5 100644 --- a/src/mbgl/style/layers/line_layer_impl.cpp +++ b/src/mbgl/style/layers/line_layer_impl.cpp @@ -1,5 +1,5 @@ #include <mbgl/style/layers/line_layer_impl.hpp> -#include <mbgl/style/bucket_parameters.hpp> +#include <mbgl/style/property_evaluation_parameters.hpp> #include <mbgl/renderer/line_bucket.hpp> #include <mbgl/geometry/feature_index.hpp> #include <mbgl/util/math.hpp> @@ -20,31 +20,25 @@ bool LineLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { paint.evaluate(parameters); - passes = (paint.evaluated.get<LineOpacity>() > 0 && paint.evaluated.get<LineColor>().a > 0 && paint.evaluated.get<LineWidth>() > 0) + passes = (paint.evaluated.get<LineOpacity>().constantOr(1.0) > 0 + && paint.evaluated.get<LineColor>().constantOr(Color::black()).a > 0 + && paint.evaluated.get<LineWidth>() > 0) ? RenderPass::Translucent : RenderPass::None; return paint.hasTransition(); } -std::unique_ptr<Bucket> LineLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const { - auto bucket = std::make_unique<LineBucket>(parameters.tileID.overscaleFactor()); - - bucket->layout = layout.evaluate(PropertyEvaluationParameters(parameters.tileID.overscaledZ)); - - parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) { - auto geometries = feature.getGeometries(); - bucket->addGeometry(geometries); - parameters.featureIndex.insert(geometries, index, layerName, id); - }); - - return std::move(bucket); +std::unique_ptr<Bucket> LineLayer::Impl::createBucket(const BucketParameters& parameters, const std::vector<const Layer*>& layers) const { + return std::make_unique<LineBucket>(parameters, layers, layout); } float LineLayer::Impl::getLineWidth() const { - if (paint.evaluated.get<LineGapWidth>() > 0) { - return paint.evaluated.get<LineGapWidth>() + 2 * paint.evaluated.get<LineWidth>(); + float lineWidth = paint.evaluated.get<LineWidth>(); + float gapWidth = paint.evaluated.get<LineGapWidth>().constantOr(0); + if (gapWidth) { + return gapWidth + 2 * lineWidth; } else { - return paint.evaluated.get<LineWidth>(); + return lineWidth; } } @@ -80,7 +74,8 @@ optional<GeometryCollection> offsetLine(const GeometryCollection& rings, const d float LineLayer::Impl::getQueryRadius() const { const std::array<float, 2>& translate = paint.evaluated.get<LineTranslate>(); - return getLineWidth() / 2.0 + std::abs(paint.evaluated.get<LineOffset>()) + util::length(translate[0], translate[1]); + auto offset = paint.evaluated.get<LineOffset>().constantOr(LineOffset::defaultValue()); + return getLineWidth() / 2.0 + std::abs(offset) + util::length(translate[0], translate[1]); } bool LineLayer::Impl::queryIntersectsGeometry( @@ -93,7 +88,9 @@ bool LineLayer::Impl::queryIntersectsGeometry( auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry( queryGeometry, paint.evaluated.get<LineTranslate>(), paint.evaluated.get<LineTranslateAnchor>(), bearing, pixelsToTileUnits); - auto offsetGeometry = offsetLine(geometry, paint.evaluated.get<LineOffset>() * pixelsToTileUnits); + + auto offset = paint.evaluated.get<LineOffset>().constantOr(LineOffset::defaultValue()); + auto offsetGeometry = offsetLine(geometry, offset * pixelsToTileUnits); return util::polygonIntersectsBufferedMultiLine( translatedQueryGeometry.value_or(queryGeometry), diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp index 1955c019af..67e793f2ea 100644 --- a/src/mbgl/style/layers/line_layer_impl.hpp +++ b/src/mbgl/style/layers/line_layer_impl.hpp @@ -16,7 +16,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; float getQueryRadius() const override; bool queryIntersectsGeometry( diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp index 2ea7f6b125..724026e3a6 100644 --- a/src/mbgl/style/layers/line_layer_properties.hpp +++ b/src/mbgl/style/layers/line_layer_properties.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { @@ -29,11 +30,11 @@ struct LineRoundLimit : LayoutProperty<float> { static float defaultValue() { return 1; } }; -struct LineOpacity : PaintProperty<float> { +struct LineOpacity : DataDrivenPaintProperty<float, attributes::a_opacity> { static float defaultValue() { return 1; } }; -struct LineColor : PaintProperty<Color> { +struct LineColor : DataDrivenPaintProperty<Color, attributes::a_color> { static Color defaultValue() { return Color::black(); } }; @@ -49,15 +50,15 @@ struct LineWidth : PaintProperty<float> { static float defaultValue() { return 1; } }; -struct LineGapWidth : PaintProperty<float> { +struct LineGapWidth : DataDrivenPaintProperty<float, attributes::a_gap_width> { static float defaultValue() { return 0; } }; -struct LineOffset : PaintProperty<float> { +struct LineOffset : DataDrivenPaintProperty<float, attributes::a_offset<1>> { static float defaultValue() { return 0; } }; -struct LineBlur : PaintProperty<float> { +struct LineBlur : DataDrivenPaintProperty<float, attributes::a_blur> { static float defaultValue() { return 0; } }; diff --git a/src/mbgl/style/layers/raster_layer_impl.cpp b/src/mbgl/style/layers/raster_layer_impl.cpp index a78614aee9..a667ccb5a8 100644 --- a/src/mbgl/style/layers/raster_layer_impl.cpp +++ b/src/mbgl/style/layers/raster_layer_impl.cpp @@ -16,7 +16,8 @@ bool RasterLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) return paint.hasTransition(); } -std::unique_ptr<Bucket> RasterLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { +std::unique_ptr<Bucket> RasterLayer::Impl::createBucket(const BucketParameters&, const std::vector<const Layer*>&) const { + assert(false); return nullptr; } diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp index 8e69c21ca8..42985ce0f1 100644 --- a/src/mbgl/style/layers/raster_layer_impl.hpp +++ b/src/mbgl/style/layers/raster_layer_impl.hpp @@ -16,7 +16,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; RasterPaintProperties paint; }; diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp index caa6d0c58d..219fe34d8c 100644 --- a/src/mbgl/style/layers/raster_layer_properties.hpp +++ b/src/mbgl/style/layers/raster_layer_properties.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index c9014e7ee7..94c47f48b7 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -217,15 +217,15 @@ void SymbolLayer::setIconImage(PropertyValue<std::string> value) { impl->layout.unevaluated.get<IconImage>() = value; impl->observer->onLayerLayoutPropertyChanged(*this, "icon-image"); } -PropertyValue<float> SymbolLayer::getDefaultIconRotate() { +DataDrivenPropertyValue<float> SymbolLayer::getDefaultIconRotate() { return IconRotate::defaultValue(); } -PropertyValue<float> SymbolLayer::getIconRotate() const { +DataDrivenPropertyValue<float> SymbolLayer::getIconRotate() const { return impl->layout.unevaluated.get<IconRotate>(); } -void SymbolLayer::setIconRotate(PropertyValue<float> value) { +void SymbolLayer::setIconRotate(DataDrivenPropertyValue<float> value) { if (value == getIconRotate()) return; impl->layout.unevaluated.get<IconRotate>() = value; @@ -259,15 +259,15 @@ void SymbolLayer::setIconKeepUpright(PropertyValue<bool> value) { impl->layout.unevaluated.get<IconKeepUpright>() = value; impl->observer->onLayerLayoutPropertyChanged(*this, "icon-keep-upright"); } -PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconOffset() { +DataDrivenPropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconOffset() { return IconOffset::defaultValue(); } -PropertyValue<std::array<float, 2>> SymbolLayer::getIconOffset() const { +DataDrivenPropertyValue<std::array<float, 2>> SymbolLayer::getIconOffset() const { return impl->layout.unevaluated.get<IconOffset>(); } -void SymbolLayer::setIconOffset(PropertyValue<std::array<float, 2>> value) { +void SymbolLayer::setIconOffset(DataDrivenPropertyValue<std::array<float, 2>> value) { if (value == getIconOffset()) return; impl->layout.unevaluated.get<IconOffset>() = value; diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index f058598f5f..32547e465a 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -1,5 +1,5 @@ #include <mbgl/style/layers/symbol_layer_impl.hpp> -#include <mbgl/style/bucket_parameters.hpp> +#include <mbgl/style/property_evaluation_parameters.hpp> #include <mbgl/layout/symbol_layout.hpp> #include <mbgl/renderer/bucket.hpp> @@ -24,52 +24,17 @@ bool SymbolLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) return paint.hasTransition(); } -std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { +std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(const BucketParameters&, const std::vector<const Layer*>&) const { assert(false); // Should be calling createLayout() instead. return nullptr; } -std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& parameters, - const GeometryTileLayer& layer, - std::vector<std::string> group) const { - PropertyEvaluationParameters p(parameters.tileID.overscaledZ); - SymbolLayoutProperties::Evaluated evaluated = layout.evaluate(p); - - if (evaluated.get<IconRotationAlignment>() == AlignmentType::Auto) { - if (evaluated.get<SymbolPlacement>() == SymbolPlacementType::Line) { - evaluated.get<IconRotationAlignment>() = AlignmentType::Map; - } else { - evaluated.get<IconRotationAlignment>() = AlignmentType::Viewport; - } - } - - if (evaluated.get<TextRotationAlignment>() == AlignmentType::Auto) { - if (evaluated.get<SymbolPlacement>() == SymbolPlacementType::Line) { - evaluated.get<TextRotationAlignment>() = AlignmentType::Map; - } else { - evaluated.get<TextRotationAlignment>() = AlignmentType::Viewport; - } - } - - // If unspecified `text-pitch-alignment` inherits `text-rotation-alignment` - if (evaluated.get<TextPitchAlignment>() == AlignmentType::Auto) { - evaluated.get<TextPitchAlignment>() = evaluated.get<TextRotationAlignment>(); - } - - float textMaxSize = layout.evaluate<TextSize>(PropertyEvaluationParameters(18)); - - evaluated.get<IconSize>() = layout.evaluate<IconSize>(PropertyEvaluationParameters(p.z + 1)); - evaluated.get<TextSize>() = layout.evaluate<TextSize>(PropertyEvaluationParameters(p.z + 1)); - - return std::make_unique<SymbolLayout>(std::move(group), - layer.getName(), - parameters.tileID.overscaleFactor(), - parameters.tileID.overscaledZ, - parameters.mode, +std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(const BucketParameters& parameters, + const std::vector<const Layer*>& group, + const GeometryTileLayer& layer) const { + return std::make_unique<SymbolLayout>(parameters, + group, layer, - filter, - evaluated, - textMaxSize, *spriteAtlas); } diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp index db18da07e2..c00c2b0bba 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.hpp +++ b/src/mbgl/style/layers/symbol_layer_impl.hpp @@ -50,9 +50,9 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; - std::unique_ptr<SymbolLayout> createLayout(BucketParameters&, const GeometryTileLayer&, - std::vector<std::string>) const; + std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const Layer*>&) const override; + std::unique_ptr<SymbolLayout> createLayout(const BucketParameters&, const std::vector<const Layer*>&, + const GeometryTileLayer&) const; SymbolPropertyValues iconPropertyValues(const SymbolLayoutProperties::Evaluated&) const; SymbolPropertyValues textPropertyValues(const SymbolLayoutProperties::Evaluated&) const; diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index f5fd6ce3df..a447eb7efa 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/types.hpp> #include <mbgl/style/layout_property.hpp> #include <mbgl/style/paint_property.hpp> +#include <mbgl/programs/attributes.hpp> namespace mbgl { namespace style { @@ -64,7 +65,7 @@ struct IconImage : LayoutProperty<std::string> { static std::string defaultValue() { return ""; } }; -struct IconRotate : LayoutProperty<float> { +struct IconRotate : DataDrivenLayoutProperty<float> { static constexpr const char * key = "icon-rotate"; static float defaultValue() { return 0; } }; @@ -79,7 +80,7 @@ struct IconKeepUpright : LayoutProperty<bool> { static bool defaultValue() { return false; } }; -struct IconOffset : LayoutProperty<std::array<float, 2>> { +struct IconOffset : DataDrivenLayoutProperty<std::array<float, 2>> { static constexpr const char * key = "icon-offset"; static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; } }; |