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

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: Add checks for MainThreadIsInHighLatencyMode. 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
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_settings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler.cc
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 93b91311e6e94c9f821ad8753cbe56d40d6b27b4..d4f8e778ab67a68eebefccbacc64950e220f4ac4 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() &&
+ CanCommitAndActivateBeforeDeadline());
+ }
+
ProcessScheduledActions();
if (!state_machine_.HasInitializedOutputSurface())
@@ -344,4 +351,15 @@ bool Scheduler::WillDrawIfNeeded() const {
return !state_machine_.PendingDrawsShouldBeAborted();
}
+bool Scheduler::CanCommitAndActivateBeforeDeadline() 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
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698