blob: e85f3a90f9638ade36222ed42a0f1de84b18311d (
plain)
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
|
#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);
}
} // namespace style
} // namespace mbgl
|