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

Side by Side Diff: cc/frame_rate_counter.h

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« no previous file with comments | « cc/frame_rate_controller.cc ('k') | cc/frame_rate_counter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 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
5 #ifndef CCFrameRateCounter_h
6 #define CCFrameRateCounter_h
7
8 #if USE(ACCELERATED_COMPOSITING)
9
10 #include "base/basictypes.h"
11 #include <wtf/PassOwnPtr.h>
12
13 namespace cc {
14
15 // This class maintains a history of timestamps, and provides functionality to
16 // intelligently compute average frames per second (and standard deviation).
17 class CCFrameRateCounter {
18 public:
19 static PassOwnPtr<CCFrameRateCounter> create()
20 {
21 return adoptPtr(new CCFrameRateCounter());
22 }
23
24 void markBeginningOfFrame(double timestamp);
25 void markEndOfFrame();
26 int currentFrameNumber() const { return m_currentFrameNumber; }
27 void getAverageFPSAndStandardDeviation(double& averageFPS, double& standardD eviation) const;
28 int timeStampHistorySize() const { return kTimeStampHistorySize; }
29
30 // n = 0 returns the oldest frame retained in the history,
31 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr ame.
32 double timeStampOfRecentFrame(int /* n */);
33
34 // This is a heuristic that can be used to ignore frames in a reasonable way . Returns
35 // true if the given frame interval is too fast or too slow, based on consta nt thresholds.
36 bool isBadFrameInterval(double intervalBetweenConsecutiveFrames) const;
37
38 int droppedFrameCount() const { return m_droppedFrameCount; }
39
40 private:
41 CCFrameRateCounter();
42
43 double frameInterval(int frameNumber) const;
44 int frameIndex(int frameNumber) const;
45 bool isBadFrame(int frameNumber) const;
46
47 // Two thresholds (measured in seconds) that describe what is considered to be a "no-op frame" that should not be counted.
48 // - if the frame is too fast, then given our compositor implementation, the frame probably was a no-op and did not draw.
49 // - if the frame is too slow, then there is probably not animating content, so we should not pollute the average.
50 static const double kFrameTooFast;
51 static const double kFrameTooSlow;
52
53 // If a frame takes longer than this threshold (measured in seconds) then we
54 // (naively) assume that it missed a screen refresh; that is, we dropped a f rame.
55 // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/ 138642.
56 static const double kDroppedFrameTime;
57
58 static const int kTimeStampHistorySize = 120;
59
60 int m_currentFrameNumber;
61 double m_timeStampHistory[kTimeStampHistorySize];
62
63 int m_droppedFrameCount;
64
65 DISALLOW_COPY_AND_ASSIGN(CCFrameRateCounter);
66 };
67
68 } // namespace cc
69
70 #endif // USE(ACCELERATED_COMPOSITING)
71
72 #endif
OLDNEW
« no previous file with comments | « cc/frame_rate_controller.cc ('k') | cc/frame_rate_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698