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.cpp | |
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.cpp')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.cpp | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index 32547e465a..ff59b14d65 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -16,9 +16,14 @@ bool SymbolLayer::Impl::evaluate(const PropertyEvaluationParameters& 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); - - passes = ((paint.evaluated.get<IconOpacity>() > 0 && (paint.evaluated.get<IconColor>().a > 0 || paint.evaluated.get<IconHaloColor>().a > 0) && iconSize > 0) - || (paint.evaluated.get<TextOpacity>() > 0 && (paint.evaluated.get<TextColor>().a > 0 || paint.evaluated.get<TextHaloColor>().a > 0) && textSize > 0)) + + 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 || + paint.evaluated.get<TextHaloColor>().constantOr(Color::black()).a > 0; + + passes = ((paint.evaluated.get<IconOpacity>().constantOr(1) > 0 && hasIconOpacity && iconSize > 0) + || (paint.evaluated.get<TextOpacity>().constantOr(1) > 0 && hasTextOpacity && textSize > 0)) ? RenderPass::Translucent : RenderPass::None; return paint.hasTransition(); @@ -38,20 +43,43 @@ std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(const BucketParame *spriteAtlas); } -SymbolPropertyValues SymbolLayer::Impl::iconPropertyValues(const SymbolLayoutProperties::Evaluated& layout_) const { - return SymbolPropertyValues { - layout_.get<IconRotationAlignment>(), // icon-pitch-alignment is not yet implemented; inherit the rotation alignment - layout_.get<IconRotationAlignment>(), - layout_.get<IconSize>(), +IconPaintProperties::Evaluated SymbolLayer::Impl::iconPaintProperties() const { + return IconPaintProperties::Evaluated { paint.evaluated.get<IconOpacity>(), paint.evaluated.get<IconColor>(), paint.evaluated.get<IconHaloColor>(), paint.evaluated.get<IconHaloWidth>(), paint.evaluated.get<IconHaloBlur>(), paint.evaluated.get<IconTranslate>(), + paint.evaluated.get<IconTranslateAnchor>() + }; +} + +TextPaintProperties::Evaluated SymbolLayer::Impl::textPaintProperties() const { + return TextPaintProperties::Evaluated { + paint.evaluated.get<TextOpacity>(), + paint.evaluated.get<TextColor>(), + paint.evaluated.get<TextHaloColor>(), + paint.evaluated.get<TextHaloWidth>(), + paint.evaluated.get<TextHaloBlur>(), + paint.evaluated.get<TextTranslate>(), + paint.evaluated.get<TextTranslateAnchor>() + }; +} + + +SymbolPropertyValues SymbolLayer::Impl::iconPropertyValues(const SymbolLayoutProperties::Evaluated& layout_) const { + return SymbolPropertyValues { + layout_.get<IconRotationAlignment>(), // icon-pitch-alignment is not yet implemented; inherit the rotation alignment + layout_.get<IconRotationAlignment>(), + layout_.get<IconSize>(), + paint.evaluated.get<IconTranslate>(), paint.evaluated.get<IconTranslateAnchor>(), iconSize, - 1.0f + 1.0f, + paint.evaluated.get<IconHaloColor>().constantOr(Color::black()).a > 0 && + paint.evaluated.get<IconHaloWidth>().constantOr(1), + paint.evaluated.get<IconColor>().constantOr(Color::black()).a > 0 }; } @@ -60,15 +88,13 @@ SymbolPropertyValues SymbolLayer::Impl::textPropertyValues(const SymbolLayoutPro layout_.get<TextPitchAlignment>(), layout_.get<TextRotationAlignment>(), layout_.get<TextSize>(), - paint.evaluated.get<TextOpacity>(), - paint.evaluated.get<TextColor>(), - paint.evaluated.get<TextHaloColor>(), - paint.evaluated.get<TextHaloWidth>(), - paint.evaluated.get<TextHaloBlur>(), paint.evaluated.get<TextTranslate>(), paint.evaluated.get<TextTranslateAnchor>(), textSize, - 24.0f + 24.0f, + paint.evaluated.get<TextHaloColor>().constantOr(Color::black()).a > 0 && + paint.evaluated.get<TextHaloWidth>().constantOr(1), + paint.evaluated.get<TextColor>().constantOr(Color::black()).a > 0 }; } |