Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] look for loaded parent tiles in cache #4595

Merged
merged 1 commit into from
Apr 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/mbgl/source/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ bool Source::findLoadedChildren(const TileID& tileID, int32_t maxCoveringZoom, s
*
* @return boolean Whether a parent was found.
*/
void Source::findLoadedParent(const TileID& tileID, int32_t minCoveringZoom, std::vector<TileID>& retain) {
void Source::findLoadedParent(const TileID& tileID, int32_t minCoveringZoom, std::vector<TileID>& retain, const StyleUpdateParameters& parameters) {
for (int32_t z = tileID.z - 1; z >= minCoveringZoom; --z) {
const TileID parent_id = tileID.parent(z, info->maxZoom);
const TileData::State state = hasTile(parent_id);
Expand All @@ -338,6 +338,12 @@ void Source::findLoadedParent(const TileID& tileID, int32_t minCoveringZoom, std
return;
}
}

if (cache.has(parent_id.normalized().to_uint64())) {
addTile(parent_id, parameters);
retain.emplace_back(parent_id);
return;
}
}
}

Expand Down Expand Up @@ -400,7 +406,7 @@ bool Source::update(const StyleUpdateParameters& parameters) {
// Then, if there are no complete child tiles, try to find existing
// parent tiles that completely cover the missing tile.
if (!complete) {
findLoadedParent(tileID, minCoveringZoom, retain);
findLoadedParent(tileID, minCoveringZoom, retain, parameters);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/source/source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Source : private util::noncopyable {
bool isNewTile);
bool handlePartialTile(const TileID&);
bool findLoadedChildren(const TileID&, int32_t maxCoveringZoom, std::vector<TileID>& retain);
void findLoadedParent(const TileID&, int32_t minCoveringZoom, std::vector<TileID>& retain);
void findLoadedParent(const TileID&, int32_t minCoveringZoom, std::vector<TileID>& retain, const StyleUpdateParameters&);

TileData::State addTile(const TileID&, const StyleUpdateParameters&);
TileData::State hasTile(const TileID&);
Expand Down