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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 199523002: cc: Throttle swaps in Scheduler instead of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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 0ff27f4a1355979515c780722943536178ed73eb..0863849de2b545bf098b89e35e5349463564318d 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -28,6 +28,8 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
last_frame_number_update_visible_tiles_was_called_(-1),
manage_tiles_funnel_(0),
consecutive_checkerboard_animations_(0),
+ max_pending_swaps_(1),
+ pending_swaps_(0),
needs_redraw_(false),
needs_manage_tiles_(false),
swap_used_incomplete_tile_(false),
@@ -245,6 +247,8 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const {
minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_);
minor_state->SetInteger("consecutive_checkerboard_animations",
consecutive_checkerboard_animations_);
+ minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_);
+ minor_state->SetInteger("pending_swaps_", pending_swaps_);
minor_state->SetBoolean("needs_redraw", needs_redraw_);
minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_);
minor_state->SetBoolean("swap_used_incomplete_tile",
@@ -390,6 +394,10 @@ bool SchedulerStateMachine::ShouldDraw() const {
if (HasSwappedThisFrame())
return false;
+ // Do not queue too many swaps.
+ if (pending_swaps_ >= max_pending_swaps_)
+ return false;
+
// Except for the cases above, do not draw outside of the BeginImplFrame
// deadline.
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
@@ -507,6 +515,11 @@ bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
if (!HasInitializedOutputSurface())
return false;
+ // SwapAck throttle the BeginMainFrames
+ // TODO(brianderson): Remove this restriction to improve throughput.
+ if (pending_swaps_ >= max_pending_swaps_)
+ return false;
+
if (skip_begin_main_frame_to_reduce_latency_)
return false;
@@ -855,8 +868,7 @@ bool SchedulerStateMachine::SupportsProactiveBeginFrame() const {
// Both the synchronous compositor and disabled vsync settings
// make it undesirable to proactively request BeginImplFrames.
// If this is true, the scheduler should poll.
- return !settings_.using_synchronous_renderer_compositor &&
- settings_.throttle_frame_production;
+ return !settings_.using_synchronous_renderer_compositor;
}
// These are the cases where we definitely (or almost definitely) have a
@@ -971,6 +983,10 @@ bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineEarly() const {
if (output_surface_state_ == OUTPUT_SURFACE_LOST)
return true;
+ // SwapAck throttle the deadline since we wont draw and swap anyway.
+ if (pending_swaps_ >= max_pending_swaps_)
+ return false;
+
if (active_tree_needs_first_draw_)
return true;
@@ -1059,11 +1075,26 @@ void SchedulerStateMachine::SetNeedsManageTiles() {
}
}
+void SchedulerStateMachine::SetMaxSwapsPending(int max) {
+ max_pending_swaps_ = max;
+}
+
+void SchedulerStateMachine::DidSwapBuffers() {
+ pending_swaps_++;
+ DCHECK_LE(pending_swaps_, max_pending_swaps_);
+}
+
void SchedulerStateMachine::SetSwapUsedIncompleteTile(
bool used_incomplete_tile) {
swap_used_incomplete_tile_ = used_incomplete_tile;
}
+void SchedulerStateMachine::OnSwapBuffersComplete() {
+ DCHECK(HasInitializedOutputSurface());
+ DCHECK_GT(pending_swaps_, 0);
+ pending_swaps_--;
+}
+
void SchedulerStateMachine::SetSmoothnessTakesPriority(
bool smoothness_takes_priority) {
smoothness_takes_priority_ = smoothness_takes_priority;
@@ -1178,6 +1209,7 @@ void SchedulerStateMachine::DidLoseOutputSurface() {
return;
output_surface_state_ = OUTPUT_SURFACE_LOST;
needs_redraw_ = false;
+ pending_swaps_ = 0;
}
void SchedulerStateMachine::NotifyReadyToActivate() {

Powered by Google App Engine
This is Rietveld 408576698