summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-20 12:19:35 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-20 21:54:31 +0300
commit9a698fe3b1a64777835d4d5409c1ff5c43ea2aee (patch)
treec25c004e9dbbcf81202939d258c2ed5b9872d123 /src
parent3c6ccfbb5d7a80e266eda4fa41ae35cf8f625f0d (diff)
downloadqtlocation-mapboxgl-9a698fe3b1a64777835d4d5409c1ff5c43ea2aee.tar.gz
[core] Introduce Source::setMinimumTileUpdateInterval API
The `Source::setMinimumTileUpdateInterval()` method sets the minimum tile update interval, which is used to throttle the tile update network requests. Default value is `Duration::zero()`.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/custom_tile_loader.hpp6
-rw-r--r--src/mbgl/style/source.cpp12
-rw-r--r--src/mbgl/style/source_impl.hpp6
3 files changed, 21 insertions, 3 deletions
diff --git a/src/mbgl/style/custom_tile_loader.hpp b/src/mbgl/style/custom_tile_loader.hpp
index b27a8a1521..78317fdcb1 100644
--- a/src/mbgl/style/custom_tile_loader.hpp
+++ b/src/mbgl/style/custom_tile_loader.hpp
@@ -1,9 +1,9 @@
#pragma once
+#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/geojson.hpp>
-#include <mbgl/actor/actor_ref.hpp>
#include <map>
#include <mutex>
@@ -14,8 +14,10 @@ class CustomGeometryTile;
namespace style {
-class CustomTileLoader : private util::noncopyable {
+class CustomTileLoader {
public:
+ CustomTileLoader(const CustomTileLoader&) = delete;
+ CustomTileLoader& operator=(const CustomTileLoader&) = delete;
using OverscaledIDFunctionTuple = std::tuple<uint8_t, int16_t, ActorRef<CustomGeometryTile>>;
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index 51a3c80089..42ad367d66 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -43,6 +43,18 @@ optional<uint8_t> Source::getPrefetchZoomDelta() const noexcept {
return baseImpl->getPrefetchZoomDelta();
}
+void Source::setMinimumTileUpdateInterval(Duration interval) noexcept {
+ if (getMinimumTileUpdateInterval() == interval) return;
+ auto newImpl = createMutable();
+ newImpl->setMinimumTileUpdateInterval(interval);
+ baseImpl = std::move(newImpl);
+ observer->onSourceChanged(*this);
+}
+
+Duration Source::getMinimumTileUpdateInterval() const noexcept {
+ return baseImpl->getMinimumTileUpdateInterval();
+}
+
void Source::setMaxOverscaleFactorForParentTiles(optional<uint8_t> overscaleFactor) noexcept {
if (getMaxOverscaleFactorForParentTiles() == overscaleFactor) return;
auto newImpl = createMutable();
diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp
index af8435537a..b16b763766 100644
--- a/src/mbgl/style/source_impl.hpp
+++ b/src/mbgl/style/source_impl.hpp
@@ -22,15 +22,19 @@ public:
virtual optional<std::string> getAttribution() const = 0;
void setPrefetchZoomDelta(optional<uint8_t> delta) noexcept;
optional<uint8_t> getPrefetchZoomDelta() const noexcept;
+ void setMinimumTileUpdateInterval(Duration interval) { minimumTileUpdateInterval = interval; }
+ Duration getMinimumTileUpdateInterval() const { return minimumTileUpdateInterval; }
void setMaxOverscaleFactorForParentTiles(optional<uint8_t> overscaleFactor) noexcept;
optional<uint8_t> getMaxOverscaleFactorForParentTiles() const noexcept;
const SourceType type;
const std::string id;
+
+protected:
optional<uint8_t> prefetchZoomDelta;
optional<uint8_t> maxOverscaleFactor;
+ Duration minimumTileUpdateInterval{Duration::zero()};
-protected:
Impl(SourceType, std::string);
Impl(const Impl&) = default;
};