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

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: 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
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 state_machine_(scheduler_settings), 80 state_machine_(scheduler_settings),
98 inside_process_scheduled_actions_(false), 81 inside_process_scheduled_actions_(false),
99 inside_action_(SchedulerStateMachine::ACTION_NONE), 82 inside_action_(SchedulerStateMachine::ACTION_NONE),
100 weak_factory_(this) { 83 weak_factory_(this) {
101 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 84 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
102 "Scheduler::Scheduler", 85 "Scheduler::Scheduler",
(...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() { 156 void Scheduler::UpdateActiveFrameSource() {
brianderson 2015/04/01 21:58:08 Delete?
mithro-old 2015/04/02 01:03:59 Done.
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_);
jdduke (slow) 2015/04/01 19:21:21 Why not set the active source to null if we're inv
mithro-old 2015/04/02 01:03:59 The approach I took was to make scheduler understa
185 }
186 ProcessScheduledActions();
187 } 157 }
188 158
189 void Scheduler::SetVisible(bool visible) { 159 void Scheduler::SetVisible(bool visible) {
190 state_machine_.SetVisible(visible); 160 state_machine_.SetVisible(visible);
191 UpdateActiveFrameSource(); 161 ProcessScheduledActions();
192 } 162 }
193 163
194 void Scheduler::SetCanDraw(bool can_draw) { 164 void Scheduler::SetCanDraw(bool can_draw) {
195 state_machine_.SetCanDraw(can_draw); 165 state_machine_.SetCanDraw(can_draw);
196 ProcessScheduledActions(); 166 ProcessScheduledActions();
197 } 167 }
198 168
199 void Scheduler::NotifyReadyToActivate() { 169 void Scheduler::NotifyReadyToActivate() {
200 state_machine_.NotifyReadyToActivate(); 170 state_machine_.NotifyReadyToActivate();
201 ProcessScheduledActions(); 171 ProcessScheduledActions();
202 } 172 }
203 173
204 void Scheduler::NotifyReadyToDraw() { 174 void Scheduler::NotifyReadyToDraw() {
205 // Empty for now, until we take action based on the notification as part of 175 // Empty for now, until we take action based on the notification as part of
206 // crbugs 352894, 383157, 421923. 176 // crbugs 352894, 383157, 421923.
207 } 177 }
208 178
209 void Scheduler::SetThrottleFrameProduction(bool throttle) { 179 void Scheduler::SetThrottleFrameProduction(bool throttle) {
210 throttle_frame_production_ = throttle; 180 throttle_frame_production_ = throttle;
211 UpdateActiveFrameSource(); 181 if (throttle) {
182 frame_source_->SetActiveSource(primary_frame_source_);
183 } else {
184 frame_source_->SetActiveSource(unthrottled_frame_source_);
185 }
186 ProcessScheduledActions();
212 } 187 }
213 188
214 void Scheduler::SetNeedsCommit() { 189 void Scheduler::SetNeedsCommit() {
215 state_machine_.SetNeedsCommit(); 190 state_machine_.SetNeedsCommit();
216 ProcessScheduledActions(); 191 ProcessScheduledActions();
217 } 192 }
218 193
219 void Scheduler::SetNeedsRedraw() { 194 void Scheduler::SetNeedsRedraw() {
220 state_machine_.SetNeedsRedraw(); 195 state_machine_.SetNeedsRedraw();
221 ProcessScheduledActions(); 196 ProcessScheduledActions();
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 } 817 }
843 818
844 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 819 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
845 return (state_machine_.commit_state() == 820 return (state_machine_.commit_state() ==
846 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 821 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
847 state_machine_.commit_state() == 822 state_machine_.commit_state() ==
848 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 823 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
849 } 824 }
850 825
851 } // namespace cc 826 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698