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 |
274 protected: | 278 protected: |
275 bool BeginFrameRequiredForAction() const; | 279 bool BeginFrameRequiredForAction() const; |
276 bool BeginFrameNeededForVideo() const; | 280 bool BeginFrameNeededForVideo() const; |
277 bool ProactiveBeginFrameWanted() const; | 281 bool ProactiveBeginFrameWanted() const; |
278 | 282 |
| 283 bool ShouldPerformImplSideInvalidation() const; |
| 284 bool CouldCreatePendingTree() const; |
| 285 |
279 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; | 286 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; |
280 | 287 |
281 // True if we need to force activations to make forward progress. | 288 // True if we need to force activations to make forward progress. |
282 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. | 289 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. |
283 bool PendingActivationsShouldBeForced() const; | 290 bool PendingActivationsShouldBeForced() const; |
284 | 291 |
285 bool ShouldBeginCompositorFrameSinkCreation() const; | 292 bool ShouldBeginCompositorFrameSinkCreation() const; |
286 bool ShouldDraw() const; | 293 bool ShouldDraw() const; |
287 bool ShouldActivatePendingTree() const; | 294 bool ShouldActivatePendingTree() const; |
288 bool ShouldSendBeginMainFrame() const; | 295 bool ShouldSendBeginMainFrame() const; |
289 bool ShouldCommit() const; | 296 bool ShouldCommit() const; |
290 bool ShouldPrepareTiles() const; | 297 bool ShouldPrepareTiles() const; |
291 bool ShouldInvalidateCompositorFrameSink() const; | 298 bool ShouldInvalidateCompositorFrameSink() const; |
292 | 299 |
293 void WillDrawInternal(); | 300 void WillDrawInternal(); |
| 301 void WillPerformImplSideInvalidationInternal(); |
294 void DidDrawInternal(DrawResult draw_result); | 302 void DidDrawInternal(DrawResult draw_result); |
295 | 303 |
296 const SchedulerSettings settings_; | 304 const SchedulerSettings settings_; |
297 | 305 |
298 CompositorFrameSinkState compositor_frame_sink_state_; | 306 CompositorFrameSinkState compositor_frame_sink_state_; |
299 BeginImplFrameState begin_impl_frame_state_; | 307 BeginImplFrameState begin_impl_frame_state_; |
300 BeginMainFrameState begin_main_frame_state_; | 308 BeginMainFrameState begin_main_frame_state_; |
301 ForcedRedrawOnTimeoutState forced_redraw_state_; | 309 ForcedRedrawOnTimeoutState forced_redraw_state_; |
302 | 310 |
303 // These are used for tracing only. | 311 // These are used for tracing only. |
304 int commit_count_; | 312 int commit_count_; |
305 int current_frame_number_; | 313 int current_frame_number_; |
306 int last_frame_number_submit_performed_; | 314 int last_frame_number_submit_performed_; |
307 int last_frame_number_draw_performed_; | 315 int last_frame_number_draw_performed_; |
308 int last_frame_number_begin_main_frame_sent_; | 316 int last_frame_number_begin_main_frame_sent_; |
309 int last_frame_number_invalidate_compositor_frame_sink_performed_; | 317 int last_frame_number_invalidate_compositor_frame_sink_performed_; |
310 | 318 |
311 // These are used to ensure that an action only happens once per frame, | 319 // These are used to ensure that an action only happens once per frame, |
312 // deadline, etc. | 320 // deadline, etc. |
313 bool draw_funnel_; | 321 bool draw_funnel_; |
314 bool send_begin_main_frame_funnel_; | 322 bool send_begin_main_frame_funnel_; |
315 bool invalidate_compositor_frame_sink_funnel_; | 323 bool invalidate_compositor_frame_sink_funnel_; |
| 324 bool impl_side_invalidation_funnel_; |
316 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called | 325 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
317 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 326 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
318 // we start throttling ACTION_PREPARE_TILES such that we average one | 327 // we start throttling ACTION_PREPARE_TILES such that we average one |
319 // PrepareTiles per BeginImplFrame. | 328 // PrepareTiles per BeginImplFrame. |
320 int prepare_tiles_funnel_; | 329 int prepare_tiles_funnel_; |
321 | 330 |
322 int consecutive_checkerboard_animations_; | 331 int consecutive_checkerboard_animations_; |
323 int pending_submit_frames_; | 332 int pending_submit_frames_; |
324 int submit_frames_with_current_compositor_frame_sink_; | 333 int submit_frames_with_current_compositor_frame_sink_; |
325 bool needs_redraw_; | 334 bool needs_redraw_; |
(...skipping 12 matching lines...) Expand all Loading... |
338 ScrollHandlerState scroll_handler_state_; | 347 ScrollHandlerState scroll_handler_state_; |
339 bool critical_begin_main_frame_to_activate_is_fast_; | 348 bool critical_begin_main_frame_to_activate_is_fast_; |
340 bool main_thread_missed_last_deadline_; | 349 bool main_thread_missed_last_deadline_; |
341 bool skip_next_begin_main_frame_to_reduce_latency_; | 350 bool skip_next_begin_main_frame_to_reduce_latency_; |
342 bool defer_commits_; | 351 bool defer_commits_; |
343 bool video_needs_begin_frames_; | 352 bool video_needs_begin_frames_; |
344 bool last_commit_had_no_updates_; | 353 bool last_commit_had_no_updates_; |
345 bool wait_for_ready_to_draw_; | 354 bool wait_for_ready_to_draw_; |
346 bool did_draw_in_last_frame_; | 355 bool did_draw_in_last_frame_; |
347 bool did_submit_in_last_frame_; | 356 bool did_submit_in_last_frame_; |
| 357 bool needs_impl_side_invalidation_; |
| 358 bool impl_side_invalidations_take_priority_; |
348 | 359 |
349 private: | 360 private: |
350 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 361 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
351 }; | 362 }; |
352 | 363 |
353 } // namespace cc | 364 } // namespace cc |
354 | 365 |
355 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 366 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |