summaryrefslogtreecommitdiff
path: root/src/mbgl/text
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-18 10:48:51 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-18 15:15:24 -0800
commit7b39ce95210ceb6640b3a3399dacd1d0e826ac1f (patch)
treeeb97fdc8a284826d3a3fe9426a8a10f88a654799 /src/mbgl/text
parentd5eb5240f8c35016927e89bf9d186addc09b83fa (diff)
downloadqtlocation-mapboxgl-7b39ce95210ceb6640b3a3399dacd1d0e826ac1f.tar.gz
[core] Remove ThreadContext::getFileSource; instead thread FileSource through
Diffstat (limited to 'src/mbgl/text')
-rw-r--r--src/mbgl/text/glyph_pbf.cpp7
-rw-r--r--src/mbgl/text/glyph_pbf.hpp4
-rw-r--r--src/mbgl/text/glyph_store.cpp7
-rw-r--r--src/mbgl/text/glyph_store.hpp4
4 files changed, 14 insertions, 8 deletions
diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp
index 5973c0ce14..c9466e8652 100644
--- a/src/mbgl/text/glyph_pbf.cpp
+++ b/src/mbgl/text/glyph_pbf.cpp
@@ -8,7 +8,6 @@
#include <mbgl/util/exception.hpp>
#include <mbgl/util/pbf.hpp>
#include <mbgl/util/string.hpp>
-#include <mbgl/util/thread_context.hpp>
#include <mbgl/util/token.hpp>
#include <mbgl/util/url.hpp>
@@ -64,11 +63,11 @@ namespace mbgl {
GlyphPBF::GlyphPBF(GlyphStore* store,
const std::string& fontStack,
const GlyphRange& glyphRange,
- GlyphStore::Observer* observer_)
+ GlyphStore::Observer* observer_,
+ FileSource& fileSource)
: parsed(false),
observer(observer_) {
- FileSource* fs = util::ThreadContext::getFileSource();
- req = fs->request(Resource::glyphs(store->getURL(), fontStack, glyphRange), [this, store, fontStack, glyphRange](Response res) {
+ req = fileSource.request(Resource::glyphs(store->getURL(), fontStack, glyphRange), [this, store, fontStack, glyphRange](Response res) {
if (res.error) {
observer->onGlyphsError(fontStack, glyphRange, std::make_exception_ptr(std::runtime_error(res.error->message)));
} else if (res.notModified) {
diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp
index 9e2ee4eacf..016792aae8 100644
--- a/src/mbgl/text/glyph_pbf.hpp
+++ b/src/mbgl/text/glyph_pbf.hpp
@@ -14,13 +14,15 @@ namespace mbgl {
class FontStack;
class FileRequest;
+class FileSource;
class GlyphPBF : private util::noncopyable {
public:
GlyphPBF(GlyphStore* store,
const std::string& fontStack,
const GlyphRange&,
- GlyphStore::Observer*);
+ GlyphStore::Observer*,
+ FileSource&);
~GlyphPBF();
bool isParsed() const {
diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp
index a3d1530e3d..1c75f7191e 100644
--- a/src/mbgl/text/glyph_store.cpp
+++ b/src/mbgl/text/glyph_store.cpp
@@ -7,7 +7,10 @@
namespace mbgl {
-GlyphStore::GlyphStore() = default;
+GlyphStore::GlyphStore(FileSource& fileSource_)
+ : fileSource(fileSource_) {
+}
+
GlyphStore::~GlyphStore() = default;
void GlyphStore::requestGlyphRange(const std::string& fontStackName, const GlyphRange& range) {
@@ -22,7 +25,7 @@ void GlyphStore::requestGlyphRange(const std::string& fontStackName, const Glyph
}
rangeSets.emplace(range,
- std::make_unique<GlyphPBF>(this, fontStackName, range, observer));
+ std::make_unique<GlyphPBF>(this, fontStackName, range, observer, fileSource));
}
diff --git a/src/mbgl/text/glyph_store.hpp b/src/mbgl/text/glyph_store.hpp
index 2236bce38c..6829397851 100644
--- a/src/mbgl/text/glyph_store.hpp
+++ b/src/mbgl/text/glyph_store.hpp
@@ -14,6 +14,7 @@
namespace mbgl {
+class FileSource;
class GlyphPBF;
// The GlyphStore manages the loading and storage of Glyphs
@@ -29,7 +30,7 @@ public:
virtual void onGlyphsError(const std::string& /* fontStack */, const GlyphRange&, std::exception_ptr) {};
};
- GlyphStore();
+ GlyphStore(FileSource&);
~GlyphStore();
util::exclusive<FontStack> getFontStack(const std::string& fontStack);
@@ -54,6 +55,7 @@ public:
private:
void requestGlyphRange(const std::string& fontStackName, const GlyphRange& range);
+ FileSource& fileSource;
std::string glyphURL;
std::unordered_map<std::string, std::map<GlyphRange, std::unique_ptr<GlyphPBF>>> ranges;