| 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_FRAME_RATE_CONTROLLER_H_ | 5 #ifndef CC_FRAME_RATE_CONTROLLER_H_ |
| 6 #define CC_FRAME_RATE_CONTROLLER_H_ | 6 #define CC_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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 virtual void vsyncTick(bool throttled) = 0; | 22 virtual void vsyncTick(bool throttled) = 0; |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 virtual ~FrameRateControllerClient() {} | 25 virtual ~FrameRateControllerClient() {} |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class FrameRateControllerTimeSourceAdapter; | 28 class FrameRateControllerTimeSourceAdapter; |
| 29 | 29 |
| 30 class CC_EXPORT FrameRateController { | 30 class CC_EXPORT FrameRateController { |
| 31 public: | 31 public: |
| 32 enum { | |
| 33 kDefaultMaxFramesPending = 2 | |
| 34 }; | |
| 35 | |
| 36 explicit FrameRateController(scoped_refptr<TimeSource>); | 32 explicit FrameRateController(scoped_refptr<TimeSource>); |
| 37 // Alternate form of FrameRateController with unthrottled frame-rate. | 33 // Alternate form of FrameRateController with unthrottled frame-rate. |
| 38 explicit FrameRateController(Thread*); | 34 explicit FrameRateController(Thread*); |
| 39 virtual ~FrameRateController(); | 35 virtual ~FrameRateController(); |
| 40 | 36 |
| 41 void setClient(FrameRateControllerClient* client) { m_client = client; } | 37 void setClient(FrameRateControllerClient* client) { m_client = client; } |
| 42 | 38 |
| 43 void setActive(bool); | 39 void setActive(bool); |
| 44 | 40 |
| 45 // Use the following methods to adjust target frame rate. | 41 // Use the following methods to adjust target frame rate. |
| 46 // | 42 // |
| 47 // Multiple frames can be in-progress, but for every didBeginFrame, a | 43 // Multiple frames can be in-progress, but for every didBeginFrame, a |
| 48 // didFinishFrame should be posted. | 44 // didFinishFrame should be posted. |
| 49 // | 45 // |
| 50 // If the rendering pipeline crashes, call didAbortAllPendingFrames. | 46 // If the rendering pipeline crashes, call didAbortAllPendingFrames. |
| 51 void didBeginFrame(); | 47 void didBeginFrame(); |
| 52 void didFinishFrame(); | 48 void didFinishFrame(); |
| 53 void didAbortAllPendingFrames(); | 49 void didAbortAllPendingFrames(); |
| 54 void setMaxFramesPending(int); // 0 for unlimited. | 50 void setMaxFramesPending(int); // 0 for unlimited. |
| 55 int maxFramesPending() const { return m_maxFramesPending; } | |
| 56 | 51 |
| 57 // This returns null for unthrottled frame-rate. | 52 // This returns null for unthrottled frame-rate. |
| 58 base::TimeTicks nextTickTime(); | 53 base::TimeTicks nextTickTime(); |
| 59 | 54 |
| 60 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv
al); | 55 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv
al); |
| 61 void setSwapBuffersCompleteSupported(bool); | 56 void setSwapBuffersCompleteSupported(bool); |
| 62 | 57 |
| 63 protected: | 58 protected: |
| 64 friend class FrameRateControllerTimeSourceAdapter; | 59 friend class FrameRateControllerTimeSourceAdapter; |
| 65 void onTimerTick(); | 60 void onTimerTick(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 bool m_isTimeSourceThrottling; | 74 bool m_isTimeSourceThrottling; |
| 80 base::WeakPtrFactory<FrameRateController> m_weakFactory; | 75 base::WeakPtrFactory<FrameRateController> m_weakFactory; |
| 81 Thread* m_thread; | 76 Thread* m_thread; |
| 82 | 77 |
| 83 DISALLOW_COPY_AND_ASSIGN(FrameRateController); | 78 DISALLOW_COPY_AND_ASSIGN(FrameRateController); |
| 84 }; | 79 }; |
| 85 | 80 |
| 86 } // namespace cc | 81 } // namespace cc |
| 87 | 82 |
| 88 #endif // CC_FRAME_RATE_CONTROLLER_H_ | 83 #endif // CC_FRAME_RATE_CONTROLLER_H_ |
| OLD | NEW |