OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BEGIN_FRAME_SOURCE_H_ | 5 #ifndef CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ |
6 #define CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ | 6 #define CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 BeginFrameArgs CreateBeginFrameArgs(base::TimeTicks frame_time, | 243 BeginFrameArgs CreateBeginFrameArgs(base::TimeTicks frame_time, |
244 BeginFrameArgs::BeginFrameArgsType type); | 244 BeginFrameArgs::BeginFrameArgsType type); |
245 | 245 |
246 scoped_ptr<DelayBasedTimeSource> time_source_; | 246 scoped_ptr<DelayBasedTimeSource> time_source_; |
247 | 247 |
248 private: | 248 private: |
249 DISALLOW_COPY_AND_ASSIGN(SyntheticBeginFrameSource); | 249 DISALLOW_COPY_AND_ASSIGN(SyntheticBeginFrameSource); |
250 }; | 250 }; |
251 | 251 |
252 // A "virtual" frame source which lets you switch between multiple other frame | |
253 // sources while making sure the BeginFrameArgs stays increasing (possibly | |
254 // enforcing minimum boundry between BeginFrameArgs messages). | |
255 class CC_EXPORT BeginFrameSourceMultiplexer : public BeginFrameSourceBase, | |
256 public BeginFrameObserver { | |
257 public: | |
258 static scoped_ptr<BeginFrameSourceMultiplexer> Create(); | |
259 ~BeginFrameSourceMultiplexer() override; | |
260 | |
261 void SetMinimumInterval(base::TimeDelta new_minimum_interval); | |
262 | |
263 void AddSource(BeginFrameSource* new_source); | |
264 void RemoveSource(BeginFrameSource* existing_source); | |
265 void SetActiveSource(BeginFrameSource* new_source); | |
266 const BeginFrameSource* ActiveSource(); | |
267 | |
268 // BeginFrameObserver | |
269 // The mux is an BeginFrameObserver as it needs to proxy the OnBeginFrame | |
270 // calls to preserve the monotonicity of the BeginFrameArgs when switching | |
271 // sources. | |
272 void OnBeginFrame(const BeginFrameArgs& args) override; | |
273 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; | |
274 void OnBeginFrameSourcePausedChanged(bool paused) override; | |
275 | |
276 // BeginFrameSourceBase | |
277 void DidFinishFrame(size_t remaining_frames) override; | |
278 void AddObserver(BeginFrameObserver* obs) override; | |
279 void OnNeedsBeginFramesChanged(bool needs_begin_frames) override; | |
280 | |
281 // Tracing | |
282 void AsValueInto(base::trace_event::TracedValue* dict) const override; | |
283 | |
284 protected: | |
285 BeginFrameSourceMultiplexer(); | |
286 explicit BeginFrameSourceMultiplexer(base::TimeDelta minimum_interval); | |
287 | |
288 bool HasSource(BeginFrameSource* source); | |
289 bool IsIncreasing(const BeginFrameArgs& args); | |
290 | |
291 base::TimeDelta minimum_interval_; | |
292 | |
293 BeginFrameSource* active_source_; | |
294 std::set<BeginFrameSource*> source_list_; | |
295 | |
296 BeginFrameArgs last_begin_frame_args_; | |
297 bool inside_add_observer_; | |
298 | |
299 private: | |
300 DISALLOW_COPY_AND_ASSIGN(BeginFrameSourceMultiplexer); | |
301 }; | |
302 | |
303 } // namespace cc | 252 } // namespace cc |
304 | 253 |
305 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ | 254 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ |
OLD | NEW |