| 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 <stdint.h> |
| 9 |
| 8 #include <memory> | 10 #include <memory> |
| 9 #include <string> | 11 #include <string> |
| 10 | 12 |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
| 13 #include "cc/output/begin_frame_args.h" | |
| 14 #include "cc/scheduler/commit_earlyout_reason.h" | 15 #include "cc/scheduler/commit_earlyout_reason.h" |
| 15 #include "cc/scheduler/draw_result.h" | 16 #include "cc/scheduler/draw_result.h" |
| 16 #include "cc/scheduler/scheduler_settings.h" | 17 #include "cc/scheduler/scheduler_settings.h" |
| 17 #include "cc/tiles/tile_priority.h" | 18 #include "cc/tiles/tile_priority.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 namespace trace_event { | 21 namespace trace_event { |
| 21 class ConvertableToTraceFormat; | 22 class ConvertableToTraceFormat; |
| 22 class TracedValue; | 23 class TracedValue; |
| 23 } | 24 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void WillPerformImplSideInvalidation(); | 140 void WillPerformImplSideInvalidation(); |
| 140 | 141 |
| 141 void DidDraw(DrawResult draw_result); | 142 void DidDraw(DrawResult draw_result); |
| 142 | 143 |
| 143 void AbortDraw(); | 144 void AbortDraw(); |
| 144 | 145 |
| 145 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 146 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
| 146 // to make progress. | 147 // to make progress. |
| 147 bool BeginFrameNeeded() const; | 148 bool BeginFrameNeeded() const; |
| 148 | 149 |
| 150 // Indicates that the Scheduler has received a BeginFrame that did not require |
| 151 // a BeginImplFrame, because the Scheduler stopped observing BeginFrames. |
| 152 // Updates the sequence and freshness numbers for the dropped BeginFrame. |
| 153 void OnBeginFrameDroppedNotObserving(uint32_t source_id, |
| 154 uint64_t sequence_number); |
| 155 |
| 149 // Indicates that the system has entered and left a BeginImplFrame callback. | 156 // Indicates that the system has entered and left a BeginImplFrame callback. |
| 150 // The scheduler will not draw more than once in a given BeginImplFrame | 157 // The scheduler will not draw more than once in a given BeginImplFrame |
| 151 // callback nor send more than one BeginMainFrame message. | 158 // callback nor send more than one BeginMainFrame message. |
| 152 void OnBeginImplFrame(); | 159 void OnBeginImplFrame(uint32_t source_id, uint64_t sequence_number); |
| 153 // Indicates that the scheduler has entered the draw phase. The scheduler | 160 // Indicates that the scheduler has entered the draw phase. The scheduler |
| 154 // will not draw more than once in a single draw phase. | 161 // will not draw more than once in a single draw phase. |
| 155 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar. | 162 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar. |
| 156 void OnBeginImplFrameDeadline(); | 163 void OnBeginImplFrameDeadline(); |
| 157 void OnBeginImplFrameIdle(); | 164 void OnBeginImplFrameIdle(); |
| 158 | 165 |
| 159 int current_frame_number() const { return current_frame_number_; } | 166 int current_frame_number() const { return current_frame_number_; } |
| 160 | 167 |
| 161 BeginImplFrameState begin_impl_frame_state() const { | 168 BeginImplFrameState begin_impl_frame_state() const { |
| 162 return begin_impl_frame_state_; | 169 return begin_impl_frame_state_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 282 |
| 276 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; } | 283 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; } |
| 277 | 284 |
| 278 bool needs_impl_side_invalidation() const { | 285 bool needs_impl_side_invalidation() const { |
| 279 return needs_impl_side_invalidation_; | 286 return needs_impl_side_invalidation_; |
| 280 } | 287 } |
| 281 bool previous_pending_tree_was_impl_side() const { | 288 bool previous_pending_tree_was_impl_side() const { |
| 282 return previous_pending_tree_was_impl_side_; | 289 return previous_pending_tree_was_impl_side_; |
| 283 } | 290 } |
| 284 | 291 |
| 292 uint32_t begin_frame_source_id() const { return begin_frame_source_id_; } |
| 293 uint64_t last_begin_frame_sequence_number_compositor_frame_was_fresh() const { |
| 294 return last_begin_frame_sequence_number_compositor_frame_was_fresh_; |
| 295 } |
| 296 |
| 285 protected: | 297 protected: |
| 286 bool BeginFrameRequiredForAction() const; | 298 bool BeginFrameRequiredForAction() const; |
| 287 bool BeginFrameNeededForVideo() const; | 299 bool BeginFrameNeededForVideo() const; |
| 288 bool ProactiveBeginFrameWanted() const; | 300 bool ProactiveBeginFrameWanted() const; |
| 289 | 301 |
| 290 bool ShouldPerformImplSideInvalidation() const; | 302 bool ShouldPerformImplSideInvalidation() const; |
| 291 bool CouldCreatePendingTree() const; | 303 bool CouldCreatePendingTree() const; |
| 292 | 304 |
| 293 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; | 305 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; |
| 294 | 306 |
| 295 // True if we need to force activations to make forward progress. | 307 // True if we need to force activations to make forward progress. |
| 296 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. | 308 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. |
| 297 bool PendingActivationsShouldBeForced() const; | 309 bool PendingActivationsShouldBeForced() const; |
| 298 | 310 |
| 299 bool ShouldBeginCompositorFrameSinkCreation() const; | 311 bool ShouldBeginCompositorFrameSinkCreation() const; |
| 300 bool ShouldDraw() const; | 312 bool ShouldDraw() const; |
| 301 bool ShouldActivatePendingTree() const; | 313 bool ShouldActivatePendingTree() const; |
| 302 bool ShouldSendBeginMainFrame() const; | 314 bool ShouldSendBeginMainFrame() const; |
| 303 bool ShouldCommit() const; | 315 bool ShouldCommit() const; |
| 304 bool ShouldPrepareTiles() const; | 316 bool ShouldPrepareTiles() const; |
| 305 bool ShouldInvalidateCompositorFrameSink() const; | 317 bool ShouldInvalidateCompositorFrameSink() const; |
| 306 | 318 |
| 307 void WillDrawInternal(); | 319 void WillDrawInternal(); |
| 308 void WillPerformImplSideInvalidationInternal(); | 320 void WillPerformImplSideInvalidationInternal(); |
| 309 void DidDrawInternal(DrawResult draw_result); | 321 void DidDrawInternal(DrawResult draw_result); |
| 310 | 322 |
| 323 void UpdateBeginFrameSequenceNumbersForBeginFrame(uint32_t source_id, |
| 324 uint64_t sequence_number); |
| 325 void UpdateBeginFrameSequenceNumbersForBeginFrameDeadline(); |
| 326 |
| 311 const SchedulerSettings settings_; | 327 const SchedulerSettings settings_; |
| 312 | 328 |
| 313 CompositorFrameSinkState compositor_frame_sink_state_; | 329 CompositorFrameSinkState compositor_frame_sink_state_; |
| 314 BeginImplFrameState begin_impl_frame_state_; | 330 BeginImplFrameState begin_impl_frame_state_; |
| 315 BeginMainFrameState begin_main_frame_state_; | 331 BeginMainFrameState begin_main_frame_state_; |
| 316 ForcedRedrawOnTimeoutState forced_redraw_state_; | 332 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 317 | 333 |
| 334 // These fields are used to track the freshness of pending updates in the |
| 335 // commit/activate/draw pipeline. The Scheduler uses the CompositorFrame's |
| 336 // freshness to fill the |latest_confirmed_sequence_number| field in |
| 337 // BeginFrameAcks. |
| 338 uint32_t begin_frame_source_id_; |
| 339 uint64_t begin_frame_sequence_number_; |
| 340 uint64_t last_begin_frame_sequence_number_begin_main_frame_sent_; |
| 341 uint64_t last_begin_frame_sequence_number_pending_tree_was_fresh_; |
| 342 uint64_t last_begin_frame_sequence_number_active_tree_was_fresh_; |
| 343 uint64_t last_begin_frame_sequence_number_compositor_frame_was_fresh_; |
| 344 |
| 318 // These are used for tracing only. | 345 // These are used for tracing only. |
| 319 int commit_count_; | 346 int commit_count_; |
| 320 int current_frame_number_; | 347 int current_frame_number_; |
| 321 int last_frame_number_submit_performed_; | 348 int last_frame_number_submit_performed_; |
| 322 int last_frame_number_draw_performed_; | 349 int last_frame_number_draw_performed_; |
| 323 int last_frame_number_begin_main_frame_sent_; | 350 int last_frame_number_begin_main_frame_sent_; |
| 324 int last_frame_number_invalidate_compositor_frame_sink_performed_; | 351 int last_frame_number_invalidate_compositor_frame_sink_performed_; |
| 325 | 352 |
| 326 // These are used to ensure that an action only happens once per frame, | 353 // These are used to ensure that an action only happens once per frame, |
| 327 // deadline, etc. | 354 // deadline, etc. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 bool previous_pending_tree_was_impl_side_; | 393 bool previous_pending_tree_was_impl_side_; |
| 367 bool current_pending_tree_is_impl_side_; | 394 bool current_pending_tree_is_impl_side_; |
| 368 | 395 |
| 369 private: | 396 private: |
| 370 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 397 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 371 }; | 398 }; |
| 372 | 399 |
| 373 } // namespace cc | 400 } // namespace cc |
| 374 | 401 |
| 375 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 402 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |