1 #include <mbgl/layout/symbol_instance.hpp>
2 #include <mbgl/style/layers/symbol_layer_properties.hpp>
3
4 namespace mbgl {
5
6 using namespace style;
7
SymbolInstance(Anchor & anchor_,GeometryCoordinates line_,const std::pair<Shaping,Shaping> & shapedTextOrientations,optional<PositionedIcon> shapedIcon,const SymbolLayoutProperties::Evaluated & layout,const float layoutTextSize,const float textBoxScale,const float textPadding,const SymbolPlacementType textPlacement,const std::array<float,2> textOffset_,const float iconBoxScale,const float iconPadding,const std::array<float,2> iconOffset_,const GlyphPositionMap & positions,const IndexedSubfeature & indexedFeature,const std::size_t layoutFeatureIndex_,const std::size_t dataFeatureIndex_,const std::u16string & key_,const float overscaling)8 SymbolInstance::SymbolInstance(Anchor& anchor_,
9 GeometryCoordinates line_,
10 const std::pair<Shaping, Shaping>& shapedTextOrientations,
11 optional<PositionedIcon> shapedIcon,
12 const SymbolLayoutProperties::Evaluated& layout,
13 const float layoutTextSize,
14 const float textBoxScale,
15 const float textPadding,
16 const SymbolPlacementType textPlacement,
17 const std::array<float, 2> textOffset_,
18 const float iconBoxScale,
19 const float iconPadding,
20 const std::array<float, 2> iconOffset_,
21 const GlyphPositionMap& positions,
22 const IndexedSubfeature& indexedFeature,
23 const std::size_t layoutFeatureIndex_,
24 const std::size_t dataFeatureIndex_,
25 const std::u16string& key_,
26 const float overscaling) :
27 anchor(anchor_),
28 line(line_),
29 hasText(false),
30 hasIcon(shapedIcon),
31
32 // Create the collision features that will be used to check whether this symbol instance can be placed
33 textCollisionFeature(line_, anchor, shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature, overscaling),
34 iconCollisionFeature(line_, anchor, shapedIcon, iconBoxScale, iconPadding, indexedFeature),
35 layoutFeatureIndex(layoutFeatureIndex_),
36 dataFeatureIndex(dataFeatureIndex_),
37 textOffset(textOffset_),
38 iconOffset(iconOffset_),
39 key(key_) {
40
41 // Create the quads used for rendering the icon and glyphs.
42 if (shapedIcon) {
43 iconQuad = getIconQuad(*shapedIcon, layout, layoutTextSize, shapedTextOrientations.first);
44 }
45 if (shapedTextOrientations.first) {
46 horizontalGlyphQuads = getGlyphQuads(shapedTextOrientations.first, layout, textPlacement, positions);
47 }
48 if (shapedTextOrientations.second) {
49 verticalGlyphQuads = getGlyphQuads(shapedTextOrientations.second, layout, textPlacement, positions);
50 }
51 // 'hasText' depends on finding at least one glyph in the shaping that's also in the GlyphPositionMap
52 hasText = horizontalGlyphQuads.size() > 0 || verticalGlyphQuads.size() > 0;
53
54 if (shapedTextOrientations.first && shapedTextOrientations.second) {
55 writingModes = WritingModeType::Horizontal | WritingModeType::Vertical;
56 } else if (shapedTextOrientations.first) {
57 writingModes = WritingModeType::Horizontal;
58 } else if (shapedTextOrientations.second) {
59 writingModes = WritingModeType::Vertical;
60 } else {
61 writingModes = WritingModeType::None;
62 }
63 }
64
65 } // namespace mbgl
66