[core][tile|static mode] Introduce MapOptions::keepRenderData() flag
Render orchestrator stores the render data between render frames if this flag is set.
This commit is contained in:
@@ -88,6 +88,28 @@ public:
|
||||
*/
|
||||
bool crossSourceCollisions() const;
|
||||
|
||||
/**
|
||||
* @brief Specify whether render data for layers, sources and images should be kept between renderStill() calls.
|
||||
*
|
||||
* This flag is ignored in Continuous mode. In Static mode and Tile mode, if this flag is set to false, all the data
|
||||
* are created from scratch for every renderStill() call, which guaranties that no extra memory is used, however it
|
||||
* might cause higher CPU load and network traffic.
|
||||
*
|
||||
* By default, it is set to true.
|
||||
*
|
||||
* @param keepRenderData true to enable, false to disable
|
||||
* @return MapOptions for chaining options together.
|
||||
*/
|
||||
MapOptions& withKeepRenderData(bool keepRenderData);
|
||||
|
||||
/**
|
||||
* @brief Gets the previously set (or default) keepRenderData value.
|
||||
*
|
||||
* @return true if render data is kept between renderStill() calls,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool keepRenderData() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the orientation of the Map. By default, it is set to
|
||||
* Upwards.
|
||||
|
||||
@@ -17,6 +17,7 @@ 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) {
|
||||
@@ -64,8 +65,9 @@ void Map::Impl::onUpdate() {
|
||||
annotationManager.makeWeakPtr(),
|
||||
fileSource,
|
||||
prefetchZoomDelta,
|
||||
bool(stillImageRequest),
|
||||
crossSourceCollisions};
|
||||
stillImageRequest.get(),
|
||||
crossSourceCollisions,
|
||||
keepRenderData};
|
||||
|
||||
rendererFrontend.update(std::make_shared<UpdateParameters>(std::move(params)));
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
const MapMode mode;
|
||||
const float pixelRatio;
|
||||
const bool crossSourceCollisions;
|
||||
const bool keepRenderData;
|
||||
|
||||
MapDebugOptions debugOptions { MapDebugOptions::NoDebug };
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public:
|
||||
ViewportMode viewportMode = ViewportMode::Default;
|
||||
NorthOrientation orientation = NorthOrientation::Upwards;
|
||||
bool crossSourceCollisions = true;
|
||||
bool keepRenderData = true;
|
||||
Size size = { 64, 64 };
|
||||
float pixelRatio = 1.0;
|
||||
};
|
||||
@@ -54,6 +55,15 @@ 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,6 +141,13 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
if (!isMapModeContinuous) {
|
||||
// Reset zoom history state.
|
||||
zoomHistory.first = true;
|
||||
if (!updateParameters->keepRenderData && stillImageRequest != updateParameters->stillImageRequest) {
|
||||
sourceImpls = makeMutable<std::vector<Immutable<style::Source::Impl>>>();
|
||||
layerImpls = makeMutable<std::vector<Immutable<style::Layer::Impl>>>();
|
||||
renderSources.clear();
|
||||
renderLayers.clear();
|
||||
stillImageRequest = updateParameters->stillImageRequest;
|
||||
}
|
||||
}
|
||||
|
||||
if (LayerManager::annotationsEnabled) {
|
||||
|
||||
@@ -126,6 +126,7 @@ private:
|
||||
|
||||
const bool backgroundLayerAsColor;
|
||||
bool contextLost = false;
|
||||
const void* stillImageRequest = nullptr;
|
||||
|
||||
// Vectors with reserved capacity of layerImpls->size() to avoid reallocation
|
||||
// on each frame.
|
||||
|
||||
@@ -41,9 +41,12 @@ public:
|
||||
const uint8_t prefetchZoomDelta;
|
||||
|
||||
// For still image requests, render requested
|
||||
const bool stillImageRequest;
|
||||
|
||||
const void* 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