summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-07-08 10:59:45 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-07-09 11:43:46 +0300
commit8d94bb1be0abfb03e958abe740976e920ea53f27 (patch)
tree171b39ec3cffabd43615b571a54a0aa7f84f1019 /src/mbgl
parent57402314e1be3180ce6f67d8ba29c17aceba6b60 (diff)
downloadqtlocation-mapboxgl-8d94bb1be0abfb03e958abe740976e920ea53f27.tar.gz
[core] Reserve size for filtered render layers
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp11
-rw-r--r--src/mbgl/renderer/render_orchestrator.hpp8
2 files changed, 17 insertions, 2 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index c42273eca2..7df74cda71 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -271,11 +271,17 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
std::vector<std::reference_wrapper<RenderLayer>> layersNeedPlacement;
auto renderItemsEmplaceHint = layerRenderItems.begin();
+ // Reserve size for filteredLayersForSource if there are sources.
+ if (!sourceImpls->empty()) {
+ filteredLayersForSource.reserve(layerImpls->size());
+ if (filteredLayersForSource.capacity() > layerImpls->size()) {
+ filteredLayersForSource.shrink_to_fit();
+ }
+ }
+
// Update all sources and initialize renderItems.
for (const auto& sourceImpl : *sourceImpls) {
RenderSource* source = renderSources.at(sourceImpl->id).get();
- std::vector<Immutable<LayerProperties>> filteredLayersForSource;
- filteredLayersForSource.reserve(layerImpls->size());
bool sourceNeedsRendering = false;
bool sourceNeedsRelayout = false;
@@ -321,6 +327,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
sourceNeedsRendering,
sourceNeedsRelayout,
tileParameters);
+ filteredLayersForSource.clear();
}
renderTreeParameters->loaded = updateParameters.styleLoaded && isLoaded();
diff --git a/src/mbgl/renderer/render_orchestrator.hpp b/src/mbgl/renderer/render_orchestrator.hpp
index 4622ac1749..884bd21b7b 100644
--- a/src/mbgl/renderer/render_orchestrator.hpp
+++ b/src/mbgl/renderer/render_orchestrator.hpp
@@ -33,6 +33,10 @@ class PatternAtlas;
class CrossTileSymbolIndex;
class RenderTree;
+namespace style {
+ class LayerProperties;
+} // namespace style
+
class RenderOrchestrator final : public GlyphManagerObserver,
public ImageManagerObserver,
public RenderSourceObserver {
@@ -113,6 +117,10 @@ private:
const bool backgroundLayerAsColor;
bool contextLost = false;
+
+ // Vector with reserved capacity of layerImpls->size() to avoid reallocation
+ // on each frame.
+ std::vector<Immutable<style::LayerProperties>> filteredLayersForSource;
};
} // namespace mbgl