summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-12-05 17:46:41 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-12-09 17:32:49 +0200
commitffd378c68e3bb47917468872cad03be7295e33fe (patch)
treeead5563c25f19ed86eb87d900f6f1b859acf8c3f /src/mbgl
parent89665326c2251608ac2f3408f73b781a23fb1ba5 (diff)
downloadqtlocation-mapboxgl-ffd378c68e3bb47917468872cad03be7295e33fe.tar.gz
[core] Simplify placement code path for still and tile modes
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp39
-rw-r--r--src/mbgl/text/placement.cpp1
2 files changed, 29 insertions, 11 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index e13a439ae4..1b689cf82f 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -377,21 +377,17 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
}
// Symbol placement.
bool symbolBucketsChanged = false;
- {
- if (!isMapModeContinuous) {
- // TODO: Think about right way for symbol index to handle still rendering
- crossTileSymbolIndex.reset();
- }
-
+ if (isMapModeContinuous) {
bool symbolBucketsAdded = false;
- for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
- auto result = crossTileSymbolIndex.addLayer(*it, updateParameters.transformState.getLatLng().longitude());
+ for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
+ auto result = crossTileSymbolIndex.addLayer(*it, updateParameters.transformState.getLatLng().longitude());
symbolBucketsAdded = symbolBucketsAdded || (result & CrossTileSymbolIndex::AddLayerResult::BucketsAdded);
symbolBucketsChanged = symbolBucketsChanged || (result != CrossTileSymbolIndex::AddLayerResult::NoChanges);
}
// We want new symbols to show up faster, however simple setting `placementChanged` to `true` would
// initiate placement too often as new buckets ususally come from several rendered tiles in a row within
- // a short period of time. Instead, we squeeze placement update period to coalesce buckets updates from several tiles.
+ // a short period of time. Instead, we squeeze placement update period to coalesce buckets updates from several
+ // tiles.
optional<Duration> maximumPlacementUpdatePeriod;
if (symbolBucketsAdded) maximumPlacementUpdatePeriod = optional<Duration>(Milliseconds(30));
renderTreeParameters->placementChanged = !placementController.placementIsRecent(
@@ -406,7 +402,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
updateParameters.crossSourceCollisions,
placementController.getPlacement());
- for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
+ for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
const RenderLayer& layer = *it;
usedSymbolLayers.insert(layer.getID());
placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix, updateParameters.debugOptions & MapDebugOptions::Collision);
@@ -423,9 +419,30 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
}
renderTreeParameters->symbolFadeChange =
placementController.getPlacement()->symbolFadeChange(updateParameters.timePoint);
+ renderTreeParameters->needsRepaint = hasTransitions(updateParameters.timePoint);
+ } else {
+ crossTileSymbolIndex.reset();
+ renderTreeParameters->placementChanged = symbolBucketsChanged = !layersNeedPlacement.empty();
+ if (renderTreeParameters->placementChanged) {
+ Mutable<Placement> placement = makeMutable<Placement>(updateParameters.transformState,
+ updateParameters.mode,
+ updateParameters.transitionOptions,
+ updateParameters.crossSourceCollisions,
+ placementController.getPlacement());
+ for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
+ const RenderLayer& layer = *it;
+ crossTileSymbolIndex.addLayer(layer, updateParameters.transformState.getLatLng().longitude());
+ placement->placeLayer(layer,
+ renderTreeParameters->transformParams.projMatrix,
+ updateParameters.debugOptions & MapDebugOptions::Collision);
+ }
+ placement->commit(updateParameters.timePoint, updateParameters.transformState.getZoom());
+ placementController.setPlacement(std::move(placement));
+ }
+ renderTreeParameters->symbolFadeChange = 1.0f;
+ renderTreeParameters->needsRepaint = false;
}
- renderTreeParameters->needsRepaint = isMapModeContinuous && hasTransitions(updateParameters.timePoint);
if (!renderTreeParameters->needsRepaint && renderTreeParameters->loaded) {
// Notify observer about unused images when map is fully loaded
// and there are no ongoing transitions.
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 7964ad24c7..639ed7e1de 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -533,6 +533,7 @@ void Placement::placeBucket(
}
void Placement::commit(TimePoint now, const double zoom) {
+ assert(getPrevPlacement());
commitTime = now;
bool placementChanged = false;