diff options
author | Anand Thakker <anandthakker@users.noreply.github.com> | 2017-04-06 15:29:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-06 15:29:59 -0400 |
commit | 693c9f3641b3189b4cd439049904c95a516ae609 (patch) | |
tree | 8341a16f57ff184a2fe9e085c490e8762eb206ce /src/mbgl/style | |
parent | f9cc044357d60dd5cf15ba951384529f88802089 (diff) | |
download | qtlocation-mapboxgl-693c9f3641b3189b4cd439049904c95a516ae609.tar.gz |
[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)
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_properties.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/paint_property_binder.hpp | 10 |
5 files changed, 12 insertions, 20 deletions
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index bd5cf30ad6..e79a3f967f 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -161,15 +161,15 @@ void SymbolLayer::setIconRotationAlignment(PropertyValue<AlignmentType> value) { impl->layout.unevaluated.get<IconRotationAlignment>() = value; impl->observer->onLayerLayoutPropertyChanged(*this, "icon-rotation-alignment"); } -PropertyValue<float> SymbolLayer::getDefaultIconSize() { +DataDrivenPropertyValue<float> SymbolLayer::getDefaultIconSize() { return IconSize::defaultValue(); } -PropertyValue<float> SymbolLayer::getIconSize() const { +DataDrivenPropertyValue<float> SymbolLayer::getIconSize() const { return impl->layout.unevaluated.get<IconSize>(); } -void SymbolLayer::setIconSize(PropertyValue<float> value) { +void SymbolLayer::setIconSize(DataDrivenPropertyValue<float> value) { if (value == getIconSize()) return; impl->layout.unevaluated.get<IconSize>() = value; @@ -329,15 +329,15 @@ void SymbolLayer::setTextFont(PropertyValue<std::vector<std::string>> value) { impl->layout.unevaluated.get<TextFont>() = value; impl->observer->onLayerLayoutPropertyChanged(*this, "text-font"); } -PropertyValue<float> SymbolLayer::getDefaultTextSize() { +DataDrivenPropertyValue<float> SymbolLayer::getDefaultTextSize() { return TextSize::defaultValue(); } -PropertyValue<float> SymbolLayer::getTextSize() const { +DataDrivenPropertyValue<float> SymbolLayer::getTextSize() const { return impl->layout.unevaluated.get<TextSize>(); } -void SymbolLayer::setTextSize(PropertyValue<float> value) { +void SymbolLayer::setTextSize(DataDrivenPropertyValue<float> value) { if (value == getTextSize()) return; impl->layout.unevaluated.get<TextSize>() = value; diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index c637770c04..109d1c43e7 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -13,10 +13,6 @@ void SymbolLayer::Impl::cascade(const CascadeParameters& parameters) { bool SymbolLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { paint.evaluate(parameters); - // text-size and icon-size are layout properties but they also need to be evaluated as paint properties: - iconSize = layout.evaluate<IconSize>(parameters); - textSize = layout.evaluate<TextSize>(parameters); - auto hasIconOpacity = paint.evaluated.get<IconColor>().constantOr(Color::black()).a > 0 || paint.evaluated.get<IconHaloColor>().constantOr(Color::black()).a > 0; auto hasTextOpacity = paint.evaluated.get<TextColor>().constantOr(Color::black()).a > 0 || diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp index db20989f01..3d81ff1f69 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.hpp +++ b/src/mbgl/style/layers/symbol_layer_impl.hpp @@ -44,7 +44,7 @@ public: // Layout AlignmentType pitchAlignment; AlignmentType rotationAlignment; - float layoutSize; + PossiblyEvaluatedPropertyValue<float> layoutSize; // Paint std::array<float, 2> translate; diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index 4f63ed419a..42f593890b 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -45,7 +45,7 @@ struct IconRotationAlignment : LayoutProperty<AlignmentType> { static AlignmentType defaultValue() { return AlignmentType::Auto; } }; -struct IconSize : LayoutProperty<float> { +struct IconSize : DataDrivenLayoutProperty<float> { static constexpr const char * key = "icon-size"; static float defaultValue() { return 1; } }; @@ -105,7 +105,7 @@ struct TextFont : LayoutProperty<std::vector<std::string>> { static std::vector<std::string> defaultValue() { return { "Open Sans Regular", "Arial Unicode MS Regular" }; } }; -struct TextSize : LayoutProperty<float> { +struct TextSize : DataDrivenLayoutProperty<float> { static constexpr const char * key = "text-size"; static float defaultValue() { return 16; } }; diff --git a/src/mbgl/style/paint_property_binder.hpp b/src/mbgl/style/paint_property_binder.hpp index 7e44b509a1..bf98e6ef9a 100644 --- a/src/mbgl/style/paint_property_binder.hpp +++ b/src/mbgl/style/paint_property_binder.hpp @@ -26,16 +26,12 @@ inline std::array<float, 1> attributeValue(float v) { uses 8-bit precision for each color component, for each float we use the upper 8 bits for one component (e.g. (color.r * 255) * 256), and the lower 8 for another. - Also note: - - Colors come in as floats 0..1, so we scale by 255. - - Casting the scaled values to ints is important: without doing this, e.g., the - fractional part of the `r` component would corrupt the lower-8 bits of the encoded - value, which must be reserved for the `g` component. + Also note that colors come in as floats 0..1, so we scale by 255. */ inline std::array<float, 2> attributeValue(const Color& color) { return {{ - static_cast<float>(static_cast<uint16_t>(color.r * 255) * 256 + static_cast<uint16_t>(color.g * 255)), - static_cast<float>(static_cast<uint16_t>(color.b * 255) * 256 + static_cast<uint16_t>(color.a * 255)) + static_cast<float>(mbgl::attributes::packUint8Pair(255 * color.r, 255 * color.g)), + static_cast<float>(mbgl::attributes::packUint8Pair(255 * color.b, 255 * color.a)) }}; } |