Index: cc/scheduler/scheduler_state_machine.h |
diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h |
index 238c08c42d166c47acd80c4a682fd225cbf6d033..b6dcdbdd2d8b08351ca8d4500caee82c0aeb5cb7 100644 |
--- a/cc/scheduler/scheduler_state_machine.h |
+++ b/cc/scheduler/scheduler_state_machine.h |
@@ -67,6 +67,7 @@ class CC_EXPORT SchedulerStateMachine { |
BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE, |
BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR, |
BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE, |
+ BEGIN_IMPL_FRAME_DEADLINE_MODE_TRY_TO_AVOID_CHECKERBOARD, |
BEGIN_IMPL_FRAME_DEADLINE_MODE_BLOCKED_ON_READY_TO_DRAW, |
}; |
static const char* BeginImplFrameDeadlineModeToString( |
@@ -82,14 +83,35 @@ class CC_EXPORT SchedulerStateMachine { |
}; |
static const char* CommitStateToString(CommitState state); |
- enum ForcedRedrawOnTimeoutState { |
- FORCED_REDRAW_STATE_IDLE, |
- FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, |
- FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, |
- FORCED_REDRAW_STATE_WAITING_FOR_DRAW, |
+ enum PrepareTilesApproach { |
+ // PREPARE_TILES_APPROACH_PRIORITIZE_LATENCY calls PrepareTiles after |
+ // every commit and after draws if there wasn't a commit for that frame. |
+ // NotifyReadyToActivate and NotifyReadyToDraw are NOT trustworthy, but |
+ // can be used as hints. |
+ // The scheduler only calls DrawAndSwapIfPossible with this approach. |
+ // We transition to PREPARE_TILES_APPROACH_ACCURATE_ACTIVE_WORK whenever |
+ // DrawAndSwapIfPossible aborts due to checkerboards. |
+ PREPARE_TILES_APPROACH_PRIORITIZE_LATENCY, |
+ // PREPARE_TILES_APPROACH_ACCURATE_ACTIVE_WORK only calls PrepareTiles at |
+ // the start of a frame so new active tree work starts ASAP, but the |
+ // pending tree work doesn't. |
+ // NotifyReadyToActivate and NotifyReadyToDraw are trustworthy. |
+ // The scheduler only calls DrawAndSwapForced with this approach. |
+ // We transition to PREPARE_TILES_APPROACH_PRIORITIZE_LATENCY upon |
+ // either going idle or recovering main-thread latency. |
+ PREPARE_TILES_APPROACH_ACCURATE_ACTIVE_WORK, |
}; |
- static const char* ForcedRedrawOnTimeoutStateToString( |
- ForcedRedrawOnTimeoutState state); |
+ static const char* PrepareTilesApproachToString( |
+ PrepareTilesApproach approach); |
+ |
+ enum PrepareTilesReason { |
+ PREPARE_TILES_NOT_NEEDED, |
+ PREPARE_TILES_REQUESTED, |
+ PREPARE_TILES_NEEDED_FOR_COMMIT, |
+ PREPARE_TILES_NEEDED_FOR_ABORTED_DRAW, |
+ PREPARE_TILES_NEEDED_TO_EVICT_TILES, |
+ }; |
+ static const char* PrepareTilesReasonToString(PrepareTilesReason reason); |
bool CommitPending() const { |
return commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
@@ -99,7 +121,9 @@ class CC_EXPORT SchedulerStateMachine { |
CommitState commit_state() const { return commit_state_; } |
bool RedrawPending() const { return needs_redraw_; } |
- bool PrepareTilesPending() const { return needs_prepare_tiles_; } |
+ bool PrepareTilesPending() const { |
+ return prepare_tiles_reason_ != PREPARE_TILES_NOT_NEEDED; |
+ } |
enum Action { |
ACTION_NONE, |
@@ -120,12 +144,28 @@ class CC_EXPORT SchedulerStateMachine { |
void AsValueInto(base::trace_event::TracedValue* dict) const; |
Action NextAction() const; |
- void UpdateState(Action action); |
+ void WillAction(Action action); |
+ void DidAction(Action action); |
// Indicates whether the impl thread needs a BeginImplFrame callback in order |
// to make progress. |
bool BeginFrameNeeded() const; |
+ // Indicates that the Scheduler should retry the BeginImplFrame or the |
+ // deadline because the draw aborted due to checkerboards. |
+ bool retry_begin_impl_frame() const { return retry_begin_impl_frame_; } |
+ bool retry_begin_impl_frame_deadline() const { |
+ return retry_begin_impl_frame_deadline_; |
+ } |
+ void ResetRetryBeginImplFrame() { |
+ retry_begin_impl_frame_ = false; |
+ retry_begin_impl_frame_deadline_ = false; |
+ } |
+ |
+ // This reflects the actual state of the BeginFrameSource, not just whether |
+ // the SchedulerStateMachine wants BeginFrames at this instance. |
+ void NotifyBeginFrameSourceActive(bool active); |
+ |
// Indicates that the system has entered and left a BeginImplFrame callback. |
// The scheduler will not draw more than once in a given BeginImplFrame |
// callback nor send more than one BeginMainFrame message. |
@@ -159,7 +199,7 @@ class CC_EXPORT SchedulerStateMachine { |
// Indicates that prepare-tiles is required. This guarantees another |
// PrepareTiles will occur shortly (even if no redraw is required). |
- void SetNeedsPrepareTiles(); |
+ void SetNeedsPrepareTiles(bool for_commit); |
// Make deadline wait for ReadyToDraw signal. |
void SetWaitForReadyToDraw(); |
@@ -186,8 +226,8 @@ class CC_EXPORT SchedulerStateMachine { |
return impl_latency_takes_priority_; |
} |
- // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen. |
- void DidDrawIfPossibleCompleted(DrawResult result); |
+ // Indicates whether a draw request succeeded or not. |
+ void SetDrawResult(DrawResult result); |
// Indicates that a new commit flow needs to be performed, either to pull |
// updates from the main thread to the impl, or to push deltas from the impl |
@@ -224,12 +264,14 @@ class CC_EXPORT SchedulerStateMachine { |
// Indicates the active tree's visible tiles are ready to be drawn. |
void NotifyReadyToDraw(); |
+ // Indicates we shouldn't draw the active tree until we won't checkerboard. |
+ void SetRequiresHighResToDraw(bool required); |
+ |
bool has_pending_tree() const { return has_pending_tree_; } |
bool active_tree_needs_first_draw() const { |
return active_tree_needs_first_draw_; |
} |
- void DidPrepareTiles(); |
void DidLoseOutputSurface(); |
void DidCreateAndInitializeOutputSurface(); |
bool HasInitializedOutputSurface() const; |
@@ -280,21 +322,24 @@ class CC_EXPORT SchedulerStateMachine { |
bool ShouldPrepareTiles() const; |
bool ShouldInvalidateOutputSurface() const; |
- void UpdateStateOnAnimate(); |
- void UpdateStateOnSendBeginMainFrame(); |
- void UpdateStateOnCommit(bool commit_had_no_updates); |
- void UpdateStateOnActivation(); |
- void UpdateStateOnDraw(bool did_request_swap); |
- void UpdateStateOnBeginOutputSurfaceCreation(); |
- void UpdateStateOnPrepareTiles(); |
- void UpdateStateOnInvalidateOutputSurface(); |
+ void WillCommit(); |
+ |
+ void WillAnimate(); |
+ void WillSendBeginMainFrame(); |
+ void DidCommit(bool commit_had_no_updates); |
+ void WillActivateSyncTree(); |
+ void DidDraw(bool did_request_swap); |
+ void WillBeginOutputSurfaceCreation(); |
+ void DidPrepareTiles(); |
+ void WillInvalidateOutputSurface(); |
const SchedulerSettings settings_; |
OutputSurfaceState output_surface_state_; |
BeginImplFrameState begin_impl_frame_state_; |
CommitState commit_state_; |
- ForcedRedrawOnTimeoutState forced_redraw_state_; |
+ PrepareTilesApproach prepare_tiles_approach_; |
+ PrepareTilesReason prepare_tiles_reason_; |
// These are used for tracing only. |
int commit_count_; |
@@ -311,25 +356,29 @@ class CC_EXPORT SchedulerStateMachine { |
bool request_swap_funnel_; |
bool send_begin_main_frame_funnel_; |
bool invalidate_output_surface_funnel_; |
+ // TODO(brianderson): Update the comment below. |
// prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
// and "drained" on each BeginImplFrame. If the funnel gets too full, |
// we start throttling ACTION_PREPARE_TILES such that we average one |
// PrepareTiles per BeginImplFrame. |
int prepare_tiles_funnel_; |
- int consecutive_checkerboard_animations_; |
int max_pending_swaps_; |
int pending_swaps_; |
bool needs_redraw_; |
+ DrawResult last_draw_result_; |
+ bool retry_begin_impl_frame_; |
+ bool retry_begin_impl_frame_deadline_; |
bool needs_animate_; |
- bool needs_prepare_tiles_; |
bool needs_commit_; |
bool visible_; |
bool can_start_; |
bool can_draw_; |
bool has_pending_tree_; |
bool pending_tree_is_ready_for_activation_; |
+ bool requires_high_res_to_draw_; |
bool active_tree_needs_first_draw_; |
+ bool active_tree_ready_to_draw_; |
bool did_create_and_initialize_first_output_surface_; |
bool impl_latency_takes_priority_; |
bool skip_next_begin_main_frame_to_reduce_latency_; |