summaryrefslogtreecommitdiff
path: root/src
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
parentfd1f8703cdd73420f23cb8617ffb6f5c42f8a32d (diff)
downloadqtlocation-mapboxgl-7ba5d5e2dd85044eb51f1ed72e5d07dfcba35e54.tar.gz
[core] Introduce Placement::placeLayers()
Diffstat (limited to 'src')
-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
-rw-r--r--src/mbgl/text/placement.cpp7
-rw-r--r--src/mbgl/text/placement.hpp6
5 files changed, 29 insertions, 28 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
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index e62be00b47..a6de0baba7 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -105,6 +105,13 @@ Placement::Placement(std::shared_ptr<const UpdateParameters> updateParameters_,
Placement::Placement() : collisionIndex({}, MapMode::Static), collisionGroups(true) {}
+void Placement::placeLayers(const RenderLayerReferences& layers) {
+ for (auto it = layers.crbegin(); it != layers.crend(); ++it) {
+ placeLayer(*it);
+ }
+ commit();
+}
+
void Placement::placeLayer(const RenderLayer& layer) {
std::set<uint32_t> seenCrossTileIDs;
for (const BucketPlacementData& data : layer.getPlacementData()) {
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index d3f92eb068..dcb67fa8c8 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -108,9 +108,7 @@ class Placement {
public:
Placement(std::shared_ptr<const UpdateParameters>, optional<Immutable<Placement>> prevPlacement = nullopt);
Placement();
-
- void placeLayer(const RenderLayer&);
- void commit();
+ void placeLayers(const RenderLayerReferences&);
void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const;
float symbolFadeChange(TimePoint now) const;
bool hasTransitions(TimePoint now) const;
@@ -128,6 +126,8 @@ public:
private:
friend SymbolBucket;
void placeSymbolBucket(const BucketPlacementData&, std::set<uint32_t>& seenCrossTileIDs);
+ void placeLayer(const RenderLayer&);
+ void commit();
// Returns `true` if bucket vertices were updated; returns `false` otherwise.
bool updateBucketDynamicVertices(SymbolBucket&, const TransformState&, const RenderTile& tile) const;
void updateBucketOpacities(SymbolBucket&, const TransformState&, std::set<uint32_t>&) const;