#ifndef LLMR_GEOMETRY_GLYPH_ATLAS #define LLMR_GEOMETRY_GLYPH_ATLAS #include #include #include #include #include #include #include namespace llmr { class GlyphAtlas { public: private: struct GlyphValue { GlyphValue(const Rect& rect, uint64_t id) : rect(rect), ids({ id }) {} Rect rect; std::set ids; }; public: GlyphAtlas(uint16_t width, uint16_t height); ~GlyphAtlas(); Rect addGlyph(uint64_t tile_id, const std::string& face_name, const SDFGlyph& glyph); void removeGlyphs(uint64_t tile_id); void bind(); public: const uint16_t width = 0; const uint16_t height = 0; private: std::mutex mtx; BinPack bin; std::map> index; char *const data = nullptr; std::atomic dirty; uint32_t texture = 0; }; }; #endif