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 #include "cc/scheduler/scheduler_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 // Do not queue too many swaps. | 359 // Do not queue too many swaps. |
360 if (SwapThrottled()) | 360 if (SwapThrottled()) |
361 return false; | 361 return false; |
362 | 362 |
363 // Except for the cases above, do not draw outside of the BeginImplFrame | 363 // Except for the cases above, do not draw outside of the BeginImplFrame |
364 // deadline. | 364 // deadline. |
365 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 365 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
366 return false; | 366 return false; |
367 | 367 |
| 368 if (wait_for_ready_to_draw_) |
| 369 return false; |
| 370 |
368 // Only handle forced redraws due to timeouts on the regular deadline. | 371 // Only handle forced redraws due to timeouts on the regular deadline. |
369 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 372 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
370 return true; | 373 return true; |
371 | 374 |
372 return needs_redraw_; | 375 return needs_redraw_; |
373 } | 376 } |
374 | 377 |
375 bool SchedulerStateMachine::ShouldActivatePendingTree() const { | 378 bool SchedulerStateMachine::ShouldActivatePendingTree() const { |
376 // There is nothing to activate. | 379 // There is nothing to activate. |
377 if (!has_pending_tree_) | 380 if (!has_pending_tree_) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 bool SchedulerStateMachine::ShouldCommit() const { | 478 bool SchedulerStateMachine::ShouldCommit() const { |
476 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) | 479 if (begin_main_frame_state_ != BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) |
477 return false; | 480 return false; |
478 | 481 |
479 // We must not finish the commit until the pending tree is free. | 482 // We must not finish the commit until the pending tree is free. |
480 if (has_pending_tree_) { | 483 if (has_pending_tree_) { |
481 DCHECK(settings_.main_frame_before_activation_enabled); | 484 DCHECK(settings_.main_frame_before_activation_enabled); |
482 return false; | 485 return false; |
483 } | 486 } |
484 | 487 |
| 488 // Active tree resources might still be in use until the Display draws. |
| 489 if (settings_.commit_to_active_tree && SwapThrottled()) |
| 490 return false; |
| 491 |
485 // If we only have an active tree, it is incorrect to replace it | 492 // If we only have an active tree, it is incorrect to replace it |
486 // before we've drawn it. | 493 // before we've drawn it. |
487 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); | 494 DCHECK(!settings_.commit_to_active_tree || !active_tree_needs_first_draw_); |
488 | 495 |
489 return true; | 496 return true; |
490 } | 497 } |
491 | 498 |
492 bool SchedulerStateMachine::ShouldPrepareTiles() const { | 499 bool SchedulerStateMachine::ShouldPrepareTiles() const { |
493 // PrepareTiles only really needs to be called immediately after commit | 500 // PrepareTiles only really needs to be called immediately after commit |
494 // and then periodically after that. Use a funnel to make sure we average | 501 // and then periodically after that. Use a funnel to make sure we average |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 } | 1025 } |
1019 | 1026 |
1020 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { | 1027 void SchedulerStateMachine::SetNeedsOneBeginImplFrame() { |
1021 needs_one_begin_impl_frame_ = true; | 1028 needs_one_begin_impl_frame_ = true; |
1022 } | 1029 } |
1023 | 1030 |
1024 void SchedulerStateMachine::NotifyReadyToCommit() { | 1031 void SchedulerStateMachine::NotifyReadyToCommit() { |
1025 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) | 1032 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED) |
1026 << AsValue()->ToString(); | 1033 << AsValue()->ToString(); |
1027 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; | 1034 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT; |
1028 // In commit_to_active_tree mode, commit should happen right after | |
1029 // BeginFrame, meaning when this function is called, next action should be | |
1030 // commit. | |
1031 if (settings_.commit_to_active_tree) | |
1032 DCHECK(ShouldCommit()); | |
1033 } | 1035 } |
1034 | 1036 |
1035 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { | 1037 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { |
1036 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); | 1038 DCHECK_EQ(begin_main_frame_state_, BEGIN_MAIN_FRAME_STATE_STARTED); |
1037 | 1039 |
1038 // If the main thread aborted, it doesn't matter if the main thread missed | 1040 // If the main thread aborted, it doesn't matter if the main thread missed |
1039 // the last deadline since it didn't have an update anyway. | 1041 // the last deadline since it didn't have an update anyway. |
1040 main_thread_missed_last_deadline_ = false; | 1042 main_thread_missed_last_deadline_ = false; |
1041 | 1043 |
1042 switch (reason) { | 1044 switch (reason) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 case OUTPUT_SURFACE_ACTIVE: | 1108 case OUTPUT_SURFACE_ACTIVE: |
1107 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1109 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
1108 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1110 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
1109 return true; | 1111 return true; |
1110 } | 1112 } |
1111 NOTREACHED(); | 1113 NOTREACHED(); |
1112 return false; | 1114 return false; |
1113 } | 1115 } |
1114 | 1116 |
1115 } // namespace cc | 1117 } // namespace cc |
OLD | NEW |