1 #pragma once
2 
3 #include <mbgl/text/glyph.hpp>
4 #include <mbgl/renderer/render_layer.hpp>
5 #include <mbgl/style/image_impl.hpp>
6 #include <mbgl/style/layers/symbol_layer_impl.hpp>
7 #include <mbgl/style/layers/symbol_layer_properties.hpp>
8 
9 namespace mbgl {
10 
11 namespace style {
12 
13 // {icon,text}-specific paint-property packs for use in the symbol Programs.
14 // Since each program deals either with icons or text, using a smaller property set
15 // lets us avoid unnecessarily binding attributes for properties the program wouldn't use.
16 class IconPaintProperties : public Properties<
17         IconOpacity,
18         IconColor,
19         IconHaloColor,
20         IconHaloWidth,
21         IconHaloBlur,
22         IconTranslate,
23         IconTranslateAnchor
24 > {};
25 
26 class TextPaintProperties : public Properties<
27         TextOpacity,
28         TextColor,
29         TextHaloColor,
30         TextHaloWidth,
31         TextHaloBlur,
32         TextTranslate,
33         TextTranslateAnchor
34 > {};
35 
36 // Repackaging evaluated values from SymbolLayoutProperties + SymbolPaintProperties
37 // for genericity over icons vs. text.
38 class SymbolPropertyValues {
39 public:
40     // Layout
41     AlignmentType pitchAlignment;
42     AlignmentType rotationAlignment;
43     bool keepUpright;
44 
45     // Paint
46     std::array<float, 2> translate;
47     TranslateAnchorType translateAnchor;
48 
49     bool hasHalo;
50     bool hasFill;
51 };
52 
53 } // namespace style
54 
55 class BucketParameters;
56 class SymbolLayout;
57 class GeometryTileLayer;
58 
59 class RenderSymbolLayer: public RenderLayer {
60 public:
61     RenderSymbolLayer(Immutable<style::SymbolLayer::Impl>);
62     ~RenderSymbolLayer() final = default;
63 
64     void transition(const TransitionParameters&) override;
65     void evaluate(const PropertyEvaluationParameters&) override;
66     bool hasTransition() const override;
67     void render(PaintParameters&, RenderSource*) override;
68 
69     style::IconPaintProperties::PossiblyEvaluated iconPaintProperties() const;
70     style::TextPaintProperties::PossiblyEvaluated textPaintProperties() const;
71 
72     style::SymbolPropertyValues iconPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated&) const;
73     style::SymbolPropertyValues textPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated&) const;
74 
75     std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) const override;
76     std::unique_ptr<SymbolLayout> createLayout(const BucketParameters&,
77                                                const std::vector<const RenderLayer*>&,
78                                                std::unique_ptr<GeometryTileLayer>,
79                                                GlyphDependencies&,
80                                                ImageDependencies&) const;
81 
82     // Paint properties
83     style::SymbolPaintProperties::Unevaluated unevaluated;
84     style::SymbolPaintProperties::PossiblyEvaluated evaluated;
85 
86     float iconSize = 1.0f;
87     float textSize = 16.0f;
88 
89     const style::SymbolLayer::Impl& impl() const;
90 };
91 
92 template <>
is() const93 inline bool RenderLayer::is<RenderSymbolLayer>() const {
94     return type == style::LayerType::Symbol;
95 }
96 
97 } // namespace mbgl
98