| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CCFrameRateController_h | 5 // Temporary forwarding header |
| 6 #define CCFrameRateController_h | 6 #include "cc/frame_rate_controller.h" |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/time.h" | |
| 10 #include "CCTimer.h" | |
| 11 #include <wtf/PassRefPtr.h> | |
| 12 #include <wtf/RefPtr.h> | |
| 13 | |
| 14 namespace cc { | |
| 15 | |
| 16 class CCThread; | |
| 17 class CCTimeSource; | |
| 18 | |
| 19 class CCFrameRateControllerClient { | |
| 20 public: | |
| 21 // Throttled is true when we have a maximum number of frames pending. | |
| 22 virtual void vsyncTick(bool throttled) = 0; | |
| 23 | |
| 24 protected: | |
| 25 virtual ~CCFrameRateControllerClient() {} | |
| 26 }; | |
| 27 | |
| 28 class CCFrameRateControllerTimeSourceAdapter; | |
| 29 | |
| 30 class CCFrameRateController : public CCTimerClient { | |
| 31 public: | |
| 32 explicit CCFrameRateController(PassRefPtr<CCTimeSource>); | |
| 33 // Alternate form of CCFrameRateController with unthrottled frame-rate. | |
| 34 explicit CCFrameRateController(CCThread*); | |
| 35 virtual ~CCFrameRateController(); | |
| 36 | |
| 37 void setClient(CCFrameRateControllerClient* client) { m_client = client; } | |
| 38 | |
| 39 void setActive(bool); | |
| 40 | |
| 41 // Use the following methods to adjust target frame rate. | |
| 42 // | |
| 43 // Multiple frames can be in-progress, but for every didBeginFrame, a | |
| 44 // didFinishFrame should be posted. | |
| 45 // | |
| 46 // If the rendering pipeline crashes, call didAbortAllPendingFrames. | |
| 47 void didBeginFrame(); | |
| 48 void didFinishFrame(); | |
| 49 void didAbortAllPendingFrames(); | |
| 50 void setMaxFramesPending(int); // 0 for unlimited. | |
| 51 | |
| 52 // This returns null for unthrottled frame-rate. | |
| 53 base::TimeTicks nextTickTime(); | |
| 54 | |
| 55 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv
al); | |
| 56 void setSwapBuffersCompleteSupported(bool); | |
| 57 | |
| 58 protected: | |
| 59 friend class CCFrameRateControllerTimeSourceAdapter; | |
| 60 void onTimerTick(); | |
| 61 | |
| 62 void postManualTick(); | |
| 63 | |
| 64 // CCTimerClient implementation (used for unthrottled frame-rate). | |
| 65 virtual void onTimerFired() OVERRIDE; | |
| 66 | |
| 67 CCFrameRateControllerClient* m_client; | |
| 68 int m_numFramesPending; | |
| 69 int m_maxFramesPending; | |
| 70 RefPtr<CCTimeSource> m_timeSource; | |
| 71 scoped_ptr<CCFrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter
; | |
| 72 bool m_active; | |
| 73 bool m_swapBuffersCompleteSupported; | |
| 74 | |
| 75 // Members for unthrottled frame-rate. | |
| 76 bool m_isTimeSourceThrottling; | |
| 77 scoped_ptr<CCTimer> m_manualTicker; | |
| 78 }; | |
| 79 | |
| 80 } // namespace cc | |
| 81 | |
| 82 #endif // CCFrameRateController_h | |
| OLD | NEW |