#ifndef MBGL_GEOMETRY_GLYPH_ATLAS #define MBGL_GEOMETRY_GLYPH_ATLAS #include #include #include #include #include #include #include #include namespace mbgl { class GlyphAtlas : public util::noncopyable { public: GlyphAtlas(uint16_t width, uint16_t height); void addGlyphs(uintptr_t tileUID, const std::u32string& text, const std::string& stackName, const FontStack&, GlyphPositions&); void removeGlyphs(uintptr_t tileUID); // Binds the atlas texture to the GPU, and uploads data if it is out of date. void bind(); // Uploads the texture to the GPU to be available when we need it. This is a lazy operation; // the texture is only bound when the data is out of date (=dirty). void upload(); const uint16_t width = 0; const uint16_t height = 0; private: struct GlyphValue { GlyphValue(const Rect& rect_, uintptr_t id) : rect(rect_), ids({ id }) {} Rect rect; std::set ids; }; Rect addGlyph(uintptr_t tileID, const std::string& stackName, const SDFGlyph&); std::mutex mtx; BinPack bin; std::map> index; const std::unique_ptr data; std::atomic dirty; uint32_t texture = 0; }; }; #endif