diff options
33 files changed, 426 insertions, 148 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 5c13e925be..c76bb3592f 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -229,6 +229,7 @@ set(MBGL_CORE_FILES src/mbgl/style/layer.cpp src/mbgl/style/layer_impl.cpp src/mbgl/style/layer_impl.hpp + src/mbgl/style/layer_observer.hpp src/mbgl/style/layout_property.hpp src/mbgl/style/observer.hpp src/mbgl/style/paint_property.hpp diff --git a/include/mbgl/style/function.hpp b/include/mbgl/style/function.hpp index 44ffa31079..97e880b280 100644 --- a/include/mbgl/style/function.hpp +++ b/include/mbgl/style/function.hpp @@ -21,7 +21,19 @@ public: private: float base = 1; std::vector<std::pair<float, T>> stops; + + template <class S> friend bool operator==(const Function<S>&, const Function<S>&); }; +template <class T> +bool operator==(const Function<T>& lhs, const Function<T>& rhs) { + return lhs.base == rhs.base && lhs.stops == rhs.stops; +} + +template <class T> +bool operator!=(const Function<T>& lhs, const Function<T>& rhs) { + return !(lhs == rhs); +} + } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp index d8f83a0fb3..d7e160fdca 100644 --- a/include/mbgl/style/property_value.hpp +++ b/include/mbgl/style/property_value.hpp @@ -8,12 +8,17 @@ namespace style { class Undefined {}; +inline bool operator==(const Undefined&, const Undefined&) { return true; } +inline bool operator!=(const Undefined&, const Undefined&) { return false; } + template <class T> class PropertyValue { private: using Value = variant<Undefined, T, Function<T>>; Value value; + template <class S> friend bool operator==(const PropertyValue<S>&, const PropertyValue<S>&); + public: PropertyValue() : value() {} PropertyValue( T constant) : value(constant) {} @@ -34,5 +39,15 @@ public: } }; +template <class T> +bool operator==(const PropertyValue<T>& lhs, const PropertyValue<T>& rhs) { + return lhs.value == rhs.value; +} + +template <class T> +bool operator!=(const PropertyValue<T>& lhs, const PropertyValue<T>& rhs) { + return !(lhs == rhs); +} + } // namespace style } // namespace mbgl diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java index 8c33fc976a..54d18962ce 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java @@ -24,18 +24,14 @@ public abstract class Layer { return; } - boolean updateClasses = false; for (Property<?> property : properties) { Object converted = convertValue(property.value); if (property instanceof PaintProperty) { - updateClasses = true; nativeSetPaintProperty(property.name, converted); } else { nativeSetLayoutProperty(property.name, converted); } } - - nativeUpdateStyle(updateClasses); } public String getId() { @@ -83,8 +79,6 @@ public abstract class Layer { protected native void nativeSetSourceLayer(String sourceLayer); - protected native void nativeUpdateStyle(boolean updateClasses); - protected native float nativeGetMinZoom(); protected native float nativeGetMaxZoom(); diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp index 4d5f90f67e..3c1fc0af62 100644 --- a/platform/android/src/style/layers/layer.cpp +++ b/platform/android/src/style/layers/layer.cpp @@ -63,19 +63,6 @@ namespace android { } } - void Layer::updateStyle(jni::JNIEnv&, jni::jboolean updateClasses) { - //Update the style only if attached - if (ownedLayer == nullptr) { - Update flags = mbgl::Update::RecalculateStyle; - if(updateClasses) { - flags = flags | mbgl::Update::Classes; - } - map->update(flags); - } else { - mbgl::Log::Debug(mbgl::Event::JNI, "Not updating as layer is not attached to map (yet)"); - } - } - void Layer::setFilter(jni::JNIEnv& env, jni::Array<jni::Object<>> jfilter) { using namespace mbgl::style; using namespace mbgl::style::conversion; @@ -155,7 +142,6 @@ namespace android { METHOD(&Layer::getId, "nativeGetId"), METHOD(&Layer::setLayoutProperty, "nativeSetLayoutProperty"), METHOD(&Layer::setPaintProperty, "nativeSetPaintProperty"), - METHOD(&Layer::updateStyle, "nativeUpdateStyle"), METHOD(&Layer::setFilter, "nativeSetFilter"), METHOD(&Layer::setSourceLayer, "nativeSetSourceLayer"), METHOD(&Layer::getMinZoom, "nativeGetMinZoom"), diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 29040d3c54..4a875f784a 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -219,7 +219,6 @@ global.setterImplementation = function(property, layerType) { break; default: throw new Error(`unknown type for ${property.name}`) } - implementation += "\n [self update];" return implementation; } diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 32e2e7847e..adfa31e4ed 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGLBackgroundStyleLayer.h" @@ -33,7 +33,6 @@ - (void)setBackgroundColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)backgroundColor { self.layer->setBackgroundColor(backgroundColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)backgroundColor { @@ -42,7 +41,6 @@ - (void)setBackgroundPattern:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)backgroundPattern { self.layer->setBackgroundPattern(backgroundPattern.mbgl_stringPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)backgroundPattern { @@ -51,7 +49,6 @@ - (void)setBackgroundOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)backgroundOpacity { self.layer->setBackgroundOpacity(backgroundOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)backgroundOpacity { diff --git a/platform/darwin/src/MGLBaseStyleLayer.mm b/platform/darwin/src/MGLBaseStyleLayer.mm index d9d57d661a..a747467739 100644 --- a/platform/darwin/src/MGLBaseStyleLayer.mm +++ b/platform/darwin/src/MGLBaseStyleLayer.mm @@ -1,6 +1,5 @@ #import "MGLBaseStyleLayer.h" -#import "MGLBaseStyleLayer_Private.h" #import "MGLStyleLayer_Private.h" #import "MGLMapView_Private.h" @@ -15,14 +14,6 @@ @synthesize mapView; @synthesize layer; -- (void)update -{ - // A style layer's map view can be nil when first created at runtime - // before being added to a map style. In these cases, just no-op since - // the addition of the layer will trigger a visual refresh. - if (self.mapView) self.mapView.mbglMap->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes); -} - - (void)setVisible:(BOOL)visible { mbgl::style::VisibilityType v = visible diff --git a/platform/darwin/src/MGLBaseStyleLayer_Private.h b/platform/darwin/src/MGLBaseStyleLayer_Private.h deleted file mode 100644 index 0cbb076b35..0000000000 --- a/platform/darwin/src/MGLBaseStyleLayer_Private.h +++ /dev/null @@ -1,9 +0,0 @@ -#import "MGLBaseStyleLayer.h" - -#import "NSPredicate+MGLAdditions.h" - -@interface MGLBaseStyleLayer (MGLBaseStyleLayer_Private) - -- (void)update; - -@end diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 6c038318cc..a906407486 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGLCircleStyleLayer.h" @@ -43,7 +43,6 @@ - (void)setCircleRadius:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleRadius { self.layer->setCircleRadius(circleRadius.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)circleRadius { @@ -52,7 +51,6 @@ - (void)setCircleColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleColor { self.layer->setCircleColor(circleColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)circleColor { @@ -61,7 +59,6 @@ - (void)setCircleBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleBlur { self.layer->setCircleBlur(circleBlur.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)circleBlur { @@ -70,7 +67,6 @@ - (void)setCircleOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleOpacity { self.layer->setCircleOpacity(circleOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)circleOpacity { @@ -79,7 +75,6 @@ - (void)setCircleTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleTranslate { self.layer->setCircleTranslate(circleTranslate.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)circleTranslate { @@ -88,7 +83,6 @@ - (void)setCircleTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleTranslateAnchor { MGLSetEnumProperty(circleTranslateAnchor, CircleTranslateAnchor, TranslateAnchorType, MGLCircleStyleLayerCircleTranslateAnchor); - [self update]; } - (id <MGLStyleAttributeValue>)circleTranslateAnchor { @@ -97,7 +91,6 @@ - (void)setCirclePitchScale:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circlePitchScale { MGLSetEnumProperty(circlePitchScale, CirclePitchScale, CirclePitchScaleType, MGLCircleStyleLayerCirclePitchScale); - [self update]; } - (id <MGLStyleAttributeValue>)circlePitchScale { diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index c54ddba428..6867c50f16 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGLFillStyleLayer.h" @@ -43,7 +43,6 @@ - (void)setFillAntialias:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillAntialias { self.layer->setFillAntialias(fillAntialias.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)fillAntialias { @@ -52,7 +51,6 @@ - (void)setFillOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillOpacity { self.layer->setFillOpacity(fillOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)fillOpacity { @@ -61,7 +59,6 @@ - (void)setFillColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillColor { self.layer->setFillColor(fillColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)fillColor { @@ -70,7 +67,6 @@ - (void)setFillOutlineColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillOutlineColor { self.layer->setFillOutlineColor(fillOutlineColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)fillOutlineColor { @@ -79,7 +75,6 @@ - (void)setFillTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillTranslate { self.layer->setFillTranslate(fillTranslate.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)fillTranslate { @@ -88,7 +83,6 @@ - (void)setFillTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillTranslateAnchor { MGLSetEnumProperty(fillTranslateAnchor, FillTranslateAnchor, TranslateAnchorType, MGLFillStyleLayerFillTranslateAnchor); - [self update]; } - (id <MGLStyleAttributeValue>)fillTranslateAnchor { @@ -97,7 +91,6 @@ - (void)setFillPattern:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillPattern { self.layer->setFillPattern(fillPattern.mbgl_stringPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)fillPattern { diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index ce9ad75f87..8c5af877fe 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGLLineStyleLayer.h" @@ -43,7 +43,6 @@ - (void)setLineCap:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineCap { MGLSetEnumProperty(lineCap, LineCap, LineCapType, MGLLineStyleLayerLineCap); - [self update]; } - (id <MGLStyleAttributeValue>)lineCap { @@ -52,7 +51,6 @@ - (void)setLineJoin:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineJoin { MGLSetEnumProperty(lineJoin, LineJoin, LineJoinType, MGLLineStyleLayerLineJoin); - [self update]; } - (id <MGLStyleAttributeValue>)lineJoin { @@ -61,7 +59,6 @@ - (void)setLineMiterLimit:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineMiterLimit { self.layer->setLineMiterLimit(lineMiterLimit.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineMiterLimit { @@ -70,7 +67,6 @@ - (void)setLineRoundLimit:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineRoundLimit { self.layer->setLineRoundLimit(lineRoundLimit.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineRoundLimit { @@ -81,7 +77,6 @@ - (void)setLineOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineOpacity { self.layer->setLineOpacity(lineOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineOpacity { @@ -90,7 +85,6 @@ - (void)setLineColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineColor { self.layer->setLineColor(lineColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineColor { @@ -99,7 +93,6 @@ - (void)setLineTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineTranslate { self.layer->setLineTranslate(lineTranslate.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineTranslate { @@ -108,7 +101,6 @@ - (void)setLineTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineTranslateAnchor { MGLSetEnumProperty(lineTranslateAnchor, LineTranslateAnchor, TranslateAnchorType, MGLLineStyleLayerLineTranslateAnchor); - [self update]; } - (id <MGLStyleAttributeValue>)lineTranslateAnchor { @@ -117,7 +109,6 @@ - (void)setLineWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineWidth { self.layer->setLineWidth(lineWidth.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineWidth { @@ -126,7 +117,6 @@ - (void)setLineGapWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineGapWidth { self.layer->setLineGapWidth(lineGapWidth.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineGapWidth { @@ -135,7 +125,6 @@ - (void)setLineOffset:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineOffset { self.layer->setLineOffset(lineOffset.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineOffset { @@ -144,7 +133,6 @@ - (void)setLineBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineBlur { self.layer->setLineBlur(lineBlur.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineBlur { @@ -153,7 +141,6 @@ - (void)setLineDasharray:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineDasharray { self.layer->setLineDasharray(lineDasharray.mbgl_numberArrayPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)lineDasharray { @@ -162,7 +149,6 @@ - (void)setLinePattern:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)linePattern { self.layer->setLinePattern(linePattern.mbgl_stringPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)linePattern { diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index 37368c6577..dc70dfbde7 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGLRasterStyleLayer.h" @@ -33,7 +33,6 @@ - (void)setRasterOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterOpacity { self.layer->setRasterOpacity(rasterOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterOpacity { @@ -42,7 +41,6 @@ - (void)setRasterHueRotate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterHueRotate { self.layer->setRasterHueRotate(rasterHueRotate.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterHueRotate { @@ -51,7 +49,6 @@ - (void)setRasterBrightnessMin:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterBrightnessMin { self.layer->setRasterBrightnessMin(rasterBrightnessMin.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterBrightnessMin { @@ -60,7 +57,6 @@ - (void)setRasterBrightnessMax:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterBrightnessMax { self.layer->setRasterBrightnessMax(rasterBrightnessMax.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterBrightnessMax { @@ -69,7 +65,6 @@ - (void)setRasterSaturation:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterSaturation { self.layer->setRasterSaturation(rasterSaturation.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterSaturation { @@ -78,7 +73,6 @@ - (void)setRasterContrast:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterContrast { self.layer->setRasterContrast(rasterContrast.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterContrast { @@ -87,7 +81,6 @@ - (void)setRasterFadeDuration:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterFadeDuration { self.layer->setRasterFadeDuration(rasterFadeDuration.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)rasterFadeDuration { diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 4e59c3c6cb..4615aeeb9b 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -6,7 +6,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGL<%- camelize(type) %>StyleLayer.h" diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index b0553ea425..1fb3a0a587 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLBaseStyleLayer_Private.h" +#import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleAttributeValue.h" #import "MGLSymbolStyleLayer.h" @@ -43,7 +43,6 @@ - (void)setSymbolPlacement:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)symbolPlacement { MGLSetEnumProperty(symbolPlacement, SymbolPlacement, SymbolPlacementType, MGLSymbolStyleLayerSymbolPlacement); - [self update]; } - (id <MGLStyleAttributeValue>)symbolPlacement { @@ -52,7 +51,6 @@ - (void)setSymbolSpacing:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)symbolSpacing { self.layer->setSymbolSpacing(symbolSpacing.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)symbolSpacing { @@ -61,7 +59,6 @@ - (void)setSymbolAvoidEdges:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)symbolAvoidEdges { self.layer->setSymbolAvoidEdges(symbolAvoidEdges.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)symbolAvoidEdges { @@ -70,7 +67,6 @@ - (void)setIconAllowOverlap:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconAllowOverlap { self.layer->setIconAllowOverlap(iconAllowOverlap.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconAllowOverlap { @@ -79,7 +75,6 @@ - (void)setIconIgnorePlacement:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconIgnorePlacement { self.layer->setIconIgnorePlacement(iconIgnorePlacement.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconIgnorePlacement { @@ -88,7 +83,6 @@ - (void)setIconOptional:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconOptional { self.layer->setIconOptional(iconOptional.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconOptional { @@ -97,7 +91,6 @@ - (void)setIconRotationAlignment:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconRotationAlignment { MGLSetEnumProperty(iconRotationAlignment, IconRotationAlignment, AlignmentType, MGLSymbolStyleLayerIconRotationAlignment); - [self update]; } - (id <MGLStyleAttributeValue>)iconRotationAlignment { @@ -106,7 +99,6 @@ - (void)setIconSize:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconSize { self.layer->setIconSize(iconSize.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconSize { @@ -115,7 +107,6 @@ - (void)setIconTextFit:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTextFit { MGLSetEnumProperty(iconTextFit, IconTextFit, IconTextFitType, MGLSymbolStyleLayerIconTextFit); - [self update]; } - (id <MGLStyleAttributeValue>)iconTextFit { @@ -124,7 +115,6 @@ - (void)setIconTextFitPadding:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTextFitPadding { self.layer->setIconTextFitPadding(iconTextFitPadding.mbgl_paddingPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconTextFitPadding { @@ -133,7 +123,6 @@ - (void)setIconImage:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconImage { self.layer->setIconImage(iconImage.mbgl_stringPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconImage { @@ -142,7 +131,6 @@ - (void)setIconRotate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconRotate { self.layer->setIconRotate(iconRotate.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconRotate { @@ -151,7 +139,6 @@ - (void)setIconPadding:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconPadding { self.layer->setIconPadding(iconPadding.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconPadding { @@ -160,7 +147,6 @@ - (void)setIconKeepUpright:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconKeepUpright { self.layer->setIconKeepUpright(iconKeepUpright.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconKeepUpright { @@ -169,7 +155,6 @@ - (void)setIconOffset:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconOffset { self.layer->setIconOffset(iconOffset.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconOffset { @@ -178,7 +163,6 @@ - (void)setTextPitchAlignment:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textPitchAlignment { MGLSetEnumProperty(textPitchAlignment, TextPitchAlignment, AlignmentType, MGLSymbolStyleLayerTextPitchAlignment); - [self update]; } - (id <MGLStyleAttributeValue>)textPitchAlignment { @@ -187,7 +171,6 @@ - (void)setTextRotationAlignment:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textRotationAlignment { MGLSetEnumProperty(textRotationAlignment, TextRotationAlignment, AlignmentType, MGLSymbolStyleLayerTextRotationAlignment); - [self update]; } - (id <MGLStyleAttributeValue>)textRotationAlignment { @@ -196,7 +179,6 @@ - (void)setTextField:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textField { self.layer->setTextField(textField.mbgl_stringPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textField { @@ -205,7 +187,6 @@ - (void)setTextFont:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textFont { self.layer->setTextFont(textFont.mbgl_stringArrayPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textFont { @@ -214,7 +195,6 @@ - (void)setTextSize:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textSize { self.layer->setTextSize(textSize.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textSize { @@ -223,7 +203,6 @@ - (void)setTextMaxWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textMaxWidth { self.layer->setTextMaxWidth(textMaxWidth.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textMaxWidth { @@ -232,7 +211,6 @@ - (void)setTextLineHeight:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textLineHeight { self.layer->setTextLineHeight(textLineHeight.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textLineHeight { @@ -241,7 +219,6 @@ - (void)setTextLetterSpacing:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textLetterSpacing { self.layer->setTextLetterSpacing(textLetterSpacing.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textLetterSpacing { @@ -250,7 +227,6 @@ - (void)setTextJustify:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textJustify { MGLSetEnumProperty(textJustify, TextJustify, TextJustifyType, MGLSymbolStyleLayerTextJustify); - [self update]; } - (id <MGLStyleAttributeValue>)textJustify { @@ -259,7 +235,6 @@ - (void)setTextAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textAnchor { MGLSetEnumProperty(textAnchor, TextAnchor, TextAnchorType, MGLSymbolStyleLayerTextAnchor); - [self update]; } - (id <MGLStyleAttributeValue>)textAnchor { @@ -268,7 +243,6 @@ - (void)setTextMaxAngle:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textMaxAngle { self.layer->setTextMaxAngle(textMaxAngle.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textMaxAngle { @@ -277,7 +251,6 @@ - (void)setTextRotate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textRotate { self.layer->setTextRotate(textRotate.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textRotate { @@ -286,7 +259,6 @@ - (void)setTextPadding:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textPadding { self.layer->setTextPadding(textPadding.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textPadding { @@ -295,7 +267,6 @@ - (void)setTextKeepUpright:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textKeepUpright { self.layer->setTextKeepUpright(textKeepUpright.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textKeepUpright { @@ -304,7 +275,6 @@ - (void)setTextTransform:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textTransform { MGLSetEnumProperty(textTransform, TextTransform, TextTransformType, MGLSymbolStyleLayerTextTransform); - [self update]; } - (id <MGLStyleAttributeValue>)textTransform { @@ -313,7 +283,6 @@ - (void)setTextOffset:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textOffset { self.layer->setTextOffset(textOffset.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textOffset { @@ -322,7 +291,6 @@ - (void)setTextAllowOverlap:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textAllowOverlap { self.layer->setTextAllowOverlap(textAllowOverlap.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textAllowOverlap { @@ -331,7 +299,6 @@ - (void)setTextIgnorePlacement:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textIgnorePlacement { self.layer->setTextIgnorePlacement(textIgnorePlacement.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textIgnorePlacement { @@ -340,7 +307,6 @@ - (void)setTextOptional:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textOptional { self.layer->setTextOptional(textOptional.mbgl_boolPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textOptional { @@ -351,7 +317,6 @@ - (void)setIconOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconOpacity { self.layer->setIconOpacity(iconOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconOpacity { @@ -360,7 +325,6 @@ - (void)setIconColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconColor { self.layer->setIconColor(iconColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconColor { @@ -369,7 +333,6 @@ - (void)setIconHaloColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconHaloColor { self.layer->setIconHaloColor(iconHaloColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconHaloColor { @@ -378,7 +341,6 @@ - (void)setIconHaloWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconHaloWidth { self.layer->setIconHaloWidth(iconHaloWidth.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconHaloWidth { @@ -387,7 +349,6 @@ - (void)setIconHaloBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconHaloBlur { self.layer->setIconHaloBlur(iconHaloBlur.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconHaloBlur { @@ -396,7 +357,6 @@ - (void)setIconTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTranslate { self.layer->setIconTranslate(iconTranslate.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)iconTranslate { @@ -405,7 +365,6 @@ - (void)setIconTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTranslateAnchor { MGLSetEnumProperty(iconTranslateAnchor, IconTranslateAnchor, TranslateAnchorType, MGLSymbolStyleLayerIconTranslateAnchor); - [self update]; } - (id <MGLStyleAttributeValue>)iconTranslateAnchor { @@ -414,7 +373,6 @@ - (void)setTextOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textOpacity { self.layer->setTextOpacity(textOpacity.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textOpacity { @@ -423,7 +381,6 @@ - (void)setTextColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textColor { self.layer->setTextColor(textColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textColor { @@ -432,7 +389,6 @@ - (void)setTextHaloColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textHaloColor { self.layer->setTextHaloColor(textHaloColor.mbgl_colorPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textHaloColor { @@ -441,7 +397,6 @@ - (void)setTextHaloWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textHaloWidth { self.layer->setTextHaloWidth(textHaloWidth.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textHaloWidth { @@ -450,7 +405,6 @@ - (void)setTextHaloBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textHaloBlur { self.layer->setTextHaloBlur(textHaloBlur.mbgl_floatPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textHaloBlur { @@ -459,7 +413,6 @@ - (void)setTextTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textTranslate { self.layer->setTextTranslate(textTranslate.mbgl_offsetPropertyValue); - [self update]; } - (id <MGLStyleAttributeValue>)textTranslate { @@ -468,7 +421,6 @@ - (void)setTextTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textTranslateAnchor { MGLSetEnumProperty(textTranslateAnchor, TextTranslateAnchor, TranslateAnchorType, MGLSymbolStyleLayerTextTranslateAnchor); - [self update]; } - (id <MGLStyleAttributeValue>)textTranslateAnchor { diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 6c71b1b3df..90e0f1cfbc 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -353,8 +353,6 @@ DAA4E4341CBB730400178DFB /* MGLFaux3DUserLocationAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88484E1CBAFB9800AB86E3 /* MGLFaux3DUserLocationAnnotationView.m */; }; DAA4E4351CBB730400178DFB /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88488A1CBB037E00AB86E3 /* SMCalloutView.m */; }; DAABF73D1CBC59BB005B1825 /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAABF73B1CBC59BB005B1825 /* libmbgl-core.a */; }; - DAB4F8301D63DD7600E27738 /* MGLBaseStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAB4F82F1D63DD7600E27738 /* MGLBaseStyleLayer_Private.h */; }; - DAB4F8311D63DD7600E27738 /* MGLBaseStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAB4F82F1D63DD7600E27738 /* MGLBaseStyleLayer_Private.h */; }; DABCABAC1CB80692000A7C39 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DABCABAB1CB80692000A7C39 /* main.m */; }; DABCABAF1CB80692000A7C39 /* MBXBenchAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DABCABAE1CB80692000A7C39 /* MBXBenchAppDelegate.m */; }; DABCABB21CB80692000A7C39 /* MBXBenchViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = DABCABB11CB80692000A7C39 /* MBXBenchViewController.mm */; }; @@ -729,7 +727,6 @@ DAA4E4061CBB5CBF00178DFB /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; DAA4E4131CBB71D400178DFB /* libMapbox.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMapbox.a; sourceTree = BUILT_PRODUCTS_DIR; }; DAABF73B1CBC59BB005B1825 /* libmbgl-core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libmbgl-core.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - DAB4F82F1D63DD7600E27738 /* MGLBaseStyleLayer_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLBaseStyleLayer_Private.h; sourceTree = "<group>"; }; DABCABA81CB80692000A7C39 /* Bench GL.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Bench GL.app"; sourceTree = BUILT_PRODUCTS_DIR; }; DABCABAB1CB80692000A7C39 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; DABCABAD1CB80692000A7C39 /* MBXBenchAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXBenchAppDelegate.h; sourceTree = "<group>"; }; @@ -836,7 +833,6 @@ 353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */, 35136D441D42275100C20EFD /* MGLSymbolStyleLayer.mm */, 3538AA1B1D542239008EC33D /* MGLBaseStyleLayer.h */, - DAB4F82F1D63DD7600E27738 /* MGLBaseStyleLayer_Private.h */, 3538AA1C1D542239008EC33D /* MGLBaseStyleLayer.mm */, ); name = Layers; @@ -1391,7 +1387,6 @@ 35E0CFE61D3E501500188327 /* MGLStyle_Private.h in Headers */, 3510FFF01D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, 353AFA141D65AB17005A69F4 /* NSDate+MGLAdditions.h in Headers */, - DAB4F8301D63DD7600E27738 /* MGLBaseStyleLayer_Private.h in Headers */, 3593E5261D529EDC006D9365 /* UIColor+MGLStyleAttributeAdditions_Private.h in Headers */, 35599DF01D46F3A60048254D /* MGLStyleAttributeValue.h in Headers */, DA8848531CBAFB9800AB86E3 /* MGLCompactCalloutView.h in Headers */, @@ -1494,7 +1489,6 @@ DABFB8611CBE99E500D62B32 /* MGLMultiPoint.h in Headers */, 3510FFF11D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, 35E0CFE71D3E501500188327 /* MGLStyle_Private.h in Headers */, - DAB4F8311D63DD7600E27738 /* MGLBaseStyleLayer_Private.h in Headers */, DABFB86D1CBE9A0F00D62B32 /* MGLAnnotationImage.h in Headers */, DABFB8721CBE9A0F00D62B32 /* MGLUserLocation.h in Headers */, 3566C7721D4A9198008152BC /* MGLSource_Private.h in Headers */, diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 2fb0630ea8..92a130594e 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -98,7 +98,6 @@ DA8F25B21D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8F25A61D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA8F25B31D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA8F25A71D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.mm */; }; DA8F25B41D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8F25A81D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions_Private.h */; }; - DAB4F8331D63DD8900E27738 /* MGLBaseStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAB4F8321D63DD8900E27738 /* MGLBaseStyleLayer_Private.h */; }; DAC2ABC51CC6D343006D18C4 /* MGLAnnotationImage_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DAC2ABC41CC6D343006D18C4 /* MGLAnnotationImage_Private.h */; }; DACC22141CF3D3E200D220D9 /* MGLFeature.h in Headers */ = {isa = PBXBuildFile; fileRef = DACC22121CF3D3E200D220D9 /* MGLFeature.h */; settings = {ATTRIBUTES = (Public, ); }; }; DACC22151CF3D3E200D220D9 /* MGLFeature.mm in Sources */ = {isa = PBXBuildFile; fileRef = DACC22131CF3D3E200D220D9 /* MGLFeature.mm */; }; @@ -325,7 +324,6 @@ DA8F25B51D51D2240010E6B5 /* MGLRuntimeStylingTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLRuntimeStylingTests.m.ejs; sourceTree = "<group>"; }; DA8F25B61D51D2240010E6B5 /* MGLStyleLayer.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.h.ejs; sourceTree = "<group>"; }; DA8F25B71D51D2240010E6B5 /* MGLStyleLayer.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.mm.ejs; sourceTree = "<group>"; }; - DAB4F8321D63DD8900E27738 /* MGLBaseStyleLayer_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLBaseStyleLayer_Private.h; sourceTree = "<group>"; }; DAC2ABC41CC6D343006D18C4 /* MGLAnnotationImage_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationImage_Private.h; sourceTree = "<group>"; }; DACC22121CF3D3E200D220D9 /* MGLFeature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFeature.h; sourceTree = "<group>"; }; DACC22131CF3D3E200D220D9 /* MGLFeature.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFeature.mm; sourceTree = "<group>"; }; @@ -453,7 +451,6 @@ isa = PBXGroup; children = ( 3538AA211D542685008EC33D /* MGLBaseStyleLayer.h */, - DAB4F8321D63DD8900E27738 /* MGLBaseStyleLayer_Private.h */, 3538AA221D542685008EC33D /* MGLBaseStyleLayer.mm */, DA8F25851D51C9E10010E6B5 /* MGLBackgroundStyleLayer.h */, DA8F25861D51C9E10010E6B5 /* MGLBackgroundStyleLayer.mm */, @@ -922,7 +919,6 @@ DAE6C3A51CC31E9400DB3429 /* MGLMapView+IBAdditions.h in Headers */, DA35A2AD1CCA091800E826B2 /* MGLCompassDirectionFormatter.h in Headers */, 352742851D4C244700A1ECE6 /* MGLRasterSource.h in Headers */, - DAB4F8331D63DD8900E27738 /* MGLBaseStyleLayer_Private.h in Headers */, DACC22181CF3D4F700D220D9 /* MGLFeature_Private.h in Headers */, 352742891D4C245800A1ECE6 /* MGLGeoJSONSource.h in Headers */, DAE6C3671CC31E0400DB3429 /* MGLStyle.h in Headers */, diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index f737ddfd86..31259f8972 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -579,7 +579,6 @@ void NodeMap::SetLayoutProperty(const Nan::FunctionCallbackInfo<v8::Value>& info return Nan::ThrowTypeError(error->message.c_str()); } - nodeMap->map->update(mbgl::Update::RecalculateStyle); info.GetReturnValue().SetUndefined(); } @@ -617,7 +616,6 @@ void NodeMap::SetPaintProperty(const Nan::FunctionCallbackInfo<v8::Value>& info) return Nan::ThrowTypeError(error->message.c_str()); } - nodeMap->map->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes); info.GetReturnValue().SetUndefined(); } diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 111e92d1f0..f7f1a7fb5e 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -541,8 +541,6 @@ void QMapboxGL::setLayoutProperty(const QString& layer_, const QString& property qWarning() << "Error setting layout property:" << layer_ << "-" << property; return; } - - d_ptr->mapObj->update(mbgl::Update::RecalculateStyle); } void QMapboxGL::setPaintProperty(const QString& layer_, const QString& property, const QVariant& value, const QString& klass_) @@ -564,8 +562,6 @@ void QMapboxGL::setPaintProperty(const QString& layer_, const QString& property, qWarning() << "Error setting paint property:" << layer_ << "-" << property; return; } - - d_ptr->mapObj->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes); } bool QMapboxGL::isRotating() const 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; diff --git a/test/src/mbgl/test/stub_layer_observer.hpp b/test/src/mbgl/test/stub_layer_observer.hpp new file mode 100644 index 0000000000..500103055d --- /dev/null +++ b/test/src/mbgl/test/stub_layer_observer.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include <mbgl/style/layer_observer.hpp> + +using namespace mbgl; +using namespace mbgl::style; + +/** + * An implementation of style::LayerObserver that forwards all methods to dynamically-settable lambas. + */ +class StubLayerObserver : public style::LayerObserver { +public: + void onLayerFilterChanged(Layer& layer) override { + if (layerFilterChanged) layerFilterChanged(layer); + } + + void onLayerPaintPropertyChanged(Layer& layer) override { + if (layerPaintPropertyChanged) layerPaintPropertyChanged(layer); + } + + void onLayerLayoutPropertyChanged(Layer& layer) override { + if (layerLayoutPropertyChanged) layerLayoutPropertyChanged(layer); + } + + std::function<void (Layer&)> layerFilterChanged; + std::function<void (Layer&)> layerPaintPropertyChanged; + std::function<void (Layer&)> layerLayoutPropertyChanged; +}; diff --git a/test/style/style_layer.cpp b/test/style/style_layer.cpp index 9c6a6e924a..0d2ed88edd 100644 --- a/test/style/style_layer.cpp +++ b/test/style/style_layer.cpp @@ -1,4 +1,5 @@ #include <mbgl/test/util.hpp> +#include <mbgl/test/stub_layer_observer.hpp> #include <mbgl/style/layers/background_layer.hpp> #include <mbgl/style/layers/background_layer_impl.hpp> #include <mbgl/style/layers/circle_layer.hpp> @@ -210,3 +211,46 @@ TEST(Layer, RasterProperties) { layer->setRasterFadeDuration(duration); EXPECT_EQ(layer->getRasterFadeDuration().asConstant(), duration.asConstant()); } + +TEST(Layer, Observer) { + auto layer = std::make_unique<LineLayer>("line", "source"); + StubLayerObserver observer; + layer->baseImpl->setObserver(&observer); + + // Notifies observer on filter change. + bool filterChanged = false; + observer.layerFilterChanged = [&] (Layer& layer_) { + EXPECT_EQ(layer.get(), &layer_); + filterChanged = true; + }; + layer->setFilter(NullFilter()); + EXPECT_TRUE(filterChanged); + + // Notifies observer on paint property change. + bool paintPropertyChanged = false; + observer.layerPaintPropertyChanged = [&] (Layer& layer_) { + EXPECT_EQ(layer.get(), &layer_); + paintPropertyChanged = true; + }; + layer->setLineColor(color); + EXPECT_TRUE(paintPropertyChanged); + + // Notifies observer on layout property change. + bool layoutPropertyChanged = false; + observer.layerLayoutPropertyChanged = [&] (Layer& layer_) { + EXPECT_EQ(layer.get(), &layer_); + layoutPropertyChanged = true; + }; + layer->setLineCap(lineCap); + EXPECT_TRUE(layoutPropertyChanged); + + // Does not notify observer on no-op paint property change. + paintPropertyChanged = false; + layer->setLineColor(color); + EXPECT_FALSE(paintPropertyChanged); + + // Does not notify observer on no-op layout property change. + layoutPropertyChanged = false; + layer->setLineCap(lineCap); + EXPECT_FALSE(layoutPropertyChanged); +} |