summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-16 15:12:41 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-22 10:41:03 +0300
commitbbe7679bc66ac6848d3b38931a3065de1b7a30ae (patch)
treec8cda18b0d424f3f286baf3f384e447b26f60c9e
parent1aa4776dc1d7e60989fa7524a816e7db1b92056b (diff)
downloadqtlocation-mapboxgl-bbe7679bc66ac6848d3b38931a3065de1b7a30ae.tar.gz
[core] Render sources keep the existing tiles until the new tileset is ready
In Continuous map mode, keep the existing tiles if the new tileset is not yet available, thus providing smart style transitions without flickering.
-rw-r--r--src/mbgl/renderer/sources/render_raster_dem_source.cpp12
-rw-r--r--src/mbgl/renderer/sources/render_raster_source.cpp12
-rw-r--r--src/mbgl/renderer/sources/render_vector_source.cpp12
3 files changed, 24 insertions, 12 deletions
diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.cpp b/src/mbgl/renderer/sources/render_raster_dem_source.cpp
index 841124fa4a..06ddf3e7e0 100644
--- a/src/mbgl/renderer/sources/render_raster_dem_source.cpp
+++ b/src/mbgl/renderer/sources/render_raster_dem_source.cpp
@@ -4,6 +4,7 @@
#include <mbgl/algorithm/update_tile_masks.hpp>
#include <mbgl/geometry/dem_data.hpp>
#include <mbgl/renderer/buckets/hillshade_bucket.hpp>
+#include <mbgl/renderer/tile_parameters.hpp>
namespace mbgl {
@@ -27,16 +28,19 @@ void RenderRasterDEMSource::update(Immutable<style::Source::Impl> baseImpl_,
enabled = needsRendering;
optional<Tileset> _tileset = impl().getTileset();
-
- if (tileset != _tileset) {
+ // In Continuous mode, keep the existing tiles if the new tileset is not
+ // yet available, thus providing smart style transitions without flickering.
+ // In other modes, allow clearing the tile pyramid first, before the early
+ // return in order to avoid render tests being flaky.
+ bool canUpdateTileset = _tileset || parameters.mode != MapMode::Continuous;
+ if (canUpdateTileset && tileset != _tileset) {
tileset = _tileset;
maxzoom = tileset->zoomRange.max;
// TODO: this removes existing buckets, and will cause flickering.
// Should instead refresh tile data in place.
tilePyramid.clearAll();
}
- // Allow clearing the tile pyramid first, before the early return in case
- // the new tileset is not yet available or has an error in loading
+
if (!_tileset) {
return;
}
diff --git a/src/mbgl/renderer/sources/render_raster_source.cpp b/src/mbgl/renderer/sources/render_raster_source.cpp
index 06eb36795b..7c7a987c85 100644
--- a/src/mbgl/renderer/sources/render_raster_source.cpp
+++ b/src/mbgl/renderer/sources/render_raster_source.cpp
@@ -2,6 +2,7 @@
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/tile/raster_tile.hpp>
#include <mbgl/algorithm/update_tile_masks.hpp>
+#include <mbgl/renderer/tile_parameters.hpp>
namespace mbgl {
@@ -25,16 +26,19 @@ void RenderRasterSource::update(Immutable<style::Source::Impl> baseImpl_,
enabled = needsRendering;
optional<Tileset> _tileset = impl().getTileset();
-
- if (tileset != _tileset) {
+ // In Continuous mode, keep the existing tiles if the new tileset is not
+ // yet available, thus providing smart style transitions without flickering.
+ // In other modes, allow clearing the tile pyramid first, before the early
+ // return in order to avoid render tests being flaky.
+ bool canUpdateTileset = _tileset || parameters.mode != MapMode::Continuous;
+ if (canUpdateTileset && tileset != _tileset) {
tileset = _tileset;
// TODO: this removes existing buckets, and will cause flickering.
// Should instead refresh tile data in place.
tilePyramid.clearAll();
}
- // Allow clearing the tile pyramid first, before the early return in case
- // the new tileset is not yet available or has an error in loading
+
if (!_tileset) {
return;
}
diff --git a/src/mbgl/renderer/sources/render_vector_source.cpp b/src/mbgl/renderer/sources/render_vector_source.cpp
index 53fc4c8299..3990cb86fa 100644
--- a/src/mbgl/renderer/sources/render_vector_source.cpp
+++ b/src/mbgl/renderer/sources/render_vector_source.cpp
@@ -2,6 +2,7 @@
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/tile/vector_tile.hpp>
+#include <mbgl/renderer/tile_parameters.hpp>
namespace mbgl {
@@ -25,16 +26,19 @@ void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_,
enabled = needsRendering;
optional<Tileset> _tileset = impl().getTileset();
-
- if (tileset != _tileset) {
+ // In Continuous mode, keep the existing tiles if the new tileset is not
+ // yet available, thus providing smart style transitions without flickering.
+ // In other modes, allow clearing the tile pyramid first, before the early
+ // return in order to avoid render tests being flaky.
+ bool canUpdateTileset = _tileset || parameters.mode != MapMode::Continuous;
+ if (canUpdateTileset && tileset != _tileset) {
tileset = _tileset;
// TODO: this removes existing buckets, and will cause flickering.
// Should instead refresh tile data in place.
tilePyramid.clearAll();
}
- // Allow clearing the tile pyramid first, before the early return in case
- // the new tileset is not yet available or has an error in loading
+
if (!_tileset) {
return;
}