| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool RedrawPending() const { return needs_redraw_; } | 110 bool RedrawPending() const { return needs_redraw_; } |
| 111 bool PrepareTilesPending() const { return needs_prepare_tiles_; } | 111 bool PrepareTilesPending() const { return needs_prepare_tiles_; } |
| 112 | 112 |
| 113 enum Action { | 113 enum Action { |
| 114 ACTION_NONE, | 114 ACTION_NONE, |
| 115 ACTION_SEND_BEGIN_MAIN_FRAME, | 115 ACTION_SEND_BEGIN_MAIN_FRAME, |
| 116 ACTION_COMMIT, | 116 ACTION_COMMIT, |
| 117 ACTION_ACTIVATE_SYNC_TREE, | 117 ACTION_ACTIVATE_SYNC_TREE, |
| 118 ACTION_PERFORM_IMPL_SIDE_INVALIDATION, |
| 118 ACTION_DRAW_IF_POSSIBLE, | 119 ACTION_DRAW_IF_POSSIBLE, |
| 119 ACTION_DRAW_FORCED, | 120 ACTION_DRAW_FORCED, |
| 120 ACTION_DRAW_ABORT, | 121 ACTION_DRAW_ABORT, |
| 121 ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION, | 122 ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION, |
| 122 ACTION_PREPARE_TILES, | 123 ACTION_PREPARE_TILES, |
| 123 ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK, | 124 ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK, |
| 124 }; | 125 }; |
| 125 static const char* ActionToString(Action action); | 126 static const char* ActionToString(Action action); |
| 126 | 127 |
| 127 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | 128 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; |
| 128 void AsValueInto(base::trace_event::TracedValue* dict) const; | 129 void AsValueInto(base::trace_event::TracedValue* dict) const; |
| 129 | 130 |
| 130 Action NextAction() const; | 131 Action NextAction() const; |
| 131 void WillSendBeginMainFrame(); | 132 void WillSendBeginMainFrame(); |
| 132 void WillCommit(bool commit_had_no_updates); | 133 void WillCommit(bool commit_had_no_updates); |
| 133 void WillActivate(); | 134 void WillActivate(); |
| 134 void WillDraw(); | 135 void WillDraw(); |
| 135 void WillBeginCompositorFrameSinkCreation(); | 136 void WillBeginCompositorFrameSinkCreation(); |
| 136 void WillPrepareTiles(); | 137 void WillPrepareTiles(); |
| 137 void WillInvalidateCompositorFrameSink(); | 138 void WillInvalidateCompositorFrameSink(); |
| 139 void WillPerformImplSideInvalidation(); |
| 138 | 140 |
| 139 void DidDraw(DrawResult draw_result); | 141 void DidDraw(DrawResult draw_result); |
| 140 | 142 |
| 141 void AbortDraw(); | 143 void AbortDraw(); |
| 142 | 144 |
| 143 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 145 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
| 144 // to make progress. | 146 // to make progress. |
| 145 bool BeginFrameNeeded() const; | 147 bool BeginFrameNeeded() const; |
| 146 | 148 |
| 147 // Indicates that the system has entered and left a BeginImplFrame callback. | 149 // Indicates that the system has entered and left a BeginImplFrame callback. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 244 |
| 243 // Indicates that scheduled BeginMainFrame is started. | 245 // Indicates that scheduled BeginMainFrame is started. |
| 244 void NotifyBeginMainFrameStarted(); | 246 void NotifyBeginMainFrameStarted(); |
| 245 | 247 |
| 246 // Indicates that the pending tree is ready for activation. | 248 // Indicates that the pending tree is ready for activation. |
| 247 void NotifyReadyToActivate(); | 249 void NotifyReadyToActivate(); |
| 248 | 250 |
| 249 // Indicates the active tree's visible tiles are ready to be drawn. | 251 // Indicates the active tree's visible tiles are ready to be drawn. |
| 250 void NotifyReadyToDraw(); | 252 void NotifyReadyToDraw(); |
| 251 | 253 |
| 254 void SetNeedsImplSideInvalidation(); |
| 255 |
| 252 bool has_pending_tree() const { return has_pending_tree_; } | 256 bool has_pending_tree() const { return has_pending_tree_; } |
| 253 bool active_tree_needs_first_draw() const { | 257 bool active_tree_needs_first_draw() const { |
| 254 return active_tree_needs_first_draw_; | 258 return active_tree_needs_first_draw_; |
| 255 } | 259 } |
| 256 | 260 |
| 257 void DidPrepareTiles(); | 261 void DidPrepareTiles(); |
| 258 void DidLoseCompositorFrameSink(); | 262 void DidLoseCompositorFrameSink(); |
| 259 void DidCreateAndInitializeCompositorFrameSink(); | 263 void DidCreateAndInitializeCompositorFrameSink(); |
| 260 bool HasInitializedCompositorFrameSink() const; | 264 bool HasInitializedCompositorFrameSink() const; |
| 261 | 265 |
| 262 // True if we need to abort draws to make forward progress. | 266 // True if we need to abort draws to make forward progress. |
| 263 bool PendingDrawsShouldBeAborted() const; | 267 bool PendingDrawsShouldBeAborted() const; |
| 264 | 268 |
| 265 bool CouldSendBeginMainFrame() const; | 269 bool CouldSendBeginMainFrame() const; |
| 266 | 270 |
| 267 void SetDeferCommits(bool defer_commits); | 271 void SetDeferCommits(bool defer_commits); |
| 268 | 272 |
| 269 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); | 273 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); |
| 270 bool video_needs_begin_frames() const { return video_needs_begin_frames_; } | 274 bool video_needs_begin_frames() const { return video_needs_begin_frames_; } |
| 271 | 275 |
| 272 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; } | 276 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; } |
| 273 | 277 |
| 278 bool needs_impl_side_invalidation() const { |
| 279 return needs_impl_side_invalidation_; |
| 280 } |
| 281 bool previous_pending_tree_was_impl_side() const { |
| 282 return previous_pending_tree_was_impl_side_; |
| 283 } |
| 284 |
| 274 protected: | 285 protected: |
| 275 bool BeginFrameRequiredForAction() const; | 286 bool BeginFrameRequiredForAction() const; |
| 276 bool BeginFrameNeededForVideo() const; | 287 bool BeginFrameNeededForVideo() const; |
| 277 bool ProactiveBeginFrameWanted() const; | 288 bool ProactiveBeginFrameWanted() const; |
| 278 | 289 |
| 290 bool ShouldPerformImplSideInvalidation() const; |
| 291 bool CouldCreatePendingTree() const; |
| 292 |
| 279 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; | 293 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; |
| 280 | 294 |
| 281 // True if we need to force activations to make forward progress. | 295 // True if we need to force activations to make forward progress. |
| 282 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. | 296 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. |
| 283 bool PendingActivationsShouldBeForced() const; | 297 bool PendingActivationsShouldBeForced() const; |
| 284 | 298 |
| 285 bool ShouldBeginCompositorFrameSinkCreation() const; | 299 bool ShouldBeginCompositorFrameSinkCreation() const; |
| 286 bool ShouldDraw() const; | 300 bool ShouldDraw() const; |
| 287 bool ShouldActivatePendingTree() const; | 301 bool ShouldActivatePendingTree() const; |
| 288 bool ShouldSendBeginMainFrame() const; | 302 bool ShouldSendBeginMainFrame() const; |
| 289 bool ShouldCommit() const; | 303 bool ShouldCommit() const; |
| 290 bool ShouldPrepareTiles() const; | 304 bool ShouldPrepareTiles() const; |
| 291 bool ShouldInvalidateCompositorFrameSink() const; | 305 bool ShouldInvalidateCompositorFrameSink() const; |
| 292 | 306 |
| 293 void WillDrawInternal(); | 307 void WillDrawInternal(); |
| 308 void WillPerformImplSideInvalidationInternal(); |
| 294 void DidDrawInternal(DrawResult draw_result); | 309 void DidDrawInternal(DrawResult draw_result); |
| 295 | 310 |
| 296 const SchedulerSettings settings_; | 311 const SchedulerSettings settings_; |
| 297 | 312 |
| 298 CompositorFrameSinkState compositor_frame_sink_state_; | 313 CompositorFrameSinkState compositor_frame_sink_state_; |
| 299 BeginImplFrameState begin_impl_frame_state_; | 314 BeginImplFrameState begin_impl_frame_state_; |
| 300 BeginMainFrameState begin_main_frame_state_; | 315 BeginMainFrameState begin_main_frame_state_; |
| 301 ForcedRedrawOnTimeoutState forced_redraw_state_; | 316 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 302 | 317 |
| 303 // These are used for tracing only. | 318 // These are used for tracing only. |
| 304 int commit_count_; | 319 int commit_count_; |
| 305 int current_frame_number_; | 320 int current_frame_number_; |
| 306 int last_frame_number_submit_performed_; | 321 int last_frame_number_submit_performed_; |
| 307 int last_frame_number_draw_performed_; | 322 int last_frame_number_draw_performed_; |
| 308 int last_frame_number_begin_main_frame_sent_; | 323 int last_frame_number_begin_main_frame_sent_; |
| 309 int last_frame_number_invalidate_compositor_frame_sink_performed_; | 324 int last_frame_number_invalidate_compositor_frame_sink_performed_; |
| 310 | 325 |
| 311 // These are used to ensure that an action only happens once per frame, | 326 // These are used to ensure that an action only happens once per frame, |
| 312 // deadline, etc. | 327 // deadline, etc. |
| 313 bool draw_funnel_; | 328 bool draw_funnel_; |
| 314 bool send_begin_main_frame_funnel_; | 329 bool send_begin_main_frame_funnel_; |
| 315 bool invalidate_compositor_frame_sink_funnel_; | 330 bool invalidate_compositor_frame_sink_funnel_; |
| 331 bool impl_side_invalidation_funnel_; |
| 316 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called | 332 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
| 317 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 333 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
| 318 // we start throttling ACTION_PREPARE_TILES such that we average one | 334 // we start throttling ACTION_PREPARE_TILES such that we average one |
| 319 // PrepareTiles per BeginImplFrame. | 335 // PrepareTiles per BeginImplFrame. |
| 320 int prepare_tiles_funnel_; | 336 int prepare_tiles_funnel_; |
| 321 | 337 |
| 322 int consecutive_checkerboard_animations_; | 338 int consecutive_checkerboard_animations_; |
| 323 int pending_submit_frames_; | 339 int pending_submit_frames_; |
| 324 int submit_frames_with_current_compositor_frame_sink_; | 340 int submit_frames_with_current_compositor_frame_sink_; |
| 325 bool needs_redraw_; | 341 bool needs_redraw_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 338 ScrollHandlerState scroll_handler_state_; | 354 ScrollHandlerState scroll_handler_state_; |
| 339 bool critical_begin_main_frame_to_activate_is_fast_; | 355 bool critical_begin_main_frame_to_activate_is_fast_; |
| 340 bool main_thread_missed_last_deadline_; | 356 bool main_thread_missed_last_deadline_; |
| 341 bool skip_next_begin_main_frame_to_reduce_latency_; | 357 bool skip_next_begin_main_frame_to_reduce_latency_; |
| 342 bool defer_commits_; | 358 bool defer_commits_; |
| 343 bool video_needs_begin_frames_; | 359 bool video_needs_begin_frames_; |
| 344 bool last_commit_had_no_updates_; | 360 bool last_commit_had_no_updates_; |
| 345 bool wait_for_ready_to_draw_; | 361 bool wait_for_ready_to_draw_; |
| 346 bool did_draw_in_last_frame_; | 362 bool did_draw_in_last_frame_; |
| 347 bool did_submit_in_last_frame_; | 363 bool did_submit_in_last_frame_; |
| 364 bool needs_impl_side_invalidation_; |
| 365 |
| 366 bool previous_pending_tree_was_impl_side_; |
| 367 bool current_pending_tree_is_impl_side_; |
| 348 | 368 |
| 349 private: | 369 private: |
| 350 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 370 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 351 }; | 371 }; |
| 352 | 372 |
| 353 } // namespace cc | 373 } // namespace cc |
| 354 | 374 |
| 355 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 375 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |