#pragma once #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class FileSource; class GlyphPBF; class GlyphStoreObserver; // The GlyphStore manages the loading and storage of Glyphs // and creation of GlyphSet objects. The GlyphStore lives // on the MapThread but can be queried from any thread. class GlyphStore : private util::noncopyable { public: GlyphStore(FileSource&); ~GlyphStore(); util::exclusive getGlyphSet(const FontStack&); // Returns true if the set of GlyphRanges are available and parsed or false // if they are not. For the missing ranges, a request on the FileSource is // made and when the glyph if finally parsed, it gets added to the respective // GlyphSet and a signal is emitted to notify the observers. This method // can be called from any thread. bool hasGlyphRanges(const FontStack&, const std::set&); void setURL(const std::string &url) { glyphURL = url; } std::string getURL() const { return glyphURL; } void setObserver(GlyphStoreObserver* observer); private: void requestGlyphRange(const FontStack&, const GlyphRange&); FileSource& fileSource; std::string glyphURL; std::unordered_map>, FontStackHash> ranges; std::mutex rangesMutex; std::unordered_map, FontStackHash> glyphSets; std::mutex glyphSetsMutex; util::WorkQueue workQueue; GlyphStoreObserver* observer = nullptr; }; } // namespace mbgl