summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-21 18:27:58 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-22 19:21:56 +0300
commitdc7b1dd34fcea40e07d1a2831efee20132fbb4ab (patch)
treea073026984e8a6221ed74e67709db1a36349e432
parent11efffb35108619badec52d5b8baf70493cc000c (diff)
downloadqtlocation-mapboxgl-dc7b1dd34fcea40e07d1a2831efee20132fbb4ab.tar.gz
[core] Source::setVolatile enables Resource::StoragePolicy::Volatile for tiles
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp3
-rw-r--r--src/mbgl/tile/tile.hpp3
-rw-r--r--src/mbgl/tile/tile_loader.hpp2
-rw-r--r--src/mbgl/tile/tile_loader_impl.hpp2
4 files changed, 7 insertions, 3 deletions
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index 9d1c8a89b8..bd22dd81cc 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -93,6 +93,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
const optional<uint8_t>& sourcePrefetchZoomDelta = sourceImpl.getPrefetchZoomDelta();
const optional<uint8_t>& maxParentTileOverscaleFactor = sourceImpl.getMaxOverscaleFactorForParentTiles();
const Duration minimumUpdateInterval = sourceImpl.getMinimumTileUpdateInterval();
+ const bool isVolatile = sourceImpl.isVolatile();
std::vector<OverscaledTileID> idealTiles;
std::vector<OverscaledTileID> panTiles;
@@ -132,7 +133,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
auto retainTileFn = [&](Tile& tile, TileNecessity necessity) -> void {
if (retain.emplace(tile.id).second) {
- tile.setUpdateParameters({minimumUpdateInterval});
+ tile.setUpdateParameters({minimumUpdateInterval, isVolatile});
tile.setNecessity(necessity);
}
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index 3bb8d87d6c..573b3a1c50 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -36,10 +36,11 @@ class UploadPass;
struct TileUpdateParameters {
Duration minimumUpdateInterval;
+ bool isVolatile;
};
inline bool operator==(const TileUpdateParameters& a, const TileUpdateParameters& b) {
- return a.minimumUpdateInterval == b.minimumUpdateInterval;
+ return a.minimumUpdateInterval == b.minimumUpdateInterval && a.isVolatile == b.isVolatile;
}
inline bool operator!=(const TileUpdateParameters& a, const TileUpdateParameters& b) {
diff --git a/src/mbgl/tile/tile_loader.hpp b/src/mbgl/tile/tile_loader.hpp
index e4b9a1dc5e..99d9047f8d 100644
--- a/src/mbgl/tile/tile_loader.hpp
+++ b/src/mbgl/tile/tile_loader.hpp
@@ -49,7 +49,7 @@ private:
Resource resource;
std::shared_ptr<FileSource> fileSource;
std::unique_ptr<AsyncRequest> request;
- TileUpdateParameters updateParameters{{Duration::zero()}};
+ TileUpdateParameters updateParameters{Duration::zero(), false};
};
} // namespace mbgl
diff --git a/src/mbgl/tile/tile_loader_impl.hpp b/src/mbgl/tile/tile_loader_impl.hpp
index cf37650484..a034ea7401 100644
--- a/src/mbgl/tile/tile_loader_impl.hpp
+++ b/src/mbgl/tile/tile_loader_impl.hpp
@@ -160,6 +160,8 @@ void TileLoader<T>::loadFromNetwork() {
// NetworkOnly request.
resource.loadingMethod = Resource::LoadingMethod::NetworkOnly;
resource.minimumUpdateInterval = updateParameters.minimumUpdateInterval;
+ resource.storagePolicy =
+ updateParameters.isVolatile ? Resource::StoragePolicy::Volatile : Resource::StoragePolicy::Permanent;
request = fileSource->request(resource, [this](const Response& res) { loadedData(res); });
}