summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-09 16:34:18 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-12 23:35:55 +0200
commitf29865f31ddd9e6293053e810a65c6c093b7d597 (patch)
tree4206f235131e3338b98d94c4436ce660a07dc804
parent7a2126bebb080c6f7b013dbe94ca4cd242b71136 (diff)
downloadqtlocation-mapboxgl-f29865f31ddd9e6293053e810a65c6c093b7d597.tar.gz
[core] Do not squeeze placement period if the view is tilted
If the view is not tilted, we want the new symbols to show up faster, so we squeeze the placement period. On contrary, with the tilted view it's more important to make placement rarely for performance reasons and as the new symbols are normally "far away" and the user is not that interested to see them ASAP.
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp21
-rw-r--r--src/mbgl/text/placement.cpp8
-rw-r--r--src/mbgl/text/placement.hpp2
3 files changed, 17 insertions, 14 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index f00f9ee9be..7fb6eff29c 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -281,6 +281,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
renderSources.emplace(entry.first, std::move(renderSource));
}
transformState = updateParameters->transformState;
+ const bool tiltedView = transformState.getPitch() != 0.0f;
// Create parameters for the render tree.
auto renderTreeParameters = std::make_unique<RenderTreeParameters>(updateParameters->transformState,
@@ -386,14 +387,20 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
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.
- optional<Duration> maximumPlacementUpdatePeriod;
- if (symbolBucketsAdded) maximumPlacementUpdatePeriod = optional<Duration>(Milliseconds(30));
+
+ optional<Duration> placementUpdatePeriodOverride;
+ if (symbolBucketsAdded && !tiltedView) {
+ // If the view is not tilted, we want *the new* symbols to show up faster, however simple setting
+ // `placementChanged` to `true` would initiate placement too often as new buckets usually 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. On contrary, with the tilted view it's more important to
+ // make placement rarely for performance reasons and as the new symbols are normally "far away" and the user
+ // is not that interested to see them ASAP.
+ placementUpdatePeriodOverride = optional<Duration>(Milliseconds(30));
+ }
+
renderTreeParameters->placementChanged = !placementController.placementIsRecent(
- updateParameters->timePoint, updateParameters->transformState.getZoom(), maximumPlacementUpdatePeriod);
+ updateParameters->timePoint, updateParameters->transformState.getZoom(), placementUpdatePeriodOverride);
symbolBucketsChanged |= renderTreeParameters->placementChanged;
std::set<std::string> usedSymbolLayers;
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index f5e0be0829..d8cf4653c6 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -68,14 +68,10 @@ void PlacementController::setPlacement(Immutable<Placement> placement_) {
stale = false;
}
-bool PlacementController::placementIsRecent(TimePoint now, const float zoom, optional<Duration> maximumDuration) const {
+bool PlacementController::placementIsRecent(TimePoint now, const float zoom, optional<Duration> periodOverride) const {
if (!placement->transitionsEnabled()) return false;
- auto updatePeriod = placement->getUpdatePeriod(zoom);
-
- if (maximumDuration) {
- updatePeriod = std::min(*maximumDuration, updatePeriod);
- }
+ auto updatePeriod = periodOverride ? *periodOverride : placement->getUpdatePeriod(zoom);
return placement->getCommitTime() + updatePeriod > now;
}
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index b2ad5d62e0..2ceb531d44 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -96,7 +96,7 @@ public:
void setPlacement(Immutable<Placement>);
const Immutable<Placement>& getPlacement() const { return placement; }
void setPlacementStale() { stale = true; }
- bool placementIsRecent(TimePoint now, const float zoom, optional<Duration> maximumDuration = nullopt) const;
+ bool placementIsRecent(TimePoint now, const float zoom, optional<Duration> periodOverride = nullopt) const;
bool hasTransitions(TimePoint now) const;
private: