OLD | NEW |
---|---|
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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 virtual void DidFinishImplFrame() = 0; | 48 virtual void DidFinishImplFrame() = 0; |
49 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; | 49 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; |
50 virtual void SendBeginMainFrameNotExpectedSoon() = 0; | 50 virtual void SendBeginMainFrameNotExpectedSoon() = 0; |
51 | 51 |
52 protected: | 52 protected: |
53 virtual ~SchedulerClient() {} | 53 virtual ~SchedulerClient() {} |
54 }; | 54 }; |
55 | 55 |
56 class CC_EXPORT Scheduler : public BeginFrameObserverBase { | 56 class CC_EXPORT Scheduler : public BeginFrameObserverBase { |
57 public: | 57 public: |
58 static scoped_ptr<Scheduler> Create( | 58 static scoped_ptr<Scheduler> Create( |
Sami
2016/03/08 19:15:24
Could you add a note saying both |client| and |beg
| |
59 SchedulerClient* client, | 59 SchedulerClient* client, |
60 const SchedulerSettings& scheduler_settings, | 60 const SchedulerSettings& scheduler_settings, |
61 int layer_tree_host_id, | 61 int layer_tree_host_id, |
62 base::SingleThreadTaskRunner* task_runner, | 62 base::SingleThreadTaskRunner* task_runner, |
63 BeginFrameSource* external_frame_source, | 63 BeginFrameSource* begin_frame_source, |
64 scoped_ptr<CompositorTimingHistory> compositor_timing_history); | 64 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
65 | 65 |
66 ~Scheduler() override; | 66 ~Scheduler() override; |
67 | 67 |
68 // BeginFrameObserverBase | 68 // BeginFrameObserverBase |
69 void OnBeginFrameSourcePausedChanged(bool paused) override; | 69 void OnBeginFrameSourcePausedChanged(bool paused) override; |
70 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; | 70 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; |
71 | 71 |
72 void OnDrawForOutputSurface(bool resourceless_software_draw); | 72 void OnDrawForOutputSurface(bool resourceless_software_draw); |
73 | 73 |
74 const SchedulerSettings& settings() const { return settings_; } | 74 const SchedulerSettings& settings() const { return settings_; } |
75 | 75 |
76 void CommitVSyncParameters(base::TimeTicks timebase, | |
77 base::TimeDelta interval); | |
78 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); | 76 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); |
79 | 77 |
80 void SetVisible(bool visible); | 78 void SetVisible(bool visible); |
81 bool visible() { return state_machine_.visible(); } | 79 bool visible() { return state_machine_.visible(); } |
82 void SetCanDraw(bool can_draw); | 80 void SetCanDraw(bool can_draw); |
83 void NotifyReadyToActivate(); | 81 void NotifyReadyToActivate(); |
84 void NotifyReadyToDraw(); | 82 void NotifyReadyToDraw(); |
85 | 83 |
86 void SetNeedsBeginMainFrame(); | 84 void SetNeedsBeginMainFrame(); |
87 // Requests a single impl frame (after the current frame if there is one | 85 // Requests a single impl frame (after the current frame if there is one |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 base::TimeTicks LastBeginImplFrameTime(); | 133 base::TimeTicks LastBeginImplFrameTime(); |
136 | 134 |
137 void SetDeferCommits(bool defer_commits); | 135 void SetDeferCommits(bool defer_commits); |
138 | 136 |
139 scoped_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | 137 scoped_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; |
140 void AsValueInto(base::trace_event::TracedValue* value) const override; | 138 void AsValueInto(base::trace_event::TracedValue* value) const override; |
141 | 139 |
142 void SetChildrenNeedBeginFrames(bool children_need_begin_frames); | 140 void SetChildrenNeedBeginFrames(bool children_need_begin_frames); |
143 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); | 141 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); |
144 | 142 |
145 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); | |
146 | |
147 protected: | 143 protected: |
148 Scheduler(SchedulerClient* client, | 144 Scheduler(SchedulerClient* client, |
149 const SchedulerSettings& scheduler_settings, | 145 const SchedulerSettings& scheduler_settings, |
150 int layer_tree_host_id, | 146 int layer_tree_host_id, |
151 base::SingleThreadTaskRunner* task_runner, | 147 base::SingleThreadTaskRunner* task_runner, |
152 BeginFrameSource* external_frame_source, | 148 BeginFrameSource* begin_frame_source, |
153 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source, | |
154 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source, | |
155 scoped_ptr<CompositorTimingHistory> compositor_timing_history); | 149 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
156 | 150 |
157 // Virtual for testing. | 151 // Virtual for testing. |
158 virtual base::TimeTicks Now() const; | 152 virtual base::TimeTicks Now() const; |
159 | 153 |
160 const SchedulerSettings settings_; | 154 const SchedulerSettings settings_; |
161 SchedulerClient* client_; | 155 SchedulerClient* client_; |
162 int layer_tree_host_id_; | 156 int layer_tree_host_id_; |
163 base::SingleThreadTaskRunner* task_runner_; | 157 base::SingleThreadTaskRunner* task_runner_; |
164 BeginFrameSource* external_frame_source_; | |
165 scoped_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; | |
166 scoped_ptr<BackToBackBeginFrameSource> unthrottled_frame_source_; | |
167 | 158 |
168 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; | 159 BeginFrameSource* frame_source_; |
Sami
2016/03/08 19:15:25
nit: Could you add " // Not owned." to make it cl
| |
169 bool observing_frame_source_; | 160 bool observing_frame_source_; |
170 | 161 |
171 base::TimeDelta authoritative_vsync_interval_; | |
172 base::TimeTicks last_vsync_timebase_; | |
173 | |
174 scoped_ptr<CompositorTimingHistory> compositor_timing_history_; | 162 scoped_ptr<CompositorTimingHistory> compositor_timing_history_; |
175 base::TimeDelta estimated_parent_draw_time_; | 163 base::TimeDelta estimated_parent_draw_time_; |
176 | 164 |
177 std::deque<BeginFrameArgs> begin_retro_frame_args_; | 165 std::deque<BeginFrameArgs> begin_retro_frame_args_; |
178 SchedulerStateMachine::BeginImplFrameDeadlineMode | 166 SchedulerStateMachine::BeginImplFrameDeadlineMode |
179 begin_impl_frame_deadline_mode_; | 167 begin_impl_frame_deadline_mode_; |
180 BeginFrameTracker begin_impl_frame_tracker_; | 168 BeginFrameTracker begin_impl_frame_tracker_; |
181 BeginFrameArgs begin_main_frame_args_; | 169 BeginFrameArgs begin_main_frame_args_; |
182 | 170 |
183 base::Closure begin_retro_frame_closure_; | 171 base::Closure begin_retro_frame_closure_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 void PollToAdvanceCommitState(); | 205 void PollToAdvanceCommitState(); |
218 | 206 |
219 base::TimeDelta EstimatedParentDrawTime() { | 207 base::TimeDelta EstimatedParentDrawTime() { |
220 return estimated_parent_draw_time_; | 208 return estimated_parent_draw_time_; |
221 } | 209 } |
222 | 210 |
223 bool IsInsideAction(SchedulerStateMachine::Action action) { | 211 bool IsInsideAction(SchedulerStateMachine::Action action) { |
224 return inside_action_ == action; | 212 return inside_action_ == action; |
225 } | 213 } |
226 | 214 |
227 BeginFrameSource* primary_frame_source() { | |
228 if (settings_.use_external_begin_frame_source) { | |
229 DCHECK(external_frame_source_); | |
230 return external_frame_source_; | |
231 } | |
232 return synthetic_frame_source_.get(); | |
233 } | |
234 | |
235 base::WeakPtrFactory<Scheduler> weak_factory_; | 215 base::WeakPtrFactory<Scheduler> weak_factory_; |
236 | 216 |
237 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 217 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
238 }; | 218 }; |
239 | 219 |
240 } // namespace cc | 220 } // namespace cc |
241 | 221 |
242 #endif // CC_SCHEDULER_SCHEDULER_H_ | 222 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |