| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time/time.h" | |
| 13 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 14 #include "cc/output/begin_frame_args.h" | 13 #include "cc/output/begin_frame_args.h" |
| 15 #include "cc/scheduler/commit_earlyout_reason.h" | 14 #include "cc/scheduler/commit_earlyout_reason.h" |
| 16 #include "cc/scheduler/draw_result.h" | 15 #include "cc/scheduler/draw_result.h" |
| 17 #include "cc/scheduler/scheduler_settings.h" | 16 #include "cc/scheduler/scheduler_settings.h" |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 namespace trace_event { | 19 namespace trace_event { |
| 21 class ConvertableToTraceFormat; | 20 class ConvertableToTraceFormat; |
| 22 class TracedValue; | 21 class TracedValue; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 ACTION_ACTIVATE_SYNC_TREE, | 107 ACTION_ACTIVATE_SYNC_TREE, |
| 109 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 108 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
| 110 ACTION_DRAW_AND_SWAP_FORCED, | 109 ACTION_DRAW_AND_SWAP_FORCED, |
| 111 ACTION_DRAW_AND_SWAP_ABORT, | 110 ACTION_DRAW_AND_SWAP_ABORT, |
| 112 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 111 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 113 ACTION_PREPARE_TILES, | 112 ACTION_PREPARE_TILES, |
| 114 }; | 113 }; |
| 115 static const char* ActionToString(Action action); | 114 static const char* ActionToString(Action action); |
| 116 | 115 |
| 117 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | 116 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; |
| 118 void AsValueInto(base::trace_event::TracedValue* dict, | 117 void AsValueInto(base::trace_event::TracedValue* dict) const; |
| 119 base::TimeTicks now) const; | |
| 120 | 118 |
| 121 Action NextAction() const; | 119 Action NextAction() const; |
| 122 void UpdateState(Action action); | 120 void UpdateState(Action action); |
| 123 | 121 |
| 124 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 122 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
| 125 // to make progress. | 123 // to make progress. |
| 126 bool BeginFrameNeeded() const; | 124 bool BeginFrameNeeded() const; |
| 127 | 125 |
| 128 // Indicates whether the scheduler should call | |
| 129 // SetNeedsBeginFrames(BeginFrameNeeded()) on the frame source. | |
| 130 bool ShouldSetNeedsBeginFrames(bool frame_source_needs_begin_frames) const; | |
| 131 | |
| 132 // Indicates that we need to independently poll for new state and actions | 126 // Indicates that we need to independently poll for new state and actions |
| 133 // because we can't expect a BeginImplFrame. This is mostly used to avoid | 127 // because we can't expect a BeginImplFrame. This is mostly used to avoid |
| 134 // drawing repeat frames with the synchronous compositor without dropping | 128 // drawing repeat frames with the synchronous compositor without dropping |
| 135 // necessary actions on the floor. | 129 // necessary actions on the floor. |
| 136 bool ShouldPollForAnticipatedDrawTriggers() const; | 130 bool ShouldPollForAnticipatedDrawTriggers() const; |
| 137 | 131 |
| 138 // Indicates that the system has entered and left a BeginImplFrame callback. | 132 // Indicates that the system has entered and left a BeginImplFrame callback. |
| 139 // The scheduler will not draw more than once in a given BeginImplFrame | 133 // The scheduler will not draw more than once in a given BeginImplFrame |
| 140 // callback nor send more than one BeginMainFrame message. | 134 // callback nor send more than one BeginMainFrame message. |
| 141 void OnBeginImplFrame(const BeginFrameArgs& args); | 135 void OnBeginImplFrame(); |
| 142 void OnBeginImplFrameDeadlinePending(); | 136 void OnBeginImplFrameDeadlinePending(); |
| 143 void OnBeginImplFrameDeadline(); | 137 void OnBeginImplFrameDeadline(); |
| 144 void OnBeginImplFrameIdle(); | 138 void OnBeginImplFrameIdle(); |
| 145 BeginImplFrameState begin_impl_frame_state() const { | 139 BeginImplFrameState begin_impl_frame_state() const { |
| 146 return begin_impl_frame_state_; | 140 return begin_impl_frame_state_; |
| 147 } | 141 } |
| 148 BeginImplFrameDeadlineMode CurrentBeginImplFrameDeadlineMode() const; | 142 BeginImplFrameDeadlineMode CurrentBeginImplFrameDeadlineMode() const; |
| 149 | 143 |
| 150 // If the main thread didn't manage to produce a new frame in time for the | 144 // If the main thread didn't manage to produce a new frame in time for the |
| 151 // impl thread to draw, it is in a high latency mode. | 145 // impl thread to draw, it is in a high latency mode. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 271 |
| 278 bool ShouldAnimate() const; | 272 bool ShouldAnimate() const; |
| 279 bool ShouldBeginOutputSurfaceCreation() const; | 273 bool ShouldBeginOutputSurfaceCreation() const; |
| 280 bool ShouldDraw() const; | 274 bool ShouldDraw() const; |
| 281 bool ShouldActivatePendingTree() const; | 275 bool ShouldActivatePendingTree() const; |
| 282 bool ShouldSendBeginMainFrame() const; | 276 bool ShouldSendBeginMainFrame() const; |
| 283 bool ShouldCommit() const; | 277 bool ShouldCommit() const; |
| 284 bool ShouldPrepareTiles() const; | 278 bool ShouldPrepareTiles() const; |
| 285 | 279 |
| 286 void AdvanceCurrentFrameNumber(); | 280 void AdvanceCurrentFrameNumber(); |
| 287 bool HasAnimatedThisFrame() const; | |
| 288 bool HasSentBeginMainFrameThisFrame() const; | |
| 289 bool HasRequestedSwapThisFrame() const; | |
| 290 bool HasSwappedThisFrame() const; | |
| 291 | 281 |
| 292 void UpdateStateOnCommit(bool commit_had_no_updates); | 282 void UpdateStateOnCommit(bool commit_had_no_updates); |
| 293 void UpdateStateOnActivation(); | 283 void UpdateStateOnActivation(); |
| 294 void UpdateStateOnDraw(bool did_request_swap); | 284 void UpdateStateOnDraw(bool did_request_swap); |
| 295 void UpdateStateOnPrepareTiles(); | 285 void UpdateStateOnPrepareTiles(); |
| 296 | 286 |
| 297 const SchedulerSettings settings_; | 287 const SchedulerSettings settings_; |
| 298 | 288 |
| 299 OutputSurfaceState output_surface_state_; | 289 OutputSurfaceState output_surface_state_; |
| 300 BeginImplFrameState begin_impl_frame_state_; | 290 BeginImplFrameState begin_impl_frame_state_; |
| 301 CommitState commit_state_; | 291 CommitState commit_state_; |
| 302 ForcedRedrawOnTimeoutState forced_redraw_state_; | 292 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 303 | 293 |
| 304 BeginFrameArgs begin_impl_frame_args_; | 294 // These are used for tracing only. |
| 305 | |
| 306 int commit_count_; | 295 int commit_count_; |
| 307 int current_frame_number_; | 296 int current_frame_number_; |
| 308 int last_frame_number_animate_performed_; | 297 int last_frame_number_animate_performed_; |
| 309 int last_frame_number_swap_performed_; | 298 int last_frame_number_swap_performed_; |
| 310 int last_frame_number_swap_requested_; | 299 int last_frame_number_swap_requested_; |
| 311 int last_frame_number_begin_main_frame_sent_; | 300 int last_frame_number_begin_main_frame_sent_; |
| 312 | 301 |
| 302 // These are used to ensure that an action only happens once per frame, |
| 303 // deadline, etc. |
| 304 bool animate_funnel_; |
| 305 bool perform_swap_funnel_; |
| 306 bool request_swap_funnel_; |
| 307 bool send_begin_main_frame_funnel_; |
| 313 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called | 308 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
| 314 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 309 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
| 315 // we start throttling ACTION_PREPARE_TILES such that we average one | 310 // we start throttling ACTION_PREPARE_TILES such that we average one |
| 316 // PrepareTiles per BeginImplFrame. | 311 // PrepareTiles per BeginImplFrame. |
| 317 int prepare_tiles_funnel_; | 312 int prepare_tiles_funnel_; |
| 313 |
| 318 int consecutive_checkerboard_animations_; | 314 int consecutive_checkerboard_animations_; |
| 319 int max_pending_swaps_; | 315 int max_pending_swaps_; |
| 320 int pending_swaps_; | 316 int pending_swaps_; |
| 321 bool needs_redraw_; | 317 bool needs_redraw_; |
| 322 bool needs_animate_; | 318 bool needs_animate_; |
| 323 bool needs_prepare_tiles_; | 319 bool needs_prepare_tiles_; |
| 324 bool needs_commit_; | 320 bool needs_commit_; |
| 325 bool inside_poll_for_anticipated_draw_triggers_; | 321 bool inside_poll_for_anticipated_draw_triggers_; |
| 326 bool visible_; | 322 bool visible_; |
| 327 bool can_start_; | 323 bool can_start_; |
| 328 bool can_draw_; | 324 bool can_draw_; |
| 329 bool has_pending_tree_; | 325 bool has_pending_tree_; |
| 330 bool pending_tree_is_ready_for_activation_; | 326 bool pending_tree_is_ready_for_activation_; |
| 331 bool active_tree_needs_first_draw_; | 327 bool active_tree_needs_first_draw_; |
| 332 bool did_commit_after_animating_; | |
| 333 bool did_create_and_initialize_first_output_surface_; | 328 bool did_create_and_initialize_first_output_surface_; |
| 334 bool impl_latency_takes_priority_; | 329 bool impl_latency_takes_priority_; |
| 335 bool skip_next_begin_main_frame_to_reduce_latency_; | 330 bool skip_next_begin_main_frame_to_reduce_latency_; |
| 336 bool skip_begin_main_frame_to_reduce_latency_; | 331 bool skip_begin_main_frame_to_reduce_latency_; |
| 337 bool continuous_painting_; | 332 bool continuous_painting_; |
| 338 bool children_need_begin_frames_; | 333 bool children_need_begin_frames_; |
| 339 bool defer_commits_; | 334 bool defer_commits_; |
| 335 bool last_commit_had_no_updates_; |
| 340 | 336 |
| 341 private: | 337 private: |
| 342 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 338 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 343 }; | 339 }; |
| 344 | 340 |
| 345 } // namespace cc | 341 } // namespace cc |
| 346 | 342 |
| 347 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 343 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |