diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-20 17:13:35 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-21 14:25:11 -0800 |
commit | 9e971095d3561f7af5b0016614035a8b4e479b81 (patch) | |
tree | be6a4d226e37ebe5db7dc2d132b27ecdefae37ff /src | |
parent | a9b20fc09a51d62d471d8234387d07a838b4ca76 (diff) | |
download | qtlocation-mapboxgl-9e971095d3561f7af5b0016614035a8b4e479b81.tar.gz |
Pass FileSource by reference
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.cpp | 6 | ||||
-rw-r--r-- | src/map/sprite.cpp | 8 | ||||
-rw-r--r-- | src/text/glyph_store.cpp | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index 3daaa87987..73867b2298 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -346,7 +346,7 @@ void Map::setStyleJSON(std::string newStyleJSON, const std::string &base) { style->loadJSON((const uint8_t *)styleJSON.c_str()); if (!fileSource) { fileSource = std::make_shared<FileSource>(**loop, platform::defaultCacheDatabase()); - glyphStore = std::make_shared<GlyphStore>(fileSource); + glyphStore = std::make_shared<GlyphStore>(*fileSource); } fileSource->setBase(base); glyphStore->setURL(util::mapbox::normalizeGlyphsURL(style->glyph_url, getAccessToken())); @@ -370,7 +370,7 @@ util::ptr<Sprite> Map::getSprite() { const float pixelRatio = state.getPixelRatio(); const std::string &sprite_url = style->getSpriteURL(); if (!sprite || sprite->pixelRatio != pixelRatio) { - sprite = Sprite::Create(sprite_url, pixelRatio, fileSource); + sprite = Sprite::Create(sprite_url, pixelRatio, *fileSource); } return sprite; @@ -649,7 +649,7 @@ void Map::updateTiles() { void Map::prepare() { if (!fileSource) { fileSource = std::make_shared<FileSource>(**loop, platform::defaultCacheDatabase()); - glyphStore = std::make_shared<GlyphStore>(fileSource); + glyphStore = std::make_shared<GlyphStore>(*fileSource); } if (!style) { diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index ad1a8e770b..82073619d4 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -22,7 +22,7 @@ SpritePosition::SpritePosition(uint16_t x_, uint16_t y_, uint16_t width_, uint16 sdf(sdf_) { } -util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr<FileSource> &fileSource) { +util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, FileSource& fileSource) { util::ptr<Sprite> sprite(std::make_shared<Sprite>(Key(), base_url, pixelRatio)); sprite->load(fileSource); return sprite; @@ -51,7 +51,7 @@ Sprite::operator bool() const { // Note: This is a separate function that must be called exactly once after creation // The reason this isn't part of the constructor is that calling shared_from_this() in // the constructor fails. -void Sprite::load(const util::ptr<FileSource> &fileSource) { +void Sprite::load(FileSource& fileSource) { if (!valid) { // Treat a non-existent sprite as a successfully loaded empty sprite. loadedImage = true; @@ -62,7 +62,7 @@ void Sprite::load(const util::ptr<FileSource> &fileSource) { util::ptr<Sprite> sprite = shared_from_this(); - fileSource->request(ResourceType::JSON, jsonURL)->onload([sprite](const Response &res) { + fileSource.request(ResourceType::JSON, jsonURL)->onload([sprite](const Response &res) { if (res.code == 200) { sprite->body = res.data; sprite->parseJSON(); @@ -75,7 +75,7 @@ void Sprite::load(const util::ptr<FileSource> &fileSource) { } }); - fileSource->request(ResourceType::Image, spriteURL)->onload([sprite](const Response &res) { + fileSource.request(ResourceType::Image, spriteURL)->onload([sprite](const Response &res) { if (res.code == 200) { sprite->image = res.data; sprite->parseImage(); diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 5619c4f93f..737bad35d8 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -137,7 +137,7 @@ void FontStack::lineWrap(Shaping &shaping, const float lineHeight, const float m align(shaping, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, line); } -GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, const util::ptr<FileSource> &fileSource) +GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, FileSource& fileSource) : future(promise.get_future().share()) { // Load the glyph set URL @@ -148,8 +148,8 @@ GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, Gl }); // The prepare call jumps back to the main thread. - fileSource->prepare([&, url, fileSource] { - auto request = fileSource->request(ResourceType::Glyphs, url); + fileSource.prepare([&, url] { + auto request = fileSource.request(ResourceType::Glyphs, url); request->onload([&, url](const Response &res) { if (res.code != 200) { // Something went wrong with loading the glyph pbf. Pass on the error to the future listeners. @@ -228,7 +228,7 @@ void GlyphPBF::parse(FontStack &stack) { data.clear(); } -GlyphStore::GlyphStore(const util::ptr<FileSource> &fileSource_) : fileSource(fileSource_) {} +GlyphStore::GlyphStore(FileSource& fileSource_) : fileSource(fileSource_) {} void GlyphStore::setURL(const std::string &url) { glyphURL = url; |