Chromium Code Reviews| Index: cc/scheduler/scheduler_state_machine.h |
| diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h |
| index 48dd8288d74e89ccb0efaeb202bcc1812b735380..059cf824a43d8f7b28c1592e305e8feb5af68fa6 100644 |
| --- a/cc/scheduler/scheduler_state_machine.h |
| +++ b/cc/scheduler/scheduler_state_machine.h |
| @@ -45,6 +45,18 @@ class CC_EXPORT SchedulerStateMachine { |
| }; |
| static const char* OutputSurfaceStateToString(OutputSurfaceState state); |
| + // Note: BeginFrameState will always cycle through all the states in order. |
| + // Whether or not it actually waits or draws, it will at least try to wait in |
| + // BEGIN_FRAME_STATE_DEADLINE_PENDING and try to draw in |
| + // BEGIN_FRAME_STATE_INSIDE_DEADLINE |
| + enum BeginFrameState { |
| + BEGIN_FRAME_STATE_IDLE, |
| + BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME, |
| + BEGIN_FRAME_STATE_DEADLINE_PENDING, |
|
danakj
2013/09/17 20:26:19
I am anti-"pending" in these names as they are not
brianderson
2013/09/17 21:08:24
Done.
|
| + BEGIN_FRAME_STATE_INSIDE_DEADLINE, |
| + }; |
| + static const char* BeginFrameStateToString(BeginFrameState state); |
| + |
| enum CommitState { |
| COMMIT_STATE_IDLE, |
| COMMIT_STATE_FRAME_IN_PROGRESS, |
| @@ -82,8 +94,7 @@ class CC_EXPORT SchedulerStateMachine { |
| ForcedRedrawOnTimeoutState state); |
| bool CommitPending() const { |
| - return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || |
| - commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
|
danakj
2013/09/17 20:26:19
This is going to affect the unit tests that do not
brianderson
2013/09/17 21:08:24
Ok. To recap offline discussions: I thought I need
|
| + return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS; |
| } |
| bool RedrawPending() const { return needs_redraw_; } |
| @@ -109,19 +120,30 @@ class CC_EXPORT SchedulerStateMachine { |
| Action NextAction() const; |
| void UpdateState(Action action); |
| + |
| void CheckInvariants(); |
| // Indicates whether the main thread needs a begin frame callback in order to |
| // make progress. |
| - bool BeginFrameNeededToDrawByImplThread() const; |
| - bool ProactiveBeginFrameWantedByImplThread() const; |
| + bool BeginFrameNeededByImplThread() const; |
| + |
| + // Idicates that we need to independently poll for new state and actions |
| + // because we can't expect a BeginFrame. This is mostly used to avoid |
| + // drawing repeat frames with the synchronous compositor without dropping |
| + // necessary actions on the floor. |
| + bool ShouldPollForAnticipatedDrawTriggers() const; |
| // Indicates that the system has entered and left a BeginFrame callback. |
| // The scheduler will not draw more than once in a given BeginFrame |
| // callback nor send more than one BeginFrame message. |
| - void DidEnterBeginFrame(const BeginFrameArgs& args); |
| - void DidLeaveBeginFrame(); |
| - bool inside_begin_frame() const { return inside_begin_frame_; } |
| + void OnBeginFrame(const BeginFrameArgs& args); |
| + void OnBeginFrameDeadlinePending(); |
| + void OnBeginFrameDeadline(); |
| + void OnBeginFrameIdle(); |
| + bool ShouldTriggerBeginFrameDeadlineEarly() const; |
| + BeginFrameState begin_frame_state() const { |
| + return begin_frame_state_; |
| + } |
| // PollForAnticipatedDrawTriggers is used by the synchronous compositor to |
| // avoid requesting BeginImplFrames when we won't actually draw but still |
| @@ -138,6 +160,7 @@ class CC_EXPORT SchedulerStateMachine { |
| // Indicates that a redraw is required, either due to the impl tree changing |
| // or the screen being damaged and simply needing redisplay. |
| void SetNeedsRedraw(); |
| + bool needs_redraw() const { return needs_redraw_; } |
| // Indicates that manage-tiles is required. This guarantees another |
| // ManageTiles will occur shortly (even if no redraw is required). |
| @@ -147,8 +170,7 @@ class CC_EXPORT SchedulerStateMachine { |
| // with a low resolution or checkerboarded tile. |
| void SetSwapUsedIncompleteTile(bool used_incomplete_tile); |
| - // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen or |
| - // not. |
| + // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen. |
| void DidDrawIfPossibleCompleted(bool success); |
| // Indicates that a new commit flow needs to be performed, either to pull |
| @@ -201,6 +223,9 @@ class CC_EXPORT SchedulerStateMachine { |
| bool PendingDrawsShouldBeAborted() const; |
| protected: |
| + bool BeginFrameNeededToDrawByImplThread() const; |
| + bool ProactiveBeginFrameWantedByImplThread() const; |
| + |
| // True if we need to force activations to make forward progress. |
| bool PendingActivationsShouldBeForced() const; |
| @@ -214,11 +239,10 @@ class CC_EXPORT SchedulerStateMachine { |
| bool ShouldCommit() const; |
| bool ShouldManageTiles() const; |
| - bool HasDrawnAndSwappedThisFrame() const; |
| - bool HasActivatedPendingTreeThisFrame() const; |
| - bool HasUpdatedVisibleTilesThisFrame() const; |
| bool HasSentBeginFrameToMainThreadThisFrame() const; |
| bool HasScheduledManageTilesThisFrame() const; |
| + bool HasUpdatedVisibleTilesThisFrame() const; |
| + bool HasSwappedThisFrame() const; |
| void UpdateStateOnCommit(bool commit_was_aborted); |
| void UpdateStateOnActivation(); |
| @@ -228,26 +252,27 @@ class CC_EXPORT SchedulerStateMachine { |
| const SchedulerSettings settings_; |
| OutputSurfaceState output_surface_state_; |
| + BeginFrameState begin_frame_state_; |
| CommitState commit_state_; |
| TextureState texture_state_; |
| ForcedRedrawOnTimeoutState forced_redraw_state_; |
| SynchronousReadbackState readback_state_; |
| + BeginFrameArgs last_begin_frame_args_; |
| + |
| int commit_count_; |
| int current_frame_number_; |
| - int last_frame_number_where_begin_frame_sent_to_main_thread_; |
| int last_frame_number_swap_performed_; |
| - int last_frame_number_where_update_visible_tiles_was_called_; |
| + int last_frame_number_begin_frame_sent_to_main_thread_; |
| + int last_frame_number_update_visible_tiles_was_called_; |
| + |
| int consecutive_failed_draws_; |
| bool needs_redraw_; |
| bool needs_manage_tiles_; |
| bool swap_used_incomplete_tile_; |
| bool needs_commit_; |
| bool main_thread_needs_layer_textures_; |
| - bool inside_begin_frame_; |
| bool inside_poll_for_anticipated_draw_triggers_; |
| - |
| - BeginFrameArgs last_begin_frame_args_; |
| bool visible_; |
| bool can_start_; |
| bool can_draw_; |