Chromium Code Reviews| Index: cc/scheduler/scheduler.cc |
| diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc |
| index 2a03a34225e55b6da9cb03b1d162e82389836789..e50608b9cbc1f97a6bdaec6dc3ceb6c1ae69d10d 100644 |
| --- a/cc/scheduler/scheduler.cc |
| +++ b/cc/scheduler/scheduler.cc |
| @@ -129,8 +129,18 @@ base::TimeTicks Scheduler::Now() const { |
| return now; |
| } |
| +void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { |
|
mithro-old
2015/05/27 04:40:14
Moving this SetAuthoritativeVSyncInterval seems un
|
| + authoritative_vsync_interval_ = interval; |
|
mithro-old
2015/05/27 04:40:14
Would it be useful to do a TRACE_EVENT here too?
|
| + if (vsync_observer_) |
| + vsync_observer_->OnUpdateVSyncParameters(last_vsync_timebase_, interval); |
| +} |
| + |
| void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, |
| base::TimeDelta interval) { |
| + TRACE_EVENT2("cc", "Scheduler::CommitVSyncParameters", "timebase", |
| + (timebase - base::TimeTicks()).InSecondsF(), "interval", |
|
mithro-old
2015/05/27 04:40:14
TRACE_EVENT should have native support for base::T
|
| + interval.InSecondsF()); |
| + |
| if (authoritative_vsync_interval_ != base::TimeDelta()) { |
| interval = authoritative_vsync_interval_; |
| } else if (interval == base::TimeDelta()) { |
| @@ -387,12 +397,6 @@ void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| ProcessScheduledActions(); |
| } |
| -void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { |
| - authoritative_vsync_interval_ = interval; |
| - if (vsync_observer_) |
| - vsync_observer_->OnUpdateVSyncParameters(last_vsync_timebase_, interval); |
| -} |
| - |
| void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { |
| state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); |
| ProcessScheduledActions(); |
| @@ -498,10 +502,15 @@ void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { |
| begin_impl_frame_args_ = args; |
| begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); |
| - if (!state_machine_.impl_latency_takes_priority() && |
| - main_thread_is_in_high_latency_mode && |
| - CanCommitAndActivateBeforeDeadline()) { |
| + if (ShouldRecoverMainLatency()) { |
| + TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", |
| + TRACE_EVENT_SCOPE_THREAD); |
| state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); |
| + } else if (ShouldRecoverImplLatency()) { |
| + TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency", |
|
mithro-old
2015/05/27 04:40:14
Should this be Scheduler::SkipBeginImplFrameToRedu
|
| + TRACE_EVENT_SCOPE_THREAD); |
| + frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); |
| + return; |
| } |
| BeginImplFrame(); |
| @@ -516,6 +525,7 @@ void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) { |
| args.AsValue()); |
| begin_impl_frame_args_ = args; |
| BeginImplFrame(); |
| + |
|
mithro-old
2015/05/27 04:40:14
nit: Extra newline?
|
| FinishImplFrame(); |
| } |
| @@ -553,7 +563,6 @@ void Scheduler::ScheduleBeginImplFrameDeadline() { |
| begin_impl_frame_deadline_mode_ = |
| state_machine_.CurrentBeginImplFrameDeadlineMode(); |
|
mithro-old
2015/05/27 04:40:14
nit: Random new line removal?
|
| - |
| base::TimeTicks deadline; |
| switch (begin_impl_frame_deadline_mode_) { |
| case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: |
| @@ -771,6 +780,9 @@ void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { |
| state->BeginDictionary("begin_impl_frame_args"); |
| begin_impl_frame_args_.AsValueInto(state); |
| state->EndDictionary(); |
| + state->SetString("begin_impl_frame_deadline_mode_", |
| + SchedulerStateMachine::BeginImplFrameDeadlineModeToString( |
| + begin_impl_frame_deadline_mode_)); |
| base::TimeTicks now = Now(); |
| base::TimeTicks frame_time = begin_impl_frame_args_.frame_time; |
| @@ -803,6 +815,43 @@ void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { |
| state->EndDictionary(); |
| } |
| +bool Scheduler::ShouldRecoverMainLatency() const { |
| + if (!state_machine_.MainThreadIsInHighLatencyMode()) |
| + return false; |
| + |
| + if (state_machine_.impl_latency_takes_priority()) |
| + return false; |
| + |
| + return CanCommitAndActivateBeforeDeadline(); |
| +} |
| + |
| +bool Scheduler::ShouldRecoverImplLatency() const { |
| + if (!state_machine_.SwapThrottled()) |
| + return false; |
| + |
| + bool frame_time_is_before_deadline = |
| + begin_impl_frame_args_.frame_time < begin_impl_frame_args_.deadline; |
|
mithro-old
2015/05/27 04:40:14
When is this ever not true? Is it because begin_im
brianderson
2015/05/27 23:22:31
Yes, if the estimated draw time is 20ms, for examp
|
| + |
| + SchedulerStateMachine::BeginImplFrameDeadlineMode |
| + next_begin_impl_frame_deadline_mode = |
| + state_machine_.CurrentBeginImplFrameDeadlineMode(); |
| + switch (next_begin_impl_frame_deadline_mode) { |
| + case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE: |
| + return false; |
| + case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE: |
| + return frame_time_is_before_deadline; |
|
mithro-old
2015/05/27 04:40:14
I can't remember, are we allow to use fall through
brianderson
2015/05/27 23:22:32
Looks like it is allowed.
|
| + case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR: |
| + return frame_time_is_before_deadline; |
| + case SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE: |
| + return CanCommitAndActivateBeforeDeadline(); |
| + case SchedulerStateMachine:: |
| + BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW: |
| + return false; |
| + } |
| + NOTREACHED(); |
| + return false; |
| +} |
| + |
| bool Scheduler::CanCommitAndActivateBeforeDeadline() const { |
| // Check if the main thread computation and commit can be finished before the |
| // impl thread's deadline. |
| @@ -811,14 +860,6 @@ bool Scheduler::CanCommitAndActivateBeforeDeadline() const { |
| client_->BeginMainFrameToCommitDurationEstimate() + |
| client_->CommitToActivateDurationEstimate(); |
|
mithro-old
2015/05/27 04:40:14
nit: Unrelated removal?
brianderson
2015/06/30 22:03:53
I added a trace event on line 506 above and remove
|
| - TRACE_EVENT2( |
| - TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| - "CanCommitAndActivateBeforeDeadline", |
| - "time_left_after_drawing_ms", |
| - (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), |
| - "state", |
| - AsValue()); |
| - |
| return estimated_draw_time < begin_impl_frame_args_.deadline; |
| } |