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 30 matching lines...) Expand all Loading... |
41 virtual void ScheduledActionAnimate() = 0; | 41 virtual void ScheduledActionAnimate() = 0; |
42 virtual void ScheduledActionCommit() = 0; | 42 virtual void ScheduledActionCommit() = 0; |
43 virtual void ScheduledActionActivateSyncTree() = 0; | 43 virtual void ScheduledActionActivateSyncTree() = 0; |
44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; | 44 virtual void ScheduledActionBeginOutputSurfaceCreation() = 0; |
45 virtual void ScheduledActionPrepareTiles() = 0; | 45 virtual void ScheduledActionPrepareTiles() = 0; |
46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; | 46 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) = 0; |
47 virtual base::TimeDelta DrawDurationEstimate() = 0; | 47 virtual base::TimeDelta DrawDurationEstimate() = 0; |
48 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0; | 48 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0; |
49 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; | 49 virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; |
50 virtual void DidBeginImplFrameDeadline() = 0; | 50 virtual void DidBeginImplFrameDeadline() = 0; |
51 virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; | |
52 | 51 |
53 protected: | 52 protected: |
54 virtual ~SchedulerClient() {} | 53 virtual ~SchedulerClient() {} |
55 }; | 54 }; |
56 | 55 |
57 class Scheduler; | 56 class Scheduler; |
58 // This class exists to allow tests to override the frame source construction. | 57 // This class exists to allow tests to override the frame source construction. |
59 // A virtual method can't be used as this needs to happen in the constructor | 58 // A virtual method can't be used as this needs to happen in the constructor |
60 // (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why). | 59 // (see C++ FAQ / Section 23 - http://goo.gl/fnrwom for why). |
61 // This class exists solely long enough to construct the frame sources. | 60 // This class exists solely long enough to construct the frame sources. |
62 class CC_EXPORT SchedulerFrameSourcesConstructor { | 61 class CC_EXPORT SchedulerFrameSourcesConstructor { |
63 public: | 62 public: |
64 virtual ~SchedulerFrameSourcesConstructor() {} | 63 virtual ~SchedulerFrameSourcesConstructor() {} |
65 virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler); | 64 virtual BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler); |
66 virtual BeginFrameSource* ConstructBackgroundFrameSource( | 65 virtual BeginFrameSource* ConstructBackgroundFrameSource( |
67 Scheduler* scheduler); | 66 Scheduler* scheduler); |
68 virtual BeginFrameSource* ConstructUnthrottledFrameSource( | 67 virtual BeginFrameSource* ConstructUnthrottledFrameSource( |
69 Scheduler* scheduler); | 68 Scheduler* scheduler); |
70 | 69 |
71 protected: | 70 protected: |
72 SchedulerFrameSourcesConstructor() {} | 71 SchedulerFrameSourcesConstructor() {} |
73 | 72 |
74 friend class Scheduler; | 73 friend class Scheduler; |
75 }; | 74 }; |
76 | 75 |
77 class CC_EXPORT Scheduler : public BeginFrameObserverMixIn, | 76 class CC_EXPORT Scheduler : public BeginFrameObserverMixIn, |
78 public base::PowerObserver { | 77 public base::PowerObserver, |
| 78 public ProxyBeginFrameSource::Delegate { |
79 public: | 79 public: |
80 static scoped_ptr<Scheduler> Create( | 80 static scoped_ptr<Scheduler> Create( |
81 SchedulerClient* client, | 81 SchedulerClient* client, |
82 const SchedulerSettings& scheduler_settings, | 82 const SchedulerSettings& scheduler_settings, |
83 int layer_tree_host_id, | 83 int layer_tree_host_id, |
84 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 84 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
85 base::PowerMonitor* power_monitor, | 85 base::PowerMonitor* power_monitor, |
86 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 86 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 87 ProxyBeginFrameSource* proxy_begin_frame_source) { |
87 SchedulerFrameSourcesConstructor frame_sources_constructor; | 88 SchedulerFrameSourcesConstructor frame_sources_constructor; |
88 return make_scoped_ptr(new Scheduler(client, | 89 return make_scoped_ptr(new Scheduler(client, |
89 scheduler_settings, | 90 scheduler_settings, |
90 layer_tree_host_id, | 91 layer_tree_host_id, |
91 task_runner, | 92 task_runner, |
92 power_monitor, | 93 power_monitor, |
93 external_begin_frame_source.Pass(), | 94 external_begin_frame_source.Pass(), |
| 95 proxy_begin_frame_source, |
94 &frame_sources_constructor)); | 96 &frame_sources_constructor)); |
95 } | 97 } |
96 | 98 |
97 ~Scheduler() override; | 99 ~Scheduler() override; |
98 | 100 |
99 // BeginFrameObserverMixin | 101 // BeginFrameObserverMixin |
100 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override; | 102 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override; |
101 | 103 |
102 // base::PowerObserver method. | 104 // base::PowerObserver method. |
103 void OnPowerStateChange(bool on_battery_power) override; | 105 void OnPowerStateChange(bool on_battery_power) override; |
104 | 106 |
| 107 // ProxyBeginFrameSource::Delegate. |
| 108 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override; |
| 109 |
105 const SchedulerSettings& settings() const { return settings_; } | 110 const SchedulerSettings& settings() const { return settings_; } |
106 | 111 |
107 void CommitVSyncParameters(base::TimeTicks timebase, | 112 void CommitVSyncParameters(base::TimeTicks timebase, |
108 base::TimeDelta interval); | 113 base::TimeDelta interval); |
109 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); | 114 void SetEstimatedParentDrawTime(base::TimeDelta draw_time); |
110 | 115 |
111 void SetCanStart(); | 116 void SetCanStart(); |
112 | 117 |
113 void SetVisible(bool visible); | 118 void SetVisible(bool visible); |
114 void SetCanDraw(bool can_draw); | 119 void SetCanDraw(bool can_draw); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 167 |
163 base::TimeTicks LastBeginImplFrameTime(); | 168 base::TimeTicks LastBeginImplFrameTime(); |
164 | 169 |
165 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; | 170 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; |
166 void AsValueInto(base::debug::TracedValue* value) const override; | 171 void AsValueInto(base::debug::TracedValue* value) const override; |
167 | 172 |
168 void SetContinuousPainting(bool continuous_painting) { | 173 void SetContinuousPainting(bool continuous_painting) { |
169 state_machine_.SetContinuousPainting(continuous_painting); | 174 state_machine_.SetContinuousPainting(continuous_painting); |
170 } | 175 } |
171 | 176 |
172 void SetChildrenNeedBeginFrames(bool children_need_begin_frames); | |
173 | |
174 protected: | 177 protected: |
175 Scheduler(SchedulerClient* client, | 178 Scheduler(SchedulerClient* client, |
176 const SchedulerSettings& scheduler_settings, | 179 const SchedulerSettings& scheduler_settings, |
177 int layer_tree_host_id, | 180 int layer_tree_host_id, |
178 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 181 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
179 base::PowerMonitor* power_monitor, | 182 base::PowerMonitor* power_monitor, |
180 scoped_ptr<BeginFrameSource> external_begin_frame_source, | 183 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 184 ProxyBeginFrameSource* proxy_begin_frame_source, |
181 SchedulerFrameSourcesConstructor* frame_sources_constructor); | 185 SchedulerFrameSourcesConstructor* frame_sources_constructor); |
182 | 186 |
183 // virtual for testing - Don't call these in the constructor or | 187 // virtual for testing - Don't call these in the constructor or |
184 // destructor! | 188 // destructor! |
185 virtual base::TimeTicks Now() const; | 189 virtual base::TimeTicks Now() const; |
186 | 190 |
187 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; | 191 scoped_ptr<BeginFrameSourceMultiplexer> frame_source_; |
188 BeginFrameSource* primary_frame_source_; | 192 BeginFrameSource* primary_frame_source_; |
189 BeginFrameSource* background_frame_source_; | 193 BeginFrameSource* background_frame_source_; |
190 BeginFrameSource* unthrottled_frame_source_; | 194 BeginFrameSource* unthrottled_frame_source_; |
(...skipping 25 matching lines...) Expand all Loading... |
216 base::Closure poll_for_draw_triggers_closure_; | 220 base::Closure poll_for_draw_triggers_closure_; |
217 base::Closure advance_commit_state_closure_; | 221 base::Closure advance_commit_state_closure_; |
218 base::CancelableClosure begin_retro_frame_task_; | 222 base::CancelableClosure begin_retro_frame_task_; |
219 base::CancelableClosure begin_impl_frame_deadline_task_; | 223 base::CancelableClosure begin_impl_frame_deadline_task_; |
220 base::CancelableClosure poll_for_draw_triggers_task_; | 224 base::CancelableClosure poll_for_draw_triggers_task_; |
221 base::CancelableClosure advance_commit_state_task_; | 225 base::CancelableClosure advance_commit_state_task_; |
222 | 226 |
223 SchedulerStateMachine state_machine_; | 227 SchedulerStateMachine state_machine_; |
224 bool inside_process_scheduled_actions_; | 228 bool inside_process_scheduled_actions_; |
225 SchedulerStateMachine::Action inside_action_; | 229 SchedulerStateMachine::Action inside_action_; |
| 230 ProxyBeginFrameSource* proxy_begin_frame_source_; |
226 | 231 |
227 private: | 232 private: |
228 void ScheduleBeginImplFrameDeadline(); | 233 void ScheduleBeginImplFrameDeadline(); |
229 void RescheduleBeginImplFrameDeadlineIfNeeded(); | 234 void RescheduleBeginImplFrameDeadlineIfNeeded(); |
230 void SetupNextBeginFrameIfNeeded(); | 235 void SetupNextBeginFrameIfNeeded(); |
231 void PostBeginRetroFrameIfNeeded(); | 236 void PostBeginRetroFrameIfNeeded(); |
232 void SetupPollingMechanisms(); | 237 void SetupPollingMechanisms(); |
233 void DrawAndSwapIfPossible(); | 238 void DrawAndSwapIfPossible(); |
234 void ProcessScheduledActions(); | 239 void ProcessScheduledActions(); |
235 bool CanCommitAndActivateBeforeDeadline() const; | 240 bool CanCommitAndActivateBeforeDeadline() const; |
(...skipping 20 matching lines...) Expand all Loading... |
256 | 261 |
257 friend class SchedulerFrameSourcesConstructor; | 262 friend class SchedulerFrameSourcesConstructor; |
258 friend class TestSchedulerFrameSourcesConstructor; | 263 friend class TestSchedulerFrameSourcesConstructor; |
259 | 264 |
260 DISALLOW_COPY_AND_ASSIGN(Scheduler); | 265 DISALLOW_COPY_AND_ASSIGN(Scheduler); |
261 }; | 266 }; |
262 | 267 |
263 } // namespace cc | 268 } // namespace cc |
264 | 269 |
265 #endif // CC_SCHEDULER_SCHEDULER_H_ | 270 #endif // CC_SCHEDULER_SCHEDULER_H_ |
OLD | NEW |