| 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
|
|
|