Enabling tests which should be fixed by r173829.
[chromium-blink-merge.git] / cc / frame_rate_controller.h
blob681c6d20d65d4d746c30b3a267dda227d9fc36f9
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
3 // found in the LICENSE file.
5 #ifndef CC_FRAME_RATE_CONTROLLER_H_
6 #define CC_FRAME_RATE_CONTROLLER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/time.h"
12 #include "cc/cc_export.h"
14 namespace cc {
16 class Thread;
17 class TimeSource;
19 class CC_EXPORT FrameRateControllerClient {
20 public:
21 // Throttled is true when we have a maximum number of frames pending.
22 virtual void vsyncTick(bool throttled) = 0;
24 protected:
25 virtual ~FrameRateControllerClient() {}
28 class FrameRateControllerTimeSourceAdapter;
30 class CC_EXPORT FrameRateController {
31 public:
32 enum {
33 kDefaultMaxFramesPending = 2
36 explicit FrameRateController(scoped_refptr<TimeSource>);
37 // Alternate form of FrameRateController with unthrottled frame-rate.
38 explicit FrameRateController(Thread*);
39 virtual ~FrameRateController();
41 void setClient(FrameRateControllerClient* client) { m_client = client; }
43 void setActive(bool);
45 // Use the following methods to adjust target frame rate.
47 // Multiple frames can be in-progress, but for every didBeginFrame, a
48 // didFinishFrame should be posted.
50 // If the rendering pipeline crashes, call didAbortAllPendingFrames.
51 void didBeginFrame();
52 void didFinishFrame();
53 void didAbortAllPendingFrames();
54 void setMaxFramesPending(int); // 0 for unlimited.
55 int maxFramesPending() const { return m_maxFramesPending; }
57 // This returns null for unthrottled frame-rate.
58 base::TimeTicks nextTickTime();
60 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interval);
61 void setSwapBuffersCompleteSupported(bool);
63 protected:
64 friend class FrameRateControllerTimeSourceAdapter;
65 void onTimerTick();
67 void postManualTick();
68 void manualTick();
70 FrameRateControllerClient* m_client;
71 int m_numFramesPending;
72 int m_maxFramesPending;
73 scoped_refptr<TimeSource> m_timeSource;
74 scoped_ptr<FrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter;
75 bool m_active;
76 bool m_swapBuffersCompleteSupported;
78 // Members for unthrottled frame-rate.
79 bool m_isTimeSourceThrottling;
80 base::WeakPtrFactory<FrameRateController> m_weakFactory;
81 Thread* m_thread;
83 DISALLOW_COPY_AND_ASSIGN(FrameRateController);
86 } // namespace cc
88 #endif // CC_FRAME_RATE_CONTROLLER_H_