summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-11 16:46:22 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-11-12 15:12:31 +0200
commit49bcf69a3bc9e73e0f81542b9747ead16f3117ae (patch)
tree086c8f87e823df3a556768029fecf40100787909
parentbd5397a8864ddac45259e42efdc497f675669d90 (diff)
downloadqtlocation-mapboxgl-49bcf69a3bc9e73e0f81542b9747ead16f3117ae.tar.gz
[core] Avoid GeoJSON source flickering on style transitions
Before this change, all GeoJSON source cleared tile pyramid at the style transition and it caused flickering. Now, in Continuous mode, we keep the existing tiles until the new GeoJSON data is not yet available, thus providing smart style transitions without flickering. In other modes (Static, Tile) clear the tile pyramid in order to avoid render tests being flaky.
-rw-r--r--src/mbgl/renderer/sources/render_geojson_source.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mbgl/renderer/sources/render_geojson_source.cpp b/src/mbgl/renderer/sources/render_geojson_source.cpp
index 035244e371..67b4c48d9b 100644
--- a/src/mbgl/renderer/sources/render_geojson_source.cpp
+++ b/src/mbgl/renderer/sources/render_geojson_source.cpp
@@ -85,26 +85,27 @@ void RenderGeoJSONSource::update(Immutable<style::Source::Impl> baseImpl_,
enabled = needsRendering;
auto data_ = impl().getData().lock();
+ if (!data_) {
+ // In Continuous mode, keep the existing tiles if the new data_ 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.
+ if (parameters.mode != MapMode::Continuous) tilePyramid.clearAll();
+ return;
+ }
if (data.lock() != data_) {
data = data_;
tilePyramid.reduceMemoryUse();
-
- if (data_) {
- const uint8_t maxZ = impl().getZoomRange().max;
- for (const auto& pair : tilePyramid.getTiles()) {
- if (pair.first.canonical.z <= maxZ) {
- static_cast<GeoJSONTile*>(pair.second.get())->updateData(data_->getTile(pair.first.canonical), needsRelayout);
- }
+ const uint8_t maxZ = impl().getZoomRange().max;
+ for (const auto& pair : tilePyramid.getTiles()) {
+ if (pair.first.canonical.z <= maxZ) {
+ static_cast<GeoJSONTile*>(pair.second.get())
+ ->updateData(data_->getTile(pair.first.canonical), needsRelayout);
}
}
}
- if (!data_) {
- tilePyramid.clearAll();
- return;
- }
-
tilePyramid.update(layers,
needsRendering,
needsRelayout,