From 693c9f3641b3189b4cd439049904c95a516ae609 Mon Sep 17 00:00:00 2001 From: Anand Thakker Date: Thu, 6 Apr 2017 15:29:59 -0400 Subject: [core] Add DDS support for {text,icon}-size (#8593) * Update gl-js and generate style code * Factor out packUint8Pair() helper function * Draft implementation of DDS for {text,icon}-size Ports https://github.com/mapbox/mapbox-gl-js/pull/4455 * Fix text-size/composite-function-line-placement test * Refactor to PaintPropertyBinders-like strategy * Dedupe gl::Program construction * Use exponential function base for interpolation * Dedupe coveringZoomStops method * Fixup tests * Fix CI errors (hidden within #if block) --- include/mbgl/style/conversion/make_property_setters.hpp | 4 ++-- include/mbgl/style/data_driven_property_value.hpp | 9 +++++++++ include/mbgl/style/function/camera_function.hpp | 2 +- include/mbgl/style/layers/symbol_layer.hpp | 12 ++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/mbgl/style/conversion/make_property_setters.hpp b/include/mbgl/style/conversion/make_property_setters.hpp index 85bcd44cf3..105cca99d6 100644 --- a/include/mbgl/style/conversion/make_property_setters.hpp +++ b/include/mbgl/style/conversion/make_property_setters.hpp @@ -37,7 +37,7 @@ auto makeLayoutPropertySetters() { result["icon-ignore-placement"] = &setLayoutProperty, &SymbolLayer::setIconIgnorePlacement>; result["icon-optional"] = &setLayoutProperty, &SymbolLayer::setIconOptional>; result["icon-rotation-alignment"] = &setLayoutProperty, &SymbolLayer::setIconRotationAlignment>; - result["icon-size"] = &setLayoutProperty, &SymbolLayer::setIconSize>; + result["icon-size"] = &setLayoutProperty, &SymbolLayer::setIconSize>; result["icon-text-fit"] = &setLayoutProperty, &SymbolLayer::setIconTextFit>; result["icon-text-fit-padding"] = &setLayoutProperty>, &SymbolLayer::setIconTextFitPadding>; result["icon-image"] = &setLayoutProperty, &SymbolLayer::setIconImage>; @@ -49,7 +49,7 @@ auto makeLayoutPropertySetters() { result["text-rotation-alignment"] = &setLayoutProperty, &SymbolLayer::setTextRotationAlignment>; result["text-field"] = &setLayoutProperty, &SymbolLayer::setTextField>; result["text-font"] = &setLayoutProperty>, &SymbolLayer::setTextFont>; - result["text-size"] = &setLayoutProperty, &SymbolLayer::setTextSize>; + result["text-size"] = &setLayoutProperty, &SymbolLayer::setTextSize>; result["text-max-width"] = &setLayoutProperty, &SymbolLayer::setTextMaxWidth>; result["text-line-height"] = &setLayoutProperty, &SymbolLayer::setTextLineHeight>; result["text-letter-spacing"] = &setLayoutProperty, &SymbolLayer::setTextLetterSpacing>; diff --git a/include/mbgl/style/data_driven_property_value.hpp b/include/mbgl/style/data_driven_property_value.hpp index 3f9ac69436..5acf800840 100644 --- a/include/mbgl/style/data_driven_property_value.hpp +++ b/include/mbgl/style/data_driven_property_value.hpp @@ -45,6 +45,15 @@ public: bool isDataDriven() const { return value.template is>() || value.template is>(); } + + bool isZoomConstant() const { + return !value.template is>() && !value.template is>(); + } + + template + auto match(Ts&&... ts) const { + return value.match(std::forward(ts)...); + } template auto evaluate(const Evaluator& evaluator) const { diff --git a/include/mbgl/style/function/camera_function.hpp b/include/mbgl/style/function/camera_function.hpp index 5636b1663c..2e4aac2238 100644 --- a/include/mbgl/style/function/camera_function.hpp +++ b/include/mbgl/style/function/camera_function.hpp @@ -28,7 +28,7 @@ public: return s.evaluate(Value(double(zoom))).value_or(T()); }); } - + friend bool operator==(const CameraFunction& lhs, const CameraFunction& rhs) { return lhs.stops == rhs.stops; diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index 853a71bef2..6e29faa949 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -59,9 +59,9 @@ public: PropertyValue getIconRotationAlignment() const; void setIconRotationAlignment(PropertyValue); - static PropertyValue getDefaultIconSize(); - PropertyValue getIconSize() const; - void setIconSize(PropertyValue); + static DataDrivenPropertyValue getDefaultIconSize(); + DataDrivenPropertyValue getIconSize() const; + void setIconSize(DataDrivenPropertyValue); static PropertyValue getDefaultIconTextFit(); PropertyValue getIconTextFit() const; @@ -107,9 +107,9 @@ public: PropertyValue> getTextFont() const; void setTextFont(PropertyValue>); - static PropertyValue getDefaultTextSize(); - PropertyValue getTextSize() const; - void setTextSize(PropertyValue); + static DataDrivenPropertyValue getDefaultTextSize(); + DataDrivenPropertyValue getTextSize() const; + void setTextSize(DataDrivenPropertyValue); static PropertyValue getDefaultTextMaxWidth(); PropertyValue getTextMaxWidth() const; -- cgit v1.2.1