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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 enum ForcedRedrawOnTimeoutState { | 92 enum ForcedRedrawOnTimeoutState { |
93 FORCED_REDRAW_STATE_IDLE, | 93 FORCED_REDRAW_STATE_IDLE, |
94 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, | 94 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, |
95 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, | 95 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, |
96 FORCED_REDRAW_STATE_WAITING_FOR_DRAW, | 96 FORCED_REDRAW_STATE_WAITING_FOR_DRAW, |
97 }; | 97 }; |
98 static const char* ForcedRedrawOnTimeoutStateToString( | 98 static const char* ForcedRedrawOnTimeoutStateToString( |
99 ForcedRedrawOnTimeoutState state); | 99 ForcedRedrawOnTimeoutState state); |
100 | 100 |
| 101 BeginMainFrameState begin_main_frame_state() const { |
| 102 return begin_main_frame_state_; |
| 103 } |
| 104 |
101 bool CommitPending() const { | 105 bool CommitPending() const { |
102 return begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_SENT || | 106 return begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_SENT || |
103 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_STARTED || | 107 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_STARTED || |
104 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; | 108 begin_main_frame_state_ == BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; |
105 } | 109 } |
106 BeginMainFrameState begin_main_frame_state() const { | 110 |
107 return begin_main_frame_state_; | 111 bool NewActiveTreeLikely() const { |
| 112 return needs_begin_main_frame_ || CommitPending() || has_pending_tree_; |
108 } | 113 } |
109 | 114 |
110 bool RedrawPending() const { return needs_redraw_; } | 115 bool RedrawPending() const { return needs_redraw_; } |
111 bool PrepareTilesPending() const { return needs_prepare_tiles_; } | 116 bool PrepareTilesPending() const { return needs_prepare_tiles_; } |
112 | 117 |
113 enum Action { | 118 enum Action { |
114 ACTION_NONE, | 119 ACTION_NONE, |
115 ACTION_ANIMATE, | 120 ACTION_ANIMATE, |
116 ACTION_SEND_BEGIN_MAIN_FRAME, | 121 ACTION_SEND_BEGIN_MAIN_FRAME, |
117 ACTION_COMMIT, | 122 ACTION_COMMIT, |
118 ACTION_ACTIVATE_SYNC_TREE, | 123 ACTION_ACTIVATE_SYNC_TREE, |
119 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 124 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
120 ACTION_DRAW_AND_SWAP_FORCED, | 125 ACTION_DRAW_AND_SWAP_FORCED, |
121 ACTION_DRAW_AND_SWAP_ABORT, | 126 ACTION_DRAW_AND_SWAP_ABORT, |
122 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 127 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
123 ACTION_PREPARE_TILES, | 128 ACTION_PREPARE_TILES, |
124 ACTION_INVALIDATE_OUTPUT_SURFACE, | 129 ACTION_INVALIDATE_OUTPUT_SURFACE, |
125 }; | 130 }; |
126 static const char* ActionToString(Action action); | 131 static const char* ActionToString(Action action); |
127 | 132 |
128 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | 133 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; |
129 void AsValueInto(base::trace_event::TracedValue* dict) const; | 134 void AsValueInto(base::trace_event::TracedValue* dict) const; |
130 | 135 |
131 Action NextAction() const; | 136 Action NextAction() const; |
132 void WillAnimate(); | 137 void WillAnimate(); |
133 void WillSendBeginMainFrame(); | 138 void WillSendBeginMainFrame(); |
134 void WillCommit(bool commit_had_no_updates); | 139 void WillCommit(bool commit_had_no_updates); |
135 void WillActivate(); | 140 void WillActivate(); |
136 void WillDraw(bool did_request_swap); | 141 void WillDraw(); |
137 void WillBeginOutputSurfaceCreation(); | 142 void WillBeginOutputSurfaceCreation(); |
138 void WillPrepareTiles(); | 143 void WillPrepareTiles(); |
139 void WillInvalidateOutputSurface(); | 144 void WillInvalidateOutputSurface(); |
140 | 145 |
| 146 void DidDraw(DrawResult draw_result); |
| 147 |
| 148 void AbortDrawAndSwap(); |
| 149 |
141 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 150 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
142 // to make progress. | 151 // to make progress. |
143 bool BeginFrameNeeded() const; | 152 bool BeginFrameNeeded() const; |
144 | 153 |
145 // Indicates that the system has entered and left a BeginImplFrame callback. | 154 // Indicates that the system has entered and left a BeginImplFrame callback. |
146 // The scheduler will not draw more than once in a given BeginImplFrame | 155 // The scheduler will not draw more than once in a given BeginImplFrame |
147 // callback nor send more than one BeginMainFrame message. | 156 // callback nor send more than one BeginMainFrame message. |
148 void OnBeginImplFrame(); | 157 void OnBeginImplFrame(); |
149 void OnBeginImplFrameDeadlinePending(); | 158 void OnBeginImplFrameDeadlinePending(); |
150 // Indicates that the scheduler has entered the draw phase. The scheduler | 159 // Indicates that the scheduler has entered the draw phase. The scheduler |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void SetTreePrioritiesAndScrollState(TreePriority tree_priority, | 209 void SetTreePrioritiesAndScrollState(TreePriority tree_priority, |
201 ScrollHandlerState scroll_handler_state); | 210 ScrollHandlerState scroll_handler_state); |
202 | 211 |
203 // Indicates if the main thread will likely respond within 1 vsync. | 212 // Indicates if the main thread will likely respond within 1 vsync. |
204 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast); | 213 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast); |
205 | 214 |
206 // A function of SetTreePrioritiesAndScrollState and | 215 // A function of SetTreePrioritiesAndScrollState and |
207 // SetCriticalBeginMainFrameToActivateIsFast. | 216 // SetCriticalBeginMainFrameToActivateIsFast. |
208 bool ImplLatencyTakesPriority() const; | 217 bool ImplLatencyTakesPriority() const; |
209 | 218 |
210 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen. | |
211 void DidDrawIfPossibleCompleted(DrawResult result); | |
212 | |
213 // Indicates that a new begin main frame flow needs to be performed, either | 219 // Indicates that a new begin main frame flow needs to be performed, either |
214 // to pull updates from the main thread to the impl, or to push deltas from | 220 // to pull updates from the main thread to the impl, or to push deltas from |
215 // the impl thread to main. | 221 // the impl thread to main. |
216 void SetNeedsBeginMainFrame(); | 222 void SetNeedsBeginMainFrame(); |
217 bool needs_begin_main_frame() const { return needs_begin_main_frame_; } | 223 bool needs_begin_main_frame() const { return needs_begin_main_frame_; } |
218 | 224 |
219 // Requests a single impl frame (after the current frame if there is one | 225 // Requests a single impl frame (after the current frame if there is one |
220 // active). | 226 // active). |
221 void SetNeedsOneBeginImplFrame(); | 227 void SetNeedsOneBeginImplFrame(); |
222 | 228 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 297 |
292 bool ShouldAnimate() const; | 298 bool ShouldAnimate() const; |
293 bool ShouldBeginOutputSurfaceCreation() const; | 299 bool ShouldBeginOutputSurfaceCreation() const; |
294 bool ShouldDraw() const; | 300 bool ShouldDraw() const; |
295 bool ShouldActivatePendingTree() const; | 301 bool ShouldActivatePendingTree() const; |
296 bool ShouldSendBeginMainFrame() const; | 302 bool ShouldSendBeginMainFrame() const; |
297 bool ShouldCommit() const; | 303 bool ShouldCommit() const; |
298 bool ShouldPrepareTiles() const; | 304 bool ShouldPrepareTiles() const; |
299 bool ShouldInvalidateOutputSurface() const; | 305 bool ShouldInvalidateOutputSurface() const; |
300 | 306 |
| 307 void WillDrawInternal(); |
| 308 void DidDrawInternal(DrawResult draw_result); |
| 309 |
301 const SchedulerSettings settings_; | 310 const SchedulerSettings settings_; |
302 | 311 |
303 OutputSurfaceState output_surface_state_; | 312 OutputSurfaceState output_surface_state_; |
304 BeginImplFrameState begin_impl_frame_state_; | 313 BeginImplFrameState begin_impl_frame_state_; |
305 BeginMainFrameState begin_main_frame_state_; | 314 BeginMainFrameState begin_main_frame_state_; |
306 ForcedRedrawOnTimeoutState forced_redraw_state_; | 315 ForcedRedrawOnTimeoutState forced_redraw_state_; |
307 | 316 |
308 // These are used for tracing only. | 317 // These are used for tracing only. |
309 int commit_count_; | 318 int commit_count_; |
310 int current_frame_number_; | 319 int current_frame_number_; |
311 int last_frame_number_animate_performed_; | 320 int last_frame_number_animate_performed_; |
312 int last_frame_number_swap_performed_; | 321 int last_frame_number_swap_performed_; |
313 int last_frame_number_swap_requested_; | 322 int last_frame_number_draw_performed_; |
314 int last_frame_number_begin_main_frame_sent_; | 323 int last_frame_number_begin_main_frame_sent_; |
315 int last_frame_number_invalidate_output_surface_performed_; | 324 int last_frame_number_invalidate_output_surface_performed_; |
316 | 325 |
317 // 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, |
318 // deadline, etc. | 327 // deadline, etc. |
319 bool animate_funnel_; | 328 bool animate_funnel_; |
320 bool request_swap_funnel_; | 329 bool draw_funnel_; |
321 bool send_begin_main_frame_funnel_; | 330 bool send_begin_main_frame_funnel_; |
322 bool invalidate_output_surface_funnel_; | 331 bool invalidate_output_surface_funnel_; |
323 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called | 332 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
324 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 333 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
325 // we start throttling ACTION_PREPARE_TILES such that we average one | 334 // we start throttling ACTION_PREPARE_TILES such that we average one |
326 // PrepareTiles per BeginImplFrame. | 335 // PrepareTiles per BeginImplFrame. |
327 int prepare_tiles_funnel_; | 336 int prepare_tiles_funnel_; |
328 | 337 |
329 int consecutive_checkerboard_animations_; | 338 int consecutive_checkerboard_animations_; |
330 int max_pending_swaps_; | 339 int max_pending_swaps_; |
(...skipping 14 matching lines...) Expand all Loading... |
345 TreePriority tree_priority_; | 354 TreePriority tree_priority_; |
346 ScrollHandlerState scroll_handler_state_; | 355 ScrollHandlerState scroll_handler_state_; |
347 bool critical_begin_main_frame_to_activate_is_fast_; | 356 bool critical_begin_main_frame_to_activate_is_fast_; |
348 bool main_thread_missed_last_deadline_; | 357 bool main_thread_missed_last_deadline_; |
349 bool skip_next_begin_main_frame_to_reduce_latency_; | 358 bool skip_next_begin_main_frame_to_reduce_latency_; |
350 bool children_need_begin_frames_; | 359 bool children_need_begin_frames_; |
351 bool defer_commits_; | 360 bool defer_commits_; |
352 bool video_needs_begin_frames_; | 361 bool video_needs_begin_frames_; |
353 bool last_commit_had_no_updates_; | 362 bool last_commit_had_no_updates_; |
354 bool wait_for_ready_to_draw_; | 363 bool wait_for_ready_to_draw_; |
355 bool did_request_swap_in_last_frame_; | 364 bool did_draw_in_last_frame_; |
356 bool did_perform_swap_in_last_draw_; | 365 bool did_swap_in_last_frame_; |
357 | 366 |
358 private: | 367 private: |
359 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 368 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
360 }; | 369 }; |
361 | 370 |
362 } // namespace cc | 371 } // namespace cc |
363 | 372 |
364 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 373 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |