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.
This commit is contained in:
Thiago Marcos P. Santos
2015-05-08 19:21:50 +03:00
parent 3f445e8578
commit 4e7c97466c
4 changed files with 12 additions and 8 deletions

View File

@@ -101,7 +101,11 @@ void ResourceLoader::onSourceLoaded() {
emitTileDataChanged();
}
void ResourceLoader::onTileLoaded() {
void ResourceLoader::onTileLoaded(bool isNewTile) {
if (isNewTile) {
shouldReparsePartialTiles_ = true;
}
emitTileDataChanged();
}

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);