| 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_FRAME_RATE_CONTROLLER_H_ | 5 #ifndef CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ |
| 6 #define CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ | 6 #define CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 13 #include "cc/output/begin_frame_args.h" |
| 13 | 14 |
| 14 namespace base { class SingleThreadTaskRunner; } | 15 namespace base { class SingleThreadTaskRunner; } |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 class TimeSource; | 19 class TimeSource; |
| 19 class FrameRateController; | 20 class FrameRateController; |
| 20 | 21 |
| 21 class CC_EXPORT FrameRateControllerClient { | 22 class CC_EXPORT FrameRateControllerClient { |
| 22 protected: | 23 protected: |
| 23 virtual ~FrameRateControllerClient() {} | 24 virtual ~FrameRateControllerClient() {} |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 // Throttled is true when we have a maximum number of frames pending. | 27 // Throttled is true when we have a maximum number of frames pending. |
| 27 virtual void FrameRateControllerTick(bool throttled) = 0; | 28 virtual void FrameRateControllerTick(bool throttled, |
| 29 const BeginFrameArgs& args) = 0; |
| 28 }; | 30 }; |
| 29 | 31 |
| 30 class FrameRateControllerTimeSourceAdapter; | 32 class FrameRateControllerTimeSourceAdapter; |
| 31 | 33 |
| 32 // The FrameRateController is used in cases where we self-tick (i.e. BeginFrame | 34 // The FrameRateController is used in cases where we self-tick (i.e. BeginFrame |
| 33 // is not sent by a parent compositor. | 35 // is not sent by a parent compositor. |
| 34 class CC_EXPORT FrameRateController { | 36 class CC_EXPORT FrameRateController { |
| 35 public: | 37 public: |
| 36 enum { | |
| 37 DEFAULT_MAX_FRAMES_PENDING = 2 | |
| 38 }; | |
| 39 | |
| 40 explicit FrameRateController(scoped_refptr<TimeSource> timer); | 38 explicit FrameRateController(scoped_refptr<TimeSource> timer); |
| 41 // Alternate form of FrameRateController with unthrottled frame-rate. | 39 // Alternate form of FrameRateController with unthrottled frame-rate. |
| 42 explicit FrameRateController(base::SingleThreadTaskRunner* task_runner); | 40 explicit FrameRateController(base::SingleThreadTaskRunner* task_runner); |
| 43 virtual ~FrameRateController(); | 41 virtual ~FrameRateController(); |
| 44 | 42 |
| 45 void SetClient(FrameRateControllerClient* client) { client_ = client; } | 43 void SetClient(FrameRateControllerClient* client) { client_ = client; } |
| 46 | 44 |
| 47 void SetActive(bool active); | 45 void SetActive(bool active); |
| 48 bool IsActive() { return active_; } | 46 bool IsActive() { return active_; } |
| 49 | 47 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 61 int NumSwapsPendingForTesting() const { return num_frames_pending_; } | 59 int NumSwapsPendingForTesting() const { return num_frames_pending_; } |
| 62 | 60 |
| 63 // This returns null for unthrottled frame-rate. | 61 // This returns null for unthrottled frame-rate. |
| 64 base::TimeTicks NextTickTime(); | 62 base::TimeTicks NextTickTime(); |
| 65 | 63 |
| 66 // This returns now for unthrottled frame-rate. | 64 // This returns now for unthrottled frame-rate. |
| 67 base::TimeTicks LastTickTime(); | 65 base::TimeTicks LastTickTime(); |
| 68 | 66 |
| 69 void SetTimebaseAndInterval(base::TimeTicks timebase, | 67 void SetTimebaseAndInterval(base::TimeTicks timebase, |
| 70 base::TimeDelta interval); | 68 base::TimeDelta interval); |
| 69 void SetDeadlineAdjustment(base::TimeDelta delta); |
| 71 | 70 |
| 72 protected: | 71 protected: |
| 73 friend class FrameRateControllerTimeSourceAdapter; | 72 friend class FrameRateControllerTimeSourceAdapter; |
| 74 void OnTimerTick(); | 73 void OnTimerTick(); |
| 75 | 74 |
| 76 void PostManualTick(); | 75 void PostManualTick(); |
| 77 void ManualTick(); | 76 void ManualTick(); |
| 78 | 77 |
| 79 FrameRateControllerClient* client_; | 78 FrameRateControllerClient* client_; |
| 80 int num_frames_pending_; | 79 int num_frames_pending_; |
| 81 int max_swaps_pending_; | 80 int max_swaps_pending_; |
| 81 base::TimeDelta interval_; |
| 82 base::TimeDelta deadline_adjustment_; |
| 82 scoped_refptr<TimeSource> time_source_; | 83 scoped_refptr<TimeSource> time_source_; |
| 83 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_; | 84 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_; |
| 84 bool active_; | 85 bool active_; |
| 85 | 86 |
| 86 // Members for unthrottled frame-rate. | 87 // Members for unthrottled frame-rate. |
| 87 bool is_time_source_throttling_; | 88 bool is_time_source_throttling_; |
| 88 base::WeakPtrFactory<FrameRateController> weak_factory_; | 89 base::WeakPtrFactory<FrameRateController> weak_factory_; |
| 89 base::SingleThreadTaskRunner* task_runner_; | 90 base::SingleThreadTaskRunner* task_runner_; |
| 90 | 91 |
| 91 private: | 92 private: |
| 92 DISALLOW_COPY_AND_ASSIGN(FrameRateController); | 93 DISALLOW_COPY_AND_ASSIGN(FrameRateController); |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 } // namespace cc | 96 } // namespace cc |
| 96 | 97 |
| 97 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ | 98 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ |
| OLD | NEW |