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