diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-07 16:43:26 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-11 10:40:30 +0200 |
commit | 07c0c63fda08a638591d7f911d7f9ddc0ef4d2aa (patch) | |
tree | 96b922aad9477c63b714a34817ef37d58f30ab21 | |
parent | ac50f5275b45fa6a0859da0b162b561f8f2e567e (diff) | |
download | qtlocation-mapboxgl-07c0c63fda08a638591d7f911d7f9ddc0ef4d2aa.tar.gz |
[core] Clear tile pyramid for custom source only if there is a significant change
Clear tile pyramid only if updated source has different tile options,
zoom range or initialization state for a custom tile loader.
4 files changed, 16 insertions, 5 deletions
diff --git a/src/mbgl/renderer/sources/render_custom_geometry_source.cpp b/src/mbgl/renderer/sources/render_custom_geometry_source.cpp index ea6f5c3102..a54802b21b 100644 --- a/src/mbgl/renderer/sources/render_custom_geometry_source.cpp +++ b/src/mbgl/renderer/sources/render_custom_geometry_source.cpp @@ -23,7 +23,14 @@ void RenderCustomGeometrySource::update(Immutable<style::Source::Impl> baseImpl_ const TileParameters& parameters) { if (baseImpl != baseImpl_) { std::swap(baseImpl, baseImpl_); - tilePyramid.clearAll(); + + // Clear tile pyramid only if updated source has different tile options, + // zoom range or initialization state for a custom tile loader. + auto newImpl = staticImmutableCast<style::CustomGeometrySource::Impl>(baseImpl); + auto currentImpl = staticImmutableCast<style::CustomGeometrySource::Impl>(baseImpl_); + if (*newImpl != *currentImpl) { + tilePyramid.clearAll(); + } } enabled = needsRendering; diff --git a/src/mbgl/style/sources/custom_geometry_source.cpp b/src/mbgl/style/sources/custom_geometry_source.cpp index 113298dd3c..44401c1a8f 100644 --- a/src/mbgl/style/sources/custom_geometry_source.cpp +++ b/src/mbgl/style/sources/custom_geometry_source.cpp @@ -14,11 +14,10 @@ namespace mbgl { namespace style { -CustomGeometrySource::CustomGeometrySource(std::string id, - const CustomGeometrySource::Options options) +CustomGeometrySource::CustomGeometrySource(std::string id, CustomGeometrySource::Options options) : Source(makeMutable<CustomGeometrySource::Impl>(std::move(id), options)), - loader(std::make_unique<Actor<CustomTileLoader>>(Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) { -} + loader(std::make_unique<Actor<CustomTileLoader>>( + Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) {} CustomGeometrySource::~CustomGeometrySource() = default; diff --git a/src/mbgl/style/sources/custom_geometry_source_impl.cpp b/src/mbgl/style/sources/custom_geometry_source_impl.cpp index 95da377277..e456bd8719 100644 --- a/src/mbgl/style/sources/custom_geometry_source_impl.cpp +++ b/src/mbgl/style/sources/custom_geometry_source_impl.cpp @@ -13,6 +13,10 @@ CustomGeometrySource::Impl::Impl(std::string id_, CustomGeometrySource::Options CustomGeometrySource::Impl::Impl(const Impl& impl, ActorRef<CustomTileLoader> loaderRef_) : Source::Impl(impl), tileOptions(impl.tileOptions), zoomRange(impl.zoomRange), loaderRef(loaderRef_) {} +bool CustomGeometrySource::Impl::operator!=(const Impl& other) const noexcept { + return tileOptions != other.tileOptions || zoomRange != other.zoomRange || bool(loaderRef) != bool(other.loaderRef); +} + optional<std::string> CustomGeometrySource::Impl::getAttribution() const { return {}; } diff --git a/src/mbgl/style/sources/custom_geometry_source_impl.hpp b/src/mbgl/style/sources/custom_geometry_source_impl.hpp index 1ae77b02ec..04e301f198 100644 --- a/src/mbgl/style/sources/custom_geometry_source_impl.hpp +++ b/src/mbgl/style/sources/custom_geometry_source_impl.hpp @@ -18,6 +18,7 @@ public: Immutable<CustomGeometrySource::TileOptions> getTileOptions() const; Range<uint8_t> getZoomRange() const; optional<ActorRef<CustomTileLoader>> getTileLoader() const; + bool operator!=(const Impl&) const noexcept; private: Immutable<CustomGeometrySource::TileOptions> tileOptions; |