#pragma once #include #include #include #include #include #include #include #include #include #include namespace mbgl { class BucketParameters; class Anchor; class PlacedSymbol; namespace style { class Filter; } // namespace style class SymbolLayout final : public Layout { public: SymbolLayout(const BucketParameters&, const std::vector>&, std::unique_ptr, const LayoutParameters& parameters); ~SymbolLayout() final = default; void prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions&, const ImageMap&, const ImagePositions&) override; void createBucket(const ImagePositions&, std::unique_ptr&, std::unordered_map&, bool firstLoad, bool showCollisionBoxes, const CanonicalTileID& canonical) override; bool hasSymbolInstances() const override; bool hasDependencies() const override; std::map> layerPaintProperties; const std::string bucketLeaderID; std::vector symbolInstances; std::vector sortKeyRanges; static constexpr float INVALID_OFFSET_VALUE = std::numeric_limits::max(); /** * @brief Calculates variable text offset. * * @param anchor text anchor * @param textOffset Either `text-offset` or [ `text-radial-offset`, INVALID_OFFSET_VALUE ] * @return std::array offset along x- and y- axis correspondingly. */ static std::array evaluateVariableOffset(style::SymbolAnchorType anchor, std::array textOffset); static std::vector calculateTileDistances(const GeometryCoordinates& line, const Anchor& anchor); private: void addFeature(size_t, const SymbolFeature&, const ShapedTextOrientations& shapedTextOrientations, optional shapedIcon, const ImageMap&, std::array textOffset, float layoutTextSize, float layoutIconSize, SymbolContent iconType); bool anchorIsTooClose(const std::u16string& text, float repeatDistance, const Anchor&); std::map> compareText; void addToDebugBuffers(SymbolBucket&); // Adds placed items to the buffer. size_t addSymbol(SymbolBucket::Buffer&, Range sizeData, const SymbolQuad&, const Anchor& labelAnchor, PlacedSymbol& placedSymbol, float sortKey); size_t addSymbols(SymbolBucket::Buffer&, Range sizeData, const SymbolQuads&, const Anchor& labelAnchor, PlacedSymbol& placedSymbol, float sortKey); // Adds symbol quads to bucket and returns formatted section index of last // added quad. std::size_t addSymbolGlyphQuads(SymbolBucket&, SymbolInstance&, const SymbolFeature&, WritingModeType, optional& placedIndex, const SymbolQuads&, const CanonicalTileID& canonical, optional lastAddedSection = nullopt); void updatePaintPropertiesForSection(SymbolBucket&, const SymbolFeature&, std::size_t sectionIndex, const CanonicalTileID& canonical); // Stores the layer so that we can hold on to GeometryTileFeature instances in SymbolFeature, // which may reference data from this object. const std::unique_ptr sourceLayer; const float overscaling; const float zoom; const CanonicalTileID canonicalID; const MapMode mode; const float pixelRatio; const uint32_t tileSize; const float tilePixelRatio; bool iconsNeedLinear = false; bool sortFeaturesByY = false; bool sortFeaturesByKey = false; bool allowVerticalPlacement = false; bool iconsInText = false; std::vector placementModes; style::TextSize::UnevaluatedType textSize; style::IconSize::UnevaluatedType iconSize; style::TextRadialOffset::UnevaluatedType textRadialOffset; Immutable layout; std::vector features; 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 }; } // namespace mbgl