| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ | |
| 6 #define CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/time/time.h" | |
| 12 #include "cc/base/cc_export.h" | |
| 13 #include "cc/output/begin_frame_args.h" | |
| 14 #include "cc/scheduler/time_source.h" | |
| 15 | |
| 16 namespace base { class SingleThreadTaskRunner; } | |
| 17 | |
| 18 namespace cc { | |
| 19 | |
| 20 class TimeSource; | |
| 21 class FrameRateController; | |
| 22 | |
| 23 class CC_EXPORT FrameRateControllerClient { | |
| 24 protected: | |
| 25 virtual ~FrameRateControllerClient() {} | |
| 26 | |
| 27 public: | |
| 28 virtual void FrameRateControllerTick(const BeginFrameArgs& args) = 0; | |
| 29 }; | |
| 30 | |
| 31 // The FrameRateController is used in cases where we self-tick (i.e. BeginFrame | |
| 32 // is not sent by a parent compositor. | |
| 33 class CC_EXPORT FrameRateController : TimeSourceClient { | |
| 34 public: | |
| 35 explicit FrameRateController(scoped_refptr<TimeSource> timer); | |
| 36 virtual ~FrameRateController(); | |
| 37 | |
| 38 void SetClient(FrameRateControllerClient* client) { client_ = client; } | |
| 39 | |
| 40 // Returns a valid BeginFrame on activation to potentially be used | |
| 41 // retroactively. | |
| 42 BeginFrameArgs SetActive(bool active); | |
| 43 | |
| 44 bool IsActive() { return active_; } | |
| 45 | |
| 46 void SetTimebaseAndInterval(base::TimeTicks timebase, | |
| 47 base::TimeDelta interval); | |
| 48 void SetDeadlineAdjustment(base::TimeDelta delta); | |
| 49 | |
| 50 virtual void OnTimerTick() OVERRIDE; | |
| 51 | |
| 52 protected: | |
| 53 // This returns null for unthrottled frame-rate. | |
| 54 base::TimeTicks NextTickTime(); | |
| 55 // This returns now for unthrottled frame-rate. | |
| 56 base::TimeTicks LastTickTime(); | |
| 57 | |
| 58 FrameRateControllerClient* client_; | |
| 59 base::TimeDelta interval_; | |
| 60 base::TimeDelta deadline_adjustment_; | |
| 61 scoped_refptr<TimeSource> time_source_; | |
| 62 bool active_; | |
| 63 | |
| 64 private: | |
| 65 DISALLOW_COPY_AND_ASSIGN(FrameRateController); | |
| 66 }; | |
| 67 | |
| 68 } // namespace cc | |
| 69 | |
| 70 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ | |
| OLD | NEW |