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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 // If the last swap drew with checkerboard or missing tiles, we should | 416 // If the last swap drew with checkerboard or missing tiles, we should |
417 // poll for any new visible tiles so we can be notified to draw again | 417 // poll for any new visible tiles so we can be notified to draw again |
418 // when there are. | 418 // when there are. |
419 if (swap_used_incomplete_tile_) | 419 if (swap_used_incomplete_tile_) |
420 return true; | 420 return true; |
421 | 421 |
422 return false; | 422 return false; |
423 } | 423 } |
424 | 424 |
425 bool SchedulerStateMachine::ShouldAnimate() const { | 425 bool SchedulerStateMachine::ShouldAnimate() const { |
| 426 if (!can_draw_) |
| 427 return false; |
| 428 |
426 // If a commit occurred after our last call, we need to do animation again. | 429 // If a commit occurred after our last call, we need to do animation again. |
427 if (HasAnimatedThisFrame() && !did_commit_after_animating_) | 430 if (HasAnimatedThisFrame() && !did_commit_after_animating_) |
428 return false; | 431 return false; |
429 | 432 |
430 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && | 433 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && |
431 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 434 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
432 return false; | 435 return false; |
433 | 436 |
434 return needs_redraw_ || needs_animate_; | 437 return needs_redraw_ || needs_animate_; |
435 } | 438 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 758 } |
756 | 759 |
757 // These are the cases where we definitely (or almost definitely) have a | 760 // These are the cases where we definitely (or almost definitely) have a |
758 // new frame to animate and/or draw and can draw. | 761 // new frame to animate and/or draw and can draw. |
759 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { | 762 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { |
760 // The output surface is the provider of BeginImplFrames, so we are not going | 763 // The output surface is the provider of BeginImplFrames, so we are not going |
761 // to get them even if we ask for them. | 764 // to get them even if we ask for them. |
762 if (!HasInitializedOutputSurface()) | 765 if (!HasInitializedOutputSurface()) |
763 return false; | 766 return false; |
764 | 767 |
| 768 // If we can't draw, don't tick until we are notified that we can draw again. |
| 769 if (!can_draw_) |
| 770 return false; |
| 771 |
765 // The forced draw respects our normal draw scheduling, so we need to | 772 // The forced draw respects our normal draw scheduling, so we need to |
766 // request a BeginImplFrame for it. | 773 // request a BeginImplFrame for it. |
767 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 774 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
768 return true; | 775 return true; |
769 | 776 |
| 777 // There's no need to produce frames if we are not visible. |
| 778 if (!visible_) |
| 779 return false; |
| 780 |
770 // We need to draw a more complete frame than we did the last BeginImplFrame, | 781 // We need to draw a more complete frame than we did the last BeginImplFrame, |
771 // so request another BeginImplFrame in anticipation that we will have | 782 // so request another BeginImplFrame in anticipation that we will have |
772 // additional visible tiles. | 783 // additional visible tiles. |
773 if (swap_used_incomplete_tile_) | 784 if (swap_used_incomplete_tile_) |
774 return true; | 785 return true; |
775 | 786 |
776 return needs_animate_ || needs_redraw_; | 787 if (needs_animate_) |
| 788 return true; |
| 789 |
| 790 return needs_redraw_; |
777 } | 791 } |
778 | 792 |
779 // These are cases where we are very likely to draw soon, but might not | 793 // These are cases where we are very likely to draw soon, but might not |
780 // actually have a new frame to draw when we receive the next BeginImplFrame. | 794 // actually have a new frame to draw when we receive the next BeginImplFrame. |
781 // Proactively requesting the BeginImplFrame helps hide the round trip latency | 795 // Proactively requesting the BeginImplFrame helps hide the round trip latency |
782 // of the SetNeedsBeginFrame request that has to go to the Browser. | 796 // of the SetNeedsBeginFrame request that has to go to the Browser. |
783 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { | 797 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { |
784 // The output surface is the provider of BeginImplFrames, | 798 // The output surface is the provider of BeginImplFrames, |
785 // so we are not going to get them even if we ask for them. | 799 // so we are not going to get them even if we ask for them. |
786 if (!HasInitializedOutputSurface()) | 800 if (!HasInitializedOutputSurface()) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 static_cast<int>(begin_impl_frame_state_), | 1115 static_cast<int>(begin_impl_frame_state_), |
1102 static_cast<int>(commit_state_), | 1116 static_cast<int>(commit_state_), |
1103 has_pending_tree_ ? 'T' : 'F', | 1117 has_pending_tree_ ? 'T' : 'F', |
1104 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1118 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1105 active_tree_needs_first_draw_ ? 'T' : 'F', | 1119 active_tree_needs_first_draw_ ? 'T' : 'F', |
1106 max_pending_swaps_, | 1120 max_pending_swaps_, |
1107 pending_swaps_); | 1121 pending_swaps_); |
1108 } | 1122 } |
1109 | 1123 |
1110 } // namespace cc | 1124 } // namespace cc |
OLD | NEW |