| 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 TextureState { | |
| 72 LAYER_TEXTURE_STATE_UNLOCKED, | |
| 73 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD, | |
| 74 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, | |
| 75 }; | |
| 76 static const char* TextureStateToString(TextureState state); | |
| 77 | |
| 78 enum SynchronousReadbackState { | 71 enum SynchronousReadbackState { |
| 79 READBACK_STATE_IDLE, | 72 READBACK_STATE_IDLE, |
| 80 READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME, | 73 READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME, |
| 81 READBACK_STATE_WAITING_FOR_COMMIT, | 74 READBACK_STATE_WAITING_FOR_COMMIT, |
| 82 READBACK_STATE_WAITING_FOR_ACTIVATION, | 75 READBACK_STATE_WAITING_FOR_ACTIVATION, |
| 83 READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK, | 76 READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK, |
| 84 READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, | 77 READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, |
| 85 READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION, | 78 READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION, |
| 86 }; | 79 }; |
| 87 static const char* SynchronousReadbackStateToString( | 80 static const char* SynchronousReadbackStateToString( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 110 ACTION_NONE, | 103 ACTION_NONE, |
| 111 ACTION_SEND_BEGIN_MAIN_FRAME, | 104 ACTION_SEND_BEGIN_MAIN_FRAME, |
| 112 ACTION_COMMIT, | 105 ACTION_COMMIT, |
| 113 ACTION_UPDATE_VISIBLE_TILES, | 106 ACTION_UPDATE_VISIBLE_TILES, |
| 114 ACTION_ACTIVATE_PENDING_TREE, | 107 ACTION_ACTIVATE_PENDING_TREE, |
| 115 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 108 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
| 116 ACTION_DRAW_AND_SWAP_FORCED, | 109 ACTION_DRAW_AND_SWAP_FORCED, |
| 117 ACTION_DRAW_AND_SWAP_ABORT, | 110 ACTION_DRAW_AND_SWAP_ABORT, |
| 118 ACTION_DRAW_AND_READBACK, | 111 ACTION_DRAW_AND_READBACK, |
| 119 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 112 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 120 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | |
| 121 ACTION_MANAGE_TILES, | 113 ACTION_MANAGE_TILES, |
| 122 }; | 114 }; |
| 123 static const char* ActionToString(Action action); | 115 static const char* ActionToString(Action action); |
| 124 | 116 |
| 125 scoped_ptr<base::Value> AsValue() const; | 117 scoped_ptr<base::Value> AsValue() const; |
| 126 | 118 |
| 127 Action NextAction() const; | 119 Action NextAction() const; |
| 128 void UpdateState(Action action); | 120 void UpdateState(Action action); |
| 129 | 121 |
| 130 void CheckInvariants(); | 122 void CheckInvariants(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME | 194 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME |
| 203 // from NextAction. | 195 // from NextAction. |
| 204 // Indicates that all painting is complete. | 196 // Indicates that all painting is complete. |
| 205 void NotifyReadyToCommit(); | 197 void NotifyReadyToCommit(); |
| 206 | 198 |
| 207 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME | 199 // Call this only in response to receiving an ACTION_SEND_BEGIN_MAIN_FRAME |
| 208 // from NextAction if the client rejects the BeginMainFrame message. | 200 // from NextAction if the client rejects the BeginMainFrame message. |
| 209 // If did_handle is false, then another commit will be retried soon. | 201 // If did_handle is false, then another commit will be retried soon. |
| 210 void BeginMainFrameAborted(bool did_handle); | 202 void BeginMainFrameAborted(bool did_handle); |
| 211 | 203 |
| 212 // Request exclusive access to the textures that back single buffered | |
| 213 // layers on behalf of the main thread. Upon acquisition, | |
| 214 // ACTION_DRAW_AND_SWAP_IF_POSSIBLE will not draw until the main thread | |
| 215 // releases the | |
| 216 // textures to the impl thread by committing the layers. | |
| 217 void SetMainThreadNeedsLayerTextures(); | |
| 218 | |
| 219 // Set that we can create the first OutputSurface and start the scheduler. | 204 // Set that we can create the first OutputSurface and start the scheduler. |
| 220 void SetCanStart() { can_start_ = true; } | 205 void SetCanStart() { can_start_ = true; } |
| 221 | 206 |
| 222 void SetSkipNextBeginMainFrameToReduceLatency(); | 207 void SetSkipNextBeginMainFrameToReduceLatency(); |
| 223 | 208 |
| 224 // Indicates whether drawing would, at this time, make sense. | 209 // Indicates whether drawing would, at this time, make sense. |
| 225 // CanDraw can be used to suppress flashes or checkerboarding | 210 // CanDraw can be used to suppress flashes or checkerboarding |
| 226 // when such behavior would be undesirable. | 211 // when such behavior would be undesirable. |
| 227 void SetCanDraw(bool can); | 212 void SetCanDraw(bool can); |
| 228 | 213 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 255 bool BeginImplFrameNeededToDraw() const; | 240 bool BeginImplFrameNeededToDraw() const; |
| 256 bool ProactiveBeginImplFrameWanted() const; | 241 bool ProactiveBeginImplFrameWanted() const; |
| 257 | 242 |
| 258 // True if we need to force activations to make forward progress. | 243 // True if we need to force activations to make forward progress. |
| 259 bool PendingActivationsShouldBeForced() const; | 244 bool PendingActivationsShouldBeForced() const; |
| 260 | 245 |
| 261 bool ShouldBeginOutputSurfaceCreation() const; | 246 bool ShouldBeginOutputSurfaceCreation() const; |
| 262 bool ShouldDrawForced() const; | 247 bool ShouldDrawForced() const; |
| 263 bool ShouldDraw() const; | 248 bool ShouldDraw() const; |
| 264 bool ShouldActivatePendingTree() const; | 249 bool ShouldActivatePendingTree() const; |
| 265 bool ShouldAcquireLayerTexturesForMainThread() const; | |
| 266 bool ShouldUpdateVisibleTiles() const; | 250 bool ShouldUpdateVisibleTiles() const; |
| 267 bool ShouldSendBeginMainFrame() const; | 251 bool ShouldSendBeginMainFrame() const; |
| 268 bool ShouldCommit() const; | 252 bool ShouldCommit() const; |
| 269 bool ShouldManageTiles() const; | 253 bool ShouldManageTiles() const; |
| 270 | 254 |
| 271 void AdvanceCurrentFrameNumber(); | 255 void AdvanceCurrentFrameNumber(); |
| 272 bool HasSentBeginMainFrameThisFrame() const; | 256 bool HasSentBeginMainFrameThisFrame() const; |
| 273 bool HasScheduledManageTilesThisFrame() const; | 257 bool HasScheduledManageTilesThisFrame() const; |
| 274 bool HasUpdatedVisibleTilesThisFrame() const; | 258 bool HasUpdatedVisibleTilesThisFrame() const; |
| 275 bool HasSwappedThisFrame() const; | 259 bool HasSwappedThisFrame() const; |
| 276 | 260 |
| 277 void UpdateStateOnCommit(bool commit_was_aborted); | 261 void UpdateStateOnCommit(bool commit_was_aborted); |
| 278 void UpdateStateOnActivation(); | 262 void UpdateStateOnActivation(); |
| 279 void UpdateStateOnDraw(bool did_swap); | 263 void UpdateStateOnDraw(bool did_swap); |
| 280 void UpdateStateOnManageTiles(); | 264 void UpdateStateOnManageTiles(); |
| 281 | 265 |
| 282 const SchedulerSettings settings_; | 266 const SchedulerSettings settings_; |
| 283 | 267 |
| 284 OutputSurfaceState output_surface_state_; | 268 OutputSurfaceState output_surface_state_; |
| 285 BeginImplFrameState begin_impl_frame_state_; | 269 BeginImplFrameState begin_impl_frame_state_; |
| 286 CommitState commit_state_; | 270 CommitState commit_state_; |
| 287 TextureState texture_state_; | |
| 288 ForcedRedrawOnTimeoutState forced_redraw_state_; | 271 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 289 SynchronousReadbackState readback_state_; | 272 SynchronousReadbackState readback_state_; |
| 290 | 273 |
| 291 BeginFrameArgs last_begin_impl_frame_args_; | 274 BeginFrameArgs last_begin_impl_frame_args_; |
| 292 | 275 |
| 293 int commit_count_; | 276 int commit_count_; |
| 294 int current_frame_number_; | 277 int current_frame_number_; |
| 295 int last_frame_number_swap_performed_; | 278 int last_frame_number_swap_performed_; |
| 296 int last_frame_number_begin_main_frame_sent_; | 279 int last_frame_number_begin_main_frame_sent_; |
| 297 int last_frame_number_update_visible_tiles_was_called_; | 280 int last_frame_number_update_visible_tiles_was_called_; |
| 298 | 281 |
| 299 // manage_tiles_funnel_ is "filled" each time ManageTiles is called | 282 // manage_tiles_funnel_ is "filled" each time ManageTiles is called |
| 300 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 283 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
| 301 // we start throttling ACTION_MANAGE_TILES such that we average one | 284 // we start throttling ACTION_MANAGE_TILES such that we average one |
| 302 // ManageTile per BeginImplFrame. | 285 // ManageTile per BeginImplFrame. |
| 303 int manage_tiles_funnel_; | 286 int manage_tiles_funnel_; |
| 304 int consecutive_checkerboard_animations_; | 287 int consecutive_checkerboard_animations_; |
| 305 bool needs_redraw_; | 288 bool needs_redraw_; |
| 306 bool needs_manage_tiles_; | 289 bool needs_manage_tiles_; |
| 307 bool swap_used_incomplete_tile_; | 290 bool swap_used_incomplete_tile_; |
| 308 bool needs_commit_; | 291 bool needs_commit_; |
| 309 bool main_thread_needs_layer_textures_; | |
| 310 bool inside_poll_for_anticipated_draw_triggers_; | 292 bool inside_poll_for_anticipated_draw_triggers_; |
| 311 bool visible_; | 293 bool visible_; |
| 312 bool can_start_; | 294 bool can_start_; |
| 313 bool can_draw_; | 295 bool can_draw_; |
| 314 bool has_pending_tree_; | 296 bool has_pending_tree_; |
| 315 bool pending_tree_is_ready_for_activation_; | 297 bool pending_tree_is_ready_for_activation_; |
| 316 bool active_tree_needs_first_draw_; | 298 bool active_tree_needs_first_draw_; |
| 317 bool draw_if_possible_failed_; | 299 bool draw_if_possible_failed_; |
| 318 bool did_create_and_initialize_first_output_surface_; | 300 bool did_create_and_initialize_first_output_surface_; |
| 319 bool smoothness_takes_priority_; | 301 bool smoothness_takes_priority_; |
| 320 bool skip_next_begin_main_frame_to_reduce_latency_; | 302 bool skip_next_begin_main_frame_to_reduce_latency_; |
| 321 bool skip_begin_main_frame_to_reduce_latency_; | 303 bool skip_begin_main_frame_to_reduce_latency_; |
| 322 bool continuous_painting_; | 304 bool continuous_painting_; |
| 323 bool needs_back_to_back_readback_; | 305 bool needs_back_to_back_readback_; |
| 324 | 306 |
| 325 private: | 307 private: |
| 326 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 308 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 327 }; | 309 }; |
| 328 | 310 |
| 329 } // namespace cc | 311 } // namespace cc |
| 330 | 312 |
| 331 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 313 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |