1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#pragma once
#include <mbgl/text/glyph.hpp>
#include <mbgl/renderer/render_layer.hpp>
#include <mbgl/renderer/layers/render_layer_symbol_interface.hpp>
#include <mbgl/style/image_impl.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp>
namespace mbgl {
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 Properties<
IconOpacity,
IconColor,
IconHaloColor,
IconHaloWidth,
IconHaloBlur,
IconTranslate,
IconTranslateAnchor
> {};
class TextPaintProperties : public Properties<
TextOpacity,
TextColor,
TextHaloColor,
TextHaloWidth,
TextHaloBlur,
TextTranslate,
TextTranslateAnchor
> {};
// Repackaging evaluated values from SymbolLayoutProperties + SymbolPaintProperties
// for genericity over icons vs. text.
class SymbolPropertyValues {
public:
// Layout
AlignmentType pitchAlignment;
AlignmentType rotationAlignment;
bool keepUpright;
// Paint
std::array<float, 2> translate;
TranslateAnchorType translateAnchor;
bool hasHalo;
bool hasFill;
};
} // namespace style
class BucketParameters;
class SymbolLayout;
class GeometryTileLayer;
class RenderSymbolLayer: public RenderLayer, public RenderLayerSymbolInterface {
public:
RenderSymbolLayer(Immutable<style::SymbolLayer::Impl>);
~RenderSymbolLayer() final = default;
void transition(const TransitionParameters&) override;
void evaluate(const PropertyEvaluationParameters&) override;
bool hasTransition() const override;
bool hasCrossfade() const override;
void render(PaintParameters&, RenderSource*) override;
static style::IconPaintProperties::PossiblyEvaluated iconPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
static style::TextPaintProperties::PossiblyEvaluated textPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
std::unique_ptr<Bucket> createBucket(const BucketParameters&, const std::vector<const RenderLayer*>&) const override;
std::unique_ptr<Layout> createLayout(const BucketParameters&,
const std::vector<const RenderLayer*>&,
std::unique_ptr<GeometryTileLayer>,
GlyphDependencies&,
ImageDependencies&) const override;
// RenderLayerSymbolInterface overrides
const RenderLayerSymbolInterface* getSymbolInterface() const final;
const std::string& layerID() const final;
const std::vector<std::reference_wrapper<RenderTile>>& getRenderTiles() const final;
SymbolBucket* getSymbolBucket(const RenderTile&) const final;
// Paint properties
style::SymbolPaintProperties::Unevaluated unevaluated;
style::SymbolPaintProperties::PossiblyEvaluated evaluated;
float iconSize = 1.0f;
float textSize = 16.0f;
const style::SymbolLayer::Impl& impl() const;
protected:
static style::SymbolPropertyValues iconPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated&,
const style::SymbolLayoutProperties::PossiblyEvaluated&);
static style::SymbolPropertyValues textPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated&,
const style::SymbolLayoutProperties::PossiblyEvaluated&);
RenderTiles filterRenderTiles(RenderTiles) const final;
void sortRenderTiles(const TransformState&) final;
void updateBucketPaintProperties(Bucket*) const final;
};
inline const RenderSymbolLayer* toRenderSymbolLayer(const RenderLayer* layer) {
return static_cast<const RenderSymbolLayer*>(layer);
}
} // namespace mbgl
|