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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 1425973003: cc: Don't attempt main thread synchronization if it is slow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new tests Created 5 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
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..2f8400bce1b6114b47c2d4907238161ca30da210 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),
+ tree_priority_(NEW_CONTENT_TAKES_PRIORITY),
+ scroll_handler_state_(SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER),
+ 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),
@@ -146,6 +148,17 @@ const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
return "???";
}
+const char* ScrollHandlerStateToString(ScrollHandlerState state) {
+ switch (state) {
+ case SCROLL_AFFECTS_SCROLL_HANDLER:
+ return "SCROLL_AFFECTS_SCROLL_HANDLER";
+ case SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER:
+ return "SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER";
+ }
+ NOTREACHED();
+ return "???";
+}
+
const char* SchedulerStateMachine::ActionToString(Action action) {
switch (action) {
case ACTION_NONE:
@@ -237,8 +250,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->SetString("tree_priority", TreePriorityToString(tree_priority_));
+ state->SetString("scroll_handler_state",
+ ScrollHandlerStateToString(scroll_handler_state_));
+ 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 +448,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 +485,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 +916,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 +994,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(
+ TreePriority tree_priority,
+ ScrollHandlerState scroll_handler_state) {
+ tree_priority_ = tree_priority;
+ scroll_handler_state_ = scroll_handler_state;
+}
+
+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 == scroll_handler_state_ &&
+ 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 == tree_priority_)
+ return true;
+
+ return false;
}
void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {

Powered by Google App Engine
This is Rietveld 408576698