OLD | NEW |
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 | 4 |
5 #ifndef CCFrameRateCounter_h | 5 #ifndef CCFrameRateCounter_h |
6 #define CCFrameRateCounter_h | 6 #define CCFrameRateCounter_h |
7 | 7 |
8 #if USE(ACCELERATED_COMPOSITING) | 8 #if USE(ACCELERATED_COMPOSITING) |
9 | 9 |
10 #include <wtf/Noncopyable.h> | 10 #include "base/basictypes.h" |
11 #include <wtf/PassOwnPtr.h> | 11 #include <wtf/PassOwnPtr.h> |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 // This class maintains a history of timestamps, and provides functionality to | 15 // This class maintains a history of timestamps, and provides functionality to |
16 // intelligently compute average frames per second (and standard deviation). | 16 // intelligently compute average frames per second (and standard deviation). |
17 class CCFrameRateCounter { | 17 class CCFrameRateCounter { |
18 WTF_MAKE_NONCOPYABLE(CCFrameRateCounter); | |
19 public: | 18 public: |
20 static PassOwnPtr<CCFrameRateCounter> create() | 19 static PassOwnPtr<CCFrameRateCounter> create() |
21 { | 20 { |
22 return adoptPtr(new CCFrameRateCounter()); | 21 return adoptPtr(new CCFrameRateCounter()); |
23 } | 22 } |
24 | 23 |
25 void markBeginningOfFrame(double timestamp); | 24 void markBeginningOfFrame(double timestamp); |
26 void markEndOfFrame(); | 25 void markEndOfFrame(); |
27 int currentFrameNumber() const { return m_currentFrameNumber; } | 26 int currentFrameNumber() const { return m_currentFrameNumber; } |
28 void getAverageFPSAndStandardDeviation(double& averageFPS, double& standardD
eviation) const; | 27 void getAverageFPSAndStandardDeviation(double& averageFPS, double& standardD
eviation) const; |
(...skipping 26 matching lines...) Expand all Loading... |
55 // (naively) assume that it missed a screen refresh; that is, we dropped a f
rame. | 54 // (naively) assume that it missed a screen refresh; that is, we dropped a f
rame. |
56 // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/
138642. | 55 // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/
138642. |
57 static const double kDroppedFrameTime; | 56 static const double kDroppedFrameTime; |
58 | 57 |
59 static const int kTimeStampHistorySize = 120; | 58 static const int kTimeStampHistorySize = 120; |
60 | 59 |
61 int m_currentFrameNumber; | 60 int m_currentFrameNumber; |
62 double m_timeStampHistory[kTimeStampHistorySize]; | 61 double m_timeStampHistory[kTimeStampHistorySize]; |
63 | 62 |
64 int m_droppedFrameCount; | 63 int m_droppedFrameCount; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(CCFrameRateCounter); |
65 }; | 66 }; |
66 | 67 |
67 } // namespace cc | 68 } // namespace cc |
68 | 69 |
69 #endif // USE(ACCELERATED_COMPOSITING) | 70 #endif // USE(ACCELERATED_COMPOSITING) |
70 | 71 |
71 #endif | 72 #endif |
OLD | NEW |