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