| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 }; | 80 }; |
| 81 static const char* ForcedRedrawOnTimeoutStateToString( | 81 static const char* ForcedRedrawOnTimeoutStateToString( |
| 82 ForcedRedrawOnTimeoutState state); | 82 ForcedRedrawOnTimeoutState state); |
| 83 | 83 |
| 84 bool CommitPending() const { | 84 bool CommitPending() const { |
| 85 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || | 85 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || |
| 86 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 86 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool RedrawPending() const { return needs_redraw_; } | 89 bool RedrawPending() const { return needs_redraw_; } |
| 90 bool ManageTilesPending() const { return needs_manage_tiles_; } |
| 90 | 91 |
| 91 enum Action { | 92 enum Action { |
| 92 ACTION_NONE, | 93 ACTION_NONE, |
| 93 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, | 94 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, |
| 94 ACTION_COMMIT, | 95 ACTION_COMMIT, |
| 95 ACTION_UPDATE_VISIBLE_TILES, | 96 ACTION_UPDATE_VISIBLE_TILES, |
| 96 ACTION_ACTIVATE_PENDING_TREE, | 97 ACTION_ACTIVATE_PENDING_TREE, |
| 97 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 98 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
| 98 ACTION_DRAW_AND_SWAP_FORCED, | 99 ACTION_DRAW_AND_SWAP_FORCED, |
| 99 ACTION_DRAW_AND_SWAP_ABORT, | 100 ACTION_DRAW_AND_SWAP_ABORT, |
| 100 ACTION_DRAW_AND_READBACK, | 101 ACTION_DRAW_AND_READBACK, |
| 101 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 102 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 102 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | 103 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, |
| 104 ACTION_MANAGE_TILES, |
| 103 }; | 105 }; |
| 104 static const char* ActionToString(Action action); | 106 static const char* ActionToString(Action action); |
| 105 | 107 |
| 106 scoped_ptr<base::Value> AsValue() const; | 108 scoped_ptr<base::Value> AsValue() const; |
| 107 | 109 |
| 108 Action NextAction() const; | 110 Action NextAction() const; |
| 109 void UpdateState(Action action); | 111 void UpdateState(Action action); |
| 110 void CheckInvariants(); | 112 void CheckInvariants(); |
| 111 | 113 |
| 112 // Indicates whether the main thread needs a begin frame callback in order to | 114 // Indicates whether the main thread needs a begin frame callback in order to |
| (...skipping 13 matching lines...) Expand all Loading... |
| 126 // need to advance our state at vsync intervals. | 128 // need to advance our state at vsync intervals. |
| 127 void PollForAnticipatedDrawTriggers(); | 129 void PollForAnticipatedDrawTriggers(); |
| 128 | 130 |
| 129 // Indicates whether the LayerTreeHostImpl is visible. | 131 // Indicates whether the LayerTreeHostImpl is visible. |
| 130 void SetVisible(bool visible); | 132 void SetVisible(bool visible); |
| 131 | 133 |
| 132 // Indicates that a redraw is required, either due to the impl tree changing | 134 // Indicates that a redraw is required, either due to the impl tree changing |
| 133 // or the screen being damaged and simply needing redisplay. | 135 // or the screen being damaged and simply needing redisplay. |
| 134 void SetNeedsRedraw(); | 136 void SetNeedsRedraw(); |
| 135 | 137 |
| 138 // Indicates that manage-tiles is required. This guarantees another |
| 139 // ManageTiles will occur shortly (even if no redraw is required). |
| 140 void SetNeedsManageTiles(); |
| 141 |
| 136 // Indicates whether a redraw is required because we are currently rendering | 142 // Indicates whether a redraw is required because we are currently rendering |
| 137 // with a low resolution or checkerboarded tile. | 143 // with a low resolution or checkerboarded tile. |
| 138 void SetSwapUsedIncompleteTile(bool used_incomplete_tile); | 144 void SetSwapUsedIncompleteTile(bool used_incomplete_tile); |
| 139 | 145 |
| 140 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen or | 146 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen or |
| 141 // not. | 147 // not. |
| 142 void DidDrawIfPossibleCompleted(bool success); | 148 void DidDrawIfPossibleCompleted(bool success); |
| 143 | 149 |
| 144 // Indicates that a new commit flow needs to be performed, either to pull | 150 // Indicates that a new commit flow needs to be performed, either to pull |
| 145 // updates from the main thread to the impl, or to push deltas from the impl | 151 // updates from the main thread to the impl, or to push deltas from the impl |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 bool PendingActivationsShouldBeForced() const; | 201 bool PendingActivationsShouldBeForced() const; |
| 196 | 202 |
| 197 bool ShouldBeginOutputSurfaceCreation() const; | 203 bool ShouldBeginOutputSurfaceCreation() const; |
| 198 bool ShouldDrawForced() const; | 204 bool ShouldDrawForced() const; |
| 199 bool ShouldDraw() const; | 205 bool ShouldDraw() const; |
| 200 bool ShouldActivatePendingTree() const; | 206 bool ShouldActivatePendingTree() const; |
| 201 bool ShouldAcquireLayerTexturesForMainThread() const; | 207 bool ShouldAcquireLayerTexturesForMainThread() const; |
| 202 bool ShouldUpdateVisibleTiles() const; | 208 bool ShouldUpdateVisibleTiles() const; |
| 203 bool ShouldSendBeginFrameToMainThread() const; | 209 bool ShouldSendBeginFrameToMainThread() const; |
| 204 bool ShouldCommit() const; | 210 bool ShouldCommit() const; |
| 211 bool ShouldManageTiles() const; |
| 205 | 212 |
| 206 bool HasDrawnAndSwappedThisFrame() const; | 213 bool HasDrawnAndSwappedThisFrame() const; |
| 207 bool HasActivatedPendingTreeThisFrame() const; | 214 bool HasActivatedPendingTreeThisFrame() const; |
| 208 bool HasUpdatedVisibleTilesThisFrame() const; | 215 bool HasUpdatedVisibleTilesThisFrame() const; |
| 209 bool HasSentBeginFrameToMainThreadThisFrame() const; | 216 bool HasSentBeginFrameToMainThreadThisFrame() const; |
| 217 bool HasScheduledManageTilesThisFrame() const; |
| 210 | 218 |
| 211 void UpdateStateOnCommit(bool commit_was_aborted); | 219 void UpdateStateOnCommit(bool commit_was_aborted); |
| 212 void UpdateStateOnActivation(); | 220 void UpdateStateOnActivation(); |
| 213 void UpdateStateOnDraw(bool did_swap); | 221 void UpdateStateOnDraw(bool did_swap); |
| 222 void UpdateStateOnManageTiles(); |
| 214 | 223 |
| 215 const SchedulerSettings settings_; | 224 const SchedulerSettings settings_; |
| 216 | 225 |
| 217 OutputSurfaceState output_surface_state_; | 226 OutputSurfaceState output_surface_state_; |
| 218 CommitState commit_state_; | 227 CommitState commit_state_; |
| 219 TextureState texture_state_; | 228 TextureState texture_state_; |
| 220 ForcedRedrawOnTimeoutState forced_redraw_state_; | 229 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 221 SynchronousReadbackState readback_state_; | 230 SynchronousReadbackState readback_state_; |
| 222 | 231 |
| 223 int commit_count_; | 232 int commit_count_; |
| 224 int current_frame_number_; | 233 int current_frame_number_; |
| 225 int last_frame_number_where_begin_frame_sent_to_main_thread_; | 234 int last_frame_number_where_begin_frame_sent_to_main_thread_; |
| 226 int last_frame_number_swap_performed_; | 235 int last_frame_number_swap_performed_; |
| 227 int last_frame_number_where_update_visible_tiles_was_called_; | 236 int last_frame_number_where_update_visible_tiles_was_called_; |
| 237 int last_frame_number_where_manage_tiles_was_called_; |
| 228 int consecutive_failed_draws_; | 238 int consecutive_failed_draws_; |
| 229 bool needs_redraw_; | 239 bool needs_redraw_; |
| 240 bool needs_manage_tiles_; |
| 230 bool swap_used_incomplete_tile_; | 241 bool swap_used_incomplete_tile_; |
| 231 bool needs_commit_; | 242 bool needs_commit_; |
| 232 bool main_thread_needs_layer_textures_; | 243 bool main_thread_needs_layer_textures_; |
| 233 bool inside_begin_frame_; | 244 bool inside_begin_frame_; |
| 234 BeginFrameArgs last_begin_frame_args_; | 245 BeginFrameArgs last_begin_frame_args_; |
| 235 bool visible_; | 246 bool visible_; |
| 236 bool can_start_; | 247 bool can_start_; |
| 237 bool can_draw_; | 248 bool can_draw_; |
| 238 bool has_pending_tree_; | 249 bool has_pending_tree_; |
| 239 bool pending_tree_is_ready_for_activation_; | 250 bool pending_tree_is_ready_for_activation_; |
| 240 bool active_tree_needs_first_draw_; | 251 bool active_tree_needs_first_draw_; |
| 241 bool draw_if_possible_failed_; | 252 bool draw_if_possible_failed_; |
| 242 bool did_create_and_initialize_first_output_surface_; | 253 bool did_create_and_initialize_first_output_surface_; |
| 243 | 254 |
| 244 private: | 255 private: |
| 245 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 256 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 246 }; | 257 }; |
| 247 | 258 |
| 248 } // namespace cc | 259 } // namespace cc |
| 249 | 260 |
| 250 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 261 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |