diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-03-21 21:55:22 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-04-01 16:18:55 -0400 |
commit | 15f73a06f2048d4b5f0481d54a79f3f349187b11 (patch) | |
tree | 5166ba99751b11d6a994d0f3825332caf04ccd64 /src/mbgl/style | |
parent | 09f7bbcf7c07cc360c933ab1637662397b7db674 (diff) | |
download | qtlocation-mapboxgl-15f73a06f2048d4b5f0481d54a79f3f349187b11.tar.gz |
[core] Add setMaxOverscaleFactorForParentTiles
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/source.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/source_impl.cpp | 21 | ||||
-rw-r--r-- | src/mbgl/style/source_impl.hpp | 3 |
3 files changed, 36 insertions, 0 deletions
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp index 644a31dace..51a3c80089 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::setMaxOverscaleFactorForParentTiles(optional<uint8_t> overscaleFactor) noexcept { + if (getMaxOverscaleFactorForParentTiles() == overscaleFactor) return; + auto newImpl = createMutable(); + newImpl->setMaxOverscaleFactorForParentTiles(std::move(overscaleFactor)); + baseImpl = std::move(newImpl); + observer->onSourceChanged(*this); +} + +optional<uint8_t> Source::getMaxOverscaleFactorForParentTiles() const noexcept { + return baseImpl->getMaxOverscaleFactorForParentTiles(); +} + void Source::dumpDebugLogs() const { Log::Info(Event::General, "Source::id: %s", getID().c_str()); Log::Info(Event::General, "Source::loaded: %d", loaded); diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp index 7f6f633eda..98433a8c86 100644 --- a/src/mbgl/style/source_impl.cpp +++ b/src/mbgl/style/source_impl.cpp @@ -1,8 +1,19 @@ #include <mbgl/style/source_impl.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/logging.hpp> namespace mbgl { namespace style { +namespace { +void WarnIfOverscaleFactorCapsPrefetchDelta(const optional<uint8_t>& overscale, const optional<uint8_t>& prefetch) { + const uint8_t prefetchDelta = std::max<uint8_t>(util::DEFAULT_PREFETCH_ZOOM_DELTA, prefetch.value_or(0u)); + if (overscale && *overscale < prefetchDelta) { + Log::Warning(Event::Style, "Parent tile overscale factor will cap prefetch delta to %d", int(*overscale)); + } +} +} // namespace + Source::Impl::Impl(SourceType type_, std::string id_) : type(type_), id(std::move(id_)) { @@ -10,11 +21,21 @@ Source::Impl::Impl(SourceType type_, std::string id_) void Source::Impl::setPrefetchZoomDelta(optional<uint8_t> delta) noexcept { prefetchZoomDelta = std::move(delta); + WarnIfOverscaleFactorCapsPrefetchDelta(maxOverscaleFactor, prefetchZoomDelta); } optional<uint8_t> Source::Impl::getPrefetchZoomDelta() const noexcept { return prefetchZoomDelta; } +void Source::Impl::setMaxOverscaleFactorForParentTiles(optional<uint8_t> overscaleFactor) noexcept { + maxOverscaleFactor = std::move(overscaleFactor); + WarnIfOverscaleFactorCapsPrefetchDelta(maxOverscaleFactor, prefetchZoomDelta); +} + +optional<uint8_t> Source::Impl::getMaxOverscaleFactorForParentTiles() const noexcept { + return maxOverscaleFactor; +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp index d2c5d54d10..af8435537a 100644 --- a/src/mbgl/style/source_impl.hpp +++ b/src/mbgl/style/source_impl.hpp @@ -22,10 +22,13 @@ public: virtual optional<std::string> getAttribution() const = 0; void setPrefetchZoomDelta(optional<uint8_t> delta) noexcept; optional<uint8_t> getPrefetchZoomDelta() const noexcept; + 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: Impl(SourceType, std::string); |