Reset tileset-based render sources when any tileset properties changed. (#11042)

This commit is contained in:
Asheem Mamoowala
2018-02-05 19:31:03 -05:00
parent 64374711a0
commit 4ab07f5be7
4 changed files with 18 additions and 16 deletions

View File

@@ -29,14 +29,10 @@ void RenderRasterSource::update(Immutable<style::Source::Impl> baseImpl_,
enabled = needsRendering;
optional<Tileset> tileset = impl().getTileset();
optional<Tileset> _tileset = impl().getTileset();
if (!tileset) {
return;
}
if (tileURLTemplates != tileset->tiles) {
tileURLTemplates = tileset->tiles;
if (tileset != _tileset) {
tileset = _tileset;
// TODO: this removes existing buckets, and will cause flickering.
// Should instead refresh tile data in place.
@@ -44,6 +40,11 @@ void RenderRasterSource::update(Immutable<style::Source::Impl> baseImpl_,
tilePyramid.renderTiles.clear();
tilePyramid.cache.clear();
}
// 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;
}
tilePyramid.update(layers,
needsRendering,

View File

@@ -39,7 +39,7 @@ private:
const style::RasterSource::Impl& impl() const;
TilePyramid tilePyramid;
optional<std::vector<std::string>> tileURLTemplates;
optional<Tileset> tileset;
};
template <>

View File

@@ -32,14 +32,10 @@ void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_,
enabled = needsRendering;
optional<Tileset> tileset = impl().getTileset();
optional<Tileset> _tileset = impl().getTileset();
if (!tileset) {
return;
}
if (tileURLTemplates != tileset->tiles) {
tileURLTemplates = tileset->tiles;
if (tileset != _tileset) {
tileset = _tileset;
// TODO: this removes existing buckets, and will cause flickering.
// Should instead refresh tile data in place.
@@ -47,6 +43,11 @@ void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_,
tilePyramid.renderTiles.clear();
tilePyramid.cache.clear();
}
// 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;
}
tilePyramid.update(layers,
needsRendering,

View File

@@ -39,7 +39,7 @@ private:
const style::VectorSource::Impl& impl() const;
TilePyramid tilePyramid;
optional<std::vector<std::string>> tileURLTemplates;
optional<Tileset> tileset;
};
template <>