diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-06-24 18:40:46 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-06-25 16:26:21 +0300 |
commit | be4cb6786babca3368b10e2c1c1aaa9eb43e5663 (patch) | |
tree | ea3def9013e1666d92d35cff261e0f9bff16beba /src/mbgl/text/glyph_pbf.cpp | |
parent | b56c356de71a3edec76984ddf4202c92930bd17b (diff) | |
download | qtlocation-mapboxgl-be4cb6786babca3368b10e2c1c1aaa9eb43e5663.tar.gz |
Make the FileSource available from the ThreadContext
For now we set the FileSource for the Worker context
but in the future after fixing #1664 we can assert()
that FileSource are set only for the Map thread context.
Diffstat (limited to 'src/mbgl/text/glyph_pbf.cpp')
-rw-r--r-- | src/mbgl/text/glyph_pbf.cpp | 12 |
1 files changed, 6 insertions, 6 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); } } |