In iossim, ignore harmless messages from launchd.
[chromium-blink-merge.git] / cc / frame_rate_controller.h
blob16a3e37933aa5d217a0c3659c385311bfa0ba211
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 explicit FrameRateController(scoped_refptr<TimeSource>);
33 // Alternate form of FrameRateController with unthrottled frame-rate.
34 explicit FrameRateController(Thread*);
35 virtual ~FrameRateController();
37 void setClient(FrameRateControllerClient* client) { m_client = client; }
39 void setActive(bool);
41 // Use the following methods to adjust target frame rate.
43 // Multiple frames can be in-progress, but for every didBeginFrame, a
44 // didFinishFrame should be posted.
46 // If the rendering pipeline crashes, call didAbortAllPendingFrames.
47 void didBeginFrame();
48 void didFinishFrame();
49 void didAbortAllPendingFrames();
50 void setMaxFramesPending(int); // 0 for unlimited.
52 // This returns null for unthrottled frame-rate.
53 base::TimeTicks nextTickTime();
55 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interval);
56 void setSwapBuffersCompleteSupported(bool);
58 protected:
59 friend class FrameRateControllerTimeSourceAdapter;
60 void onTimerTick();
62 void postManualTick();
63 void manualTick();
65 FrameRateControllerClient* m_client;
66 int m_numFramesPending;
67 int m_maxFramesPending;
68 scoped_refptr<TimeSource> m_timeSource;
69 scoped_ptr<FrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter;
70 bool m_active;
71 bool m_swapBuffersCompleteSupported;
73 // Members for unthrottled frame-rate.
74 bool m_isTimeSourceThrottling;
75 base::WeakPtrFactory<FrameRateController> m_weakFactory;
76 Thread* m_thread;
78 DISALLOW_COPY_AND_ASSIGN(FrameRateController);
81 } // namespace cc
83 #endif // CC_FRAME_RATE_CONTROLLER_H_