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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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/resources/task_graph_runner.cc ('k') | cc/scheduler/scheduler.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 #ifndef CC_SCHEDULER_SCHEDULER_H_ 5 #ifndef CC_SCHEDULER_SCHEDULER_H_
6 #define CC_SCHEDULER_SCHEDULER_H_ 6 #define CC_SCHEDULER_SCHEDULER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/cancelable_callback.h" 12 #include "base/cancelable_callback.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/power_monitor/power_monitor.h"
15 #include "base/power_monitor/power_observer.h"
16 #include "base/time/time.h" 14 #include "base/time/time.h"
17 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
18 #include "cc/output/begin_frame_args.h" 16 #include "cc/output/begin_frame_args.h"
19 #include "cc/output/vsync_parameter_observer.h" 17 #include "cc/output/vsync_parameter_observer.h"
20 #include "cc/scheduler/begin_frame_source.h" 18 #include "cc/scheduler/begin_frame_source.h"
21 #include "cc/scheduler/delay_based_time_source.h" 19 #include "cc/scheduler/delay_based_time_source.h"
22 #include "cc/scheduler/draw_result.h" 20 #include "cc/scheduler/draw_result.h"
23 #include "cc/scheduler/scheduler_settings.h" 21 #include "cc/scheduler/scheduler_settings.h"
24 #include "cc/scheduler/scheduler_state_machine.h" 22 #include "cc/scheduler/scheduler_state_machine.h"
25 23
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Scheduler* scheduler); 66 Scheduler* scheduler);
69 virtual BeginFrameSource* ConstructUnthrottledFrameSource( 67 virtual BeginFrameSource* ConstructUnthrottledFrameSource(
70 Scheduler* scheduler); 68 Scheduler* scheduler);
71 69
72 protected: 70 protected:
73 SchedulerFrameSourcesConstructor() {} 71 SchedulerFrameSourcesConstructor() {}
74 72
75 friend class Scheduler; 73 friend class Scheduler;
76 }; 74 };
77 75
78 class CC_EXPORT Scheduler : public BeginFrameObserverMixIn, 76 class CC_EXPORT Scheduler : public BeginFrameObserverMixIn {
79 public base::PowerObserver {
80 public: 77 public:
81 static scoped_ptr<Scheduler> Create( 78 static scoped_ptr<Scheduler> Create(
82 SchedulerClient* client, 79 SchedulerClient* client,
83 const SchedulerSettings& scheduler_settings, 80 const SchedulerSettings& scheduler_settings,
84 int layer_tree_host_id, 81 int layer_tree_host_id,
85 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 82 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
86 base::PowerMonitor* power_monitor,
87 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 83 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
88 SchedulerFrameSourcesConstructor frame_sources_constructor; 84 SchedulerFrameSourcesConstructor frame_sources_constructor;
89 return make_scoped_ptr(new Scheduler(client, 85 return make_scoped_ptr(new Scheduler(client,
90 scheduler_settings, 86 scheduler_settings,
91 layer_tree_host_id, 87 layer_tree_host_id,
92 task_runner, 88 task_runner,
93 power_monitor,
94 external_begin_frame_source.Pass(), 89 external_begin_frame_source.Pass(),
95 &frame_sources_constructor)); 90 &frame_sources_constructor));
96 } 91 }
97 92
98 ~Scheduler() override; 93 ~Scheduler() override;
99 94
100 // BeginFrameObserverMixin 95 // BeginFrameObserverMixin
101 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override; 96 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override;
102 97
103 // base::PowerObserver method.
104 void OnPowerStateChange(bool on_battery_power) override;
105
106 const SchedulerSettings& settings() const { return settings_; } 98 const SchedulerSettings& settings() const { return settings_; }
107 99
108 void CommitVSyncParameters(base::TimeTicks timebase, 100 void CommitVSyncParameters(base::TimeTicks timebase,
109 base::TimeDelta interval); 101 base::TimeDelta interval);
110 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); 102 void SetEstimatedParentDrawTime(base::TimeDelta draw_time);
111 103
112 void SetCanStart(); 104 void SetCanStart();
113 105
114 void SetVisible(bool visible); 106 void SetVisible(bool visible);
115 void SetCanDraw(bool can_draw); 107 void SetCanDraw(bool can_draw);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 state_machine_.SetContinuousPainting(continuous_painting); 164 state_machine_.SetContinuousPainting(continuous_painting);
173 } 165 }
174 166
175 void SetChildrenNeedBeginFrames(bool children_need_begin_frames); 167 void SetChildrenNeedBeginFrames(bool children_need_begin_frames);
176 168
177 protected: 169 protected:
178 Scheduler(SchedulerClient* client, 170 Scheduler(SchedulerClient* client,
179 const SchedulerSettings& scheduler_settings, 171 const SchedulerSettings& scheduler_settings,
180 int layer_tree_host_id, 172 int layer_tree_host_id,
181 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 173 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
182 base::PowerMonitor* power_monitor,
183 scoped_ptr<BeginFrameSource> external_begin_frame_source, 174 scoped_ptr<BeginFrameSource> external_begin_frame_source,
184 SchedulerFrameSourcesConstructor* frame_sources_constructor); 175 SchedulerFrameSourcesConstructor* frame_sources_constructor);
185 176
186 // virtual for testing - Don't call these in the constructor or 177 // virtual for testing - Don't call these in the constructor or
187 // destructor! 178 // destructor!
188 virtual base::TimeTicks Now() const; 179 virtual base::TimeTicks Now() const;
189 180
190 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; 181 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
191 BeginFrameSource* primary_frame_source_; 182 BeginFrameSource* primary_frame_source_;
192 BeginFrameSource* background_frame_source_; 183 BeginFrameSource* background_frame_source_;
193 BeginFrameSource* unthrottled_frame_source_; 184 BeginFrameSource* unthrottled_frame_source_;
194 185
195 // Storage when frame sources are internal 186 // Storage when frame sources are internal
196 scoped_ptr<BeginFrameSource> primary_frame_source_internal_; 187 scoped_ptr<BeginFrameSource> primary_frame_source_internal_;
197 scoped_ptr<SyntheticBeginFrameSource> background_frame_source_internal_; 188 scoped_ptr<SyntheticBeginFrameSource> background_frame_source_internal_;
198 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_; 189 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_;
199 190
200 VSyncParameterObserver* vsync_observer_; 191 VSyncParameterObserver* vsync_observer_;
201 bool throttle_frame_production_; 192 bool throttle_frame_production_;
202 193
203 const SchedulerSettings settings_; 194 const SchedulerSettings settings_;
204 SchedulerClient* client_; 195 SchedulerClient* client_;
205 int layer_tree_host_id_; 196 int layer_tree_host_id_;
206 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 197 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
207 198
208 base::PowerMonitor* power_monitor_;
209
210 base::TimeDelta estimated_parent_draw_time_; 199 base::TimeDelta estimated_parent_draw_time_;
211 200
212 std::deque<BeginFrameArgs> begin_retro_frame_args_; 201 std::deque<BeginFrameArgs> begin_retro_frame_args_;
213 BeginFrameArgs begin_impl_frame_args_; 202 BeginFrameArgs begin_impl_frame_args_;
214 SchedulerStateMachine::BeginImplFrameDeadlineMode 203 SchedulerStateMachine::BeginImplFrameDeadlineMode
215 begin_impl_frame_deadline_mode_; 204 begin_impl_frame_deadline_mode_;
216 205
217 base::Closure begin_retro_frame_closure_; 206 base::Closure begin_retro_frame_closure_;
218 base::Closure begin_impl_frame_deadline_closure_; 207 base::Closure begin_impl_frame_deadline_closure_;
219 base::Closure poll_for_draw_triggers_closure_; 208 base::Closure poll_for_draw_triggers_closure_;
(...skipping 16 matching lines...) Expand all
236 void DrawAndSwapIfPossible(); 225 void DrawAndSwapIfPossible();
237 void ProcessScheduledActions(); 226 void ProcessScheduledActions();
238 bool CanCommitAndActivateBeforeDeadline() const; 227 bool CanCommitAndActivateBeforeDeadline() const;
239 void AdvanceCommitStateIfPossible(); 228 void AdvanceCommitStateIfPossible();
240 bool IsBeginMainFrameSentOrStarted() const; 229 bool IsBeginMainFrameSentOrStarted() const;
241 void BeginRetroFrame(); 230 void BeginRetroFrame();
242 void BeginImplFrame(const BeginFrameArgs& args); 231 void BeginImplFrame(const BeginFrameArgs& args);
243 void OnBeginImplFrameDeadline(); 232 void OnBeginImplFrameDeadline();
244 void PollForAnticipatedDrawTriggers(); 233 void PollForAnticipatedDrawTriggers();
245 void PollToAdvanceCommitState(); 234 void PollToAdvanceCommitState();
246 void SetupPowerMonitoring();
247 void TeardownPowerMonitoring();
248 void UpdateActiveFrameSource(); 235 void UpdateActiveFrameSource();
249 236
250 base::TimeDelta EstimatedParentDrawTime() { 237 base::TimeDelta EstimatedParentDrawTime() {
251 return estimated_parent_draw_time_; 238 return estimated_parent_draw_time_;
252 } 239 }
253 240
254 bool IsInsideAction(SchedulerStateMachine::Action action) { 241 bool IsInsideAction(SchedulerStateMachine::Action action) {
255 return inside_action_ == action; 242 return inside_action_ == action;
256 } 243 }
257 244
258 base::WeakPtrFactory<Scheduler> weak_factory_; 245 base::WeakPtrFactory<Scheduler> weak_factory_;
259 246
260 friend class SchedulerFrameSourcesConstructor; 247 friend class SchedulerFrameSourcesConstructor;
261 friend class TestSchedulerFrameSourcesConstructor; 248 friend class TestSchedulerFrameSourcesConstructor;
262 249
263 DISALLOW_COPY_AND_ASSIGN(Scheduler); 250 DISALLOW_COPY_AND_ASSIGN(Scheduler);
264 }; 251 };
265 252
266 } // namespace cc 253 } // namespace cc
267 254
268 #endif // CC_SCHEDULER_SCHEDULER_H_ 255 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW
« no previous file with comments | « cc/resources/task_graph_runner.cc ('k') | cc/scheduler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698