| 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 "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 int timeStampHistorySize() const { return kTimeStampHistorySize; } | 28 int timeStampHistorySize() const { return kTimeStampHistorySize; } |
| 29 | 29 |
| 30 // n = 0 returns the oldest frame retained in the history, | 30 // n = 0 returns the oldest frame retained in the history, |
| 31 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr
ame. | 31 // while n = timeStampHistorySize() - 1 returns the timestamp most recent fr
ame. |
| 32 double timeStampOfRecentFrame(int /* n */); | 32 double timeStampOfRecentFrame(int /* n */); |
| 33 | 33 |
| 34 // This is a heuristic that can be used to ignore frames in a reasonable way
. Returns | 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. | 35 // true if the given frame interval is too fast or too slow, based on consta
nt thresholds. |
| 36 bool isBadFrameInterval(double intervalBetweenConsecutiveFrames) const; | 36 bool isBadFrameInterval(double intervalBetweenConsecutiveFrames) const; |
| 37 | 37 |
| 38 int droppedFrameCount() const { return m_droppedFrameCount; } | |
| 39 | |
| 40 private: | 38 private: |
| 41 CCFrameRateCounter(); | 39 CCFrameRateCounter(); |
| 42 | 40 |
| 43 double frameInterval(int frameNumber) const; | 41 double frameInterval(int frameNumber) const; |
| 44 int frameIndex(int frameNumber) const; | 42 int frameIndex(int frameNumber) const; |
| 45 bool isBadFrame(int frameNumber) const; | 43 bool isBadFrame(int frameNumber) const; |
| 46 | 44 |
| 47 // Two thresholds (measured in seconds) that describe what is considered to
be a "no-op frame" that should not be counted. | 45 // 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. | 46 // - 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. | 47 // - 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; | 48 static const double kFrameTooFast; |
| 51 static const double kFrameTooSlow; | 49 static const double kFrameTooSlow; |
| 52 | 50 |
| 53 // If a frame takes longer than this threshold (measured in seconds) then we | 51 // 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. | 52 // (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. | 53 // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/
138642. |
| 56 static const double kDroppedFrameTime; | 54 static const double kDroppedFrameTime; |
| 57 | 55 |
| 58 static const int kTimeStampHistorySize = 120; | 56 static const int kTimeStampHistorySize = 120; |
| 59 | 57 |
| 60 int m_currentFrameNumber; | 58 int m_currentFrameNumber; |
| 61 double m_timeStampHistory[kTimeStampHistorySize]; | 59 double m_timeStampHistory[kTimeStampHistorySize]; |
| 62 | 60 |
| 63 int m_droppedFrameCount; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(CCFrameRateCounter); | 61 DISALLOW_COPY_AND_ASSIGN(CCFrameRateCounter); |
| 66 }; | 62 }; |
| 67 | 63 |
| 68 } // namespace cc | 64 } // namespace cc |
| 69 | 65 |
| 70 #endif // USE(ACCELERATED_COMPOSITING) | 66 #endif // USE(ACCELERATED_COMPOSITING) |
| 71 | 67 |
| 72 #endif | 68 #endif |
| OLD | NEW |