Chromium Code Reviews| 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 children_need_begin_frames_ = children_need_begin_frames; | 733 children_need_begin_frames_ = children_need_begin_frames; |
| 734 } | 734 } |
| 735 | 735 |
| 736 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { | 736 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { |
| 737 defer_commits_ = defer_commits; | 737 defer_commits_ = defer_commits; |
| 738 } | 738 } |
| 739 | 739 |
| 740 // These are the cases where we definitely (or almost definitely) have a | 740 // These are the cases where we definitely (or almost definitely) have a |
| 741 // new frame to animate and/or draw and can draw. | 741 // new frame to animate and/or draw and can draw. |
| 742 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { | 742 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { |
| 743 // If we are not visible, we don't need BeginFrame messages. | |
| 744 if (!visible_) | |
| 745 return false; | |
|
sunnyps
2015/04/07 22:55:04
Better move this to the BeginFrameNeeded method no
brianderson
2015/04/08 01:21:59
+1 to moving the visibility checks to BeginFrameNe
mithro-old
2015/04/08 23:40:50
Done.
| |
| 746 | |
| 743 // The forced draw respects our normal draw scheduling, so we need to | 747 // The forced draw respects our normal draw scheduling, so we need to |
| 744 // request a BeginImplFrame for it. | 748 // request a BeginImplFrame for it. |
| 745 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 749 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| 746 return true; | 750 return true; |
| 747 | 751 |
| 748 // TODO(mithro): Remove background animation ticking. crbug.com/371747 | 752 return needs_animate_ || needs_redraw_; |
| 749 if (needs_animate_) | |
| 750 return true; | |
| 751 | |
| 752 // Only background tick for animations - not draws, which will never happen. | |
| 753 if (!visible_) | |
| 754 return false; | |
| 755 | |
| 756 return needs_redraw_; | |
| 757 } | 753 } |
| 758 | 754 |
| 759 // These are cases where we are very likely to draw soon, but might not | 755 // These are cases where we are very likely to draw soon, but might not |
| 760 // actually have a new frame to draw when we receive the next BeginImplFrame. | 756 // actually have a new frame to draw when we receive the next BeginImplFrame. |
| 761 // Proactively requesting the BeginImplFrame helps hide the round trip latency | 757 // Proactively requesting the BeginImplFrame helps hide the round trip latency |
| 762 // of the SetNeedsBeginFrame request that has to go to the Browser. | 758 // of the SetNeedsBeginFrame request that has to go to the Browser. |
| 763 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { | 759 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { |
| 764 // Do not be proactive when invisible. | 760 // Do not be proactive when invisible. |
| 765 if (!visible_) | 761 if (!visible_) |
| 766 return false; | 762 return false; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1106 static_cast<int>(begin_impl_frame_state_), | 1102 static_cast<int>(begin_impl_frame_state_), |
| 1107 static_cast<int>(commit_state_), | 1103 static_cast<int>(commit_state_), |
| 1108 has_pending_tree_ ? 'T' : 'F', | 1104 has_pending_tree_ ? 'T' : 'F', |
| 1109 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1105 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1110 active_tree_needs_first_draw_ ? 'T' : 'F', | 1106 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1111 max_pending_swaps_, | 1107 max_pending_swaps_, |
| 1112 pending_swaps_); | 1108 pending_swaps_); |
| 1113 } | 1109 } |
| 1114 | 1110 |
| 1115 } // namespace cc | 1111 } // namespace cc |
| OLD | NEW |