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

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: Created 5 years, 2 months 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 8e4fed85c73b2667f92ce354a14ee77b7b8a72f2..b4260fef7afd5b284bdc0d14baeccab4299a792e 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -46,7 +46,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),
+ main_thread_is_fast_(true),
main_thread_missed_last_deadline_(false),
skip_next_begin_main_frame_to_reduce_latency_(false),
children_need_begin_frames_(false),
@@ -235,8 +237,10 @@ 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("main_thread_is_fast", main_thread_is_fast_);
state->SetBoolean("main_thread_missed_last_deadline",
main_thread_missed_last_deadline_);
state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
@@ -430,8 +434,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;
}
@@ -467,7 +471,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 +904,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;
@@ -975,9 +979,28 @@ 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::SetMainThreadIsFast(bool is_fast) {
+ main_thread_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_ && main_thread_is_fast_)
brianderson 2015/10/29 17:56:51 Somewhat related to this patch, I wonder if we sho
Sami 2015/10/29 18:37:04 I think that describes the underlying thing pretty
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698