| Index: cc/scheduler/scheduler_state_machine.h
|
| diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h
|
| index 5c7d5b5b8a773ede49feecaa082991d0446155d0..eb59f282f49ff1c7ec44312be69a0f7bb4b06f3e 100644
|
| --- a/cc/scheduler/scheduler_state_machine.h
|
| +++ b/cc/scheduler/scheduler_state_machine.h
|
| @@ -31,12 +31,31 @@ class CC_EXPORT SchedulerStateMachine {
|
| // settings must be valid for the lifetime of this class.
|
| explicit SchedulerStateMachine(const SchedulerSettings& settings);
|
|
|
| + enum OutputSurfaceState {
|
| + OUTPUT_SURFACE_ACTIVE,
|
| + OUTPUT_SURFACE_LOST,
|
| + OUTPUT_SURFACE_CREATING,
|
| + OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT,
|
| + OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION,
|
| + };
|
| +
|
| + // 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,
|
| + BEGIN_FRAME_STATE_INSIDE_DEADLINE,
|
| + };
|
| +
|
| enum CommitState {
|
| COMMIT_STATE_IDLE,
|
| COMMIT_STATE_FRAME_IN_PROGRESS,
|
| COMMIT_STATE_READY_TO_COMMIT,
|
| + COMMIT_STATE_WAITING_FOR_ACTIVATION,
|
| COMMIT_STATE_WAITING_FOR_FIRST_DRAW,
|
| - COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
|
| };
|
|
|
| enum TextureState {
|
| @@ -45,15 +64,25 @@ class CC_EXPORT SchedulerStateMachine {
|
| LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD,
|
| };
|
|
|
| - enum OutputSurfaceState {
|
| - OUTPUT_SURFACE_ACTIVE,
|
| - OUTPUT_SURFACE_LOST,
|
| - OUTPUT_SURFACE_CREATING,
|
| + enum SynchronousReadbackState {
|
| + READBACK_STATE_IDLE,
|
| + READBACK_STATE_FORCED_COMMIT_REQUESTED,
|
| + READBACK_STATE_FORCED_COMMIT_PENDING,
|
| + READBACK_STATE_WAITING_FOR_ACTIVATION,
|
| + READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK,
|
| + READBACK_STATE_REPLACEMENT_COMMIT_PENDING,
|
| + READBACK_STATE_REPLACEMENT_COMMIT_ACTIVATING,
|
| + };
|
| +
|
| + enum ForcedRedrawOnTimeoutState {
|
| + FORCED_REDRAW_STATE_IDLE,
|
| + FORCED_REDRAW_STATE_WAITING_FOR_COMMIT,
|
| + FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION,
|
| + FORCED_REDRAW_STATE_WAITING_FOR_DRAW,
|
| };
|
|
|
| bool CommitPending() const {
|
| - return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS ||
|
| - commit_state_ == COMMIT_STATE_READY_TO_COMMIT;
|
| + return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS;
|
| }
|
|
|
| bool RedrawPending() const { return needs_redraw_; }
|
| @@ -63,26 +92,31 @@ class CC_EXPORT SchedulerStateMachine {
|
| ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
|
| ACTION_COMMIT,
|
| ACTION_UPDATE_VISIBLE_TILES,
|
| - ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED,
|
| - ACTION_DRAW_IF_POSSIBLE,
|
| - ACTION_DRAW_FORCED,
|
| + ACTION_ACTIVATE_PENDING_TREE,
|
| + ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
|
| + ACTION_DRAW_AND_SWAP_FORCED,
|
| + ACTION_DRAW_AND_SWAP_ABORT,
|
| + ACTION_DRAW_AND_READBACK,
|
| ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
|
| ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD,
|
| };
|
| Action NextAction() const;
|
| void UpdateState(Action action);
|
| + void AdvanceBeginFrameStateWhenNoActionsRemain();
|
|
|
| // Indicates whether the main thread needs a begin frame callback in order to
|
| // make progress.
|
| + bool BeginFrameNeededByImplThread() const;
|
| bool BeginFrameNeededToDrawByImplThread() const;
|
| - bool ProactiveBeginFrameWantedByImplThread() const;
|
| + bool BeginFrameProactivelyNeededByImplThread() 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 OnBeginFrameDeadline();
|
| + bool ShouldTriggerBeginFrameDeadlineEarly() const;
|
| + bool InsideBeginFrame() const;
|
|
|
| // Indicates whether the LayerTreeHostImpl is visible.
|
| void SetVisible(bool visible);
|
| @@ -90,16 +124,13 @@ 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();
|
| -
|
| - // As SetNeedsRedraw(), but ensures the draw will definitely happen even if
|
| - // we are not visible.
|
| - void SetNeedsForcedRedraw();
|
| + bool needs_redraw() const { return needs_redraw_; }
|
|
|
| // Indicates that a redraw is required because we are currently rendering
|
| // with a low resolution or checkerboarded tile.
|
| void DidSwapUseIncompleteTile();
|
|
|
| - // Indicates whether ACTION_DRAW_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
|
| @@ -111,7 +142,7 @@ class CC_EXPORT SchedulerStateMachine {
|
| // thread even if we are not visible. After this call we expect to go through
|
| // the forced commit flow and then return to waiting for a non-forced
|
| // begin frame to finish.
|
| - void SetNeedsForcedCommit();
|
| + void SetNeedsForcedCommitForReadback();
|
|
|
| // Call this only in response to receiving an
|
| // ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD from NextAction.
|
| @@ -126,8 +157,8 @@ class CC_EXPORT SchedulerStateMachine {
|
|
|
| // Request exclusive access to the textures that back single buffered
|
| // layers on behalf of the main thread. Upon acquisition,
|
| - // ACTION_DRAW_IF_POSSIBLE will not draw until the main thread releases the
|
| - // textures to the impl thread by committing the layers.
|
| + // ACTION_DRAW_AND_SWAP_IF_POSSIBLE will not draw until the main thread
|
| + // releases the textures to the impl thread by committing the layers.
|
| void SetMainThreadNeedsLayerTextures();
|
|
|
| // Set that we can create the first OutputSurface and start the scheduler.
|
| @@ -136,14 +167,18 @@ class CC_EXPORT SchedulerStateMachine {
|
| // Indicates whether drawing would, at this time, make sense.
|
| // CanDraw can be used to supress flashes or checkerboarding
|
| // when such behavior would be undesirable.
|
| - void SetCanDraw(bool can);
|
| + void SetCanDraw(bool can_draw);
|
|
|
| - // Indicates whether or not there is a pending tree. This influences
|
| - // whether or not we can succesfully commit at this time. If the
|
| + // Indicates that the pending tree is ready for activation.
|
| + void NotifyReadyToActivate();
|
| +
|
| + // Indicates whether or not there is a pending tree (which may be null)
|
| + // and whether the active tree is null or not. This
|
| + // influences whether or not we can succesfully commit at this time. If the
|
| // last commit is still being processed (but not blocking), it may not
|
| // be possible to take another commit yet. This overrides force commit,
|
| // as a commit is already still in flight.
|
| - void SetHasPendingTree(bool has_pending_tree);
|
| + void SetHasTrees(bool has_pending_tree, bool active_tree_is_null);
|
| bool has_pending_tree() const { return has_pending_tree_; }
|
|
|
| void DidLoseOutputSurface();
|
| @@ -163,44 +198,56 @@ class CC_EXPORT SchedulerStateMachine {
|
| bool ShouldDrawForced() const;
|
| bool ScheduledToDraw() const;
|
| bool ShouldDraw() const;
|
| - bool ShouldAttemptTreeActivation() const;
|
| + bool ShouldDrawInternal(BeginFrameState begin_frame_state) const;
|
| + bool ShouldActivatePendingTree() const;
|
| bool ShouldAcquireLayerTexturesForMainThread() const;
|
| bool ShouldUpdateVisibleTiles() const;
|
| + bool ShouldSendBeginFrameToMainThread() const;
|
| bool HasDrawnThisFrame() const;
|
| - bool HasAttemptedTreeActivationThisFrame() const;
|
| - bool HasUpdatedVisibleTilesThisFrame() const;
|
| - void SetPostCommitFlags();
|
| + bool HasDrawnThisDrawAttempt() const;
|
| + bool HasUpdatedVisibleTilesThisDrawAttempt() const;
|
| + bool HasSentBeginFrameToMainThreadThisFrame() const;
|
| + bool HasActivatedPendingTreeThisDrawAttempt() const;
|
| +
|
| + void HandleCommitInternal(bool commit_was_aborted);
|
| + void UpdateStateOnDraw(bool did_swap);
|
|
|
| const SchedulerSettings settings_;
|
|
|
| + OutputSurfaceState output_surface_state_;
|
| + BeginFrameState begin_frame_state_;
|
| CommitState commit_state_;
|
| + TextureState texture_state_;
|
| + SynchronousReadbackState readback_state_;
|
| + ForcedRedrawOnTimeoutState forced_redraw_state_;
|
| +
|
| + BeginFrameArgs last_begin_frame_args_;
|
| +
|
| int commit_count_;
|
| + int begin_frame_count_;
|
| + int draw_attempt_count_;
|
| + int last_begin_frame_count_swap_performed_;
|
| + int last_draw_attempt_count_draw_was_called_;
|
| + int last_begin_frame_count_begin_frame_sent_to_main_thread_;
|
| + int last_draw_attempt_count_tree_activation_attempted_;
|
| + int last_draw_attempt_count_completed_tile_uploads_checked_;
|
| + int last_draw_attempt_count_update_visible_tiles_was_called_;
|
|
|
| - int current_frame_number_;
|
| - int last_frame_number_where_begin_frame_sent_to_main_thread_;
|
| - int last_frame_number_where_draw_was_called_;
|
| - int last_frame_number_where_tree_activation_attempted_;
|
| - int last_frame_number_where_update_visible_tiles_was_called_;
|
| int consecutive_failed_draws_;
|
| int maximum_number_of_failed_draws_before_draw_is_forced_;
|
| +
|
| bool needs_redraw_;
|
| bool swap_used_incomplete_tile_;
|
| - bool needs_forced_redraw_;
|
| - bool needs_forced_redraw_after_next_commit_;
|
| - bool needs_redraw_after_next_commit_;
|
| bool needs_commit_;
|
| - bool needs_forced_commit_;
|
| - bool expect_immediate_begin_frame_for_main_thread_;
|
| bool main_thread_needs_layer_textures_;
|
| - bool inside_begin_frame_;
|
| - BeginFrameArgs last_begin_frame_args_;
|
| + bool active_tree_has_been_drawn_;
|
| + bool active_tree_is_null_;
|
| bool visible_;
|
| bool can_start_;
|
| bool can_draw_;
|
| bool has_pending_tree_;
|
| + bool pending_tree_is_ready_for_activation_;
|
| bool draw_if_possible_failed_;
|
| - TextureState texture_state_;
|
| - OutputSurfaceState output_surface_state_;
|
| bool did_create_and_initialize_first_output_surface_;
|
|
|
| private:
|
|
|