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