From 1cf46d93b944095726396acf84649519e2fd96ad Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 10 May 2017 16:09:02 -0700 Subject: [core] Simplify LayerObserver API --- src/mbgl/style/layer_observer.hpp | 6 +- src/mbgl/style/layers/background_layer.cpp | 8 +- src/mbgl/style/layers/circle_layer.cpp | 52 +++------ src/mbgl/style/layers/custom_layer.cpp | 2 +- src/mbgl/style/layers/fill_extrusion_layer.cpp | 30 ++---- src/mbgl/style/layers/fill_layer.cpp | 30 ++---- src/mbgl/style/layers/layer.cpp.ejs | 16 +-- src/mbgl/style/layers/line_layer.cpp | 52 +++------ src/mbgl/style/layers/raster_layer.cpp | 16 +-- src/mbgl/style/layers/symbol_layer.cpp | 140 +++++++++---------------- src/mbgl/style/style.cpp | 18 +--- src/mbgl/style/style.hpp | 6 +- test/src/mbgl/test/stub_layer_observer.hpp | 26 +---- test/style/style_layer.test.cpp | 20 +++- 14 files changed, 135 insertions(+), 287 deletions(-) diff --git a/src/mbgl/style/layer_observer.hpp b/src/mbgl/style/layer_observer.hpp index 2fa1c39660..28074a65e7 100644 --- a/src/mbgl/style/layer_observer.hpp +++ b/src/mbgl/style/layer_observer.hpp @@ -9,11 +9,7 @@ class LayerObserver { public: virtual ~LayerObserver() = default; - virtual void onLayerFilterChanged(Layer&) {} - virtual void onLayerVisibilityChanged(Layer&) {} - virtual void onLayerPaintPropertyChanged(Layer&) {} - virtual void onLayerDataDrivenPaintPropertyChanged(Layer&) {} - virtual void onLayerLayoutPropertyChanged(Layer&, const char *) {} + virtual void onLayerChanged(Layer&) {} }; } // namespace style diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index c4b22aa0e3..d4ead18816 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -44,7 +44,7 @@ void BackgroundLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -80,7 +80,7 @@ void BackgroundLayer::setBackgroundColor(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void BackgroundLayer::setBackgroundColorTransition(const TransitionOptions& options) { @@ -107,7 +107,7 @@ void BackgroundLayer::setBackgroundPattern(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void BackgroundLayer::setBackgroundPatternTransition(const TransitionOptions& options) { @@ -134,7 +134,7 @@ void BackgroundLayer::setBackgroundOpacity(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void BackgroundLayer::setBackgroundOpacityTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index e5c4c33497..3bba135c84 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -57,7 +57,7 @@ void CircleLayer::setFilter(const Filter& filter) { auto impl_ = mutableImpl(); impl_->filter = filter; baseImpl = std::move(impl_); - observer->onLayerFilterChanged(*this); + observer->onLayerChanged(*this); } const Filter& CircleLayer::getFilter() const { @@ -72,7 +72,7 @@ void CircleLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -108,11 +108,7 @@ void CircleLayer::setCircleRadius(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleRadiusTransition(const TransitionOptions& options) { @@ -139,11 +135,7 @@ void CircleLayer::setCircleColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleColorTransition(const TransitionOptions& options) { @@ -170,11 +162,7 @@ void CircleLayer::setCircleBlur(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleBlurTransition(const TransitionOptions& options) { @@ -201,11 +189,7 @@ void CircleLayer::setCircleOpacity(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleOpacityTransition(const TransitionOptions& options) { @@ -232,7 +216,7 @@ void CircleLayer::setCircleTranslate(PropertyValue> value) auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void CircleLayer::setCircleTranslateTransition(const TransitionOptions& options) { @@ -259,7 +243,7 @@ void CircleLayer::setCircleTranslateAnchor(PropertyValue va auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void CircleLayer::setCircleTranslateAnchorTransition(const TransitionOptions& options) { @@ -286,7 +270,7 @@ void CircleLayer::setCirclePitchScale(PropertyValue value) auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void CircleLayer::setCirclePitchScaleTransition(const TransitionOptions& options) { @@ -313,11 +297,7 @@ void CircleLayer::setCircleStrokeWidth(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleStrokeWidthTransition(const TransitionOptions& options) { @@ -344,11 +324,7 @@ void CircleLayer::setCircleStrokeColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleStrokeColorTransition(const TransitionOptions& options) { @@ -375,11 +351,7 @@ void CircleLayer::setCircleStrokeOpacity(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void CircleLayer::setCircleStrokeOpacityTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp index f7c349b3d8..e37382d5ef 100644 --- a/src/mbgl/style/layers/custom_layer.cpp +++ b/src/mbgl/style/layers/custom_layer.cpp @@ -36,7 +36,7 @@ void CustomLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 4a5dc592e6..62f92cef75 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -57,7 +57,7 @@ void FillExtrusionLayer::setFilter(const Filter& filter) { auto impl_ = mutableImpl(); impl_->filter = filter; baseImpl = std::move(impl_); - observer->onLayerFilterChanged(*this); + observer->onLayerChanged(*this); } const Filter& FillExtrusionLayer::getFilter() const { @@ -72,7 +72,7 @@ void FillExtrusionLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -108,7 +108,7 @@ void FillExtrusionLayer::setFillExtrusionOpacity(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionOpacityTransition(const TransitionOptions& options) { @@ -135,11 +135,7 @@ void FillExtrusionLayer::setFillExtrusionColor(DataDrivenPropertyValue va auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionColorTransition(const TransitionOptions& options) { @@ -166,7 +162,7 @@ void FillExtrusionLayer::setFillExtrusionTranslate(PropertyValuepaint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionTranslateTransition(const TransitionOptions& options) { @@ -193,7 +189,7 @@ void FillExtrusionLayer::setFillExtrusionTranslateAnchor(PropertyValuepaint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionTranslateAnchorTransition(const TransitionOptions& options) { @@ -220,7 +216,7 @@ void FillExtrusionLayer::setFillExtrusionPattern(PropertyValue valu auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionPatternTransition(const TransitionOptions& options) { @@ -247,11 +243,7 @@ void FillExtrusionLayer::setFillExtrusionHeight(DataDrivenPropertyValue v auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionHeightTransition(const TransitionOptions& options) { @@ -278,11 +270,7 @@ void FillExtrusionLayer::setFillExtrusionBase(DataDrivenPropertyValue val auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void FillExtrusionLayer::setFillExtrusionBaseTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index b98c325451..65975752db 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -57,7 +57,7 @@ void FillLayer::setFilter(const Filter& filter) { auto impl_ = mutableImpl(); impl_->filter = filter; baseImpl = std::move(impl_); - observer->onLayerFilterChanged(*this); + observer->onLayerChanged(*this); } const Filter& FillLayer::getFilter() const { @@ -72,7 +72,7 @@ void FillLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -108,7 +108,7 @@ void FillLayer::setFillAntialias(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillLayer::setFillAntialiasTransition(const TransitionOptions& options) { @@ -135,11 +135,7 @@ void FillLayer::setFillOpacity(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void FillLayer::setFillOpacityTransition(const TransitionOptions& options) { @@ -166,11 +162,7 @@ void FillLayer::setFillColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void FillLayer::setFillColorTransition(const TransitionOptions& options) { @@ -197,11 +189,7 @@ void FillLayer::setFillOutlineColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void FillLayer::setFillOutlineColorTransition(const TransitionOptions& options) { @@ -228,7 +216,7 @@ void FillLayer::setFillTranslate(PropertyValue> value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillLayer::setFillTranslateTransition(const TransitionOptions& options) { @@ -255,7 +243,7 @@ void FillLayer::setFillTranslateAnchor(PropertyValue value) auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillLayer::setFillTranslateAnchorTransition(const TransitionOptions& options) { @@ -282,7 +270,7 @@ void FillLayer::setFillPattern(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void FillLayer::setFillPatternTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index b9c3e64cb4..573aabda8b 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -76,7 +76,7 @@ void <%- camelize(type) %>Layer::setFilter(const Filter& filter) { auto impl_ = mutableImpl(); impl_->filter = filter; baseImpl = std::move(impl_); - observer->onLayerFilterChanged(*this); + observer->onLayerChanged(*this); } const Filter& <%- camelize(type) %>Layer::getFilter() const { @@ -93,7 +93,7 @@ void <%- camelize(type) %>Layer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -127,7 +127,7 @@ void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyV auto impl_ = mutableImpl(); impl_->layout.get<<%- camelize(property.name) %>>() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "<%- property.name %>"); + observer->onLayerChanged(*this); } <% } -%> @@ -147,15 +147,7 @@ void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyV auto impl_ = mutableImpl(); impl_->paint.template get<<%- camelize(property.name) %>>().value = value; baseImpl = std::move(impl_); -<% if (isDataDriven(property)) { -%> - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } -<% } else { -%> - observer->onLayerPaintPropertyChanged(*this); -<% } -%> + observer->onLayerChanged(*this); } void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>Transition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 96f1fa4d11..cf3f81f613 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -58,7 +58,7 @@ void LineLayer::setFilter(const Filter& filter) { auto impl_ = mutableImpl(); impl_->filter = filter; baseImpl = std::move(impl_); - observer->onLayerFilterChanged(*this); + observer->onLayerChanged(*this); } const Filter& LineLayer::getFilter() const { @@ -73,7 +73,7 @@ void LineLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -106,7 +106,7 @@ void LineLayer::setLineCap(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "line-cap"); + observer->onLayerChanged(*this); } PropertyValue LineLayer::getDefaultLineJoin() { return LineJoin::defaultValue(); @@ -122,7 +122,7 @@ void LineLayer::setLineJoin(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "line-join"); + observer->onLayerChanged(*this); } PropertyValue LineLayer::getDefaultLineMiterLimit() { return LineMiterLimit::defaultValue(); @@ -138,7 +138,7 @@ void LineLayer::setLineMiterLimit(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "line-miter-limit"); + observer->onLayerChanged(*this); } PropertyValue LineLayer::getDefaultLineRoundLimit() { return LineRoundLimit::defaultValue(); @@ -154,7 +154,7 @@ void LineLayer::setLineRoundLimit(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "line-round-limit"); + observer->onLayerChanged(*this); } // Paint properties @@ -173,11 +173,7 @@ void LineLayer::setLineOpacity(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void LineLayer::setLineOpacityTransition(const TransitionOptions& options) { @@ -204,11 +200,7 @@ void LineLayer::setLineColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void LineLayer::setLineColorTransition(const TransitionOptions& options) { @@ -235,7 +227,7 @@ void LineLayer::setLineTranslate(PropertyValue> value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void LineLayer::setLineTranslateTransition(const TransitionOptions& options) { @@ -262,7 +254,7 @@ void LineLayer::setLineTranslateAnchor(PropertyValue value) auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void LineLayer::setLineTranslateAnchorTransition(const TransitionOptions& options) { @@ -289,7 +281,7 @@ void LineLayer::setLineWidth(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void LineLayer::setLineWidthTransition(const TransitionOptions& options) { @@ -316,11 +308,7 @@ void LineLayer::setLineGapWidth(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void LineLayer::setLineGapWidthTransition(const TransitionOptions& options) { @@ -347,11 +335,7 @@ void LineLayer::setLineOffset(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void LineLayer::setLineOffsetTransition(const TransitionOptions& options) { @@ -378,11 +362,7 @@ void LineLayer::setLineBlur(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void LineLayer::setLineBlurTransition(const TransitionOptions& options) { @@ -409,7 +389,7 @@ void LineLayer::setLineDasharray(PropertyValue> value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void LineLayer::setLineDasharrayTransition(const TransitionOptions& options) { @@ -436,7 +416,7 @@ void LineLayer::setLinePattern(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void LineLayer::setLinePatternTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index a7a32768b6..a9a8d273fa 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -50,7 +50,7 @@ void RasterLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -86,7 +86,7 @@ void RasterLayer::setRasterOpacity(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterOpacityTransition(const TransitionOptions& options) { @@ -113,7 +113,7 @@ void RasterLayer::setRasterHueRotate(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterHueRotateTransition(const TransitionOptions& options) { @@ -140,7 +140,7 @@ void RasterLayer::setRasterBrightnessMin(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterBrightnessMinTransition(const TransitionOptions& options) { @@ -167,7 +167,7 @@ void RasterLayer::setRasterBrightnessMax(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterBrightnessMaxTransition(const TransitionOptions& options) { @@ -194,7 +194,7 @@ void RasterLayer::setRasterSaturation(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterSaturationTransition(const TransitionOptions& options) { @@ -221,7 +221,7 @@ void RasterLayer::setRasterContrast(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterContrastTransition(const TransitionOptions& options) { @@ -248,7 +248,7 @@ void RasterLayer::setRasterFadeDuration(PropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void RasterLayer::setRasterFadeDurationTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index b2f9ca754f..182b4b0a48 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -58,7 +58,7 @@ void SymbolLayer::setFilter(const Filter& filter) { auto impl_ = mutableImpl(); impl_->filter = filter; baseImpl = std::move(impl_); - observer->onLayerFilterChanged(*this); + observer->onLayerChanged(*this); } const Filter& SymbolLayer::getFilter() const { @@ -73,7 +73,7 @@ void SymbolLayer::setVisibility(VisibilityType value) { auto impl_ = mutableImpl(); impl_->visibility = value; baseImpl = std::move(impl_); - observer->onLayerVisibilityChanged(*this); + observer->onLayerChanged(*this); } // Zoom range @@ -106,7 +106,7 @@ void SymbolLayer::setSymbolPlacement(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "symbol-placement"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultSymbolSpacing() { return SymbolSpacing::defaultValue(); @@ -122,7 +122,7 @@ void SymbolLayer::setSymbolSpacing(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "symbol-spacing"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultSymbolAvoidEdges() { return SymbolAvoidEdges::defaultValue(); @@ -138,7 +138,7 @@ void SymbolLayer::setSymbolAvoidEdges(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "symbol-avoid-edges"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconAllowOverlap() { return IconAllowOverlap::defaultValue(); @@ -154,7 +154,7 @@ void SymbolLayer::setIconAllowOverlap(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-allow-overlap"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconIgnorePlacement() { return IconIgnorePlacement::defaultValue(); @@ -170,7 +170,7 @@ void SymbolLayer::setIconIgnorePlacement(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-ignore-placement"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconOptional() { return IconOptional::defaultValue(); @@ -186,7 +186,7 @@ void SymbolLayer::setIconOptional(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-optional"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconRotationAlignment() { return IconRotationAlignment::defaultValue(); @@ -202,7 +202,7 @@ void SymbolLayer::setIconRotationAlignment(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-rotation-alignment"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultIconSize() { return IconSize::defaultValue(); @@ -218,7 +218,7 @@ void SymbolLayer::setIconSize(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-size"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconTextFit() { return IconTextFit::defaultValue(); @@ -234,7 +234,7 @@ void SymbolLayer::setIconTextFit(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-text-fit"); + observer->onLayerChanged(*this); } PropertyValue> SymbolLayer::getDefaultIconTextFitPadding() { return IconTextFitPadding::defaultValue(); @@ -250,7 +250,7 @@ void SymbolLayer::setIconTextFitPadding(PropertyValue> valu auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-text-fit-padding"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultIconImage() { return IconImage::defaultValue(); @@ -266,7 +266,7 @@ void SymbolLayer::setIconImage(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-image"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultIconRotate() { return IconRotate::defaultValue(); @@ -282,7 +282,7 @@ void SymbolLayer::setIconRotate(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-rotate"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconPadding() { return IconPadding::defaultValue(); @@ -298,7 +298,7 @@ void SymbolLayer::setIconPadding(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-padding"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultIconKeepUpright() { return IconKeepUpright::defaultValue(); @@ -314,7 +314,7 @@ void SymbolLayer::setIconKeepUpright(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-keep-upright"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue> SymbolLayer::getDefaultIconOffset() { return IconOffset::defaultValue(); @@ -330,7 +330,7 @@ void SymbolLayer::setIconOffset(DataDrivenPropertyValue> va auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "icon-offset"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextPitchAlignment() { return TextPitchAlignment::defaultValue(); @@ -346,7 +346,7 @@ void SymbolLayer::setTextPitchAlignment(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-pitch-alignment"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextRotationAlignment() { return TextRotationAlignment::defaultValue(); @@ -362,7 +362,7 @@ void SymbolLayer::setTextRotationAlignment(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-rotation-alignment"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultTextField() { return TextField::defaultValue(); @@ -378,7 +378,7 @@ void SymbolLayer::setTextField(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-field"); + observer->onLayerChanged(*this); } PropertyValue> SymbolLayer::getDefaultTextFont() { return TextFont::defaultValue(); @@ -394,7 +394,7 @@ void SymbolLayer::setTextFont(PropertyValue> value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-font"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultTextSize() { return TextSize::defaultValue(); @@ -410,7 +410,7 @@ void SymbolLayer::setTextSize(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-size"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextMaxWidth() { return TextMaxWidth::defaultValue(); @@ -426,7 +426,7 @@ void SymbolLayer::setTextMaxWidth(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-max-width"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextLineHeight() { return TextLineHeight::defaultValue(); @@ -442,7 +442,7 @@ void SymbolLayer::setTextLineHeight(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-line-height"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextLetterSpacing() { return TextLetterSpacing::defaultValue(); @@ -458,7 +458,7 @@ void SymbolLayer::setTextLetterSpacing(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-letter-spacing"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextJustify() { return TextJustify::defaultValue(); @@ -474,7 +474,7 @@ void SymbolLayer::setTextJustify(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-justify"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextAnchor() { return TextAnchor::defaultValue(); @@ -490,7 +490,7 @@ void SymbolLayer::setTextAnchor(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-anchor"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextMaxAngle() { return TextMaxAngle::defaultValue(); @@ -506,7 +506,7 @@ void SymbolLayer::setTextMaxAngle(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-max-angle"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultTextRotate() { return TextRotate::defaultValue(); @@ -522,7 +522,7 @@ void SymbolLayer::setTextRotate(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-rotate"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextPadding() { return TextPadding::defaultValue(); @@ -538,7 +538,7 @@ void SymbolLayer::setTextPadding(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-padding"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextKeepUpright() { return TextKeepUpright::defaultValue(); @@ -554,7 +554,7 @@ void SymbolLayer::setTextKeepUpright(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-keep-upright"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue SymbolLayer::getDefaultTextTransform() { return TextTransform::defaultValue(); @@ -570,7 +570,7 @@ void SymbolLayer::setTextTransform(DataDrivenPropertyValue va auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-transform"); + observer->onLayerChanged(*this); } DataDrivenPropertyValue> SymbolLayer::getDefaultTextOffset() { return TextOffset::defaultValue(); @@ -586,7 +586,7 @@ void SymbolLayer::setTextOffset(DataDrivenPropertyValue> va auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-offset"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextAllowOverlap() { return TextAllowOverlap::defaultValue(); @@ -602,7 +602,7 @@ void SymbolLayer::setTextAllowOverlap(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-allow-overlap"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextIgnorePlacement() { return TextIgnorePlacement::defaultValue(); @@ -618,7 +618,7 @@ void SymbolLayer::setTextIgnorePlacement(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-ignore-placement"); + observer->onLayerChanged(*this); } PropertyValue SymbolLayer::getDefaultTextOptional() { return TextOptional::defaultValue(); @@ -634,7 +634,7 @@ void SymbolLayer::setTextOptional(PropertyValue value) { auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); - observer->onLayerLayoutPropertyChanged(*this, "text-optional"); + observer->onLayerChanged(*this); } // Paint properties @@ -653,11 +653,7 @@ void SymbolLayer::setIconOpacity(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setIconOpacityTransition(const TransitionOptions& options) { @@ -684,11 +680,7 @@ void SymbolLayer::setIconColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setIconColorTransition(const TransitionOptions& options) { @@ -715,11 +707,7 @@ void SymbolLayer::setIconHaloColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setIconHaloColorTransition(const TransitionOptions& options) { @@ -746,11 +734,7 @@ void SymbolLayer::setIconHaloWidth(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setIconHaloWidthTransition(const TransitionOptions& options) { @@ -777,11 +761,7 @@ void SymbolLayer::setIconHaloBlur(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setIconHaloBlurTransition(const TransitionOptions& options) { @@ -808,7 +788,7 @@ void SymbolLayer::setIconTranslate(PropertyValue> value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void SymbolLayer::setIconTranslateTransition(const TransitionOptions& options) { @@ -835,7 +815,7 @@ void SymbolLayer::setIconTranslateAnchor(PropertyValue valu auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void SymbolLayer::setIconTranslateAnchorTransition(const TransitionOptions& options) { @@ -862,11 +842,7 @@ void SymbolLayer::setTextOpacity(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setTextOpacityTransition(const TransitionOptions& options) { @@ -893,11 +869,7 @@ void SymbolLayer::setTextColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setTextColorTransition(const TransitionOptions& options) { @@ -924,11 +896,7 @@ void SymbolLayer::setTextHaloColor(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setTextHaloColorTransition(const TransitionOptions& options) { @@ -955,11 +923,7 @@ void SymbolLayer::setTextHaloWidth(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setTextHaloWidthTransition(const TransitionOptions& options) { @@ -986,11 +950,7 @@ void SymbolLayer::setTextHaloBlur(DataDrivenPropertyValue value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - if (value.isDataDriven()) { - observer->onLayerDataDrivenPaintPropertyChanged(*this); - } else { - observer->onLayerPaintPropertyChanged(*this); - } + observer->onLayerChanged(*this); } void SymbolLayer::setTextHaloBlurTransition(const TransitionOptions& options) { @@ -1017,7 +977,7 @@ void SymbolLayer::setTextTranslate(PropertyValue> value) { auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void SymbolLayer::setTextTranslateTransition(const TransitionOptions& options) { @@ -1044,7 +1004,7 @@ void SymbolLayer::setTextTranslateAnchor(PropertyValue valu auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); - observer->onLayerPaintPropertyChanged(*this); + observer->onLayerChanged(*this); } void SymbolLayer::setTextTranslateAnchorTransition(const TransitionOptions& options) { diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 4acafba0ee..98d774f974 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -782,23 +782,7 @@ void Style::onSpriteError(std::exception_ptr error) { observer->onResourceError(error); } -void Style::onLayerFilterChanged(Layer&) { - observer->onUpdate(Update::Repaint); -} - -void Style::onLayerVisibilityChanged(Layer&) { - observer->onUpdate(Update::Repaint); -} - -void Style::onLayerPaintPropertyChanged(Layer&) { - observer->onUpdate(Update::Repaint); -} - -void Style::onLayerDataDrivenPaintPropertyChanged(Layer&) { - observer->onUpdate(Update::Repaint); -} - -void Style::onLayerLayoutPropertyChanged(Layer&, const char *) { +void Style::onLayerChanged(Layer&) { observer->onUpdate(Update::Repaint); } diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index 9138637894..a947fce44f 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -164,11 +164,7 @@ private: void onTileError(RenderSource&, const OverscaledTileID&, std::exception_ptr) override; // LayerObserver implementation. - void onLayerFilterChanged(Layer&) override; - void onLayerVisibilityChanged(Layer&) override; - void onLayerPaintPropertyChanged(Layer&) override; - void onLayerDataDrivenPaintPropertyChanged(Layer&) override; - void onLayerLayoutPropertyChanged(Layer&, const char *) override; + void onLayerChanged(Layer&) override; // LightObserver implementation. void onLightChanged(const Light&) override; diff --git a/test/src/mbgl/test/stub_layer_observer.hpp b/test/src/mbgl/test/stub_layer_observer.hpp index 9acd4b077a..0fa413aefe 100644 --- a/test/src/mbgl/test/stub_layer_observer.hpp +++ b/test/src/mbgl/test/stub_layer_observer.hpp @@ -10,29 +10,9 @@ using namespace mbgl::style; */ class StubLayerObserver : public style::LayerObserver { public: - void onLayerFilterChanged(Layer& layer) override { - if (layerFilterChanged) layerFilterChanged(layer); + void onLayerChanged(Layer& layer) override { + if (layerChanged) layerChanged(layer); } - void onLayerVisibilityChanged(Layer& layer) override { - if (layerVisibilityChanged) layerVisibilityChanged(layer); - } - - void onLayerPaintPropertyChanged(Layer& layer) override { - if (layerPaintPropertyChanged) layerPaintPropertyChanged(layer); - } - - void onLayerDataDrivenPaintPropertyChanged(Layer& layer) override { - if (layerDataDrivenPaintPropertyChanged) layerDataDrivenPaintPropertyChanged(layer); - } - - void onLayerLayoutPropertyChanged(Layer& layer, const char * property) override { - if (layerLayoutPropertyChanged) layerLayoutPropertyChanged(layer, property); - } - - std::function layerFilterChanged; - std::function layerVisibilityChanged; - std::function layerPaintPropertyChanged; - std::function layerDataDrivenPaintPropertyChanged; - std::function layerLayoutPropertyChanged; + std::function layerChanged; }; diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp index 2a8379bf20..7d0eb318c0 100644 --- a/test/style/style_layer.test.cpp +++ b/test/style/style_layer.test.cpp @@ -207,7 +207,7 @@ TEST(Layer, Observer) { // Notifies observer on filter change. bool filterChanged = false; - observer.layerFilterChanged = [&] (Layer& layer_) { + observer.layerChanged = [&] (Layer& layer_) { EXPECT_EQ(layer.get(), &layer_); filterChanged = true; }; @@ -216,7 +216,7 @@ TEST(Layer, Observer) { // Notifies observer on visibility change. bool visibilityChanged = false; - observer.layerVisibilityChanged = [&] (Layer& layer_) { + observer.layerChanged = [&] (Layer& layer_) { EXPECT_EQ(layer.get(), &layer_); visibilityChanged = true; }; @@ -225,7 +225,7 @@ TEST(Layer, Observer) { // Notifies observer on paint property change. bool paintPropertyChanged = false; - observer.layerPaintPropertyChanged = [&] (Layer& layer_) { + observer.layerChanged = [&] (Layer& layer_) { EXPECT_EQ(layer.get(), &layer_); paintPropertyChanged = true; }; @@ -234,7 +234,7 @@ TEST(Layer, Observer) { // Notifies observer on layout property change. bool layoutPropertyChanged = false; - observer.layerLayoutPropertyChanged = [&] (Layer& layer_, const char *) { + observer.layerChanged = [&] (Layer& layer_) { EXPECT_EQ(layer.get(), &layer_); layoutPropertyChanged = true; }; @@ -243,16 +243,28 @@ TEST(Layer, Observer) { // Does not notify observer on no-op visibility change. visibilityChanged = false; + observer.layerChanged = [&] (Layer& layer_) { + EXPECT_EQ(layer.get(), &layer_); + visibilityChanged = true; + }; layer->setVisibility(VisibilityType::None); EXPECT_FALSE(visibilityChanged); // Does not notify observer on no-op paint property change. paintPropertyChanged = false; + observer.layerChanged = [&] (Layer& layer_) { + EXPECT_EQ(layer.get(), &layer_); + paintPropertyChanged = true; + }; layer->setLineColor(color); EXPECT_FALSE(paintPropertyChanged); // Does not notify observer on no-op layout property change. layoutPropertyChanged = false; + observer.layerChanged = [&] (Layer& layer_) { + EXPECT_EQ(layer.get(), &layer_); + layoutPropertyChanged = true; + }; layer->setLineCap(lineCap); EXPECT_FALSE(layoutPropertyChanged); } -- cgit v1.2.1