summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <ansis@mapbox.com>2018-06-06 22:52:00 -0400
committerAnsis Brammanis <ansis.brammanis@gmail.com>2018-06-07 13:40:17 -0400
commit58b6c42f5d505204ea96faff812885f0d3723614 (patch)
tree2f66357d792fd6d55b2b5e99506c98aca5253643
parent0a15be07aea4a8ba14b0c63a66f5db8066aaacce (diff)
downloadqtlocation-mapboxgl-58b6c42f5d505204ea96faff812885f0d3723614.tar.gz
[core] always commit placement to fix #11795
Since placements will be committed even if they do not need the full fade duration to fade features in, we need the new `fadeStartTime` to keep track of how long we still need to fade. This is important because if we fade too long we will trigger another placement and never stop rendering.
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp10
-rw-r--r--src/mbgl/text/placement.cpp20
-rw-r--r--src/mbgl/text/placement.hpp4
3 files changed, 14 insertions, 20 deletions
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index ca9e809977..fea27403c9 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -387,6 +387,8 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
bool placementChanged = false;
if (!placement->stillRecent(parameters.timePoint)) {
+ placementChanged = true;
+
auto newPlacement = std::make_unique<Placement>(parameters.state, parameters.mapMode);
std::set<std::string> usedSymbolLayers;
for (auto it = order.rbegin(); it != order.rend(); ++it) {
@@ -396,13 +398,9 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
}
}
- placementChanged = newPlacement->commit(*placement, parameters.timePoint);
+ newPlacement->commit(*placement, parameters.timePoint);
crossTileSymbolIndex.pruneUnusedLayers(usedSymbolLayers);
- if (placementChanged || symbolBucketsChanged) {
- placement = std::move(newPlacement);
- }
-
- placement->setRecent(parameters.timePoint);
+ placement = std::move(newPlacement);
updateFadingTiles();
} else {
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 9883a1f456..33844e6427 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -38,7 +38,6 @@ Placement::Placement(const TransformState& state_, MapMode mapMode_)
: collisionIndex(state_)
, state(state_)
, mapMode(mapMode_)
- , recentUntil(TimePoint::min())
{}
void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatrix, bool showCollisionBoxes) {
@@ -188,7 +187,7 @@ void Placement::placeLayerBucket(
bucket.justReloaded = false;
}
-bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
+void Placement::commit(const Placement& prevPlacement, TimePoint now) {
commitTime = now;
bool placementChanged = false;
@@ -222,7 +221,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
}
}
- return placementChanged;
+ fadeStartTime = placementChanged ? commitTime : prevPlacement.fadeStartTime;
}
void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
@@ -339,18 +338,15 @@ float Placement::symbolFadeChange(TimePoint now) const {
}
bool Placement::hasTransitions(TimePoint now) const {
- return symbolFadeChange(now) < 1.0 || stale;
+ if (mapMode == MapMode::Continuous) {
+ return stale || std::chrono::duration<float>(now - fadeStartTime) < Duration(std::chrono::milliseconds(300));
+ } else {
+ return false;
+ }
}
bool Placement::stillRecent(TimePoint now) const {
- return mapMode == MapMode::Continuous && recentUntil > now;
-}
-void Placement::setRecent(TimePoint now) {
- stale = false;
- if (mapMode == MapMode::Continuous) {
- // Only set in continuous mode because "now" isn't defined in still mode
- recentUntil = now + Duration(std::chrono::milliseconds(300));
- }
+ return mapMode == MapMode::Continuous && commitTime + Duration(std::chrono::milliseconds(300)) > now;
}
void Placement::setStale() {
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 0e1751b127..24de4c054a 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -63,7 +63,7 @@ class Placement {
public:
Placement(const TransformState&, MapMode mapMode);
void placeLayer(RenderSymbolLayer&, const mat4&, bool showCollisionBoxes);
- bool commit(const Placement& prevPlacement, TimePoint);
+ void commit(const Placement& prevPlacement, TimePoint);
void updateLayerOpacities(RenderSymbolLayer&);
float symbolFadeChange(TimePoint now) const;
bool hasTransitions(TimePoint now) const;
@@ -94,12 +94,12 @@ private:
TransformState state;
MapMode mapMode;
+ TimePoint fadeStartTime;
TimePoint commitTime;
std::unordered_map<uint32_t, JointPlacement> placements;
std::unordered_map<uint32_t, JointOpacityState> opacities;
- TimePoint recentUntil;
bool stale = false;
std::unordered_map<uint32_t, RetainedQueryData> retainedQueryData;