[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()`.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/util/immutable.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#include <mbgl/util/immutable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
#include <mapbox/std/weak.hpp>
|
||||
#include <mapbox/util/type_wrapper.hpp>
|
||||
@@ -40,8 +40,11 @@ struct LayerTypeInfo;
|
||||
*
|
||||
* auto vectorSource = std::make_unique<VectorSource>("my-vector-source");
|
||||
*/
|
||||
class Source : public mbgl::util::noncopyable {
|
||||
class Source {
|
||||
public:
|
||||
Source(const Source&) = delete;
|
||||
Source& operator=(const Source&) = delete;
|
||||
|
||||
virtual ~Source();
|
||||
|
||||
// Check whether this source is of the given subtype.
|
||||
@@ -76,6 +79,14 @@ public:
|
||||
void setPrefetchZoomDelta(optional<uint8_t> delta) noexcept;
|
||||
optional<uint8_t> getPrefetchZoomDelta() const noexcept;
|
||||
|
||||
// If the given source supports loading tiles from a server,
|
||||
// sets the minimum tile update interval, which is used to
|
||||
// throttle the tile update network requests.
|
||||
//
|
||||
// Default value is `Duration::zero()`.
|
||||
void setMinimumTileUpdateInterval(Duration) noexcept;
|
||||
Duration getMinimumTileUpdateInterval() const noexcept;
|
||||
|
||||
// Sets a limit for how much a parent tile can be overscaled.
|
||||
//
|
||||
// When a set of tiles for a current zoom level is being rendered and some of the
|
||||
|
||||
@@ -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>>;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
optional<uint8_t> prefetchZoomDelta;
|
||||
optional<uint8_t> maxOverscaleFactor;
|
||||
|
||||
protected:
|
||||
optional<uint8_t> prefetchZoomDelta;
|
||||
optional<uint8_t> maxOverscaleFactor;
|
||||
Duration minimumTileUpdateInterval{Duration::zero()};
|
||||
|
||||
Impl(SourceType, std::string);
|
||||
Impl(const Impl&) = default;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user