diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-05-08 19:21:50 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-05-18 10:42:05 +0300 |
commit | 4e7c97466cdca899973dce929b7e13621e558d4a (patch) | |
tree | 1d1099a337a463aa92f882ac9757682c965fa95c /src | |
parent | 3f445e8578b25dbe4adccacd59f317cbb3b9a8d7 (diff) | |
download | qtlocation-mapboxgl-4e7c97466cdca899973dce929b7e13621e558d4a.tar.gz |
Allow reparsing partial tiles when we have new tiles
When parsing a tile, we request resources from the network, like
sprites and glyphs.
In the rare case of the resources arriving before the tile is
parsed for the first time, if we don't mark it for being parsed
again, it can end up with a tile eternally stuck in the partial
state.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/resource_loader.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/map/resource_loader.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/source.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/map/source.hpp | 4 |
4 files changed, 12 insertions, 8 deletions
diff --git a/src/mbgl/map/resource_loader.cpp b/src/mbgl/map/resource_loader.cpp index 46b7af9a28..7b5ebd19df 100644 --- a/src/mbgl/map/resource_loader.cpp +++ b/src/mbgl/map/resource_loader.cpp @@ -101,7 +101,11 @@ void ResourceLoader::onSourceLoaded() { emitTileDataChanged(); } -void ResourceLoader::onTileLoaded() { +void ResourceLoader::onTileLoaded(bool isNewTile) { + if (isNewTile) { + shouldReparsePartialTiles_ = true; + } + emitTileDataChanged(); } diff --git a/src/mbgl/map/resource_loader.hpp b/src/mbgl/map/resource_loader.hpp index cf73db5fa8..379444135e 100644 --- a/src/mbgl/map/resource_loader.hpp +++ b/src/mbgl/map/resource_loader.hpp @@ -65,7 +65,7 @@ public: // Source::Observer implementation. void onSourceLoaded() override; - void onTileLoaded() override; + void onTileLoaded(bool isNewTile) override; // Sprite::Observer implementation. void onSpriteLoaded() override; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 501dde5c25..e40cb0f16b 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -232,7 +232,7 @@ void Source::handlePartialTile(const TileID& id, Worker& worker) { return; } - auto callback = std::bind(&Source::emitTileLoaded, this); + auto callback = std::bind(&Source::emitTileLoaded, this, false); data->reparse(worker, callback); } @@ -273,7 +273,7 @@ TileData::State Source::addTile(MapData& data, new_tile.data = cache.get(normalized_id.to_uint64()); } - auto callback = std::bind(&Source::emitTileLoaded, this); + auto callback = std::bind(&Source::emitTileLoaded, this, true); if (!new_tile.data) { // If we don't find working tile data, we're just going to load it. if (info.type == SourceType::Vector) { @@ -520,9 +520,9 @@ void Source::emitSourceLoaded() { } } -void Source::emitTileLoaded() { +void Source::emitTileLoaded(bool isNewTile) { if (observer_) { - observer_->onTileLoaded(); + observer_->onTileLoaded(isNewTile); } } diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp index d5f4f8b5d0..fcb1b41839 100644 --- a/src/mbgl/map/source.hpp +++ b/src/mbgl/map/source.hpp @@ -58,7 +58,7 @@ public: virtual ~Observer() = default; virtual void onSourceLoaded() = 0; - virtual void onTileLoaded() = 0; + virtual void onTileLoaded(bool isNewTile) = 0; }; Source(); @@ -97,7 +97,7 @@ public: private: void emitSourceLoaded(); - void emitTileLoaded(); + void emitTileLoaded(bool isNewTile); void handlePartialTile(const TileID &id, Worker &worker); bool findLoadedChildren(const TileID& id, int32_t maxCoveringZoom, std::forward_list<TileID>& retain); |