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

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

Issue 1050833002: cc: Remove background ticking from LTHI. (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.h ('k') | cc/scheduler/scheduler_state_machine.cc » ('j') | 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.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 DCHECK(!scheduler->vsync_observer_); 42 DCHECK(!scheduler->vsync_observer_);
43 scheduler->vsync_observer_ = synthetic_source.get(); 43 scheduler->vsync_observer_ = synthetic_source.get();
44 44
45 DCHECK(!scheduler->primary_frame_source_internal_); 45 DCHECK(!scheduler->primary_frame_source_internal_);
46 scheduler->primary_frame_source_internal_ = synthetic_source.Pass(); 46 scheduler->primary_frame_source_internal_ = synthetic_source.Pass();
47 return scheduler->primary_frame_source_internal_.get(); 47 return scheduler->primary_frame_source_internal_.get();
48 } 48 }
49 } 49 }
50 50
51 BeginFrameSource* 51 BeginFrameSource*
52 SchedulerFrameSourcesConstructor::ConstructBackgroundFrameSource(
53 Scheduler* scheduler) {
54 TRACE_EVENT1("cc",
55 "Scheduler::Scheduler()",
56 "BackgroundFrameSource",
57 "SyntheticBeginFrameSource");
58 DCHECK(!(scheduler->background_frame_source_internal_));
59 scheduler->background_frame_source_internal_ =
60 SyntheticBeginFrameSource::Create(
61 scheduler->task_runner_.get(), scheduler->Now(),
62 scheduler->settings_.background_frame_interval);
63 return scheduler->background_frame_source_internal_.get();
64 }
65
66 BeginFrameSource*
67 SchedulerFrameSourcesConstructor::ConstructUnthrottledFrameSource( 52 SchedulerFrameSourcesConstructor::ConstructUnthrottledFrameSource(
68 Scheduler* scheduler) { 53 Scheduler* scheduler) {
69 TRACE_EVENT1("cc", "Scheduler::Scheduler()", "UnthrottledFrameSource", 54 TRACE_EVENT1("cc", "Scheduler::Scheduler()", "UnthrottledFrameSource",
70 "BackToBackBeginFrameSource"); 55 "BackToBackBeginFrameSource");
71 DCHECK(!scheduler->unthrottled_frame_source_internal_); 56 DCHECK(!scheduler->unthrottled_frame_source_internal_);
72 scheduler->unthrottled_frame_source_internal_ = 57 scheduler->unthrottled_frame_source_internal_ =
73 BackToBackBeginFrameSource::Create(scheduler->task_runner_.get()); 58 BackToBackBeginFrameSource::Create(scheduler->task_runner_.get());
74 return scheduler->unthrottled_frame_source_internal_.get(); 59 return scheduler->unthrottled_frame_source_internal_.get();
75 } 60 }
76 61
77 Scheduler::Scheduler( 62 Scheduler::Scheduler(
78 SchedulerClient* client, 63 SchedulerClient* client,
79 const SchedulerSettings& scheduler_settings, 64 const SchedulerSettings& scheduler_settings,
80 int layer_tree_host_id, 65 int layer_tree_host_id,
81 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 66 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
82 scoped_ptr<BeginFrameSource> external_begin_frame_source, 67 scoped_ptr<BeginFrameSource> external_begin_frame_source,
83 SchedulerFrameSourcesConstructor* frame_sources_constructor) 68 SchedulerFrameSourcesConstructor* frame_sources_constructor)
84 : frame_source_(), 69 : frame_source_(),
85 primary_frame_source_(NULL), 70 primary_frame_source_(NULL),
86 background_frame_source_(NULL),
87 primary_frame_source_internal_(external_begin_frame_source.Pass()), 71 primary_frame_source_internal_(external_begin_frame_source.Pass()),
88 background_frame_source_internal_(),
89 vsync_observer_(NULL), 72 vsync_observer_(NULL),
90 authoritative_vsync_interval_(base::TimeDelta()), 73 authoritative_vsync_interval_(base::TimeDelta()),
91 last_vsync_timebase_(base::TimeTicks()), 74 last_vsync_timebase_(base::TimeTicks()),
92 throttle_frame_production_(scheduler_settings.throttle_frame_production), 75 throttle_frame_production_(false),
93 settings_(scheduler_settings), 76 settings_(scheduler_settings),
94 client_(client), 77 client_(client),
95 layer_tree_host_id_(layer_tree_host_id), 78 layer_tree_host_id_(layer_tree_host_id),
96 task_runner_(task_runner), 79 task_runner_(task_runner),
97 begin_impl_frame_deadline_mode_( 80 begin_impl_frame_deadline_mode_(
98 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), 81 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE),
99 state_machine_(scheduler_settings), 82 state_machine_(scheduler_settings),
100 inside_process_scheduled_actions_(false), 83 inside_process_scheduled_actions_(false),
101 inside_action_(SchedulerStateMachine::ACTION_NONE), 84 inside_action_(SchedulerStateMachine::ACTION_NONE),
102 weak_factory_(this) { 85 weak_factory_(this) {
(...skipping 13 matching lines...) Expand all
116 99
117 frame_source_ = BeginFrameSourceMultiplexer::Create(); 100 frame_source_ = BeginFrameSourceMultiplexer::Create();
118 frame_source_->AddObserver(this); 101 frame_source_->AddObserver(this);
119 102
120 // Primary frame source 103 // Primary frame source
121 primary_frame_source_ = 104 primary_frame_source_ =
122 frame_sources_constructor->ConstructPrimaryFrameSource(this); 105 frame_sources_constructor->ConstructPrimaryFrameSource(this);
123 frame_source_->AddSource(primary_frame_source_); 106 frame_source_->AddSource(primary_frame_source_);
124 primary_frame_source_->SetClientReady(); 107 primary_frame_source_->SetClientReady();
125 108
126 // Background ticking frame source
127 background_frame_source_ =
128 frame_sources_constructor->ConstructBackgroundFrameSource(this);
129 frame_source_->AddSource(background_frame_source_);
130
131 // Unthrottled frame source 109 // Unthrottled frame source
132 unthrottled_frame_source_ = 110 unthrottled_frame_source_ =
133 frame_sources_constructor->ConstructUnthrottledFrameSource(this); 111 frame_sources_constructor->ConstructUnthrottledFrameSource(this);
134 frame_source_->AddSource(unthrottled_frame_source_); 112 frame_source_->AddSource(unthrottled_frame_source_);
113
114 SetThrottleFrameProduction(scheduler_settings.throttle_frame_production);
135 } 115 }
136 116
137 Scheduler::~Scheduler() { 117 Scheduler::~Scheduler() {
138 if (frame_source_->NeedsBeginFrames()) 118 if (frame_source_->NeedsBeginFrames())
139 frame_source_->SetNeedsBeginFrames(false); 119 frame_source_->SetNeedsBeginFrames(false);
140 } 120 }
141 121
142 base::TimeTicks Scheduler::Now() const { 122 base::TimeTicks Scheduler::Now() const {
143 base::TimeTicks now = gfx::FrameTime::Now(); 123 base::TimeTicks now = gfx::FrameTime::Now();
144 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), 124 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"),
(...skipping 21 matching lines...) Expand all
166 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 146 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
167 DCHECK_GE(draw_time.ToInternalValue(), 0); 147 DCHECK_GE(draw_time.ToInternalValue(), 0);
168 estimated_parent_draw_time_ = draw_time; 148 estimated_parent_draw_time_ = draw_time;
169 } 149 }
170 150
171 void Scheduler::SetCanStart() { 151 void Scheduler::SetCanStart() {
172 state_machine_.SetCanStart(); 152 state_machine_.SetCanStart();
173 ProcessScheduledActions(); 153 ProcessScheduledActions();
174 } 154 }
175 155
176 void Scheduler::UpdateActiveFrameSource() {
177 if (state_machine_.visible()) {
178 if (throttle_frame_production_) {
179 frame_source_->SetActiveSource(primary_frame_source_);
180 } else {
181 frame_source_->SetActiveSource(unthrottled_frame_source_);
182 }
183 } else {
184 frame_source_->SetActiveSource(background_frame_source_);
185 }
186 ProcessScheduledActions();
187 }
188
189 void Scheduler::SetVisible(bool visible) { 156 void Scheduler::SetVisible(bool visible) {
190 state_machine_.SetVisible(visible); 157 state_machine_.SetVisible(visible);
191 UpdateActiveFrameSource(); 158 ProcessScheduledActions();
192 } 159 }
193 160
194 void Scheduler::SetCanDraw(bool can_draw) { 161 void Scheduler::SetCanDraw(bool can_draw) {
195 state_machine_.SetCanDraw(can_draw); 162 state_machine_.SetCanDraw(can_draw);
196 ProcessScheduledActions(); 163 ProcessScheduledActions();
197 } 164 }
198 165
199 void Scheduler::NotifyReadyToActivate() { 166 void Scheduler::NotifyReadyToActivate() {
200 state_machine_.NotifyReadyToActivate(); 167 state_machine_.NotifyReadyToActivate();
201 ProcessScheduledActions(); 168 ProcessScheduledActions();
202 } 169 }
203 170
204 void Scheduler::NotifyReadyToDraw() { 171 void Scheduler::NotifyReadyToDraw() {
205 // Future work might still needed for crbug.com/352894. 172 // Future work might still needed for crbug.com/352894.
206 state_machine_.NotifyReadyToDraw(); 173 state_machine_.NotifyReadyToDraw();
207 ProcessScheduledActions(); 174 ProcessScheduledActions();
208 } 175 }
209 176
210 void Scheduler::SetThrottleFrameProduction(bool throttle) { 177 void Scheduler::SetThrottleFrameProduction(bool throttle) {
211 throttle_frame_production_ = throttle; 178 throttle_frame_production_ = throttle;
212 UpdateActiveFrameSource(); 179 if (throttle) {
180 frame_source_->SetActiveSource(primary_frame_source_);
181 } else {
182 frame_source_->SetActiveSource(unthrottled_frame_source_);
183 }
184 ProcessScheduledActions();
213 } 185 }
214 186
215 void Scheduler::SetNeedsCommit() { 187 void Scheduler::SetNeedsCommit() {
216 state_machine_.SetNeedsCommit(); 188 state_machine_.SetNeedsCommit();
217 ProcessScheduledActions(); 189 ProcessScheduledActions();
218 } 190 }
219 191
220 void Scheduler::SetNeedsRedraw() { 192 void Scheduler::SetNeedsRedraw() {
221 state_machine_.SetNeedsRedraw(); 193 state_machine_.SetNeedsRedraw();
222 ProcessScheduledActions(); 194 ProcessScheduledActions();
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 824 }
853 825
854 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 826 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
855 return (state_machine_.commit_state() == 827 return (state_machine_.commit_state() ==
856 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 828 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
857 state_machine_.commit_state() == 829 state_machine_.commit_state() ==
858 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 830 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
859 } 831 }
860 832
861 } // namespace cc 833 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_state_machine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698