summaryrefslogtreecommitdiff
path: root/src/mbgl/algorithm/update_renderables.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-10-09 12:59:27 +0200
committerKonstantin Käfer <mail@kkaefer.com>2017-10-12 17:58:03 +0200
commit78ea88d757ecf3a0a75b786ae343d746617ba46b (patch)
tree10efd5d389ce7290526e58b393a4c11b73ce3fe0 /src/mbgl/algorithm/update_renderables.hpp
parent56446c5d17ac74aa9bf39bdd3c8d1e9629d8fd41 (diff)
downloadqtlocation-mapboxgl-78ea88d757ecf3a0a75b786ae343d746617ba46b.tar.gz
[core] make forcing cache/network only more explicit
Previously, we used the existence of a `prior*` field in the Resource object as an indication for whether we should consult the cache or not. However, this is prone to error, since a failed cache lookup won't set any prior fields. Therefore, we manually set `priorExpires` to 0. This in turn triggered another bug where generated wrong expiration timestamps when the server response we got was expired (or expired between sending and receiving). This commit changes the flags so that we can now explicitly request CacheOnly/NetworkOnly (or All) loading methods, rather than the implicit Optional/Required naming scheme.
Diffstat (limited to 'src/mbgl/algorithm/update_renderables.hpp')
-rw-r--r--src/mbgl/algorithm/update_renderables.hpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/mbgl/algorithm/update_renderables.hpp b/src/mbgl/algorithm/update_renderables.hpp
index 0c2266ff47..c583b6b2b6 100644
--- a/src/mbgl/algorithm/update_renderables.hpp
+++ b/src/mbgl/algorithm/update_renderables.hpp
@@ -1,8 +1,8 @@
#pragma once
#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/tile/tile_necessity.hpp>
#include <mbgl/util/range.hpp>
-#include <mbgl/storage/resource.hpp>
#include <unordered_set>
@@ -40,15 +40,15 @@ void updateRenderables(GetTileFn getTile,
// if (source has the tile and bucket is loaded) {
if (tile->isRenderable()) {
- retainTile(*tile, Resource::Necessity::Required);
+ retainTile(*tile, TileNecessity::Required);
renderTile(idealRenderTileID, *tile);
} else {
// We are now attempting to load child and parent tiles.
- bool parentHasTriedOptional = tile->hasTriedOptional();
+ bool parentHasTriedOptional = tile->hasTriedCache();
bool parentIsLoaded = tile->isLoaded();
// The tile isn't loaded yet, but retain it anyway because it's an ideal tile.
- retainTile(*tile, Resource::Necessity::Required);
+ retainTile(*tile, TileNecessity::Required);
covered = true;
overscaledZ = dataTileZoom + 1;
if (overscaledZ > zoomRange.max) {
@@ -56,7 +56,7 @@ void updateRenderables(GetTileFn getTile,
const auto childDataTileID = idealDataTileID.scaledTo(overscaledZ);
tile = getTile(childDataTileID);
if (tile && tile->isRenderable()) {
- retainTile(*tile, Resource::Necessity::Optional);
+ retainTile(*tile, TileNecessity::Optional);
renderTile(idealRenderTileID, *tile);
} else {
covered = false;
@@ -67,7 +67,7 @@ void updateRenderables(GetTileFn getTile,
const OverscaledTileID childDataTileID(overscaledZ, idealRenderTileID.wrap, childTileID);
tile = getTile(childDataTileID);
if (tile && tile->isRenderable()) {
- retainTile(*tile, Resource::Necessity::Optional);
+ retainTile(*tile, TileNecessity::Optional);
renderTile(childDataTileID.toUnwrapped(), *tile);
} else {
// At least one child tile doesn't exist, so we are going to look for
@@ -97,12 +97,19 @@ void updateRenderables(GetTileFn getTile,
}
if (tile) {
- retainTile(*tile, parentIsLoaded ? Resource::Necessity::Required
- : Resource::Necessity::Optional);
+ if (!parentIsLoaded) {
+ // We haven't completed loading the child, so we only do an optional
+ // (cache) request in an attempt to quickly load data that we can show.
+ retainTile(*tile, TileNecessity::Optional);
+ } else {
+ // Now that we've checked the child and know for sure that we can't load
+ // it, we attempt to load the parent from the network.
+ retainTile(*tile, TileNecessity::Required);
+ }
// Save the current values, since they're the parent of the next iteration
// of the parent tile ascent loop.
- parentHasTriedOptional = tile->hasTriedOptional();
+ parentHasTriedOptional = tile->hasTriedCache();
parentIsLoaded = tile->isLoaded();
if (tile->isRenderable()) {