| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 enum CommitState { | 61 enum CommitState { |
| 62 COMMIT_STATE_IDLE, | 62 COMMIT_STATE_IDLE, |
| 63 COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, | 63 COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, |
| 64 COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED, | 64 COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED, |
| 65 COMMIT_STATE_READY_TO_COMMIT, | 65 COMMIT_STATE_READY_TO_COMMIT, |
| 66 COMMIT_STATE_WAITING_FOR_ACTIVATION, | 66 COMMIT_STATE_WAITING_FOR_ACTIVATION, |
| 67 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 67 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
| 68 }; | 68 }; |
| 69 static const char* CommitStateToString(CommitState state); | 69 static const char* CommitStateToString(CommitState state); |
| 70 | 70 |
| 71 enum SynchronousReadbackState { | |
| 72 READBACK_STATE_IDLE, | |
| 73 READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME, | |
| 74 READBACK_STATE_WAITING_FOR_COMMIT, | |
| 75 READBACK_STATE_WAITING_FOR_ACTIVATION, | |
| 76 READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK, | |
| 77 READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, | |
| 78 READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION, | |
| 79 }; | |
| 80 static const char* SynchronousReadbackStateToString( | |
| 81 SynchronousReadbackState state); | |
| 82 | |
| 83 enum ForcedRedrawOnTimeoutState { | 71 enum ForcedRedrawOnTimeoutState { |
| 84 FORCED_REDRAW_STATE_IDLE, | 72 FORCED_REDRAW_STATE_IDLE, |
| 85 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, | 73 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, |
| 86 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, | 74 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, |
| 87 FORCED_REDRAW_STATE_WAITING_FOR_DRAW, | 75 FORCED_REDRAW_STATE_WAITING_FOR_DRAW, |
| 88 }; | 76 }; |
| 89 static const char* ForcedRedrawOnTimeoutStateToString( | 77 static const char* ForcedRedrawOnTimeoutStateToString( |
| 90 ForcedRedrawOnTimeoutState state); | 78 ForcedRedrawOnTimeoutState state); |
| 91 | 79 |
| 92 bool CommitPending() const { | 80 bool CommitPending() const { |
| 93 return commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 81 return commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 94 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED || | 82 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED || |
| 95 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 83 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
| 96 } | 84 } |
| 97 CommitState commit_state() const { return commit_state_; } | 85 CommitState commit_state() const { return commit_state_; } |
| 98 | 86 |
| 99 bool RedrawPending() const { return needs_redraw_; } | 87 bool RedrawPending() const { return needs_redraw_; } |
| 100 bool ManageTilesPending() const { return needs_manage_tiles_; } | 88 bool ManageTilesPending() const { return needs_manage_tiles_; } |
| 101 | 89 |
| 102 enum Action { | 90 enum Action { |
| 103 ACTION_NONE, | 91 ACTION_NONE, |
| 104 ACTION_ANIMATE, | 92 ACTION_ANIMATE, |
| 105 ACTION_SEND_BEGIN_MAIN_FRAME, | 93 ACTION_SEND_BEGIN_MAIN_FRAME, |
| 106 ACTION_COMMIT, | 94 ACTION_COMMIT, |
| 107 ACTION_UPDATE_VISIBLE_TILES, | 95 ACTION_UPDATE_VISIBLE_TILES, |
| 108 ACTION_ACTIVATE_PENDING_TREE, | 96 ACTION_ACTIVATE_PENDING_TREE, |
| 109 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 97 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
| 110 ACTION_DRAW_AND_SWAP_FORCED, | 98 ACTION_DRAW_AND_SWAP_FORCED, |
| 111 ACTION_DRAW_AND_SWAP_ABORT, | 99 ACTION_DRAW_AND_SWAP_ABORT, |
| 112 ACTION_DRAW_AND_READBACK, | |
| 113 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 100 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 114 ACTION_MANAGE_TILES, | 101 ACTION_MANAGE_TILES, |
| 115 }; | 102 }; |
| 116 static const char* ActionToString(Action action); | 103 static const char* ActionToString(Action action); |
| 117 | 104 |
| 118 scoped_ptr<base::Value> AsValue() const; | 105 scoped_ptr<base::Value> AsValue() const; |
| 119 | 106 |
| 120 Action NextAction() const; | 107 Action NextAction() const; |
| 121 void UpdateState(Action action); | 108 void UpdateState(Action action); |
| 122 | 109 |
| 123 void CheckInvariants(); | |
| 124 | |
| 125 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 110 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
| 126 // to make progress. | 111 // to make progress. |
| 127 bool BeginFrameNeeded() const; | 112 bool BeginFrameNeeded() const; |
| 128 | 113 |
| 129 // Indicates that we need to independently poll for new state and actions | 114 // Indicates that we need to independently poll for new state and actions |
| 130 // because we can't expect a BeginImplFrame. This is mostly used to avoid | 115 // because we can't expect a BeginImplFrame. This is mostly used to avoid |
| 131 // drawing repeat frames with the synchronous compositor without dropping | 116 // drawing repeat frames with the synchronous compositor without dropping |
| 132 // necessary actions on the floor. | 117 // necessary actions on the floor. |
| 133 bool ShouldPollForAnticipatedDrawTriggers() const; | 118 bool ShouldPollForAnticipatedDrawTriggers() const; |
| 134 | 119 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 bool smoothness_takes_priority() const { return smoothness_takes_priority_; } | 178 bool smoothness_takes_priority() const { return smoothness_takes_priority_; } |
| 194 | 179 |
| 195 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen. | 180 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen. |
| 196 void DidDrawIfPossibleCompleted(DrawResult result); | 181 void DidDrawIfPossibleCompleted(DrawResult result); |
| 197 | 182 |
| 198 // Indicates that a new commit flow needs to be performed, either to pull | 183 // Indicates that a new commit flow needs to be performed, either to pull |
| 199 // updates from the main thread to the impl, or to push deltas from the impl | 184 // updates from the main thread to the impl, or to push deltas from the impl |
| 200 // thread to main. | 185 // thread to main. |
| 201 void SetNeedsCommit(); | 186 void SetNeedsCommit(); |
| 202 | 187 |
| 203 // As SetNeedsCommit(), but ensures the BeginMainFrame will be sent even | |
| 204 // if we are not visible. After this call we expect to go through | |
| 205 // the forced commit flow and then return to waiting for a non-forced | |
| 206 // BeginMainFrame to finish. | |
| 207 void SetNeedsForcedCommitForReadback(); | |
| 208 | |
| 209 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME | 188 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME |
| 210 // from NextAction. | 189 // from NextAction. |
| 211 // Indicates that all painting is complete. | 190 // Indicates that all painting is complete. |
| 212 void NotifyReadyToCommit(); | 191 void NotifyReadyToCommit(); |
| 213 | 192 |
| 214 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME | 193 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME |
| 215 // from NextAction if the client rejects the BeginMainFrame message. | 194 // from NextAction if the client rejects the BeginMainFrame message. |
| 216 // If did_handle is false, then another commit will be retried soon. | 195 // If did_handle is false, then another commit will be retried soon. |
| 217 void BeginMainFrameAborted(bool did_handle); | 196 void BeginMainFrameAborted(bool did_handle); |
| 218 | 197 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void UpdateStateOnActivation(); | 257 void UpdateStateOnActivation(); |
| 279 void UpdateStateOnDraw(bool did_request_swap); | 258 void UpdateStateOnDraw(bool did_request_swap); |
| 280 void UpdateStateOnManageTiles(); | 259 void UpdateStateOnManageTiles(); |
| 281 | 260 |
| 282 const SchedulerSettings settings_; | 261 const SchedulerSettings settings_; |
| 283 | 262 |
| 284 OutputSurfaceState output_surface_state_; | 263 OutputSurfaceState output_surface_state_; |
| 285 BeginImplFrameState begin_impl_frame_state_; | 264 BeginImplFrameState begin_impl_frame_state_; |
| 286 CommitState commit_state_; | 265 CommitState commit_state_; |
| 287 ForcedRedrawOnTimeoutState forced_redraw_state_; | 266 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 288 SynchronousReadbackState readback_state_; | |
| 289 | 267 |
| 290 BeginFrameArgs begin_impl_frame_args_; | 268 BeginFrameArgs begin_impl_frame_args_; |
| 291 | 269 |
| 292 int commit_count_; | 270 int commit_count_; |
| 293 int current_frame_number_; | 271 int current_frame_number_; |
| 294 int last_frame_number_animate_performed_; | 272 int last_frame_number_animate_performed_; |
| 295 int last_frame_number_swap_performed_; | 273 int last_frame_number_swap_performed_; |
| 296 int last_frame_number_swap_requested_; | 274 int last_frame_number_swap_requested_; |
| 297 int last_frame_number_begin_main_frame_sent_; | 275 int last_frame_number_begin_main_frame_sent_; |
| 298 int last_frame_number_update_visible_tiles_was_called_; | 276 int last_frame_number_update_visible_tiles_was_called_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 315 bool can_start_; | 293 bool can_start_; |
| 316 bool can_draw_; | 294 bool can_draw_; |
| 317 bool has_pending_tree_; | 295 bool has_pending_tree_; |
| 318 bool pending_tree_is_ready_for_activation_; | 296 bool pending_tree_is_ready_for_activation_; |
| 319 bool active_tree_needs_first_draw_; | 297 bool active_tree_needs_first_draw_; |
| 320 bool did_create_and_initialize_first_output_surface_; | 298 bool did_create_and_initialize_first_output_surface_; |
| 321 bool smoothness_takes_priority_; | 299 bool smoothness_takes_priority_; |
| 322 bool skip_next_begin_main_frame_to_reduce_latency_; | 300 bool skip_next_begin_main_frame_to_reduce_latency_; |
| 323 bool skip_begin_main_frame_to_reduce_latency_; | 301 bool skip_begin_main_frame_to_reduce_latency_; |
| 324 bool continuous_painting_; | 302 bool continuous_painting_; |
| 325 bool needs_back_to_back_readback_; | |
| 326 | 303 |
| 327 private: | 304 private: |
| 328 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 305 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 329 }; | 306 }; |
| 330 | 307 |
| 331 } // namespace cc | 308 } // namespace cc |
| 332 | 309 |
| 333 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 310 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |