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

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

Issue 1201573002: cc: Remove BeginFrameSourcesConstructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 #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/time/time.h" 14 #include "base/time/time.h"
15 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
16 #include "cc/output/begin_frame_args.h" 16 #include "cc/output/begin_frame_args.h"
17 #include "cc/output/vsync_parameter_observer.h"
18 #include "cc/scheduler/begin_frame_source.h" 17 #include "cc/scheduler/begin_frame_source.h"
19 #include "cc/scheduler/begin_frame_tracker.h" 18 #include "cc/scheduler/begin_frame_tracker.h"
20 #include "cc/scheduler/delay_based_time_source.h" 19 #include "cc/scheduler/delay_based_time_source.h"
21 #include "cc/scheduler/draw_result.h" 20 #include "cc/scheduler/draw_result.h"
22 #include "cc/scheduler/scheduler_settings.h" 21 #include "cc/scheduler/scheduler_settings.h"
23 #include "cc/scheduler/scheduler_state_machine.h" 22 #include "cc/scheduler/scheduler_state_machine.h"
24 23
25 namespace base { 24 namespace base {
26 namespace trace_event { 25 namespace trace_event {
27 class ConvertableToTraceFormat; 26 class ConvertableToTraceFormat;
(...skipping 20 matching lines...) Expand all
48 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0; 47 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0;
49 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; 48 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0;
50 virtual void DidFinishImplFrame() = 0; 49 virtual void DidFinishImplFrame() = 0;
51 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; 50 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0;
52 virtual void SendBeginMainFrameNotExpectedSoon() = 0; 51 virtual void SendBeginMainFrameNotExpectedSoon() = 0;
53 52
54 protected: 53 protected:
55 virtual ~SchedulerClient() {} 54 virtual ~SchedulerClient() {}
56 }; 55 };
57 56
58 class Scheduler;
59 // This class exists to allow tests to override the frame source construction.
60 // A virtual method can't be used as this needs to happen in the constructor
61 // (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why).
62 // This class exists solely long enough to construct the frame sources.
63 class CC_EXPORT SchedulerFrameSourcesConstructor {
64 public:
65 virtual ~SchedulerFrameSourcesConstructor() {}
66 virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler);
67 virtual BeginFrameSource* ConstructUnthrottledFrameSource(
68 Scheduler* scheduler);
69
70 protected:
71 SchedulerFrameSourcesConstructor() {}
72
73 friend class Scheduler;
74 };
75
76 class CC_EXPORT Scheduler : public BeginFrameObserverBase { 57 class CC_EXPORT Scheduler : public BeginFrameObserverBase {
77 public: 58 public:
78 static scoped_ptr<Scheduler> Create( 59 static scoped_ptr<Scheduler> Create(
79 SchedulerClient* client, 60 SchedulerClient* client,
80 const SchedulerSettings& scheduler_settings, 61 const SchedulerSettings& scheduler_settings,
81 int layer_tree_host_id, 62 int layer_tree_host_id,
82 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 63 base::SingleThreadTaskRunner* task_runner,
83 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 64 BeginFrameSource* external_frame_source);
84 SchedulerFrameSourcesConstructor frame_sources_constructor;
85 return make_scoped_ptr(new Scheduler(client,
86 scheduler_settings,
87 layer_tree_host_id,
88 task_runner,
89 external_begin_frame_source.Pass(),
90 &frame_sources_constructor));
91 }
92 65
93 ~Scheduler() override; 66 ~Scheduler() override;
94 67
95 // BeginFrameObserverBase 68 // BeginFrameObserverBase
96 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; 69 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override;
97 70
98 void OnDrawForOutputSurface(); 71 void OnDrawForOutputSurface();
99 72
100 const SchedulerSettings& settings() const { return settings_; } 73 const SchedulerSettings& settings() const { return settings_; }
101 74
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 146
174 void SetChildrenNeedBeginFrames(bool children_need_begin_frames); 147 void SetChildrenNeedBeginFrames(bool children_need_begin_frames);
175 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); 148 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames);
176 149
177 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); 150 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval);
178 151
179 protected: 152 protected:
180 Scheduler(SchedulerClient* client, 153 Scheduler(SchedulerClient* client,
181 const SchedulerSettings& scheduler_settings, 154 const SchedulerSettings& scheduler_settings,
182 int layer_tree_host_id, 155 int layer_tree_host_id,
183 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 156 base::SingleThreadTaskRunner* task_runner,
184 scoped_ptr<BeginFrameSource> external_begin_frame_source, 157 BeginFrameSource* external_frame_source,
185 SchedulerFrameSourcesConstructor* frame_sources_constructor); 158 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source,
159 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source);
186 160
187 // virtual for testing - Don't call these in the constructor or 161 // virtual for testing - Don't call these in the constructor or
188 // destructor! 162 // destructor!
189 virtual base::TimeTicks Now() const; 163 virtual base::TimeTicks Now() const;
190 164
191 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
192 BeginFrameSource* primary_frame_source_;
193 BeginFrameSource* unthrottled_frame_source_;
194
195 // Storage when frame sources are internal
196 scoped_ptr<BeginFrameSource> primary_frame_source_internal_;
197 scoped_ptr<BeginFrameSource> unthrottled_frame_source_internal_;
198
199 VSyncParameterObserver* vsync_observer_;
200 base::TimeDelta authoritative_vsync_interval_;
201 base::TimeTicks last_vsync_timebase_;
202
203 bool throttle_frame_production_;
204
205 const SchedulerSettings settings_; 165 const SchedulerSettings settings_;
206 SchedulerClient* client_; 166 SchedulerClient* client_;
207 int layer_tree_host_id_; 167 int layer_tree_host_id_;
208 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 168 base::SingleThreadTaskRunner* task_runner_;
169 BeginFrameSource* external_frame_source_;
170 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source_;
171 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_;
172
173 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_;
174 bool throttle_frame_production_;
175
176 base::TimeDelta authoritative_vsync_interval_;
177 base::TimeTicks last_vsync_timebase_;
209 178
210 base::TimeDelta estimated_parent_draw_time_; 179 base::TimeDelta estimated_parent_draw_time_;
211 180
212 std::deque<BeginFrameArgs> begin_retro_frame_args_; 181 std::deque<BeginFrameArgs> begin_retro_frame_args_;
213 SchedulerStateMachine::BeginImplFrameDeadlineMode 182 SchedulerStateMachine::BeginImplFrameDeadlineMode
214 begin_impl_frame_deadline_mode_; 183 begin_impl_frame_deadline_mode_;
215 BeginFrameTracker begin_impl_frame_tracker_; 184 BeginFrameTracker begin_impl_frame_tracker_;
216 185
217 base::Closure begin_retro_frame_closure_; 186 base::Closure begin_retro_frame_closure_;
218 base::Closure begin_impl_frame_deadline_closure_; 187 base::Closure begin_impl_frame_deadline_closure_;
(...skipping 26 matching lines...) Expand all
245 void PollToAdvanceCommitState(); 214 void PollToAdvanceCommitState();
246 215
247 base::TimeDelta EstimatedParentDrawTime() { 216 base::TimeDelta EstimatedParentDrawTime() {
248 return estimated_parent_draw_time_; 217 return estimated_parent_draw_time_;
249 } 218 }
250 219
251 bool IsInsideAction(SchedulerStateMachine::Action action) { 220 bool IsInsideAction(SchedulerStateMachine::Action action) {
252 return inside_action_ == action; 221 return inside_action_ == action;
253 } 222 }
254 223
224 BeginFrameSource* primary_frame_source() {
225 if (settings_.use_external_begin_frame_source)
mithro-old 2015/06/22 11:49:39 Should you DCHECK external_frame_source_ here?
sunnyps 2015/06/22 20:32:41 Done.
226 return external_frame_source_;
227 return synthetic_frame_source_.get();
228 }
229
255 base::WeakPtrFactory<Scheduler> weak_factory_; 230 base::WeakPtrFactory<Scheduler> weak_factory_;
256 231
257 friend class SchedulerFrameSourcesConstructor;
258 friend class TestSchedulerFrameSourcesConstructor;
259
260 DISALLOW_COPY_AND_ASSIGN(Scheduler); 232 DISALLOW_COPY_AND_ASSIGN(Scheduler);
261 }; 233 };
262 234
263 } // namespace cc 235 } // namespace cc
264 236
265 #endif // CC_SCHEDULER_SCHEDULER_H_ 237 #endif // CC_SCHEDULER_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698