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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 722 |
723 bool SchedulerStateMachine::BeginFrameRequiredForChildren() const { | 723 bool SchedulerStateMachine::BeginFrameRequiredForChildren() const { |
724 return children_need_begin_frames_; | 724 return children_need_begin_frames_; |
725 } | 725 } |
726 | 726 |
727 bool SchedulerStateMachine::BeginFrameNeeded() const { | 727 bool SchedulerStateMachine::BeginFrameNeeded() const { |
728 // We can't handle BeginFrames when output surface isn't initialized. | 728 // We can't handle BeginFrames when output surface isn't initialized. |
729 // TODO(brianderson): Support output surface creation inside a BeginFrame. | 729 // TODO(brianderson): Support output surface creation inside a BeginFrame. |
730 if (!HasInitializedOutputSurface()) | 730 if (!HasInitializedOutputSurface()) |
731 return false; | 731 return false; |
| 732 |
| 733 // If we are not visible, we don't need BeginFrame messages. |
| 734 if (!visible_) |
| 735 return false; |
| 736 |
732 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() || | 737 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() || |
733 ProactiveBeginFrameWanted()); | 738 ProactiveBeginFrameWanted()); |
734 } | 739 } |
735 | 740 |
736 void SchedulerStateMachine::SetChildrenNeedBeginFrames( | 741 void SchedulerStateMachine::SetChildrenNeedBeginFrames( |
737 bool children_need_begin_frames) { | 742 bool children_need_begin_frames) { |
738 children_need_begin_frames_ = children_need_begin_frames; | 743 children_need_begin_frames_ = children_need_begin_frames; |
739 } | 744 } |
740 | 745 |
741 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { | 746 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { |
742 defer_commits_ = defer_commits; | 747 defer_commits_ = defer_commits; |
743 } | 748 } |
744 | 749 |
745 // These are the cases where we require a BeginFrame message to make progress | 750 // These are the cases where we require a BeginFrame message to make progress |
746 // on requested actions. | 751 // on requested actions. |
747 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { | 752 bool SchedulerStateMachine::BeginFrameRequiredForAction() const { |
748 // The forced draw respects our normal draw scheduling, so we need to | 753 // The forced draw respects our normal draw scheduling, so we need to |
749 // request a BeginImplFrame for it. | 754 // request a BeginImplFrame for it. |
750 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 755 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
751 return true; | 756 return true; |
752 | 757 |
753 // TODO(mithro): Remove background animation ticking. crbug.com/371747 | 758 return needs_animate_ || needs_redraw_ || (needs_commit_ && !defer_commits_); |
754 if (needs_animate_) | |
755 return true; | |
756 | |
757 // Only background tick for animations - not draws, which will never happen. | |
758 if (!visible_) | |
759 return false; | |
760 | |
761 return needs_redraw_ || (needs_commit_ && !defer_commits_); | |
762 } | 759 } |
763 | 760 |
764 // These are cases where we are very likely want a BeginFrame message in the | 761 // These are cases where we are very likely want a BeginFrame message in the |
765 // near future. Proactively requesting the BeginImplFrame helps hide the round | 762 // near future. Proactively requesting the BeginImplFrame helps hide the round |
766 // trip latency of the SetNeedsBeginFrame request that has to go to the | 763 // trip latency of the SetNeedsBeginFrame request that has to go to the |
767 // Browser. | 764 // Browser. |
768 // This includes things like drawing soon, but might not actually have a new | 765 // This includes things like drawing soon, but might not actually have a new |
769 // frame to draw when we receive the next BeginImplFrame. | 766 // frame to draw when we receive the next BeginImplFrame. |
770 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { | 767 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { |
771 // Do not be proactive when invisible. | 768 // Do not be proactive when invisible. |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 static_cast<int>(begin_impl_frame_state_), | 1124 static_cast<int>(begin_impl_frame_state_), |
1128 static_cast<int>(commit_state_), | 1125 static_cast<int>(commit_state_), |
1129 has_pending_tree_ ? 'T' : 'F', | 1126 has_pending_tree_ ? 'T' : 'F', |
1130 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1127 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
1131 active_tree_needs_first_draw_ ? 'T' : 'F', | 1128 active_tree_needs_first_draw_ ? 'T' : 'F', |
1132 max_pending_swaps_, | 1129 max_pending_swaps_, |
1133 pending_swaps_); | 1130 pending_swaps_); |
1134 } | 1131 } |
1135 | 1132 |
1136 } // namespace cc | 1133 } // namespace cc |
OLD | NEW |