[core] remove tiles for disabled sources

When no layer of a source is visible anymore, we are now evicting tiles that are still stored in that source and move them to the cache.
This commit is contained in:
Konstantin Käfer
2016-09-19 15:54:13 +02:00
parent 91272992f3
commit ef8017198c
3 changed files with 31 additions and 6 deletions

View File

@@ -254,6 +254,8 @@ void Style::cascade(const TimePoint& timePoint, MapMode mode) {
}
void Style::recalculate(float z, const TimePoint& timePoint, MapMode mode) {
// Disable all sources first. If we find an enabled layer that uses this source, we will
// re-enable it later.
for (const auto& source : sources) {
source->baseImpl->enabled = false;
}
@@ -287,6 +289,13 @@ void Style::recalculate(float z, const TimePoint& timePoint, MapMode mode) {
}
}
}
// Remove the existing tiles if we didn't end up re-enabling the source.
for (const auto& source : sources) {
if (!source->baseImpl->enabled) {
source->baseImpl->removeTiles();
}
}
}
Source* Style::getSource(const std::string& id) const {