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 <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 virtual void ScheduledActionPrepareTiles() = 0; | 46 virtual void ScheduledActionPrepareTiles() = 0; |
47 virtual void ScheduledActionInvalidateOutputSurface() = 0; | 47 virtual void ScheduledActionInvalidateOutputSurface() = 0; |
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 BeginFrameObserver { |
57 public: | 57 public: |
58 static std::unique_ptr<Scheduler> Create( | 58 static std::unique_ptr<Scheduler> Create( |
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* begin_frame_source, | 63 BeginFrameSource* begin_frame_source, |
64 std::unique_ptr<CompositorTimingHistory> compositor_timing_history); | 64 std::unique_ptr<CompositorTimingHistory> compositor_timing_history); |
65 | 65 |
66 ~Scheduler() override; | 66 ~Scheduler() override; |
67 | 67 |
68 // BeginFrameObserverBase | 68 // BeginFrameObserver |
| 69 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
69 void OnBeginFrameSourcePausedChanged(bool paused) override; | 70 void OnBeginFrameSourcePausedChanged(bool paused) override; |
70 bool OnBeginFrameDerivedImpl(const BeginFrameArgs& args) override; | 71 void OnBeginFrame(const BeginFrameArgs& args) override; |
71 | 72 |
72 void OnDrawForOutputSurface(bool resourceless_software_draw); | 73 void OnDrawForOutputSurface(bool resourceless_software_draw); |
73 | 74 |
74 const SchedulerSettings& settings() const { return settings_; } | 75 const SchedulerSettings& settings() const { return settings_; } |
75 | 76 |
76 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); | 77 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); |
77 | 78 |
78 void SetVisible(bool visible); | 79 void SetVisible(bool visible); |
79 bool visible() { return state_machine_.visible(); } | 80 bool visible() { return state_machine_.visible(); } |
80 void SetCanDraw(bool can_draw); | 81 void SetCanDraw(bool can_draw); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 int layer_tree_host_id_; | 163 int layer_tree_host_id_; |
163 base::SingleThreadTaskRunner* task_runner_; | 164 base::SingleThreadTaskRunner* task_runner_; |
164 | 165 |
165 // Not owned. May be null. | 166 // Not owned. May be null. |
166 BeginFrameSource* begin_frame_source_; | 167 BeginFrameSource* begin_frame_source_; |
167 bool observing_begin_frame_source_; | 168 bool observing_begin_frame_source_; |
168 | 169 |
169 std::unique_ptr<CompositorTimingHistory> compositor_timing_history_; | 170 std::unique_ptr<CompositorTimingHistory> compositor_timing_history_; |
170 base::TimeDelta estimated_parent_draw_time_; | 171 base::TimeDelta estimated_parent_draw_time_; |
171 | 172 |
172 std::deque<BeginFrameArgs> begin_retro_frame_args_; | |
173 SchedulerStateMachine::BeginImplFrameDeadlineMode | 173 SchedulerStateMachine::BeginImplFrameDeadlineMode |
174 begin_impl_frame_deadline_mode_; | 174 begin_impl_frame_deadline_mode_; |
175 BeginFrameTracker begin_impl_frame_tracker_; | 175 BeginFrameTracker begin_impl_frame_tracker_; |
176 BeginFrameArgs begin_main_frame_args_; | 176 BeginFrameArgs begin_main_frame_args_; |
177 | 177 |
178 base::Closure begin_retro_frame_closure_; | |
179 base::Closure begin_impl_frame_deadline_closure_; | 178 base::Closure begin_impl_frame_deadline_closure_; |
180 base::CancelableClosure begin_retro_frame_task_; | |
181 base::CancelableClosure begin_impl_frame_deadline_task_; | 179 base::CancelableClosure begin_impl_frame_deadline_task_; |
182 | 180 |
183 SchedulerStateMachine state_machine_; | 181 SchedulerStateMachine state_machine_; |
184 bool inside_process_scheduled_actions_; | 182 bool inside_process_scheduled_actions_; |
185 SchedulerStateMachine::Action inside_action_; | 183 SchedulerStateMachine::Action inside_action_; |
186 | 184 |
187 private: | 185 private: |
188 void ScheduleBeginImplFrameDeadline(); | 186 void ScheduleBeginImplFrameDeadline(); |
189 void ScheduleBeginImplFrameDeadlineIfNeeded(); | 187 void ScheduleBeginImplFrameDeadlineIfNeeded(); |
190 void BeginImplFrameNotExpectedSoon(); | 188 void BeginImplFrameNotExpectedSoon(); |
191 void SetupNextBeginFrameIfNeeded(); | 189 void SetupNextBeginFrameIfNeeded(); |
192 void PostBeginRetroFrameIfNeeded(); | |
193 void DrawAndSwapIfPossible(); | 190 void DrawAndSwapIfPossible(); |
194 void DrawAndSwapForced(); | 191 void DrawAndSwapForced(); |
195 void ProcessScheduledActions(); | 192 void ProcessScheduledActions(); |
| 193 void PerformAction(SchedulerStateMachine::Action action); |
196 void UpdateCompositorTimingHistoryRecordingEnabled(); | 194 void UpdateCompositorTimingHistoryRecordingEnabled(); |
197 bool ShouldRecoverMainLatency(const BeginFrameArgs& args, | 195 bool ShouldRecoverMainLatency(const BeginFrameArgs& args, |
198 bool can_activate_before_deadline) const; | 196 bool can_activate_before_deadline) const; |
199 bool ShouldRecoverImplLatency(const BeginFrameArgs& args, | 197 bool ShouldRecoverImplLatency(const BeginFrameArgs& args, |
200 bool can_activate_before_deadline) const; | 198 bool can_activate_before_deadline) const; |
201 bool CanBeginMainFrameAndActivateBeforeDeadline( | 199 bool CanBeginMainFrameAndActivateBeforeDeadline( |
202 const BeginFrameArgs& args, | 200 const BeginFrameArgs& args, |
203 base::TimeDelta bmf_to_activate_estimate) const; | 201 base::TimeDelta bmf_to_activate_estimate) const; |
204 void AdvanceCommitStateIfPossible(); | 202 void AdvanceCommitStateIfPossible(); |
205 bool IsBeginMainFrameSentOrStarted() const; | 203 bool IsBeginMainFrameSentOrStarted() const; |
206 void BeginRetroFrame(); | |
207 void BeginImplFrameWithDeadline(const BeginFrameArgs& args); | 204 void BeginImplFrameWithDeadline(const BeginFrameArgs& args); |
208 void BeginImplFrameSynchronous(const BeginFrameArgs& args); | 205 void BeginImplFrameSynchronous(const BeginFrameArgs& args); |
209 void BeginImplFrame(const BeginFrameArgs& args); | 206 void BeginImplFrame(const BeginFrameArgs& args); |
210 void FinishImplFrame(); | 207 void FinishImplFrame(); |
211 void OnBeginImplFrameDeadline(); | 208 void OnBeginImplFrameDeadline(); |
212 void PollToAdvanceCommitState(); | 209 void PollToAdvanceCommitState(); |
213 | 210 |
214 base::TimeDelta EstimatedParentDrawTime() { | 211 base::TimeDelta EstimatedParentDrawTime() { |
215 return estimated_parent_draw_time_; | 212 return estimated_parent_draw_time_; |
216 } | 213 } |
217 | 214 |
218 bool IsInsideAction(SchedulerStateMachine::Action action) { | 215 bool IsInsideAction(SchedulerStateMachine::Action action) { |
219 return inside_action_ == action; | 216 return inside_action_ == action; |
220 } | 217 } |
221 | 218 |
222 base::WeakPtrFactory<Scheduler> weak_factory_; | 219 base::WeakPtrFactory<Scheduler> weak_factory_; |
223 | 220 |
224 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 221 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
225 }; | 222 }; |
226 | 223 |
227 } // namespace cc | 224 } // namespace cc |
228 | 225 |
229 #endif // CC_SCHEDULER_SCHEDULER_H_ | 226 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |