summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-23 11:47:32 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-25 15:11:41 +0200
commit7ba5d5e2dd85044eb51f1ed72e5d07dfcba35e54 (patch)
tree901f66a15ce15bb1823b3cd6e880f2e71b60dc02 /src/mbgl/renderer
parentfd1f8703cdd73420f23cb8617ffb6f5c42f8a32d (diff)
downloadqtlocation-mapboxgl-7ba5d5e2dd85044eb51f1ed72e5d07dfcba35e54.tar.gz
[core] Introduce Placement::placeLayers()
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r--src/mbgl/renderer/render_layer.hpp2
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp37
-rw-r--r--src/mbgl/renderer/render_orchestrator.hpp5
3 files changed, 19 insertions, 25 deletions
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index 53dafb3b7b..f7232a5aa0 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -146,4 +146,6 @@ private:
bool hasRenderFailures = false;
};
+using RenderLayerReferences = std::vector<std::reference_wrapper<RenderLayer>>;
+
} // namespace mbgl
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index bf14813492..e38990293f 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -62,7 +62,7 @@ public:
std::vector<std::unique_ptr<RenderItem>> sourceRenderItems_,
LineAtlas& lineAtlas_,
PatternAtlas& patternAtlas_,
- std::vector<std::reference_wrapper<RenderLayer>> layersNeedPlacement_,
+ RenderLayerReferences layersNeedPlacement_,
Immutable<Placement> placement_,
bool updateSymbolOpacities_)
: RenderTree(std::move(parameters_)),
@@ -96,7 +96,7 @@ public:
std::vector<std::unique_ptr<RenderItem>> sourceRenderItems;
std::reference_wrapper<LineAtlas> lineAtlas;
std::reference_wrapper<PatternAtlas> patternAtlas;
- std::vector<std::reference_wrapper<RenderLayer>> layersNeedPlacement;
+ RenderLayerReferences layersNeedPlacement;
Immutable<Placement> placement;
bool updateSymbolOpacities;
};
@@ -379,15 +379,20 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
}
// Symbol placement.
bool symbolBucketsChanged = false;
+ bool symbolBucketsAdded = false;
+ std::set<std::string> usedSymbolLayers;
auto longitude = updateParameters->transformState.getLatLng().longitude();
- if (isMapModeContinuous) {
- bool symbolBucketsAdded = false;
- for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
- auto result = crossTileSymbolIndex.addLayer(*it, longitude);
+ for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
+ RenderLayer& layer = *it;
+ auto result = crossTileSymbolIndex.addLayer(layer, longitude);
+ if (isMapModeContinuous) {
+ usedSymbolLayers.insert(layer.getID());
symbolBucketsAdded = symbolBucketsAdded || (result & CrossTileSymbolIndex::AddLayerResult::BucketsAdded);
symbolBucketsChanged = symbolBucketsChanged || (result != CrossTileSymbolIndex::AddLayerResult::NoChanges);
}
+ }
+ if (isMapModeContinuous) {
optional<Duration> placementUpdatePeriodOverride;
if (symbolBucketsAdded && !tiltedView) {
// If the view is not tilted, we want *the new* symbols to show up faster, however simple setting
@@ -403,22 +408,14 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
updateParameters->timePoint, updateParameters->transformState.getZoom(), placementUpdatePeriodOverride);
symbolBucketsChanged |= renderTreeParameters->placementChanged;
- std::set<std::string> usedSymbolLayers;
if (renderTreeParameters->placementChanged) {
Mutable<Placement> placement = makeMutable<Placement>(updateParameters, placementController.getPlacement());
-
- for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
- const RenderLayer& layer = *it;
- usedSymbolLayers.insert(layer.getID());
- placement->placeLayer(layer);
- }
-
- placement->commit();
+ placement->placeLayers(layersNeedPlacement);
+ placementController.setPlacement(std::move(placement));
crossTileSymbolIndex.pruneUnusedLayers(usedSymbolLayers);
for (const auto& entry : renderSources) {
entry.second->updateFadingTiles();
}
- placementController.setPlacement(std::move(placement));
} else {
placementController.setPlacementStale();
}
@@ -429,14 +426,10 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
renderTreeParameters->placementChanged = symbolBucketsChanged = !layersNeedPlacement.empty();
if (renderTreeParameters->placementChanged) {
Mutable<Placement> placement = makeMutable<Placement>(updateParameters);
- for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
- const RenderLayer& layer = *it;
- crossTileSymbolIndex.addLayer(layer, longitude);
- placement->placeLayer(layer);
- }
- placement->commit();
+ placement->placeLayers(layersNeedPlacement);
placementController.setPlacement(std::move(placement));
}
+ crossTileSymbolIndex.reset();
renderTreeParameters->symbolFadeChange = 1.0f;
renderTreeParameters->needsRepaint = false;
}
diff --git a/src/mbgl/renderer/render_orchestrator.hpp b/src/mbgl/renderer/render_orchestrator.hpp
index a8a6d04901..19632c3218 100644
--- a/src/mbgl/renderer/render_orchestrator.hpp
+++ b/src/mbgl/renderer/render_orchestrator.hpp
@@ -21,7 +21,6 @@ namespace mbgl {
class RendererObserver;
class RenderSource;
-class RenderLayer;
class UpdateParameters;
class RenderStaticData;
class RenderedQueryOptions;
@@ -129,8 +128,8 @@ private:
// Vectors with reserved capacity of layerImpls->size() to avoid reallocation
// on each frame.
std::vector<Immutable<style::LayerProperties>> filteredLayersForSource;
- std::vector<std::reference_wrapper<RenderLayer>> orderedLayers;
- std::vector<std::reference_wrapper<RenderLayer>> layersNeedPlacement;
+ RenderLayerReferences orderedLayers;
+ RenderLayerReferences layersNeedPlacement;
};
} // namespace mbgl