#ifndef MBGL_RENDERER_SYMBOLBUCKET #define MBGL_RENDERER_SYMBOLBUCKET #include "bucket.hpp" #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class Style; class TextShader; class IconShader; class DotShader; class Collision; class SpriteAtlas; class Sprite; class GlyphAtlas; class GlyphStore; class FontStack; class SymbolFeature { public: pbf geometry; std::u32string label; std::string sprite; }; class Symbol { public: vec2 tl, tr, bl, br; Rect tex; float angle; float minScale = 0.0f; float maxScale = std::numeric_limits::infinity(); CollisionAnchor anchor; }; typedef std::vector Symbols; class SymbolBucket : public Bucket { typedef ElementGroup<1> TextElementGroup; typedef ElementGroup<1> IconElementGroup; public: SymbolBucket(const StyleBucketSymbol &properties, Collision &collision); virtual void render(Painter &painter, std::shared_ptr layer_desc, const Tile::ID &id, const mat4 &matrix); virtual bool hasData() const; virtual bool hasTextData() const; virtual bool hasIconData() const; void addFeatures(const VectorTileLayer &layer, const FilterExpression &filter, const Tile::ID &id, SpriteAtlas &spriteAtlas, Sprite &sprite, GlyphAtlas &glyphAtlas, GlyphStore &glyphStore); void addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, PlacementRange placementRange, float zoom); void drawGlyphs(TextShader &shader); void drawIcons(IconShader& shader); private: std::vector processFeatures(const VectorTileLayer &layer, const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite); void addFeature(const pbf &geom_pbf, const Shaping &shaping, const GlyphPositions &face, const Rect &image); void addFeature(const std::vector &line, const Shaping &shaping, const GlyphPositions &face, const Rect &image); // Adds placed items to the buffer. template void addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float scale, PlacementRange placementRange); // Adds glyphs to the glyph atlas so that they have a left/top/width/height coordinates associated to them that we can use for writing to a buffer. void addGlyphsToAtlas(uint64_t tileid, const std::string stackname, const std::u32string &string, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face); public: const StyleBucketSymbol &properties; private: Collision &collision; struct { TextVertexBuffer vertices; TriangleElementsBuffer triangles; std::vector groups; } text; struct { IconVertexBuffer vertices; TriangleElementsBuffer triangles; std::vector groups; } icon; }; } #endif