[core] Introduce Renderer::clearData() instead of keepRenderData map options
`Renderer::clearData()` is a better API than the removed `MapOptions::keepRenderData()`: - gives more flexibility to the client - similar to the existing `Renderer::reduceMemoryUse()` - the `MapOptions::keepRenderData()` API implementation could not handle the raise condition, which happened if the new still image request had come before all tiles from the previous requests were loaded. Co-authored-by: Dane Springmeyer <dane@mapbox.com>
This commit is contained in:
@@ -17,7 +17,6 @@ Map::Impl::Impl(RendererFrontend& frontend_,
|
||||
mode(mapOptions.mapMode()),
|
||||
pixelRatio(mapOptions.pixelRatio()),
|
||||
crossSourceCollisions(mapOptions.crossSourceCollisions()),
|
||||
keepRenderData(mapOptions.keepRenderData()),
|
||||
fileSource(std::move(fileSource_)),
|
||||
style(std::make_unique<style::Style>(fileSource, pixelRatio)),
|
||||
annotationManager(*style) {
|
||||
@@ -65,9 +64,8 @@ void Map::Impl::onUpdate() {
|
||||
annotationManager.makeWeakPtr(),
|
||||
fileSource,
|
||||
prefetchZoomDelta,
|
||||
stillImageRequest.get(),
|
||||
crossSourceCollisions,
|
||||
keepRenderData};
|
||||
bool(stillImageRequest),
|
||||
crossSourceCollisions};
|
||||
|
||||
rendererFrontend.update(std::make_shared<UpdateParameters>(std::move(params)));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ public:
|
||||
const MapMode mode;
|
||||
const float pixelRatio;
|
||||
const bool crossSourceCollisions;
|
||||
const bool keepRenderData;
|
||||
|
||||
MapDebugOptions debugOptions { MapDebugOptions::NoDebug };
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ public:
|
||||
ViewportMode viewportMode = ViewportMode::Default;
|
||||
NorthOrientation orientation = NorthOrientation::Upwards;
|
||||
bool crossSourceCollisions = true;
|
||||
bool keepRenderData = true;
|
||||
Size size = { 64, 64 };
|
||||
float pixelRatio = 1.0;
|
||||
};
|
||||
@@ -55,15 +54,6 @@ bool MapOptions::crossSourceCollisions() const {
|
||||
return impl_->crossSourceCollisions;
|
||||
}
|
||||
|
||||
MapOptions& MapOptions::withKeepRenderData(bool keepRenderData_) {
|
||||
impl_->keepRenderData = keepRenderData_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool MapOptions::keepRenderData() const {
|
||||
return impl_->keepRenderData;
|
||||
}
|
||||
|
||||
MapOptions& MapOptions::withNorthOrientation(NorthOrientation orientation) {
|
||||
impl_->orientation = orientation;
|
||||
return *this;
|
||||
|
||||
@@ -141,10 +141,6 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
if (!isMapModeContinuous) {
|
||||
// Reset zoom history state.
|
||||
zoomHistory.first = true;
|
||||
if (!updateParameters->keepRenderData && stillImageRequest != updateParameters->stillImageRequest) {
|
||||
clearData();
|
||||
stillImageRequest = updateParameters->stillImageRequest;
|
||||
}
|
||||
}
|
||||
|
||||
if (LayerManager::annotationsEnabled) {
|
||||
|
||||
@@ -75,11 +75,11 @@ public:
|
||||
|
||||
void reduceMemoryUse();
|
||||
void dumpDebugLogs();
|
||||
void clearData();
|
||||
|
||||
private:
|
||||
bool isLoaded() const;
|
||||
bool hasTransitions(TimePoint) const;
|
||||
void clearData();
|
||||
|
||||
RenderSource* getRenderSource(const std::string& id) const;
|
||||
|
||||
@@ -127,7 +127,6 @@ private:
|
||||
|
||||
const bool backgroundLayerAsColor;
|
||||
bool contextLost = false;
|
||||
const void* stillImageRequest = nullptr;
|
||||
|
||||
// Vectors with reserved capacity of layerImpls->size() to avoid reallocation
|
||||
// on each frame.
|
||||
|
||||
@@ -131,4 +131,8 @@ void Renderer::reduceMemoryUse() {
|
||||
impl->orchestrator.reduceMemoryUse();
|
||||
}
|
||||
|
||||
void Renderer::clearData() {
|
||||
impl->orchestrator.clearData();
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -41,12 +41,9 @@ public:
|
||||
const uint8_t prefetchZoomDelta;
|
||||
|
||||
// For still image requests, render requested
|
||||
const void* stillImageRequest;
|
||||
const bool stillImageRequest;
|
||||
|
||||
const bool crossSourceCollisions;
|
||||
|
||||
// If set, the render data from the previous render calls is kept.
|
||||
const bool keepRenderData;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user