Index: cc/scheduler/scheduler_state_machine.cc |
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc |
index 01ac8cbb1cc2be98421dd455cabc1b330cd9c623..a3daf48247656c275a14abbf2b96ad65123b3141 100644 |
--- a/cc/scheduler/scheduler_state_machine.cc |
+++ b/cc/scheduler/scheduler_state_machine.cc |
@@ -47,7 +47,9 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
pending_tree_is_ready_for_activation_(false), |
active_tree_needs_first_draw_(false), |
did_create_and_initialize_first_output_surface_(false), |
- impl_latency_takes_priority_(false), |
+ smoothness_takes_priority_(false), |
+ scroll_affects_scroll_handler_(false), |
+ critical_begin_main_frame_to_activate_is_fast_(true), |
main_thread_missed_last_deadline_(false), |
skip_next_begin_main_frame_to_reduce_latency_(false), |
children_need_begin_frames_(false), |
@@ -237,8 +239,11 @@ void SchedulerStateMachine::AsValueInto( |
state->SetBoolean("wait_for_ready_to_draw", wait_for_ready_to_draw_); |
state->SetBoolean("did_create_and_initialize_first_output_surface", |
did_create_and_initialize_first_output_surface_); |
- state->SetBoolean("impl_latency_takes_priority", |
- impl_latency_takes_priority_); |
+ state->SetBoolean("smoothness_takes_priority", smoothness_takes_priority_); |
+ state->SetBoolean("scroll_affects_scroll_handler", |
+ scroll_affects_scroll_handler_); |
+ state->SetBoolean("critical_begin_main_frame_to_activate_is_fast_", |
+ critical_begin_main_frame_to_activate_is_fast_); |
state->SetBoolean("main_thread_missed_last_deadline", |
main_thread_missed_last_deadline_); |
state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", |
@@ -432,8 +437,8 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { |
return false; |
// Don't send BeginMainFrame early if we are prioritizing the active tree |
- // because of impl_latency_takes_priority_. |
- if (impl_latency_takes_priority_ && |
+ // because of ImplLatencyTakesPriority. |
+ if (ImplLatencyTakesPriority() && |
(has_pending_tree_ || active_tree_needs_first_draw_)) { |
return false; |
} |
@@ -469,7 +474,7 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { |
// SwapAck throttle the BeginMainFrames unless we just swapped to |
// potentially improve impl-thread latency over main-thread throughput. |
// TODO(brianderson): Remove this restriction to improve throughput or |
- // make it conditional on impl_latency_takes_priority_. |
+ // make it conditional on ImplLatencyTakesPriority. |
bool just_swapped_in_deadline = |
begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && |
did_perform_swap_in_last_draw_; |
@@ -900,8 +905,8 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() |
!has_pending_tree_) |
return true; |
- // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. |
- if (impl_latency_takes_priority_) |
+ // Prioritize impl-thread draws in ImplLatencyTakesPriority mode. |
+ if (ImplLatencyTakesPriority()) |
return true; |
return false; |
@@ -978,9 +983,30 @@ void SchedulerStateMachine::DidSwapBuffersComplete() { |
pending_swaps_--; |
} |
-void SchedulerStateMachine::SetImplLatencyTakesPriority( |
- bool impl_latency_takes_priority) { |
- impl_latency_takes_priority_ = impl_latency_takes_priority; |
+void SchedulerStateMachine::SetSmoothnessMode( |
+ bool smoothness_takes_priority, |
+ bool scroll_affects_scroll_handler) { |
+ smoothness_takes_priority_ = smoothness_takes_priority; |
+ scroll_affects_scroll_handler_ = scroll_affects_scroll_handler; |
+} |
+ |
+void SchedulerStateMachine::SetCriticalBeginMainFrameToActivateIsFast( |
+ bool is_fast) { |
+ critical_begin_main_frame_to_activate_is_fast_ = is_fast; |
+} |
+ |
+bool SchedulerStateMachine::ImplLatencyTakesPriority() const { |
+ // Attempt to synchronize with the main thread if it has a scroll listener |
+ // and is fast. |
+ if (scroll_affects_scroll_handler_ && |
+ critical_begin_main_frame_to_activate_is_fast_) |
+ return false; |
+ |
+ // Don't wait for the main thread if we are prioritizing smoothness. |
+ if (smoothness_takes_priority_) |
+ return true; |
+ |
+ return false; |
} |
void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { |