| 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 CC_FRAME_RATE_COUNTER_H_ | 5 #ifndef CC_FRAME_RATE_COUNTER_H_ |
| 6 #define CC_FRAME_RATE_COUNTER_H_ | 6 #define CC_FRAME_RATE_COUNTER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 // This class maintains a history of timestamps, and provides functionality to | 14 // This class maintains a history of timestamps, and provides functionality to |
| 15 // intelligently compute average frames per second (and standard deviation). | 15 // intelligently compute average frames per second. |
| 16 class FrameRateCounter { | 16 class FrameRateCounter { |
| 17 public: | 17 public: |
| 18 static scoped_ptr<FrameRateCounter> create(bool hasImplThread); | 18 static scoped_ptr<FrameRateCounter> create(bool hasImplThread); |
| 19 | 19 |
| 20 void markBeginningOfFrame(base::TimeTicks timestamp); | 20 void markBeginningOfFrame(base::TimeTicks timestamp); |
| 21 void markEndOfFrame(); | 21 void markEndOfFrame(); |
| 22 int currentFrameNumber() const { return m_currentFrameNumber; } | 22 int currentFrameNumber() const { return m_currentFrameNumber; } |
| 23 void getAverageFPSAndStandardDeviation(double& averageFPS, double& standardD
eviation) const; | 23 double getAverageFPS() const; |
| 24 int timeStampHistorySize() const { return kTimeStampHistorySize; } | 24 int timeStampHistorySize() const { return kTimeStampHistorySize; } |
| 25 | 25 |
| 26 // n = 0 returns the oldest frame retained in the history, | 26 // n = 0 returns the oldest frame retained in the history, |
| 27 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr
ame. | 27 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr
ame. |
| 28 // FIXME: Returns most recent timestamp for n = 0 when called between markBe
ginningOfFrame and markEndOfFrame calls. | 28 // FIXME: Returns most recent timestamp for n = 0 when called between markBe
ginningOfFrame and markEndOfFrame calls. |
| 29 base::TimeTicks timeStampOfRecentFrame(int n) const; | 29 base::TimeTicks timeStampOfRecentFrame(int n) const; |
| 30 | 30 |
| 31 // This is a heuristic that can be used to ignore frames in a reasonable way
. Returns | 31 // This is a heuristic that can be used to ignore frames in a reasonable way
. Returns |
| 32 // true if the given frame interval is too fast or too slow, based on consta
nt thresholds. | 32 // true if the given frame interval is too fast or too slow, based on consta
nt thresholds. |
| 33 bool isBadFrameInterval(base::TimeDelta intervalBetweenConsecutiveFrames) co
nst; | 33 bool isBadFrameInterval(base::TimeDelta intervalBetweenConsecutiveFrames) co
nst; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 60 base::TimeTicks m_timeStampHistory[kTimeStampHistorySize]; | 60 base::TimeTicks m_timeStampHistory[kTimeStampHistorySize]; |
| 61 | 61 |
| 62 int m_droppedFrameCount; | 62 int m_droppedFrameCount; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(FrameRateCounter); | 64 DISALLOW_COPY_AND_ASSIGN(FrameRateCounter); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace cc | 67 } // namespace cc |
| 68 | 68 |
| 69 #endif // CC_FRAME_RATE_COUNTER_H_ | 69 #endif // CC_FRAME_RATE_COUNTER_H_ |
| OLD | NEW |