1 #pragma once 2 3 #include <mbgl/map/mode.hpp> 4 #include <mbgl/style/layers/symbol_layer_properties.hpp> 5 #include <mbgl/layout/symbol_feature.hpp> 6 #include <mbgl/layout/symbol_instance.hpp> 7 #include <mbgl/text/bidi.hpp> 8 #include <mbgl/style/layers/symbol_layer_impl.hpp> 9 #include <mbgl/programs/symbol_program.hpp> 10 11 #include <memory> 12 #include <map> 13 #include <unordered_set> 14 #include <vector> 15 16 namespace mbgl { 17 18 class BucketParameters; 19 class SymbolBucket; 20 class Anchor; 21 class RenderLayer; 22 class PlacedSymbol; 23 24 namespace style { 25 class Filter; 26 } // namespace style 27 28 class SymbolLayout { 29 public: 30 SymbolLayout(const BucketParameters&, 31 const std::vector<const RenderLayer*>&, 32 std::unique_ptr<GeometryTileLayer>, 33 ImageDependencies&, 34 GlyphDependencies&); 35 36 void prepare(const GlyphMap&, const GlyphPositions&, 37 const ImageMap&, const ImagePositions&); 38 39 std::unique_ptr<SymbolBucket> place(const bool showCollisionBoxes); 40 41 bool hasSymbolInstances() const; 42 43 std::map<std::string, 44 std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>> layerPaintProperties; 45 46 const std::string bucketLeaderID; 47 std::vector<SymbolInstance> symbolInstances; 48 49 private: 50 void addFeature(const size_t, 51 const SymbolFeature&, 52 const std::pair<Shaping, Shaping>& shapedTextOrientations, 53 optional<PositionedIcon> shapedIcon, 54 const GlyphPositionMap&); 55 56 bool anchorIsTooClose(const std::u16string& text, const float repeatDistance, const Anchor&); 57 std::map<std::u16string, std::vector<Anchor>> compareText; 58 59 void addToDebugBuffers(SymbolBucket&); 60 61 // Adds placed items to the buffer. 62 template <typename Buffer> 63 size_t addSymbol(Buffer&, 64 const Range<float> sizeData, 65 const SymbolQuad&, 66 const Anchor& labelAnchor, 67 PlacedSymbol& placedSymbol); 68 69 // Stores the layer so that we can hold on to GeometryTileFeature instances in SymbolFeature, 70 // which may reference data from this object. 71 const std::unique_ptr<GeometryTileLayer> sourceLayer; 72 const float overscaling; 73 const float zoom; 74 const MapMode mode; 75 const float pixelRatio; 76 77 style::SymbolLayoutProperties::PossiblyEvaluated layout; 78 79 const uint32_t tileSize; 80 const float tilePixelRatio; 81 82 bool sdfIcons = false; 83 bool iconsNeedLinear = false; 84 85 style::TextSize::UnevaluatedType textSize; 86 style::IconSize::UnevaluatedType iconSize; 87 88 std::vector<SymbolFeature> features; 89 90 BiDi bidi; // Consider moving this up to geometry tile worker to reduce reinstantiation costs; use of BiDi/ubiditransform object must be constrained to one thread 91 }; 92 93 } // namespace mbgl 94