diff options
author | Anand Thakker <anandthakker@users.noreply.github.com> | 2017-02-28 19:54:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-28 19:54:24 -0800 |
commit | f901e776b3e63aaaa6bc0cc4476624bf84127fe6 (patch) | |
tree | 3e311971d57109c64e5ace45c111fb5909e7fb7b /src/mbgl/style/layers/symbol_layer_impl.hpp | |
parent | c3ed1f51ca677c8c2045320fe13ec881cbd94772 (diff) | |
download | qtlocation-mapboxgl-f901e776b3e63aaaa6bc0cc4476624bf84127fe6.tar.gz |
[core] Implement data-driven styling for {text,icon}-{color,opacity,halo-color,halo-blur,halo-width} (#7939)
* Add symbol dds attributes and adapt style code generation
* Update to mapbox-gl-js/master
* Refactor SymbolFeature as a subclass of GeometryTileFeature
Prepares for enabling DDS on symbol paint properties by allowing the
SymbolFeatures, which we keep around after constructing SymbolLayout,
to be used in evaluating data-driven paint properties later in the
layout process.
* Draft approach for splitting icon/text paint properties
The `Program` types are set up to bind GL attributes to each of the
data-driven paint properties specified in the `PaintProperties` type
provided. Since `SymbolPaintProperties` specifies both `Text*` and
`Icon*` properties, the symbolIcon, symbolIconSDF, and symbolGlyph
programs each attempt to bind roughly double the number of attributes
that they actually need.
This change addresses this by:
- Adding the more specific `IconPaintProperties` and `TextPaintProperties` types, which are subsets of the full `SymbolPaintProperties`.
- The symbol layer continues to use its `SymbolPaintProperties paint` member to track layer property state, but it provides helpers that construct objects of each the specific `{Icon,Text}PaintProperties::Evaluated` type, for use by the painter.
- The three symbol programs instantiate `Program<>` using the appropriate `{Icon,Text}PaintProperties` type.
* check in generated style code
* Populate paint buffers for symbol DDS properties
* Address first round of review comments
* Refactor VectorTile{Layer,Feature} to explicitly share data
* Update submodule
Diffstat (limited to 'src/mbgl/style/layers/symbol_layer_impl.hpp')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.hpp | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp index c00c2b0bba..1e9f05e4c7 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.hpp +++ b/src/mbgl/style/layers/symbol_layer_impl.hpp @@ -1,5 +1,6 @@ #pragma once +#include <mbgl/util/variant.hpp> #include <mbgl/style/layer_impl.hpp> #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/style/layers/symbol_layer_properties.hpp> @@ -10,6 +11,30 @@ class SpriteAtlas; class SymbolLayout; namespace style { + + +// {icon,text}-specific paint-property packs for use in the symbol Programs. +// Since each program deals either with icons or text, using a smaller property set +// lets us avoid unnecessarily binding attributes for properties the program wouldn't use. +class IconPaintProperties : public PaintProperties< + IconOpacity, + IconColor, + IconHaloColor, + IconHaloWidth, + IconHaloBlur, + IconTranslate, + IconTranslateAnchor +> {}; + +class TextPaintProperties : public PaintProperties< + TextOpacity, + TextColor, + TextHaloColor, + TextHaloWidth, + TextHaloBlur, + TextTranslate, + TextTranslateAnchor +> {}; // Repackaging evaluated values from SymbolLayoutProperties + SymbolPaintProperties // for genericity over icons vs. text. @@ -21,24 +46,14 @@ public: float layoutSize; // Paint - float opacity; - Color color; - Color haloColor; - float haloWidth; - float haloBlur; std::array<float, 2> translate; TranslateAnchorType translateAnchor; float paintSize; float sdfScale; // Constant (1.0 or 24.0) - - bool hasHalo() const { - return haloColor.a > 0.0f && haloWidth > 0.0f; - } - - bool hasForeground() const { - return color.a > 0.0f; - } + + bool hasHalo; + bool hasFill; }; class SymbolLayer::Impl : public Layer::Impl { @@ -54,6 +69,9 @@ public: std::unique_ptr<SymbolLayout> createLayout(const BucketParameters&, const std::vector<const Layer*>&, const GeometryTileLayer&) const; + IconPaintProperties::Evaluated iconPaintProperties() const; + TextPaintProperties::Evaluated textPaintProperties() const; + SymbolPropertyValues iconPropertyValues(const SymbolLayoutProperties::Evaluated&) const; SymbolPropertyValues textPropertyValues(const SymbolLayoutProperties::Evaluated&) const; |