Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse prefetched tiles to avoid empty screen #2668

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9224a15
Reuse rendered tiles to avoid empty screen.
alexcristici Jul 31, 2024
4bc2c23
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2024
7b1890f
Merge branch 'main' into reuse-rendered-tiles-to-avoid-empty-screen
alexcristici Jul 31, 2024
47a753a
Merge branch 'main' into reuse-rendered-tiles-to-avoid-empty-screen
alexcristici Jul 31, 2024
88f35a5
Typo.
alexcristici Jul 31, 2024
b145ec8
Fixed update renderables test.
alexcristici Jul 31, 2024
5f8b6b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2024
3a6fbfa
Cpp unit tests fixes.
alexcristici Jul 31, 2024
1f1afcc
Improved from using previously rendered tiles to prefetched tiles in …
alexcristici Aug 1, 2024
933984d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 1, 2024
83ae586
Removed unnecessary fix.
alexcristici Aug 1, 2024
254a29b
Merge branch 'reuse-rendered-tiles-to-avoid-empty-screen' of https://…
alexcristici Aug 1, 2024
38869c8
Merge branch 'main' into reuse-rendered-tiles-to-avoid-empty-screen
alexcristici Aug 2, 2024
81c3d59
Units tests fixed.
alexcristici Aug 2, 2024
3b5b0c6
Added unit test.
alexcristici Aug 2, 2024
e11c912
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2024
e51f373
Fixed zoom out issue that keeps the childern too long instead using p…
alexcristici Aug 2, 2024
181704c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2024
a9f6223
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2024
3ed6303
Fix comments.
alexcristici Aug 2, 2024
0a57a3c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2024
79d4a9d
manual run clang-format
louwers Aug 2, 2024
1d3b99f
Merge branch 'main' into reuse-rendered-tiles-to-avoid-empty-screen
alexcristici Aug 6, 2024
889c36f
Fixed variable initialization.
alexcristici Aug 7, 2024
e4a5905
Merge branch 'main' into reuse-rendered-tiles-to-avoid-empty-screen
alexcristici Aug 7, 2024
4de3e65
Merge branch 'main' into reuse-rendered-tiles-to-avoid-empty-screen
alexcristici Aug 12, 2024
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
39 changes: 19 additions & 20 deletions src/mbgl/algorithm/update_renderables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void updateRenderables(GetTileFn getTile,
const std::optional<uint8_t>& maxParentOverscaleFactor = std::nullopt) {
std::unordered_set<OverscaledTileID> checked;
bool covered;
bool parentOrChildTileFound;
alexcristici marked this conversation as resolved.
Show resolved Hide resolved
int32_t overscaledZ;

// for (all in the set of ideal tiles of the source) {
Expand Down Expand Up @@ -56,21 +57,8 @@ void updateRenderables(GetTileFn getTile,

// The tile isn't loaded yet, but retain it anyway because it's an ideal tile.
retainTile(*tile, TileNecessity::Required);

auto addPrefetchedTilesIfChildrenOf = [&](const OverscaledTileID& tileID) {
for (auto& prefetchedTileEntry : prefetchedTiles) {
const auto& prefetchedDataTileID = prefetchedTileEntry.first;
const UnwrappedTileID prefetchedRenderTileID = prefetchedDataTileID.toUnwrapped();
auto* prefetchedTile = prefetchedTileEntry.second.get();
if (prefetchedTile->isRenderable() && prefetchedDataTileID.canonical.z <= zoomRange.max &&
prefetchedDataTileID.isChildOf(tileID)) {
retainTile(*prefetchedTile, TileNecessity::Optional);
renderTile(prefetchedRenderTileID, *prefetchedTile);
}
}
};

covered = true;
parentOrChildTileFound = false;
overscaledZ = idealDataTileID.overscaledZ + 1;
if (overscaledZ > zoomRange.max) {
// We're looking for an overzoomed child tile.
Expand All @@ -79,11 +67,9 @@ void updateRenderables(GetTileFn getTile,
if (tile && tile->isRenderable()) {
retainTile(*tile, TileNecessity::Optional);
renderTile(idealRenderTileID, *tile);
parentOrChildTileFound = true;
} else {
covered = false;

// Reuse prefetched tiles in order to avoid empty screen
addPrefetchedTilesIfChildrenOf(idealDataTileID);
}
} else {
// Check all four actual child tiles.
Expand All @@ -93,13 +79,11 @@ void updateRenderables(GetTileFn getTile,
if (tile && tile->isRenderable()) {
retainTile(*tile, TileNecessity::Optional);
renderTile(childDataTileID.toUnwrapped(), *tile);
parentOrChildTileFound = true;
} else {
// At least one child tile doesn't exist, so we are
// going to look for parents as well.
covered = false;

// Reuse prefetched tiles in order to avoid empty screen
addPrefetchedTilesIfChildrenOf(childDataTileID);
}
}
}
Expand Down Expand Up @@ -149,11 +133,26 @@ void updateRenderables(GetTileFn getTile,

if (tile->isRenderable()) {
renderTile(parentDataTileID.toUnwrapped(), *tile);
parentOrChildTileFound = true;
// Break parent tile ascent, since we found one.
break;
}
}
}

if (!parentOrChildTileFound) {
// Reuse prefetched tiles in order to avoid empty screen
for (auto& prefetchedTileEntry : prefetchedTiles) {
const auto& prefetchedDataTileID = prefetchedTileEntry.first;
const UnwrappedTileID prefetchedRenderTileID = prefetchedDataTileID.toUnwrapped();
auto* prefetchedTile = prefetchedTileEntry.second.get();
if (prefetchedTile->isRenderable() && prefetchedDataTileID.canonical.z <= zoomRange.max &&
prefetchedDataTileID.isChildOf(idealDataTileID)) {
retainTile(*prefetchedTile, TileNecessity::Optional);
renderTile(prefetchedRenderTileID, *prefetchedTile);
}
}
}
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions test/algorithm/update_renderables.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,15 @@ TEST(UpdateRenderables, UseChildTiles) {
GetTileDataAction{{0, 0, {0, 0, 0}}, Found}, // ideal tile not ready
RetainTileDataAction{{0, 0, {0, 0, 0}}, TileNecessity::Required}, //
GetTileDataAction{{1, 0, {1, 0, 0}}, NotFound}, // child tile not found
GetTileDataAction{{1, 0, {1, 0, 1}}, NotFound}, // child tile not found
GetTileDataAction{{1, 0, {1, 1, 0}}, NotFound}, // child tile not found
GetTileDataAction{{1, 0, {1, 1, 1}}, NotFound}, // child tile not found
// no parent tile of 0 to consider
// no parent or child tile found, check prefetched tiles
RetainTileDataAction{{2, 0, {2, 0, 0}}, TileNecessity::Optional},
RenderTileAction{{2, 0, 0}, *tile_2_2_0_0}, // render child from 2 levels down
RenderTileAction{{2, 0, 0}, *tile_2_2_0_0}, // render child from 2 levels down
RetainTileDataAction{{2, 0, {2, 1, 0}}, TileNecessity::Optional},
RenderTileAction{{2, 1, 0}, *tile_2_2_1_0}, // render child from 2 levels down
GetTileDataAction{{1, 0, {1, 0, 1}}, NotFound}, // child tile not found
GetTileDataAction{{1, 0, {1, 1, 0}}, NotFound}, // child tile not found
GetTileDataAction{{1, 0, {1, 1, 1}}, NotFound}, // child tile not found
// no parent tile of 0 to consider
RenderTileAction{{2, 1, 0}, *tile_2_2_1_0}, // render child from 2 levels down
}),
log);
}
Expand Down
Loading