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

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

Issue 723713003: cc: Add SetChildrenNeedBeginFrames() & SendBeginFramesToChildren() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 can_draw_(false), 42 can_draw_(false),
43 has_pending_tree_(false), 43 has_pending_tree_(false),
44 pending_tree_is_ready_for_activation_(false), 44 pending_tree_is_ready_for_activation_(false),
45 active_tree_needs_first_draw_(false), 45 active_tree_needs_first_draw_(false),
46 did_commit_after_animating_(false), 46 did_commit_after_animating_(false),
47 did_create_and_initialize_first_output_surface_(false), 47 did_create_and_initialize_first_output_surface_(false),
48 impl_latency_takes_priority_(false), 48 impl_latency_takes_priority_(false),
49 skip_next_begin_main_frame_to_reduce_latency_(false), 49 skip_next_begin_main_frame_to_reduce_latency_(false),
50 skip_begin_main_frame_to_reduce_latency_(false), 50 skip_begin_main_frame_to_reduce_latency_(false),
51 continuous_painting_(false), 51 continuous_painting_(false),
52 impl_latency_takes_priority_on_battery_(false) { 52 impl_latency_takes_priority_on_battery_(false),
53 children_need_begin_frames_(false) {
53 } 54 }
54 55
55 const char* SchedulerStateMachine::OutputSurfaceStateToString( 56 const char* SchedulerStateMachine::OutputSurfaceStateToString(
56 OutputSurfaceState state) { 57 OutputSurfaceState state) {
57 switch (state) { 58 switch (state) {
58 case OUTPUT_SURFACE_ACTIVE: 59 case OUTPUT_SURFACE_ACTIVE:
59 return "OUTPUT_SURFACE_ACTIVE"; 60 return "OUTPUT_SURFACE_ACTIVE";
60 case OUTPUT_SURFACE_LOST: 61 case OUTPUT_SURFACE_LOST:
61 return "OUTPUT_SURFACE_LOST"; 62 return "OUTPUT_SURFACE_LOST";
62 case OUTPUT_SURFACE_CREATING: 63 case OUTPUT_SURFACE_CREATING:
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 impl_latency_takes_priority_); 235 impl_latency_takes_priority_);
235 state->SetBoolean("main_thread_is_in_high_latency_mode", 236 state->SetBoolean("main_thread_is_in_high_latency_mode",
236 MainThreadIsInHighLatencyMode()); 237 MainThreadIsInHighLatencyMode());
237 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", 238 state->SetBoolean("skip_begin_main_frame_to_reduce_latency",
238 skip_begin_main_frame_to_reduce_latency_); 239 skip_begin_main_frame_to_reduce_latency_);
239 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", 240 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
240 skip_next_begin_main_frame_to_reduce_latency_); 241 skip_next_begin_main_frame_to_reduce_latency_);
241 state->SetBoolean("continuous_painting", continuous_painting_); 242 state->SetBoolean("continuous_painting", continuous_painting_);
242 state->SetBoolean("impl_latency_takes_priority_on_battery", 243 state->SetBoolean("impl_latency_takes_priority_on_battery",
243 impl_latency_takes_priority_on_battery_); 244 impl_latency_takes_priority_on_battery_);
245 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_);
244 state->EndDictionary(); 246 state->EndDictionary();
245 } 247 }
246 248
247 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { 249 void SchedulerStateMachine::AdvanceCurrentFrameNumber() {
248 current_frame_number_++; 250 current_frame_number_++;
249 251
250 // "Drain" the ManageTiles funnel. 252 // "Drain" the ManageTiles funnel.
251 if (manage_tiles_funnel_ > 0) 253 if (manage_tiles_funnel_ > 0)
252 manage_tiles_funnel_--; 254 manage_tiles_funnel_--;
253 255
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 needs_manage_tiles_ = false; 714 needs_manage_tiles_ = false;
713 } 715 }
714 716
715 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 717 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
716 TRACE_EVENT_INSTANT0("cc", 718 TRACE_EVENT_INSTANT0("cc",
717 "Scheduler: SkipNextBeginMainFrameToReduceLatency", 719 "Scheduler: SkipNextBeginMainFrameToReduceLatency",
718 TRACE_EVENT_SCOPE_THREAD); 720 TRACE_EVENT_SCOPE_THREAD);
719 skip_next_begin_main_frame_to_reduce_latency_ = true; 721 skip_next_begin_main_frame_to_reduce_latency_ = true;
720 } 722 }
721 723
724 bool SchedulerStateMachine::BeginFrameNeededForChildren() const {
725 if (HasInitializedOutputSurface())
726 return children_need_begin_frames_;
727
728 return false;
729 }
730
722 bool SchedulerStateMachine::BeginFrameNeeded() const { 731 bool SchedulerStateMachine::BeginFrameNeeded() const {
732 if (SupportsProactiveBeginFrame())
brianderson 2014/11/21 02:08:05 Please use brackets here.
simonhong 2014/11/21 15:42:53 Done.
733 return (BeginFrameNeededToAnimateOrDraw() ||
734 BeginFrameNeededForChildren() ||
735 ProactiveBeginFrameWanted());
736
723 // Proactive BeginFrames are bad for the synchronous compositor because we 737 // Proactive BeginFrames are bad for the synchronous compositor because we
724 // have to draw when we get the BeginFrame and could end up drawing many 738 // have to draw when we get the BeginFrame and could end up drawing many
725 // duplicate frames if our new frame isn't ready in time. 739 // duplicate frames if our new frame isn't ready in time.
726 // To poll for state with the synchronous compositor without having to draw, 740 // To poll for state with the synchronous compositor without having to draw,
727 // we rely on ShouldPollForAnticipatedDrawTriggers instead. 741 // we rely on ShouldPollForAnticipatedDrawTriggers instead.
728 if (!SupportsProactiveBeginFrame()) 742 // Synchronous compositor doesn't have a browser.
729 return BeginFrameNeededToAnimateOrDraw(); 743 DCHECK(!children_need_begin_frames_);
730 744 return BeginFrameNeededToAnimateOrDraw();
731 return BeginFrameNeededToAnimateOrDraw() || ProactiveBeginFrameWanted();
732 } 745 }
733 746
734 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { 747 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const {
735 // ShouldPollForAnticipatedDrawTriggers is what we use in place of 748 // ShouldPollForAnticipatedDrawTriggers is what we use in place of
736 // ProactiveBeginFrameWanted when we are using the synchronous 749 // ProactiveBeginFrameWanted when we are using the synchronous
737 // compositor. 750 // compositor.
738 if (!SupportsProactiveBeginFrame()) { 751 if (!SupportsProactiveBeginFrame()) {
739 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted(); 752 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted();
740 } 753 }
741 754
742 // Non synchronous compositors should rely on 755 // Non synchronous compositors should rely on
743 // ProactiveBeginFrameWanted to poll for state instead. 756 // ProactiveBeginFrameWanted to poll for state instead.
744 return false; 757 return false;
745 } 758 }
746 759
747 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll 760 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll
748 // for changes in it's draw state so it can request a BeginFrame when it's 761 // for changes in it's draw state so it can request a BeginFrame when it's
749 // actually ready. 762 // actually ready.
750 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { 763 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const {
751 // It is undesirable to proactively request BeginFrames if we are 764 // It is undesirable to proactively request BeginFrames if we are
752 // using a synchronous compositor because we *must* draw for every 765 // using a synchronous compositor because we *must* draw for every
753 // BeginFrame, which could cause duplicate draws. 766 // BeginFrame, which could cause duplicate draws.
754 return !settings_.using_synchronous_renderer_compositor; 767 return !settings_.using_synchronous_renderer_compositor;
755 } 768 }
756 769
770 void SchedulerStateMachine::SetChildrenNeedBeginFrames(
771 bool children_need_begin_frames) {
772 DCHECK(settings_.forward_begin_frames_to_children);
773 children_need_begin_frames_ = children_need_begin_frames;
774 }
775
757 // These are the cases where we definitely (or almost definitely) have a 776 // These are the cases where we definitely (or almost definitely) have a
758 // new frame to animate and/or draw and can draw. 777 // new frame to animate and/or draw and can draw.
759 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { 778 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const {
760 // The output surface is the provider of BeginImplFrames, so we are not going 779 // The output surface is the provider of BeginImplFrames, so we are not going
761 // to get them even if we ask for them. 780 // to get them even if we ask for them.
762 if (!HasInitializedOutputSurface()) 781 if (!HasInitializedOutputSurface())
763 return false; 782 return false;
764 783
765 // The forced draw respects our normal draw scheduling, so we need to 784 // The forced draw respects our normal draw scheduling, so we need to
766 // request a BeginImplFrame for it. 785 // request a BeginImplFrame for it.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 static_cast<int>(begin_impl_frame_state_), 1120 static_cast<int>(begin_impl_frame_state_),
1102 static_cast<int>(commit_state_), 1121 static_cast<int>(commit_state_),
1103 has_pending_tree_ ? 'T' : 'F', 1122 has_pending_tree_ ? 'T' : 'F',
1104 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1123 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1105 active_tree_needs_first_draw_ ? 'T' : 'F', 1124 active_tree_needs_first_draw_ ? 'T' : 'F',
1106 max_pending_swaps_, 1125 max_pending_swaps_,
1107 pending_swaps_); 1126 pending_swaps_);
1108 } 1127 }
1109 1128
1110 } // namespace cc 1129 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698