Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: cc/scheduler/scheduler_state_machine.cc

Issue 792803008: cc: Split out BeginFrame needed verse proactive for commits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto master. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 current_frame_number_; 713 current_frame_number_;
714 } 714 }
715 715
716 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 716 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
717 TRACE_EVENT_INSTANT0("cc", 717 TRACE_EVENT_INSTANT0("cc",
718 "Scheduler: SkipNextBeginMainFrameToReduceLatency", 718 "Scheduler: SkipNextBeginMainFrameToReduceLatency",
719 TRACE_EVENT_SCOPE_THREAD); 719 TRACE_EVENT_SCOPE_THREAD);
720 skip_next_begin_main_frame_to_reduce_latency_ = true; 720 skip_next_begin_main_frame_to_reduce_latency_ = true;
721 } 721 }
722 722
723 bool SchedulerStateMachine::BeginFrameNeededForChildren() 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 return (BeginFrameNeededToAnimateOrDraw() || BeginFrameNeededForChildren() || 732 return (BeginFrameRequiredForAction() || BeginFrameRequiredForChildren() ||
733 ProactiveBeginFrameWanted()); 733 ProactiveBeginFrameWanted());
734 } 734 }
735 735
736 void SchedulerStateMachine::SetChildrenNeedBeginFrames( 736 void SchedulerStateMachine::SetChildrenNeedBeginFrames(
737 bool children_need_begin_frames) { 737 bool children_need_begin_frames) {
738 children_need_begin_frames_ = children_need_begin_frames; 738 children_need_begin_frames_ = children_need_begin_frames;
739 } 739 }
740 740
741 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { 741 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) {
742 defer_commits_ = defer_commits; 742 defer_commits_ = defer_commits;
743 } 743 }
744 744
745 // These are the cases where we definitely (or almost definitely) have a 745 // These are the cases where we require a BeginFrame message to make progress
746 // new frame to animate and/or draw and can draw. 746 // on requested actions.
747 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { 747 bool SchedulerStateMachine::BeginFrameRequiredForAction() const {
748 // The forced draw respects our normal draw scheduling, so we need to 748 // The forced draw respects our normal draw scheduling, so we need to
749 // request a BeginImplFrame for it. 749 // request a BeginImplFrame for it.
750 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 750 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
751 return true; 751 return true;
752 752
753 // TODO(mithro): Remove background animation ticking. crbug.com/371747 753 // TODO(mithro): Remove background animation ticking. crbug.com/371747
754 if (needs_animate_) 754 if (needs_animate_)
755 return true; 755 return true;
756 756
757 // Only background tick for animations - not draws, which will never happen. 757 // Only background tick for animations - not draws, which will never happen.
758 if (!visible_) 758 if (!visible_)
759 return false; 759 return false;
760 760
761 return needs_redraw_; 761 return needs_redraw_ || (needs_commit_ && !defer_commits_);
762 } 762 }
763 763
764 // These are cases where we are very likely to draw soon, but might not 764 // These are cases where we are very likely want a BeginFrame message in the
765 // actually have a new frame to draw when we receive the next BeginImplFrame. 765 // near future. Proactively requesting the BeginImplFrame helps hide the round
766 // Proactively requesting the BeginImplFrame helps hide the round trip latency 766 // trip latency of the SetNeedsBeginFrame request that has to go to the
767 // of the SetNeedsBeginFrame request that has to go to the Browser. 767 // Browser.
768 // This includes things like drawing soon, but might not actually have a new
769 // frame to draw when we receive the next BeginImplFrame.
768 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { 770 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
769 // Do not be proactive when invisible. 771 // Do not be proactive when invisible.
770 if (!visible_) 772 if (!visible_)
771 return false; 773 return false;
772 774
773 // We should proactively request a BeginImplFrame if a commit is pending 775 // We should proactively request a BeginImplFrame if a commit is pending
774 // because we will want to draw if the commit completes quickly. Do not 776 // because we will want to draw if the commit completes quickly. Do not
775 // request frames when commits are disabled, because the frame requests will 777 // request frames when commits are disabled, because the frame requests will
776 // not provide the needed commit (and will wake up the process when it could 778 // not provide the needed commit (and will wake up the process when it could
777 // stay idle). 779 // stay idle).
778 if ((needs_commit_ || commit_state_ != COMMIT_STATE_IDLE) && !defer_commits_) 780 if ((commit_state_ != COMMIT_STATE_IDLE) && !defer_commits_)
779 return true; 781 return true;
780 782
781 // If the pending tree activates quickly, we'll want a BeginImplFrame soon 783 // If the pending tree activates quickly, we'll want a BeginImplFrame soon
782 // to draw the new active tree. 784 // to draw the new active tree.
783 if (has_pending_tree_) 785 if (has_pending_tree_)
784 return true; 786 return true;
785 787
786 // Changing priorities may allow us to activate (given the new priorities), 788 // Changing priorities may allow us to activate (given the new priorities),
787 // which may result in a new frame. 789 // which may result in a new frame.
788 if (needs_prepare_tiles_) 790 if (needs_prepare_tiles_)
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 static_cast<int>(begin_impl_frame_state_), 1127 static_cast<int>(begin_impl_frame_state_),
1126 static_cast<int>(commit_state_), 1128 static_cast<int>(commit_state_),
1127 has_pending_tree_ ? 'T' : 'F', 1129 has_pending_tree_ ? 'T' : 'F',
1128 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1130 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1129 active_tree_needs_first_draw_ ? 'T' : 'F', 1131 active_tree_needs_first_draw_ ? 'T' : 'F',
1130 max_pending_swaps_, 1132 max_pending_swaps_,
1131 pending_swaps_); 1133 pending_swaps_);
1132 } 1134 }
1133 1135
1134 } // namespace cc 1136 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698