summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-21 18:10:57 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-22 19:21:56 +0300
commit11efffb35108619badec52d5b8baf70493cc000c (patch)
tree4ae9439a5757c454473e2637f975ec7ccff38acf /src/mbgl
parent3bebd13d2e622b5c0c923747697044283945114c (diff)
downloadqtlocation-mapboxgl-11efffb35108619badec52d5b8baf70493cc000c.tar.gz
[core] Add TileUpdateParameters and use it
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp2
-rw-r--r--src/mbgl/tile/raster_dem_tile.cpp4
-rw-r--r--src/mbgl/tile/raster_dem_tile.hpp2
-rw-r--r--src/mbgl/tile/raster_tile.cpp4
-rw-r--r--src/mbgl/tile/raster_tile.hpp2
-rw-r--r--src/mbgl/tile/tile.hpp14
-rw-r--r--src/mbgl/tile/tile_loader.hpp4
-rw-r--r--src/mbgl/tile/tile_loader_impl.hpp8
-rw-r--r--src/mbgl/tile/vector_tile.cpp4
-rw-r--r--src/mbgl/tile/vector_tile.hpp2
10 files changed, 29 insertions, 17 deletions
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index 0e4986c7e9..9d1c8a89b8 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -132,7 +132,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.setMinimumUpdateInterval(minimumUpdateInterval);
+ tile.setUpdateParameters({minimumUpdateInterval});
tile.setNecessity(necessity);
}
diff --git a/src/mbgl/tile/raster_dem_tile.cpp b/src/mbgl/tile/raster_dem_tile.cpp
index 83b41ddd83..bdd890bbbf 100644
--- a/src/mbgl/tile/raster_dem_tile.cpp
+++ b/src/mbgl/tile/raster_dem_tile.cpp
@@ -122,8 +122,8 @@ void RasterDEMTile::setNecessity(TileNecessity necessity) {
loader.setNecessity(necessity);
}
-void RasterDEMTile::setMinimumUpdateInterval(Duration interval) {
- loader.setMinimumUpdateInterval(interval);
+void RasterDEMTile::setUpdateParameters(const TileUpdateParameters& params) {
+ loader.setUpdateParameters(params);
}
} // namespace mbgl
diff --git a/src/mbgl/tile/raster_dem_tile.hpp b/src/mbgl/tile/raster_dem_tile.hpp
index d29c5337be..a6189d8d7f 100644
--- a/src/mbgl/tile/raster_dem_tile.hpp
+++ b/src/mbgl/tile/raster_dem_tile.hpp
@@ -68,7 +68,7 @@ public:
std::unique_ptr<TileRenderData> createRenderData() override;
void setNecessity(TileNecessity) override;
- void setMinimumUpdateInterval(Duration) override;
+ void setUpdateParameters(const TileUpdateParameters&) override;
void setError(std::exception_ptr);
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index 1045097a05..2ba1dfcc07 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -78,8 +78,8 @@ void RasterTile::setNecessity(TileNecessity necessity) {
loader.setNecessity(necessity);
}
-void RasterTile::setMinimumUpdateInterval(Duration interval) {
- loader.setMinimumUpdateInterval(interval);
+void RasterTile::setUpdateParameters(const TileUpdateParameters& params) {
+ loader.setUpdateParameters(params);
}
} // namespace mbgl
diff --git a/src/mbgl/tile/raster_tile.hpp b/src/mbgl/tile/raster_tile.hpp
index 78dbd95c0a..4712bfb817 100644
--- a/src/mbgl/tile/raster_tile.hpp
+++ b/src/mbgl/tile/raster_tile.hpp
@@ -24,7 +24,7 @@ public:
std::unique_ptr<TileRenderData> createRenderData() override;
void setNecessity(TileNecessity) override;
- void setMinimumUpdateInterval(Duration) override;
+ void setUpdateParameters(const TileUpdateParameters&) override;
void setError(std::exception_ptr);
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index bf84f8bd98..3bb8d87d6c 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -34,6 +34,17 @@ namespace gfx {
class UploadPass;
} // namespace gfx
+struct TileUpdateParameters {
+ Duration minimumUpdateInterval;
+};
+
+inline bool operator==(const TileUpdateParameters& a, const TileUpdateParameters& b) {
+ return a.minimumUpdateInterval == b.minimumUpdateInterval;
+}
+
+inline bool operator!=(const TileUpdateParameters& a, const TileUpdateParameters& b) {
+ return !(a == b);
+}
class Tile {
public:
enum class Kind : uint8_t {
@@ -52,7 +63,8 @@ public:
void setObserver(TileObserver* observer);
virtual void setNecessity(TileNecessity) {}
- virtual void setMinimumUpdateInterval(Duration) {}
+
+ virtual void setUpdateParameters(const TileUpdateParameters&) {}
// Mark this tile as no longer needed and cancel any pending work.
virtual void cancel();
diff --git a/src/mbgl/tile/tile_loader.hpp b/src/mbgl/tile/tile_loader.hpp
index c6d0d61fef..e4b9a1dc5e 100644
--- a/src/mbgl/tile/tile_loader.hpp
+++ b/src/mbgl/tile/tile_loader.hpp
@@ -23,7 +23,7 @@ public:
~TileLoader();
void setNecessity(TileNecessity newNecessity);
- void setMinimumUpdateInterval(Duration);
+ void setUpdateParameters(const TileUpdateParameters&);
private:
// called when the tile is one of the ideal tiles that we want to show definitely. the tile source
@@ -49,7 +49,7 @@ private:
Resource resource;
std::shared_ptr<FileSource> fileSource;
std::unique_ptr<AsyncRequest> request;
- Duration minimumUpdateInterval{Duration::zero()};
+ TileUpdateParameters updateParameters{{Duration::zero()}};
};
} // namespace mbgl
diff --git a/src/mbgl/tile/tile_loader_impl.hpp b/src/mbgl/tile/tile_loader_impl.hpp
index 78b9fe6df3..cf37650484 100644
--- a/src/mbgl/tile/tile_loader_impl.hpp
+++ b/src/mbgl/tile/tile_loader_impl.hpp
@@ -69,9 +69,9 @@ void TileLoader<T>::setNecessity(TileNecessity newNecessity) {
}
template <typename T>
-void TileLoader<T>::setMinimumUpdateInterval(Duration interval) {
- if (minimumUpdateInterval != interval) {
- minimumUpdateInterval = interval;
+void TileLoader<T>::setUpdateParameters(const TileUpdateParameters& params) {
+ if (updateParameters != params) {
+ updateParameters = params;
if (hasPendingNetworkRequest()) {
// Update the pending request.
request.reset();
@@ -159,7 +159,7 @@ void TileLoader<T>::loadFromNetwork() {
// Instead of using Resource::LoadingMethod::All, we're first doing a CacheOnly, and then a
// NetworkOnly request.
resource.loadingMethod = Resource::LoadingMethod::NetworkOnly;
- resource.minimumUpdateInterval = minimumUpdateInterval;
+ resource.minimumUpdateInterval = updateParameters.minimumUpdateInterval;
request = fileSource->request(resource, [this](const Response& res) { loadedData(res); });
}
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index 2e2dabc66e..7ae53ef203 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -16,8 +16,8 @@ void VectorTile::setNecessity(TileNecessity necessity) {
loader.setNecessity(necessity);
}
-void VectorTile::setMinimumUpdateInterval(Duration interval) {
- loader.setMinimumUpdateInterval(interval);
+void VectorTile::setUpdateParameters(const TileUpdateParameters& params) {
+ loader.setUpdateParameters(params);
}
void VectorTile::setMetadata(optional<Timestamp> modified_, optional<Timestamp> expires_) {
diff --git a/src/mbgl/tile/vector_tile.hpp b/src/mbgl/tile/vector_tile.hpp
index fdefb14e20..31ae52b7c7 100644
--- a/src/mbgl/tile/vector_tile.hpp
+++ b/src/mbgl/tile/vector_tile.hpp
@@ -16,7 +16,7 @@ public:
const Tileset&);
void setNecessity(TileNecessity) final;
- void setMinimumUpdateInterval(Duration interval) final;
+ void setUpdateParameters(const TileUpdateParameters&) final;
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
void setData(const std::shared_ptr<const std::string>& data);