diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-05-10 22:42:48 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-05-14 11:29:24 +0300 |
commit | 953ee5e81bee613680468438e3efe4f7c3ff68f6 (patch) | |
tree | 453d9145093448a0222c4b54edce4cf2dac4e81f /src/mbgl/text | |
parent | 81823e35a68eb87d9433457fe9983d06793a77bf (diff) | |
download | qtlocation-mapboxgl-953ee5e81bee613680468438e3efe4f7c3ff68f6.tar.gz |
[core] Create glyph manager at renderer construction time
Avoid unnecessary glyph manager presence check in `Renderer::Impl::()`.
Diffstat (limited to 'src/mbgl/text')
-rw-r--r-- | src/mbgl/text/glyph_manager.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/text/glyph_manager.hpp | 19 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/mbgl/text/glyph_manager.cpp b/src/mbgl/text/glyph_manager.cpp index b947ef72c8..daa142e38f 100644 --- a/src/mbgl/text/glyph_manager.cpp +++ b/src/mbgl/text/glyph_manager.cpp @@ -11,15 +11,14 @@ namespace mbgl { static GlyphManagerObserver nullObserver; -GlyphManager::GlyphManager(FileSource& fileSource_, std::unique_ptr<LocalGlyphRasterizer> localGlyphRasterizer_) - : fileSource(fileSource_), - observer(&nullObserver), +GlyphManager::GlyphManager(std::unique_ptr<LocalGlyphRasterizer> localGlyphRasterizer_) + : observer(&nullObserver), localGlyphRasterizer(std::move(localGlyphRasterizer_)) { } GlyphManager::~GlyphManager() = default; -void GlyphManager::getGlyphs(GlyphRequestor& requestor, GlyphDependencies glyphDependencies) { +void GlyphManager::getGlyphs(GlyphRequestor& requestor, GlyphDependencies glyphDependencies, FileSource& fileSource) { auto dependencies = std::make_shared<GlyphDependencies>(std::move(glyphDependencies)); // Figure out which glyph ranges need to be fetched. For each range that does need to @@ -47,7 +46,7 @@ void GlyphManager::getGlyphs(GlyphRequestor& requestor, GlyphDependencies glyphD if (it == entry.ranges.end() || !it->second.parsed) { GlyphRequest& request = entry.ranges[range]; request.requestors[&requestor] = dependencies; - requestRange(request, fontStack, range); + requestRange(request, fontStack, range, fileSource); } } } @@ -65,7 +64,7 @@ Glyph GlyphManager::generateLocalSDF(const FontStack& fontStack, GlyphID glyphID return local; } -void GlyphManager::requestRange(GlyphRequest& request, const FontStack& fontStack, const GlyphRange& range) { +void GlyphManager::requestRange(GlyphRequest& request, const FontStack& fontStack, const GlyphRange& range, FileSource& fileSource) { if (request.req) { return; } diff --git a/src/mbgl/text/glyph_manager.hpp b/src/mbgl/text/glyph_manager.hpp index 831d84719c..8603a320d2 100644 --- a/src/mbgl/text/glyph_manager.hpp +++ b/src/mbgl/text/glyph_manager.hpp @@ -4,7 +4,6 @@ #include <mbgl/text/glyph_manager_observer.hpp> #include <mbgl/text/glyph_range.hpp> #include <mbgl/text/local_glyph_rasterizer.hpp> -#include <mbgl/util/noncopyable.hpp> #include <mbgl/util/font_stack.hpp> #include <mbgl/util/immutable.hpp> @@ -19,21 +18,25 @@ class Response; class GlyphRequestor { public: - virtual ~GlyphRequestor() = default; virtual void onGlyphsAvailable(GlyphMap) = 0; + +protected: + virtual ~GlyphRequestor() = default; }; -class GlyphManager : public util::noncopyable { +class GlyphManager { public: - GlyphManager(FileSource&, std::unique_ptr<LocalGlyphRasterizer> = std::make_unique<LocalGlyphRasterizer>(optional<std::string>())); + GlyphManager(const GlyphManager&) = delete; + GlyphManager& operator=(const GlyphManager&) = delete; + explicit GlyphManager(std::unique_ptr<LocalGlyphRasterizer> = std::make_unique<LocalGlyphRasterizer>(optional<std::string>())); ~GlyphManager(); // Workers send a `getGlyphs` message to the main thread once they have determined // their `GlyphDependencies`. If all glyphs are already locally available, GlyphManager // will provide them to the requestor immediately. Otherwise, it makes a request on the - // FileSource is made for each range neeed, and notifies the observer when all are + // FileSource is made for each range needed, and notifies the observer when all are // complete. - void getGlyphs(GlyphRequestor&, GlyphDependencies); + void getGlyphs(GlyphRequestor&, GlyphDependencies, FileSource&); void removeRequestor(GlyphRequestor&); void setURL(const std::string& url) { @@ -47,8 +50,6 @@ public: private: Glyph generateLocalSDF(const FontStack& fontStack, GlyphID glyphID); - - FileSource& fileSource; std::string glyphURL; struct GlyphRequest { @@ -64,7 +65,7 @@ private: std::unordered_map<FontStack, Entry, FontStackHasher> entries; - void requestRange(GlyphRequest&, const FontStack&, const GlyphRange&); + void requestRange(GlyphRequest&, const FontStack&, const GlyphRange&, FileSource& fileSource); void processResponse(const Response&, const FontStack&, const GlyphRange&); void notify(GlyphRequestor&, const GlyphDependencies&); |