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
111
112
113
114
|
#include <mbgl/style/layers/symbol_layer_impl.hpp>
#include <mbgl/style/bucket_parameters.hpp>
#include <mbgl/layout/symbol_layout.hpp>
#include <mbgl/renderer/bucket.hpp>
namespace mbgl {
namespace style {
void SymbolLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
bool SymbolLayer::Impl::recalculate(const CalculationParameters& parameters) {
bool hasTransitions = paint.recalculate(parameters);
// text-size and icon-size are layout properties but they also need to be evaluated as paint properties:
layout.iconSize.calculate(parameters);
layout.textSize.calculate(parameters);
iconSize = layout.iconSize;
textSize = layout.textSize;
passes = ((paint.iconOpacity > 0 && (paint.iconColor.value.a > 0 || paint.iconHaloColor.value.a > 0) && iconSize > 0)
|| (paint.textOpacity > 0 && (paint.textColor.value.a > 0 || paint.textHaloColor.value.a > 0) && textSize > 0))
? RenderPass::Translucent : RenderPass::None;
return hasTransitions;
}
std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&) const {
assert(false); // Should be calling createLayout() instead.
return nullptr;
}
std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& parameters) const {
SymbolLayoutProperties layoutProperties = layout;
CalculationParameters p(parameters.tileID.overscaledZ);
layoutProperties.recalculate(p);
if (layoutProperties.iconRotationAlignment.value == AlignmentType::Auto) {
if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
layoutProperties.iconRotationAlignment.value = AlignmentType::Map;
} else {
layoutProperties.iconRotationAlignment.value = AlignmentType::Viewport;
}
}
if (layoutProperties.textRotationAlignment.value == AlignmentType::Auto) {
if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
layoutProperties.textRotationAlignment.value = AlignmentType::Map;
} else {
layoutProperties.textRotationAlignment.value = AlignmentType::Viewport;
}
}
// If unspecified `text-pitch-alignment` inherits `text-rotation-alignment`
if (layoutProperties.textPitchAlignment.value == AlignmentType::Auto) {
layoutProperties.textPitchAlignment.value = layoutProperties.textRotationAlignment.value;
}
layoutProperties.textSize.calculate(CalculationParameters(18));
float textMaxSize = layoutProperties.textSize;
layoutProperties.iconSize.calculate(CalculationParameters(p.z + 1));
layoutProperties.textSize.calculate(CalculationParameters(p.z + 1));
return std::make_unique<SymbolLayout>(id,
parameters.layer.getName(),
parameters.tileID.overscaleFactor(),
parameters.tileID.overscaledZ,
parameters.mode,
parameters.layer,
filter,
layoutProperties,
textMaxSize,
*spriteAtlas);
}
SymbolPropertyValues SymbolLayer::Impl::iconPropertyValues(const SymbolLayoutProperties& layout_) const {
return SymbolPropertyValues {
layout_.iconRotationAlignment.value, // icon-pitch-alignment is not yet implemented; inherit the rotation alignment
layout_.iconRotationAlignment.value,
layout_.iconSize.value,
paint.iconOpacity.value,
paint.iconColor.value,
paint.iconHaloColor.value,
paint.iconHaloWidth.value,
paint.iconHaloBlur.value,
paint.iconTranslate.value,
paint.iconTranslateAnchor.value,
iconSize,
1.0f
};
}
SymbolPropertyValues SymbolLayer::Impl::textPropertyValues(const SymbolLayoutProperties& layout_) const {
return SymbolPropertyValues {
layout_.textPitchAlignment.value,
layout_.textRotationAlignment.value,
layout_.textSize.value,
paint.textOpacity.value,
paint.textColor.value,
paint.textHaloColor.value,
paint.textHaloWidth.value,
paint.textHaloBlur.value,
paint.textTranslate.value,
paint.textTranslateAnchor.value,
textSize,
24.0f
};
}
} // namespace style
} // namespace mbgl
|