diff options
Diffstat (limited to 'src/mbgl/text')
-rw-r--r-- | src/mbgl/text/glyph_pbf.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/text/glyph_pbf.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/text/glyph_store.cpp | 2 |
3 files changed, 7 insertions, 10 deletions
diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp index 899df39d38..142461ec71 100644 --- a/src/mbgl/text/glyph_pbf.cpp +++ b/src/mbgl/text/glyph_pbf.cpp @@ -1,13 +1,13 @@ #include <mbgl/text/glyph_pbf.hpp> #include <mbgl/text/font_stack.hpp> -#include <mbgl/map/environment.hpp> - +#include <mbgl/storage/file_source.hpp> #include <mbgl/storage/resource.hpp> #include <mbgl/storage/response.hpp> #include <mbgl/util/pbf.hpp> #include <mbgl/util/string.hpp> +#include <mbgl/util/thread.hpp> #include <mbgl/util/token.hpp> #include <mbgl/util/url.hpp> @@ -18,10 +18,9 @@ namespace mbgl { GlyphPBF::GlyphPBF(const std::string& glyphURL, const std::string& fontStack, GlyphRange glyphRange, - Environment& env_, const GlyphLoadedCallback& successCallback, const GlyphLoadingFailedCallback& failureCallback) - : parsed(false), env(env_) { + : parsed(false) { // Load the glyph set URL url = util::replaceTokens(glyphURL, [&](const std::string &name) -> std::string { if (name == "fontstack") return util::percentEncode(fontStack); @@ -30,7 +29,8 @@ GlyphPBF::GlyphPBF(const std::string& glyphURL, }); // The prepare call jumps back to the main thread. - req = env.request({ Resource::Kind::Glyphs, url }, [&, successCallback, failureCallback](const Response &res) { + FileSource* fs = util::ThreadContext::getFileSource(); + req = fs->request({ Resource::Kind::Glyphs, url }, util::RunLoop::current.get()->get(), [&, successCallback, failureCallback](const Response &res) { req = nullptr; if (res.status != Response::Successful) { @@ -50,7 +50,7 @@ GlyphPBF::GlyphPBF(const std::string& glyphURL, GlyphPBF::~GlyphPBF() { if (req) { - env.cancelRequest(req); + util::ThreadContext::getFileSource()->cancel(req); } } diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp index bb6fa83ae6..cc083e7f10 100644 --- a/src/mbgl/text/glyph_pbf.hpp +++ b/src/mbgl/text/glyph_pbf.hpp @@ -9,7 +9,6 @@ namespace mbgl { -class Environment; class FontStack; class Request; @@ -21,7 +20,6 @@ public: GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, - Environment &env, const GlyphLoadedCallback& successCallback, const GlyphLoadingFailedCallback& failureCallback); ~GlyphPBF(); @@ -43,7 +41,6 @@ private: std::string url; std::atomic<bool> parsed; - Environment& env; Request* req = nullptr; }; diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp index 9520b63c06..9afa765424 100644 --- a/src/mbgl/text/glyph_store.cpp +++ b/src/mbgl/text/glyph_store.cpp @@ -56,7 +56,7 @@ bool GlyphStore::requestGlyphRangesIfNeeded(const std::string& fontStackName, for (const auto& range : glyphRanges) { const auto& rangeSets_it = rangeSets.find(range); if (rangeSets_it == rangeSets.end()) { - auto glyph = std::make_unique<GlyphPBF>(glyphURL, fontStackName, range, env, + auto glyph = std::make_unique<GlyphPBF>(glyphURL, fontStackName, range, successCallback, failureCallback); rangeSets.emplace(range, std::move(glyph)); requestIsNeeded = true; |