Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: cc/scheduler/scheduler.cc

Issue 54913003: Scheduler: Switch from high to low latency mode if possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update MainThreadIsInHighLatencyMode() and comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler.cc
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 93b91311e6e94c9f821ad8753cbe56d40d6b27b4..06f58f69d8ddb27acd62b1d629c622475c2d15f2 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -184,6 +184,13 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
last_begin_impl_frame_args_ = args;
last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate();
state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_);
+
+ if (settings_.switch_to_low_latency_if_possible) {
+ state_machine_.SetSkipBeginMainFrameToReduceLatency(
+ state_machine_.MainThreadIsInHighLatencyMode() &&
+ CanPaintAndCommitBeforeDeadline());
+ }
+
ProcessScheduledActions();
if (!state_machine_.HasInitializedOutputSurface())
@@ -344,4 +351,15 @@ bool Scheduler::WillDrawIfNeeded() const {
return !state_machine_.PendingDrawsShouldBeAborted();
}
+bool Scheduler::CanPaintAndCommitBeforeDeadline() const {
+ // Check if the main thread computation and commit can be finished before the
+ // impl thread's deadline.
+ base::TimeTicks estimated_draw_time =
+ last_begin_impl_frame_args_.frame_time +
+ client_->BeginMainFrameToCommitDurationEstimate() +
+ client_->CommitToActivateDurationEstimate();
+
+ return estimated_draw_time < last_begin_impl_frame_args_.deadline;
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698