Chromium Code Reviews| Index: cc/scheduler/scheduler_state_machine.cc |
| diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc |
| index ad27328ec4bd2e967426b4eeade1bb3e6fecfa15..f7e4b24bf5aface96a3237157683a72a04e57ebf 100644 |
| --- a/cc/scheduler/scheduler_state_machine.cc |
| +++ b/cc/scheduler/scheduler_state_machine.cc |
| @@ -47,6 +47,7 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
| active_tree_needs_first_draw_(false), |
| did_create_and_initialize_first_output_surface_(false), |
| impl_latency_takes_priority_(false), |
| + main_thread_missed_last_deadline_(false), |
| skip_next_begin_main_frame_to_reduce_latency_(false), |
| continuous_painting_(false), |
| children_need_begin_frames_(false), |
| @@ -237,8 +238,8 @@ void SchedulerStateMachine::AsValueInto( |
| did_create_and_initialize_first_output_surface_); |
| state->SetBoolean("impl_latency_takes_priority", |
| impl_latency_takes_priority_); |
| - state->SetBoolean("main_thread_is_in_high_latency_mode", |
| - MainThreadIsInHighLatencyMode()); |
| + state->SetBoolean("main_thread_missed_last_deadline", |
| + main_thread_missed_last_deadline_); |
| state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
| skip_next_begin_main_frame_to_reduce_latency_); |
| state->SetBoolean("continuous_painting", continuous_painting_); |
| @@ -879,6 +880,11 @@ void SchedulerStateMachine::OnBeginImplFrameIdle() { |
| begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; |
| skip_next_begin_main_frame_to_reduce_latency_ = false; |
| + |
| + // If a new or undrawn active tree is pending after the deadline, |
| + // then the main thread is in a high latency mode. |
| + main_thread_missed_last_deadline_ = |
| + CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_; |
| } |
| SchedulerStateMachine::BeginImplFrameDeadlineMode |
| @@ -939,52 +945,23 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() |
| return false; |
| } |
| -bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { |
| - // If a commit is pending before the previous commit has been drawn, we |
| - // are definitely in a high latency mode. |
| - if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) |
| - return true; |
| - |
| - // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main |
| - // thread is in a low latency mode. |
| - if (send_begin_main_frame_funnel_ && |
| - (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING || |
| - begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)) |
| - return false; |
| - |
| - // If there's a commit in progress it must either be from the previous frame |
| - // or it started after the impl thread's deadline. In either case the main |
| - // thread is in high latency mode. |
| - if (CommitPending()) |
| - return true; |
| - |
| - // Similarly, if there's a pending tree the main thread is in high latency |
| - // mode, because either |
| - // it's from the previous frame |
| - // or |
| - // we're currently drawing the active tree and the pending tree will thus |
| - // only be drawn in the next frame. |
| - if (has_pending_tree_) |
| - return true; |
| - |
| - if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) { |
| - // Even if there's a new active tree to draw at the deadline or we've just |
| - // swapped it, it may have been triggered by a previous BeginImplFrame, in |
| - // which case the main thread is in a high latency mode. |
| - return (active_tree_needs_first_draw_ || did_perform_swap_in_last_draw_) && |
| - !send_begin_main_frame_funnel_; |
| - } |
| - |
| - // If the active tree needs its first draw in any other state, we know the |
| - // main thread is in a high latency mode. |
| - return active_tree_needs_first_draw_; |
| +bool SchedulerStateMachine::main_thread_missed_last_deadline() const { |
| + return main_thread_missed_last_deadline_; |
| } |
| bool SchedulerStateMachine::SwapThrottled() const { |
| return pending_swaps_ >= max_pending_swaps_; |
| } |
| -void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; } |
| +void SchedulerStateMachine::SetVisible(bool visible) { |
| + if (visible_ == visible) |
| + return; |
| + |
| + if (visible) |
| + main_thread_missed_last_deadline_ = false; |
| + |
| + visible_ = visible; |
| +} |
| void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; } |
| @@ -1145,6 +1122,7 @@ void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() { |
| did_create_and_initialize_first_output_surface_ = true; |
| pending_swaps_ = 0; |
| swaps_with_current_output_surface_ = 0; |
| + main_thread_missed_last_deadline_ = false; |
|
sunnyps
2015/07/13 20:03:09
It looks like we need to set main_thread_missed_la
|
| } |
| void SchedulerStateMachine::NotifyBeginMainFrameStarted() { |