Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: cc/CCFrameRateController.h

Issue 11028021: cc: Improve frame/commit accounting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CCFrameRateController_h 5 #ifndef CCFrameRateController_h
6 #define CCFrameRateController_h 6 #define CCFrameRateController_h
7 7
8 #include "CCTimer.h" 8 #include "CCTimer.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include <wtf/Deque.h> 10 #include <wtf/Deque.h>
11 #include <wtf/OwnPtr.h> 11 #include <wtf/OwnPtr.h>
12 #include <wtf/PassOwnPtr.h> 12 #include <wtf/PassOwnPtr.h>
13 13
14 namespace cc { 14 namespace cc {
15 15
16 class CCRenderingStats;
16 class CCThread; 17 class CCThread;
17 class CCTimeSource; 18 class CCTimeSource;
18 19
19 class CCFrameRateControllerClient { 20 class CCFrameRateControllerClient {
20 public: 21 public:
21 // Throttled is true when we have a maximum number of frames pending. 22 // Throttled is true when we have a maximum number of frames pending.
22 virtual void vsyncTick(bool throttled) = 0; 23 virtual void vsyncTick(bool throttled) = 0;
23 24
24 protected: 25 protected:
25 virtual ~CCFrameRateControllerClient() { } 26 virtual ~CCFrameRateControllerClient() { }
26 }; 27 };
27 28
28 class CCFrameRateControllerTimeSourceAdapter; 29 class CCFrameRateControllerTimeSourceAdapter;
29 30
30 class CCFrameRateController : public CCTimerClient { 31 class CCFrameRateController : public CCTimerClient {
31 public: 32 public:
32 explicit CCFrameRateController(PassRefPtr<CCTimeSource>); 33 explicit CCFrameRateController(PassRefPtr<CCTimeSource>);
33 // Alternate form of CCFrameRateController with unthrottled frame-rate. 34 // Alternate form of CCFrameRateController with unthrottled frame-rate.
34 explicit CCFrameRateController(CCThread*); 35 explicit CCFrameRateController(CCThread*);
35 virtual ~CCFrameRateController(); 36 virtual ~CCFrameRateController();
36 37
37 void setClient(CCFrameRateControllerClient* client) { m_client = client; } 38 void setClient(CCFrameRateControllerClient* client) { m_client = client; }
38 39
39 void setActive(bool); 40 void setActive(bool drawActive, bool commitActive);
40 41
41 // Use the following methods to adjust target frame rate. 42 // Use the following methods to adjust target frame rate.
42 // 43 //
43 // Multiple frames can be in-progress, but for every didBeginFrame, a 44 // Multiple frames can be in-progress, but for every didBeginFrame, a
44 // didFinishFrame should be posted. 45 // didFinishFrame should be posted.
45 // 46 //
46 // If the rendering pipeline crashes, call didAbortAllPendingFrames. 47 // If the rendering pipeline crashes, call didAbortAllPendingFrames.
47 void didBeginFrame(); 48 void didBeginFrame();
48 void didFinishFrame(); 49 void didFinishFrame();
49 void didAbortAllPendingFrames(); 50 void didAbortAllPendingFrames();
50 void setMaxFramesPending(int); // 0 for unlimited. 51 void setMaxFramesPending(int); // 0 for unlimited.
51 52
52 // This returns null for unthrottled frame-rate. 53 // This returns null for unthrottled frame-rate.
53 base::TimeTicks nextTickTime(); 54 base::TimeTicks nextTickTime();
54 55
55 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv al); 56 void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelta interv al);
56 void setSwapBuffersCompleteSupported(bool); 57 void setSwapBuffersCompleteSupported(bool);
57 58
59 void renderingStats(CCRenderingStats* stats) const;
60
58 protected: 61 protected:
59 friend class CCFrameRateControllerTimeSourceAdapter; 62 friend class CCFrameRateControllerTimeSourceAdapter;
60 void onTimerTick(); 63 void onTimerTick();
61 64
62 void postManualTick(); 65 void postManualTick();
63 66
64 // CCTimerClient implementation (used for unthrottled frame-rate). 67 // CCTimerClient implementation (used for unthrottled frame-rate).
65 virtual void onTimerFired() OVERRIDE; 68 virtual void onTimerFired() OVERRIDE;
66 69
67 CCFrameRateControllerClient* m_client; 70 CCFrameRateControllerClient* m_client;
68 int m_numFramesPending; 71 int m_numFramesPending;
69 int m_maxFramesPending; 72 int m_maxFramesPending;
70 RefPtr<CCTimeSource> m_timeSource; 73 RefPtr<CCTimeSource> m_timeSource;
71 OwnPtr<CCFrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter; 74 OwnPtr<CCFrameRateControllerTimeSourceAdapter> m_timeSourceClientAdapter;
72 bool m_active; 75 bool m_active;
76 bool m_drawActive;
77 bool m_commitActive;
73 bool m_swapBuffersCompleteSupported; 78 bool m_swapBuffersCompleteSupported;
74 79
80 size_t m_numCsyncs;
81 size_t m_numActiveCsyncs;
82 size_t m_numBeginFrames;
83 base::TimeTicks m_activeTimestamp;
84 base::TimeTicks m_intervalChangedTime;
85 base::TimeDelta m_interval;
86
75 // Members for unthrottled frame-rate. 87 // Members for unthrottled frame-rate.
76 bool m_isTimeSourceThrottling; 88 bool m_isTimeSourceThrottling;
77 OwnPtr<CCTimer> m_manualTicker; 89 OwnPtr<CCTimer> m_manualTicker;
78 }; 90 };
79 91
80 } 92 }
81 #endif // CCFrameRateController_h 93 #endif // CCFrameRateController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698