| 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 | 13 |
| 14 namespace base { class SingleThreadTaskRunner; } |
| 15 |
| 14 namespace cc { | 16 namespace cc { |
| 15 | 17 |
| 16 class Thread; | |
| 17 class TimeSource; | 18 class TimeSource; |
| 18 | 19 |
| 19 class CC_EXPORT FrameRateControllerClient { | 20 class CC_EXPORT FrameRateControllerClient { |
| 20 public: | 21 public: |
| 21 // Throttled is true when we have a maximum number of frames pending. | 22 // Throttled is true when we have a maximum number of frames pending. |
| 22 virtual void BeginFrame(bool throttled) = 0; | 23 virtual void BeginFrame(bool throttled) = 0; |
| 23 | 24 |
| 24 protected: | 25 protected: |
| 25 virtual ~FrameRateControllerClient() {} | 26 virtual ~FrameRateControllerClient() {} |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 class FrameRateControllerTimeSourceAdapter; | 29 class FrameRateControllerTimeSourceAdapter; |
| 29 | 30 |
| 30 class CC_EXPORT FrameRateController { | 31 class CC_EXPORT FrameRateController { |
| 31 public: | 32 public: |
| 32 enum { | 33 enum { |
| 33 DEFAULT_MAX_FRAMES_PENDING = 2 | 34 DEFAULT_MAX_FRAMES_PENDING = 2 |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 explicit FrameRateController(scoped_refptr<TimeSource> timer); | 37 explicit FrameRateController(scoped_refptr<TimeSource> timer); |
| 37 // Alternate form of FrameRateController with unthrottled frame-rate. | 38 // Alternate form of FrameRateController with unthrottled frame-rate. |
| 38 explicit FrameRateController(Thread* thread); | 39 explicit FrameRateController(base::SingleThreadTaskRunner* task_runner); |
| 39 virtual ~FrameRateController(); | 40 virtual ~FrameRateController(); |
| 40 | 41 |
| 41 void SetClient(FrameRateControllerClient* client) { client_ = client; } | 42 void SetClient(FrameRateControllerClient* client) { client_ = client; } |
| 42 | 43 |
| 43 void SetActive(bool active); | 44 void SetActive(bool active); |
| 44 | 45 |
| 45 // Use the following methods to adjust target frame rate. | 46 // Use the following methods to adjust target frame rate. |
| 46 // | 47 // |
| 47 // Multiple frames can be in-progress, but for every DidSwapBuffers, a | 48 // Multiple frames can be in-progress, but for every DidSwapBuffers, a |
| 48 // DidFinishFrame should be posted. | 49 // DidFinishFrame should be posted. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 FrameRateControllerClient* client_; | 75 FrameRateControllerClient* client_; |
| 75 int num_frames_pending_; | 76 int num_frames_pending_; |
| 76 int max_frames_pending_; | 77 int max_frames_pending_; |
| 77 scoped_refptr<TimeSource> time_source_; | 78 scoped_refptr<TimeSource> time_source_; |
| 78 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_; | 79 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_; |
| 79 bool active_; | 80 bool active_; |
| 80 | 81 |
| 81 // Members for unthrottled frame-rate. | 82 // Members for unthrottled frame-rate. |
| 82 bool is_time_source_throttling_; | 83 bool is_time_source_throttling_; |
| 83 base::WeakPtrFactory<FrameRateController> weak_factory_; | 84 base::WeakPtrFactory<FrameRateController> weak_factory_; |
| 84 Thread* thread_; | 85 base::SingleThreadTaskRunner* task_runner_; |
| 85 | 86 |
| 87 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(FrameRateController); | 88 DISALLOW_COPY_AND_ASSIGN(FrameRateController); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 } // namespace cc | 91 } // namespace cc |
| 90 | 92 |
| 91 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ | 93 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ |
| OLD | NEW |