[core] Do not cache stale tiles

This commit is contained in:
Bruno de Oliveira Abinader
2017-09-11 23:30:51 -04:00
parent 88a0187f21
commit f40519e78d
3 changed files with 20 additions and 24 deletions

View File

@@ -40,7 +40,6 @@
"render-tests/regressions/mapbox-gl-js#2305": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/regressions/mapbox-gl-js#3682": "https://github.com/mapbox/mapbox-gl-js/issues/3682",
"render-tests/regressions/mapbox-gl-native#7357": "https://github.com/mapbox/mapbox-gl-native/issues/7357",
"render-tests/regressions/mapbox-gl-native#9900": "skip - https://github.com/mapbox/mapbox-gl-native/pull/9905",
"render-tests/runtime-styling/image-add-sdf": "https://github.com/mapbox/mapbox-gl-native/issues/9847",
"render-tests/runtime-styling/paint-property-fill-flat-to-extrude": "https://github.com/mapbox/mapbox-gl-native/issues/6745",
"render-tests/runtime-styling/set-style-paint-property-fill-flat-to-extrude": "https://github.com/mapbox/mapbox-gl-native/issues/6745",

View File

@@ -171,7 +171,26 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer
cache.setSize(conservativeCacheSize);
}
removeStaleTiles(retain);
// Remove stale tiles. This goes through the (sorted!) tiles map and retain set in lockstep
// and removes items from tiles that don't have the corresponding key in the retain set.
{
auto tilesIt = tiles.begin();
auto retainIt = retain.begin();
while (tilesIt != tiles.end()) {
if (retainIt == retain.end() || tilesIt->first < *retainIt) {
if (!needsRelayout) {
tilesIt->second->setNecessity(Tile::Necessity::Optional);
cache.add(tilesIt->first, std::move(tilesIt->second));
}
tiles.erase(tilesIt++);
} else {
if (!(*retainIt < tilesIt->first)) {
++tilesIt;
}
++retainIt;
}
}
}
for (auto& pair : tiles) {
const PlacementConfig config { parameters.transformState.getAngle(),
@@ -184,26 +203,6 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer
}
}
// Moves all tiles to the cache except for those specified in the retain set.
void TilePyramid::removeStaleTiles(const std::set<OverscaledTileID>& retain) {
// Remove stale tiles. This goes through the (sorted!) tiles map and retain set in lockstep
// and removes items from tiles that don't have the corresponding key in the retain set.
auto tilesIt = tiles.begin();
auto retainIt = retain.begin();
while (tilesIt != tiles.end()) {
if (retainIt == retain.end() || tilesIt->first < *retainIt) {
tilesIt->second->setNecessity(Tile::Necessity::Optional);
cache.add(tilesIt->first, std::move(tilesIt->second));
tiles.erase(tilesIt++);
} else {
if (!(*retainIt < tilesIt->first)) {
++tilesIt;
}
++retainIt;
}
}
}
std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const std::vector<const RenderLayer*>& layers,

View File

@@ -63,8 +63,6 @@ public:
bool enabled = false;
void removeStaleTiles(const std::set<OverscaledTileID>&);
std::map<OverscaledTileID, std::unique_ptr<Tile>> tiles;
TileCache cache;