[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.
This commit is contained in:
Alexander Shalamov
2020-02-07 16:43:26 +02:00
parent ac50f5275b
commit 07c0c63fda
4 changed files with 16 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {};
}

View File

@@ -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;