summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/layer_impl.cpp4
-rw-r--r--src/mbgl/style/layer_impl.hpp6
-rw-r--r--src/mbgl/style/layer_observer.hpp18
-rw-r--r--src/mbgl/style/layers/background_layer.cpp9
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp22
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp22
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs7
-rw-r--r--src/mbgl/style/layers/line_layer.cpp43
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp21
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp145
-rw-r--r--src/mbgl/style/style.cpp15
-rw-r--r--src/mbgl/style/style.hpp7
12 files changed, 319 insertions, 0 deletions
diff --git a/src/mbgl/style/layer_impl.cpp b/src/mbgl/style/layer_impl.cpp
index f50bf87339..7a0195c55c 100644
--- a/src/mbgl/style/layer_impl.cpp
+++ b/src/mbgl/style/layer_impl.cpp
@@ -28,5 +28,9 @@ bool Layer::Impl::needsRendering(float zoom) const {
&& maxZoom >= zoom;
}
+void Layer::Impl::setObserver(LayerObserver* observer_) {
+ observer = observer_;
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp
index c1f04fe513..55b1ff058c 100644
--- a/src/mbgl/style/layer_impl.hpp
+++ b/src/mbgl/style/layer_impl.hpp
@@ -3,6 +3,7 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/style/filter.hpp>
+#include <mbgl/style/layer_observer.hpp>
#include <mbgl/renderer/render_pass.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
@@ -73,6 +74,8 @@ public:
const float,
const float) const { return false; };
+ void setObserver(LayerObserver*);
+
public:
std::string id;
std::string ref;
@@ -83,6 +86,9 @@ public:
float maxZoom = std::numeric_limits<float>::infinity();
VisibilityType visibility = VisibilityType::Visible;
+ LayerObserver nullObserver;
+ LayerObserver* observer = &nullObserver;
+
protected:
Impl() = default;
Impl(const Impl&) = default;
diff --git a/src/mbgl/style/layer_observer.hpp b/src/mbgl/style/layer_observer.hpp
new file mode 100644
index 0000000000..1d3d1aef46
--- /dev/null
+++ b/src/mbgl/style/layer_observer.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+namespace mbgl {
+namespace style {
+
+class Layer;
+
+class LayerObserver {
+public:
+ virtual ~LayerObserver() = default;
+
+ virtual void onLayerFilterChanged(Layer&) {}
+ virtual void onLayerPaintPropertyChanged(Layer&) {}
+ virtual void onLayerLayoutPropertyChanged(Layer&) {}
+};
+
+} // namespace style
+} // namespace mbgl
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index 25de2a943e..5e5faf37e6 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -46,7 +46,10 @@ PropertyValue<Color> BackgroundLayer::getBackgroundColor(const optional<std::str
}
void BackgroundLayer::setBackgroundColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getBackgroundColor(klass))
+ return;
impl->paint.backgroundColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::string> BackgroundLayer::getDefaultBackgroundPattern() {
@@ -58,7 +61,10 @@ PropertyValue<std::string> BackgroundLayer::getBackgroundPattern(const optional<
}
void BackgroundLayer::setBackgroundPattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
+ if (value == getBackgroundPattern(klass))
+ return;
impl->paint.backgroundPattern.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> BackgroundLayer::getDefaultBackgroundOpacity() {
@@ -70,7 +76,10 @@ PropertyValue<float> BackgroundLayer::getBackgroundOpacity(const optional<std::s
}
void BackgroundLayer::setBackgroundOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getBackgroundOpacity(klass))
+ return;
impl->paint.backgroundOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
} // namespace style
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index 5fa29d9d37..a2b8d316d6 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -50,6 +50,7 @@ const std::string& CircleLayer::getSourceLayer() const {
void CircleLayer::setFilter(const Filter& filter) {
impl->filter = filter;
+ impl->observer->onLayerFilterChanged(*this);
}
const Filter& CircleLayer::getFilter() const {
@@ -70,7 +71,10 @@ PropertyValue<float> CircleLayer::getCircleRadius(const optional<std::string>& k
}
void CircleLayer::setCircleRadius(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getCircleRadius(klass))
+ return;
impl->paint.circleRadius.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> CircleLayer::getDefaultCircleColor() {
@@ -82,7 +86,10 @@ PropertyValue<Color> CircleLayer::getCircleColor(const optional<std::string>& kl
}
void CircleLayer::setCircleColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getCircleColor(klass))
+ return;
impl->paint.circleColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> CircleLayer::getDefaultCircleBlur() {
@@ -94,7 +101,10 @@ PropertyValue<float> CircleLayer::getCircleBlur(const optional<std::string>& kla
}
void CircleLayer::setCircleBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getCircleBlur(klass))
+ return;
impl->paint.circleBlur.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> CircleLayer::getDefaultCircleOpacity() {
@@ -106,7 +116,10 @@ PropertyValue<float> CircleLayer::getCircleOpacity(const optional<std::string>&
}
void CircleLayer::setCircleOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getCircleOpacity(klass))
+ return;
impl->paint.circleOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> CircleLayer::getDefaultCircleTranslate() {
@@ -118,7 +131,10 @@ PropertyValue<std::array<float, 2>> CircleLayer::getCircleTranslate(const option
}
void CircleLayer::setCircleTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ if (value == getCircleTranslate(klass))
+ return;
impl->paint.circleTranslate.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<TranslateAnchorType> CircleLayer::getDefaultCircleTranslateAnchor() {
@@ -130,7 +146,10 @@ PropertyValue<TranslateAnchorType> CircleLayer::getCircleTranslateAnchor(const o
}
void CircleLayer::setCircleTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ if (value == getCircleTranslateAnchor(klass))
+ return;
impl->paint.circleTranslateAnchor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<CirclePitchScaleType> CircleLayer::getDefaultCirclePitchScale() {
@@ -142,7 +161,10 @@ PropertyValue<CirclePitchScaleType> CircleLayer::getCirclePitchScale(const optio
}
void CircleLayer::setCirclePitchScale(PropertyValue<CirclePitchScaleType> value, const optional<std::string>& klass) {
+ if (value == getCirclePitchScale(klass))
+ return;
impl->paint.circlePitchScale.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
} // namespace style
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 6bc4b892ef..c61de81d1a 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -50,6 +50,7 @@ const std::string& FillLayer::getSourceLayer() const {
void FillLayer::setFilter(const Filter& filter) {
impl->filter = filter;
+ impl->observer->onLayerFilterChanged(*this);
}
const Filter& FillLayer::getFilter() const {
@@ -70,7 +71,10 @@ PropertyValue<bool> FillLayer::getFillAntialias(const optional<std::string>& kla
}
void FillLayer::setFillAntialias(PropertyValue<bool> value, const optional<std::string>& klass) {
+ if (value == getFillAntialias(klass))
+ return;
impl->paint.fillAntialias.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> FillLayer::getDefaultFillOpacity() {
@@ -82,7 +86,10 @@ PropertyValue<float> FillLayer::getFillOpacity(const optional<std::string>& klas
}
void FillLayer::setFillOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getFillOpacity(klass))
+ return;
impl->paint.fillOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> FillLayer::getDefaultFillColor() {
@@ -94,7 +101,10 @@ PropertyValue<Color> FillLayer::getFillColor(const optional<std::string>& klass)
}
void FillLayer::setFillColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getFillColor(klass))
+ return;
impl->paint.fillColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> FillLayer::getDefaultFillOutlineColor() {
@@ -106,7 +116,10 @@ PropertyValue<Color> FillLayer::getFillOutlineColor(const optional<std::string>&
}
void FillLayer::setFillOutlineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getFillOutlineColor(klass))
+ return;
impl->paint.fillOutlineColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> FillLayer::getDefaultFillTranslate() {
@@ -118,7 +131,10 @@ PropertyValue<std::array<float, 2>> FillLayer::getFillTranslate(const optional<s
}
void FillLayer::setFillTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ if (value == getFillTranslate(klass))
+ return;
impl->paint.fillTranslate.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<TranslateAnchorType> FillLayer::getDefaultFillTranslateAnchor() {
@@ -130,7 +146,10 @@ PropertyValue<TranslateAnchorType> FillLayer::getFillTranslateAnchor(const optio
}
void FillLayer::setFillTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ if (value == getFillTranslateAnchor(klass))
+ return;
impl->paint.fillTranslateAnchor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::string> FillLayer::getDefaultFillPattern() {
@@ -142,7 +161,10 @@ PropertyValue<std::string> FillLayer::getFillPattern(const optional<std::string>
}
void FillLayer::setFillPattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
+ if (value == getFillPattern(klass))
+ return;
impl->paint.fillPattern.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
} // namespace style
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 75a8de8e77..237a68aadf 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -65,6 +65,7 @@ const std::string& <%- camelize(type) %>Layer::getSourceLayer() const {
void <%- camelize(type) %>Layer::setFilter(const Filter& filter) {
impl->filter = filter;
+ impl->observer->onLayerFilterChanged(*this);
}
const Filter& <%- camelize(type) %>Layer::getFilter() const {
@@ -85,7 +86,10 @@ PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%-
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) {
+ if (value == get<%- camelize(property.name) %>())
+ return;
impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
<% } -%>
@@ -100,7 +104,10 @@ PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%-
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value, const optional<std::string>& klass) {
+ if (value == get<%- camelize(property.name) %>(klass))
+ return;
impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
<% } -%>
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index dbf4b682ba..100ee7247f 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -50,6 +50,7 @@ const std::string& LineLayer::getSourceLayer() const {
void LineLayer::setFilter(const Filter& filter) {
impl->filter = filter;
+ impl->observer->onLayerFilterChanged(*this);
}
const Filter& LineLayer::getFilter() const {
@@ -67,7 +68,10 @@ PropertyValue<LineCapType> LineLayer::getLineCap() const {
}
void LineLayer::setLineCap(PropertyValue<LineCapType> value) {
+ if (value == getLineCap())
+ return;
impl->layout.lineCap.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<LineJoinType> LineLayer::getDefaultLineJoin() {
return { LineJoinType::Miter };
@@ -78,7 +82,10 @@ PropertyValue<LineJoinType> LineLayer::getLineJoin() const {
}
void LineLayer::setLineJoin(PropertyValue<LineJoinType> value) {
+ if (value == getLineJoin())
+ return;
impl->layout.lineJoin.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> LineLayer::getDefaultLineMiterLimit() {
return { 2 };
@@ -89,7 +96,10 @@ PropertyValue<float> LineLayer::getLineMiterLimit() const {
}
void LineLayer::setLineMiterLimit(PropertyValue<float> value) {
+ if (value == getLineMiterLimit())
+ return;
impl->layout.lineMiterLimit.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> LineLayer::getDefaultLineRoundLimit() {
return { 1 };
@@ -100,7 +110,10 @@ PropertyValue<float> LineLayer::getLineRoundLimit() const {
}
void LineLayer::setLineRoundLimit(PropertyValue<float> value) {
+ if (value == getLineRoundLimit())
+ return;
impl->layout.lineRoundLimit.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
// Paint properties
@@ -114,7 +127,10 @@ PropertyValue<float> LineLayer::getLineOpacity(const optional<std::string>& klas
}
void LineLayer::setLineOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getLineOpacity(klass))
+ return;
impl->paint.lineOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> LineLayer::getDefaultLineColor() {
@@ -126,7 +142,10 @@ PropertyValue<Color> LineLayer::getLineColor(const optional<std::string>& klass)
}
void LineLayer::setLineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getLineColor(klass))
+ return;
impl->paint.lineColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> LineLayer::getDefaultLineTranslate() {
@@ -138,7 +157,10 @@ PropertyValue<std::array<float, 2>> LineLayer::getLineTranslate(const optional<s
}
void LineLayer::setLineTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ if (value == getLineTranslate(klass))
+ return;
impl->paint.lineTranslate.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<TranslateAnchorType> LineLayer::getDefaultLineTranslateAnchor() {
@@ -150,7 +172,10 @@ PropertyValue<TranslateAnchorType> LineLayer::getLineTranslateAnchor(const optio
}
void LineLayer::setLineTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ if (value == getLineTranslateAnchor(klass))
+ return;
impl->paint.lineTranslateAnchor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> LineLayer::getDefaultLineWidth() {
@@ -162,7 +187,10 @@ PropertyValue<float> LineLayer::getLineWidth(const optional<std::string>& klass)
}
void LineLayer::setLineWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getLineWidth(klass))
+ return;
impl->paint.lineWidth.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> LineLayer::getDefaultLineGapWidth() {
@@ -174,7 +202,10 @@ PropertyValue<float> LineLayer::getLineGapWidth(const optional<std::string>& kla
}
void LineLayer::setLineGapWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getLineGapWidth(klass))
+ return;
impl->paint.lineGapWidth.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> LineLayer::getDefaultLineOffset() {
@@ -186,7 +217,10 @@ PropertyValue<float> LineLayer::getLineOffset(const optional<std::string>& klass
}
void LineLayer::setLineOffset(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getLineOffset(klass))
+ return;
impl->paint.lineOffset.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> LineLayer::getDefaultLineBlur() {
@@ -198,7 +232,10 @@ PropertyValue<float> LineLayer::getLineBlur(const optional<std::string>& klass)
}
void LineLayer::setLineBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getLineBlur(klass))
+ return;
impl->paint.lineBlur.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::vector<float>> LineLayer::getDefaultLineDasharray() {
@@ -210,7 +247,10 @@ PropertyValue<std::vector<float>> LineLayer::getLineDasharray(const optional<std
}
void LineLayer::setLineDasharray(PropertyValue<std::vector<float>> value, const optional<std::string>& klass) {
+ if (value == getLineDasharray(klass))
+ return;
impl->paint.lineDasharray.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::string> LineLayer::getDefaultLinePattern() {
@@ -222,7 +262,10 @@ PropertyValue<std::string> LineLayer::getLinePattern(const optional<std::string>
}
void LineLayer::setLinePattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
+ if (value == getLinePattern(klass))
+ return;
impl->paint.linePattern.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
} // namespace style
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 084b29ee33..238bfef6e4 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -53,7 +53,10 @@ PropertyValue<float> RasterLayer::getRasterOpacity(const optional<std::string>&
}
void RasterLayer::setRasterOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterOpacity(klass))
+ return;
impl->paint.rasterOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> RasterLayer::getDefaultRasterHueRotate() {
@@ -65,7 +68,10 @@ PropertyValue<float> RasterLayer::getRasterHueRotate(const optional<std::string>
}
void RasterLayer::setRasterHueRotate(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterHueRotate(klass))
+ return;
impl->paint.rasterHueRotate.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> RasterLayer::getDefaultRasterBrightnessMin() {
@@ -77,7 +83,10 @@ PropertyValue<float> RasterLayer::getRasterBrightnessMin(const optional<std::str
}
void RasterLayer::setRasterBrightnessMin(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterBrightnessMin(klass))
+ return;
impl->paint.rasterBrightnessMin.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> RasterLayer::getDefaultRasterBrightnessMax() {
@@ -89,7 +98,10 @@ PropertyValue<float> RasterLayer::getRasterBrightnessMax(const optional<std::str
}
void RasterLayer::setRasterBrightnessMax(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterBrightnessMax(klass))
+ return;
impl->paint.rasterBrightnessMax.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> RasterLayer::getDefaultRasterSaturation() {
@@ -101,7 +113,10 @@ PropertyValue<float> RasterLayer::getRasterSaturation(const optional<std::string
}
void RasterLayer::setRasterSaturation(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterSaturation(klass))
+ return;
impl->paint.rasterSaturation.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> RasterLayer::getDefaultRasterContrast() {
@@ -113,7 +128,10 @@ PropertyValue<float> RasterLayer::getRasterContrast(const optional<std::string>&
}
void RasterLayer::setRasterContrast(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterContrast(klass))
+ return;
impl->paint.rasterContrast.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> RasterLayer::getDefaultRasterFadeDuration() {
@@ -125,7 +143,10 @@ PropertyValue<float> RasterLayer::getRasterFadeDuration(const optional<std::stri
}
void RasterLayer::setRasterFadeDuration(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getRasterFadeDuration(klass))
+ return;
impl->paint.rasterFadeDuration.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
} // namespace style
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 78fbfda6dd..c9fd2c0988 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -50,6 +50,7 @@ const std::string& SymbolLayer::getSourceLayer() const {
void SymbolLayer::setFilter(const Filter& filter) {
impl->filter = filter;
+ impl->observer->onLayerFilterChanged(*this);
}
const Filter& SymbolLayer::getFilter() const {
@@ -67,7 +68,10 @@ PropertyValue<SymbolPlacementType> SymbolLayer::getSymbolPlacement() const {
}
void SymbolLayer::setSymbolPlacement(PropertyValue<SymbolPlacementType> value) {
+ if (value == getSymbolPlacement())
+ return;
impl->layout.symbolPlacement.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultSymbolSpacing() {
return { 250 };
@@ -78,7 +82,10 @@ PropertyValue<float> SymbolLayer::getSymbolSpacing() const {
}
void SymbolLayer::setSymbolSpacing(PropertyValue<float> value) {
+ if (value == getSymbolSpacing())
+ return;
impl->layout.symbolSpacing.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultSymbolAvoidEdges() {
return { false };
@@ -89,7 +96,10 @@ PropertyValue<bool> SymbolLayer::getSymbolAvoidEdges() const {
}
void SymbolLayer::setSymbolAvoidEdges(PropertyValue<bool> value) {
+ if (value == getSymbolAvoidEdges())
+ return;
impl->layout.symbolAvoidEdges.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultIconAllowOverlap() {
return { false };
@@ -100,7 +110,10 @@ PropertyValue<bool> SymbolLayer::getIconAllowOverlap() const {
}
void SymbolLayer::setIconAllowOverlap(PropertyValue<bool> value) {
+ if (value == getIconAllowOverlap())
+ return;
impl->layout.iconAllowOverlap.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultIconIgnorePlacement() {
return { false };
@@ -111,7 +124,10 @@ PropertyValue<bool> SymbolLayer::getIconIgnorePlacement() const {
}
void SymbolLayer::setIconIgnorePlacement(PropertyValue<bool> value) {
+ if (value == getIconIgnorePlacement())
+ return;
impl->layout.iconIgnorePlacement.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultIconOptional() {
return { false };
@@ -122,7 +138,10 @@ PropertyValue<bool> SymbolLayer::getIconOptional() const {
}
void SymbolLayer::setIconOptional(PropertyValue<bool> value) {
+ if (value == getIconOptional())
+ return;
impl->layout.iconOptional.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<AlignmentType> SymbolLayer::getDefaultIconRotationAlignment() {
return { AlignmentType::Viewport };
@@ -133,7 +152,10 @@ PropertyValue<AlignmentType> SymbolLayer::getIconRotationAlignment() const {
}
void SymbolLayer::setIconRotationAlignment(PropertyValue<AlignmentType> value) {
+ if (value == getIconRotationAlignment())
+ return;
impl->layout.iconRotationAlignment.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultIconSize() {
return { 1 };
@@ -144,7 +166,10 @@ PropertyValue<float> SymbolLayer::getIconSize() const {
}
void SymbolLayer::setIconSize(PropertyValue<float> value) {
+ if (value == getIconSize())
+ return;
impl->layout.iconSize.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<IconTextFitType> SymbolLayer::getDefaultIconTextFit() {
return { IconTextFitType::None };
@@ -155,7 +180,10 @@ PropertyValue<IconTextFitType> SymbolLayer::getIconTextFit() const {
}
void SymbolLayer::setIconTextFit(PropertyValue<IconTextFitType> value) {
+ if (value == getIconTextFit())
+ return;
impl->layout.iconTextFit.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<std::array<float, 4>> SymbolLayer::getDefaultIconTextFitPadding() {
return { {{ 0, 0, 0, 0 }} };
@@ -166,7 +194,10 @@ PropertyValue<std::array<float, 4>> SymbolLayer::getIconTextFitPadding() const {
}
void SymbolLayer::setIconTextFitPadding(PropertyValue<std::array<float, 4>> value) {
+ if (value == getIconTextFitPadding())
+ return;
impl->layout.iconTextFitPadding.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<std::string> SymbolLayer::getDefaultIconImage() {
return { "" };
@@ -177,7 +208,10 @@ PropertyValue<std::string> SymbolLayer::getIconImage() const {
}
void SymbolLayer::setIconImage(PropertyValue<std::string> value) {
+ if (value == getIconImage())
+ return;
impl->layout.iconImage.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultIconRotate() {
return { 0 };
@@ -188,7 +222,10 @@ PropertyValue<float> SymbolLayer::getIconRotate() const {
}
void SymbolLayer::setIconRotate(PropertyValue<float> value) {
+ if (value == getIconRotate())
+ return;
impl->layout.iconRotate.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultIconPadding() {
return { 2 };
@@ -199,7 +236,10 @@ PropertyValue<float> SymbolLayer::getIconPadding() const {
}
void SymbolLayer::setIconPadding(PropertyValue<float> value) {
+ if (value == getIconPadding())
+ return;
impl->layout.iconPadding.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultIconKeepUpright() {
return { false };
@@ -210,7 +250,10 @@ PropertyValue<bool> SymbolLayer::getIconKeepUpright() const {
}
void SymbolLayer::setIconKeepUpright(PropertyValue<bool> value) {
+ if (value == getIconKeepUpright())
+ return;
impl->layout.iconKeepUpright.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconOffset() {
return { {{ 0, 0 }} };
@@ -221,7 +264,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getIconOffset() const {
}
void SymbolLayer::setIconOffset(PropertyValue<std::array<float, 2>> value) {
+ if (value == getIconOffset())
+ return;
impl->layout.iconOffset.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<AlignmentType> SymbolLayer::getDefaultTextPitchAlignment() {
return { AlignmentType::Undefined };
@@ -232,7 +278,10 @@ PropertyValue<AlignmentType> SymbolLayer::getTextPitchAlignment() const {
}
void SymbolLayer::setTextPitchAlignment(PropertyValue<AlignmentType> value) {
+ if (value == getTextPitchAlignment())
+ return;
impl->layout.textPitchAlignment.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<AlignmentType> SymbolLayer::getDefaultTextRotationAlignment() {
return { AlignmentType::Viewport };
@@ -243,7 +292,10 @@ PropertyValue<AlignmentType> SymbolLayer::getTextRotationAlignment() const {
}
void SymbolLayer::setTextRotationAlignment(PropertyValue<AlignmentType> value) {
+ if (value == getTextRotationAlignment())
+ return;
impl->layout.textRotationAlignment.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<std::string> SymbolLayer::getDefaultTextField() {
return { "" };
@@ -254,7 +306,10 @@ PropertyValue<std::string> SymbolLayer::getTextField() const {
}
void SymbolLayer::setTextField(PropertyValue<std::string> value) {
+ if (value == getTextField())
+ return;
impl->layout.textField.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<std::vector<std::string>> SymbolLayer::getDefaultTextFont() {
return { { "Open Sans Regular", "Arial Unicode MS Regular" } };
@@ -265,7 +320,10 @@ PropertyValue<std::vector<std::string>> SymbolLayer::getTextFont() const {
}
void SymbolLayer::setTextFont(PropertyValue<std::vector<std::string>> value) {
+ if (value == getTextFont())
+ return;
impl->layout.textFont.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextSize() {
return { 16 };
@@ -276,7 +334,10 @@ PropertyValue<float> SymbolLayer::getTextSize() const {
}
void SymbolLayer::setTextSize(PropertyValue<float> value) {
+ if (value == getTextSize())
+ return;
impl->layout.textSize.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextMaxWidth() {
return { 10 };
@@ -287,7 +348,10 @@ PropertyValue<float> SymbolLayer::getTextMaxWidth() const {
}
void SymbolLayer::setTextMaxWidth(PropertyValue<float> value) {
+ if (value == getTextMaxWidth())
+ return;
impl->layout.textMaxWidth.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextLineHeight() {
return { 1.2 };
@@ -298,7 +362,10 @@ PropertyValue<float> SymbolLayer::getTextLineHeight() const {
}
void SymbolLayer::setTextLineHeight(PropertyValue<float> value) {
+ if (value == getTextLineHeight())
+ return;
impl->layout.textLineHeight.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextLetterSpacing() {
return { 0 };
@@ -309,7 +376,10 @@ PropertyValue<float> SymbolLayer::getTextLetterSpacing() const {
}
void SymbolLayer::setTextLetterSpacing(PropertyValue<float> value) {
+ if (value == getTextLetterSpacing())
+ return;
impl->layout.textLetterSpacing.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<TextJustifyType> SymbolLayer::getDefaultTextJustify() {
return { TextJustifyType::Center };
@@ -320,7 +390,10 @@ PropertyValue<TextJustifyType> SymbolLayer::getTextJustify() const {
}
void SymbolLayer::setTextJustify(PropertyValue<TextJustifyType> value) {
+ if (value == getTextJustify())
+ return;
impl->layout.textJustify.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<TextAnchorType> SymbolLayer::getDefaultTextAnchor() {
return { TextAnchorType::Center };
@@ -331,7 +404,10 @@ PropertyValue<TextAnchorType> SymbolLayer::getTextAnchor() const {
}
void SymbolLayer::setTextAnchor(PropertyValue<TextAnchorType> value) {
+ if (value == getTextAnchor())
+ return;
impl->layout.textAnchor.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextMaxAngle() {
return { 45 };
@@ -342,7 +418,10 @@ PropertyValue<float> SymbolLayer::getTextMaxAngle() const {
}
void SymbolLayer::setTextMaxAngle(PropertyValue<float> value) {
+ if (value == getTextMaxAngle())
+ return;
impl->layout.textMaxAngle.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextRotate() {
return { 0 };
@@ -353,7 +432,10 @@ PropertyValue<float> SymbolLayer::getTextRotate() const {
}
void SymbolLayer::setTextRotate(PropertyValue<float> value) {
+ if (value == getTextRotate())
+ return;
impl->layout.textRotate.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextPadding() {
return { 2 };
@@ -364,7 +446,10 @@ PropertyValue<float> SymbolLayer::getTextPadding() const {
}
void SymbolLayer::setTextPadding(PropertyValue<float> value) {
+ if (value == getTextPadding())
+ return;
impl->layout.textPadding.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultTextKeepUpright() {
return { true };
@@ -375,7 +460,10 @@ PropertyValue<bool> SymbolLayer::getTextKeepUpright() const {
}
void SymbolLayer::setTextKeepUpright(PropertyValue<bool> value) {
+ if (value == getTextKeepUpright())
+ return;
impl->layout.textKeepUpright.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<TextTransformType> SymbolLayer::getDefaultTextTransform() {
return { TextTransformType::None };
@@ -386,7 +474,10 @@ PropertyValue<TextTransformType> SymbolLayer::getTextTransform() const {
}
void SymbolLayer::setTextTransform(PropertyValue<TextTransformType> value) {
+ if (value == getTextTransform())
+ return;
impl->layout.textTransform.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextOffset() {
return { {{ 0, 0 }} };
@@ -397,7 +488,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getTextOffset() const {
}
void SymbolLayer::setTextOffset(PropertyValue<std::array<float, 2>> value) {
+ if (value == getTextOffset())
+ return;
impl->layout.textOffset.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultTextAllowOverlap() {
return { false };
@@ -408,7 +502,10 @@ PropertyValue<bool> SymbolLayer::getTextAllowOverlap() const {
}
void SymbolLayer::setTextAllowOverlap(PropertyValue<bool> value) {
+ if (value == getTextAllowOverlap())
+ return;
impl->layout.textAllowOverlap.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultTextIgnorePlacement() {
return { false };
@@ -419,7 +516,10 @@ PropertyValue<bool> SymbolLayer::getTextIgnorePlacement() const {
}
void SymbolLayer::setTextIgnorePlacement(PropertyValue<bool> value) {
+ if (value == getTextIgnorePlacement())
+ return;
impl->layout.textIgnorePlacement.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
PropertyValue<bool> SymbolLayer::getDefaultTextOptional() {
return { false };
@@ -430,7 +530,10 @@ PropertyValue<bool> SymbolLayer::getTextOptional() const {
}
void SymbolLayer::setTextOptional(PropertyValue<bool> value) {
+ if (value == getTextOptional())
+ return;
impl->layout.textOptional.set(value);
+ impl->observer->onLayerLayoutPropertyChanged(*this);
}
// Paint properties
@@ -444,7 +547,10 @@ PropertyValue<float> SymbolLayer::getIconOpacity(const optional<std::string>& kl
}
void SymbolLayer::setIconOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getIconOpacity(klass))
+ return;
impl->paint.iconOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> SymbolLayer::getDefaultIconColor() {
@@ -456,7 +562,10 @@ PropertyValue<Color> SymbolLayer::getIconColor(const optional<std::string>& klas
}
void SymbolLayer::setIconColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getIconColor(klass))
+ return;
impl->paint.iconColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> SymbolLayer::getDefaultIconHaloColor() {
@@ -468,7 +577,10 @@ PropertyValue<Color> SymbolLayer::getIconHaloColor(const optional<std::string>&
}
void SymbolLayer::setIconHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getIconHaloColor(klass))
+ return;
impl->paint.iconHaloColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultIconHaloWidth() {
@@ -480,7 +592,10 @@ PropertyValue<float> SymbolLayer::getIconHaloWidth(const optional<std::string>&
}
void SymbolLayer::setIconHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getIconHaloWidth(klass))
+ return;
impl->paint.iconHaloWidth.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultIconHaloBlur() {
@@ -492,7 +607,10 @@ PropertyValue<float> SymbolLayer::getIconHaloBlur(const optional<std::string>& k
}
void SymbolLayer::setIconHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getIconHaloBlur(klass))
+ return;
impl->paint.iconHaloBlur.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconTranslate() {
@@ -504,7 +622,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getIconTranslate(const optional
}
void SymbolLayer::setIconTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ if (value == getIconTranslate(klass))
+ return;
impl->paint.iconTranslate.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<TranslateAnchorType> SymbolLayer::getDefaultIconTranslateAnchor() {
@@ -516,7 +637,10 @@ PropertyValue<TranslateAnchorType> SymbolLayer::getIconTranslateAnchor(const opt
}
void SymbolLayer::setIconTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ if (value == getIconTranslateAnchor(klass))
+ return;
impl->paint.iconTranslateAnchor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextOpacity() {
@@ -528,7 +652,10 @@ PropertyValue<float> SymbolLayer::getTextOpacity(const optional<std::string>& kl
}
void SymbolLayer::setTextOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getTextOpacity(klass))
+ return;
impl->paint.textOpacity.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> SymbolLayer::getDefaultTextColor() {
@@ -540,7 +667,10 @@ PropertyValue<Color> SymbolLayer::getTextColor(const optional<std::string>& klas
}
void SymbolLayer::setTextColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getTextColor(klass))
+ return;
impl->paint.textColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<Color> SymbolLayer::getDefaultTextHaloColor() {
@@ -552,7 +682,10 @@ PropertyValue<Color> SymbolLayer::getTextHaloColor(const optional<std::string>&
}
void SymbolLayer::setTextHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ if (value == getTextHaloColor(klass))
+ return;
impl->paint.textHaloColor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextHaloWidth() {
@@ -564,7 +697,10 @@ PropertyValue<float> SymbolLayer::getTextHaloWidth(const optional<std::string>&
}
void SymbolLayer::setTextHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getTextHaloWidth(klass))
+ return;
impl->paint.textHaloWidth.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<float> SymbolLayer::getDefaultTextHaloBlur() {
@@ -576,7 +712,10 @@ PropertyValue<float> SymbolLayer::getTextHaloBlur(const optional<std::string>& k
}
void SymbolLayer::setTextHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ if (value == getTextHaloBlur(klass))
+ return;
impl->paint.textHaloBlur.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextTranslate() {
@@ -588,7 +727,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getTextTranslate(const optional
}
void SymbolLayer::setTextTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ if (value == getTextTranslate(klass))
+ return;
impl->paint.textTranslate.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
PropertyValue<TranslateAnchorType> SymbolLayer::getDefaultTextTranslateAnchor() {
@@ -600,7 +742,10 @@ PropertyValue<TranslateAnchorType> SymbolLayer::getTextTranslateAnchor(const opt
}
void SymbolLayer::setTextTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ if (value == getTextTranslateAnchor(klass))
+ return;
impl->paint.textTranslateAnchor.set(value, klass);
+ impl->observer->onLayerPaintPropertyChanged(*this);
}
} // namespace style
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index bb0e2b61f6..99333b4a77 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -167,6 +167,8 @@ Layer* Style::addLayer(std::unique_ptr<Layer> layer, optional<std::string> befor
customLayer->impl->initialize();
}
+ layer->baseImpl->setObserver(this);
+
return layers.emplace(before ? findLayer(*before) : layers.end(), std::move(layer))->get();
}
@@ -481,6 +483,19 @@ void Style::onSpriteError(std::exception_ptr error) {
observer->onResourceError(error);
}
+void Style::onLayerFilterChanged(Layer&) {
+ // TODO: reload source
+}
+
+void Style::onLayerPaintPropertyChanged(Layer&) {
+ observer->onUpdate(Update::RecalculateStyle | Update::Classes);
+}
+
+void Style::onLayerLayoutPropertyChanged(Layer&) {
+ observer->onUpdate(Update::RecalculateStyle);
+ // TODO: reload source
+}
+
void Style::dumpDebugLogs() const {
for (const auto& source : sources) {
source->baseImpl->dumpDebugLogs();
diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp
index ca6526478e..9e9ec1a03c 100644
--- a/src/mbgl/style/style.hpp
+++ b/src/mbgl/style/style.hpp
@@ -3,6 +3,7 @@
#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/observer.hpp>
#include <mbgl/style/source_observer.hpp>
+#include <mbgl/style/layer_observer.hpp>
#include <mbgl/text/glyph_store_observer.hpp>
#include <mbgl/sprite/sprite_store_observer.hpp>
#include <mbgl/map/mode.hpp>
@@ -35,6 +36,7 @@ class QueryParameters;
class Style : public GlyphStoreObserver,
public SpriteStoreObserver,
public SourceObserver,
+ public LayerObserver,
public util::noncopyable {
public:
Style(FileSource&, float pixelRatio);
@@ -129,6 +131,11 @@ private:
void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) override;
void onTileUpdated(Source&, const OverscaledTileID&) override;
+ // LayerObserver implementation.
+ void onLayerFilterChanged(Layer&) override;
+ void onLayerPaintPropertyChanged(Layer&) override;
+ void onLayerLayoutPropertyChanged(Layer&) override;
+
Observer nullObserver;
Observer* observer = &nullObserver;