summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-04 15:48:12 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-13 13:45:48 +0300
commitf9c15f708ecf3d87c756a196bdc5de93b78b8cfc (patch)
tree856afe9b73714143ef83c40f50b4542fdf29f481
parent69bc5244eaaecb708e8a492f7017a451245d92bb (diff)
downloadqtlocation-mapboxgl-f9c15f708ecf3d87c756a196bdc5de93b78b8cfc.tar.gz
[core] Fix placement for updated buckets
Buckets update initiates new placement, so that newly added symbols are placed and shown immediately.
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp18
-rw-r--r--src/mbgl/text/placement.cpp8
2 files changed, 10 insertions, 16 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index 983bc09485..eb6963c970 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -361,26 +361,24 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
}
bool symbolBucketsChanged = false;
- renderTreeParameters->placementChanged = !placement->stillRecent(updateParameters.timePoint, updateParameters.transformState.getZoom());
+ for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
+ if (crossTileSymbolIndex.addLayer(*it, updateParameters.transformState.getLatLng().longitude())) symbolBucketsChanged = true;
+ }
+ renderTreeParameters->placementChanged = !placement->stillRecent(updateParameters.timePoint, updateParameters.transformState.getZoom()) || symbolBucketsChanged;
+
std::set<std::string> usedSymbolLayers;
if (renderTreeParameters->placementChanged) {
placement = std::make_unique<Placement>(
updateParameters.transformState, updateParameters.mode,
updateParameters.transitionOptions, updateParameters.crossSourceCollisions,
std::move(placement));
- }
- for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
- const RenderLayer& layer = *it;
- if (crossTileSymbolIndex.addLayer(layer, updateParameters.transformState.getLatLng().longitude())) symbolBucketsChanged = true;
-
- if (renderTreeParameters->placementChanged) {
+ for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
+ const RenderLayer& layer = *it;
usedSymbolLayers.insert(layer.getID());
placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix, updateParameters.debugOptions & MapDebugOptions::Collision);
}
- }
- if (renderTreeParameters->placementChanged) {
placement->commit(updateParameters.timePoint, updateParameters.transformState.getZoom());
crossTileSymbolIndex.pruneUnusedLayers(usedSymbolLayers);
for (const auto& entry : renderSources) {
@@ -391,7 +389,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
}
for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
- placement->updateLayerBuckets(*it, updateParameters.transformState, renderTreeParameters->placementChanged || symbolBucketsChanged);
+ placement->updateLayerBuckets(*it, updateParameters.transformState, renderTreeParameters->placementChanged);
}
renderTreeParameters->symbolFadeChange = placement->symbolFadeChange(updateParameters.timePoint);
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index a8c0a1bd44..89b3189b83 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -699,7 +699,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState
if (bucket.hasTextCollisionBoxData()) bucket.textCollisionBox->dynamicVertices.clear();
if (bucket.hasTextCollisionCircleData()) bucket.textCollisionCircle->dynamicVertices.clear();
- JointOpacityState duplicateOpacityState(false, false, true);
+ const JointOpacityState duplicateOpacityState(false, false, true);
const bool textAllowOverlap = bucket.layout->get<style::TextAllowOverlap>();
const bool iconAllowOverlap = bucket.layout->get<style::IconAllowOverlap>();
@@ -712,7 +712,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState
// But we have to wait for placement if we potentially depend on a paired icon/text
// with allow-overlap: false.
// See https://github.com/mapbox/mapbox-gl-native/issues/12483
- JointOpacityState defaultOpacityState(
+ const JointOpacityState defaultOpacityState(
textAllowOverlap && (iconAllowOverlap || !(bucket.hasIconData() || bucket.hasSdfIconData()) || bucket.layout->get<style::IconOptional>()),
iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || bucket.layout->get<style::TextOptional>()),
true);
@@ -728,10 +728,6 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState
opacityState = it->second;
}
- if (it == opacities.end()) {
- opacities.emplace(symbolInstance.crossTileID, defaultOpacityState);
- }
-
seenCrossTileIDs.insert(symbolInstance.crossTileID);
if (symbolInstance.hasText()) {