summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <ansis@mapbox.com>2017-11-02 15:27:19 -0400
committerAnsis Brammanis <ansis@mapbox.com>2017-11-03 14:30:55 -0400
commit22378c4d0f7985186ad276f39f4b6b4279148ac8 (patch)
tree97e852f367a352d3ada40559110e94f7e5e84e30
parent3c09aba711f5ab00731d5d7e96c7cd569502234f (diff)
downloadqtlocation-mapboxgl-upstream/start-collision-throttle.tar.gz
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp23
-rw-r--r--src/mbgl/text/placement.cpp3
-rw-r--r--src/mbgl/text/placement.hpp3
3 files changed, 22 insertions, 7 deletions
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index d96215a550..57135fb1fb 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -373,15 +373,26 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
}
}
- auto newPlacement = std::make_unique<Placement>(parameters.state, parameters.mapMode);
- for (auto it = order.rbegin(); it != order.rend(); ++it) {
- if (it->layer.is<RenderSymbolLayer>()) {
- newPlacement->placeLayer(*it->layer.as<RenderSymbolLayer>(), parameters.projMatrix, parameters.debugOptions & MapDebugOptions::Collision);
+ bool placementChanged = false;
+ if (placement->recentUntil <= parameters.timePoint || updateParameters.mode == MapMode::Still) {
+ auto newPlacement = std::make_unique<Placement>(parameters.state, parameters.mapMode);
+ for (auto it = order.rbegin(); it != order.rend(); ++it) {
+ if (it->layer.is<RenderSymbolLayer>()) {
+ newPlacement->placeLayer(*it->layer.as<RenderSymbolLayer>(), parameters.projMatrix, parameters.debugOptions & MapDebugOptions::Collision);
+ }
}
+
+ placementChanged = newPlacement->commit(*placement, parameters.timePoint);
+ if (placementChanged) {
+ placement = std::move(newPlacement);
+ }
+
+ placement->stale = false;
+ placement->recentUntil = parameters.timePoint + Duration(std::chrono::milliseconds(300));
+ } else {
+ placement->stale = true;
}
- const bool placementChanged = newPlacement->commit(*placement, parameters.timePoint);
- if (placementChanged) placement = std::move(newPlacement);
parameters.symbolFadeChange = placement->symbolFadeChange(parameters.timePoint);
if (placementChanged || symbolBucketsChanged) {
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 9a9456db2f..b7de01623f 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -32,6 +32,7 @@ bool JointOpacityState::isHidden() const {
Placement::Placement(const TransformState& state_, MapMode mapMode_)
: collisionIndex(state_)
+ , recentUntil(TimePoint::min())
, state(state_)
, mapMode(mapMode_)
{}
@@ -290,7 +291,7 @@ float Placement::symbolFadeChange(TimePoint now) const {
}
bool Placement::hasTransitions(TimePoint now) const {
- return symbolFadeChange(now) < 1.0;
+ return symbolFadeChange(now) < 1.0 || stale;
}
} // namespace mbgl
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 2902192b52..8d51d86ce7 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -50,6 +50,9 @@ namespace mbgl {
// TODO: public for queryRenderedFeatures
CollisionIndex collisionIndex;
+ TimePoint recentUntil;
+ bool stale = false;
+
private:
void placeLayerBucket(