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

Unified Diff: cc/frame_rate_counter.h

Issue 11817011: cc: add RingBuffer class for timestamp storing in FrameRateCounter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cleaner test fix Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/cc.gyp ('k') | cc/frame_rate_counter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/frame_rate_counter.h
diff --git a/cc/frame_rate_counter.h b/cc/frame_rate_counter.h
index d1b6e9ac4dc42dfc53a8240b8187aaac166cfa64..0ddecb55e7ebb778cacfa917309e109cb62174b3 100644
--- a/cc/frame_rate_counter.h
+++ b/cc/frame_rate_counter.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
+#include "cc/ring_buffer.h"
namespace cc {
@@ -17,29 +18,27 @@ class FrameRateCounter {
public:
static scoped_ptr<FrameRateCounter> create(bool hasImplThread);
- void markBeginningOfFrame(base::TimeTicks timestamp);
- void markEndOfFrame();
- int currentFrameNumber() const { return m_currentFrameNumber; }
- double getAverageFPS() const;
- int timeStampHistorySize() const { return kTimeStampHistorySize; }
+ int currentFrameNumber() const { return m_ringBuffer.CurrentIndex(); }
+ int droppedFrameCount() const { return m_droppedFrameCount; }
+ size_t timeStampHistorySize() const { return m_ringBuffer.BufferSize(); }
+
+ void saveTimeStamp(base::TimeTicks timestamp);
// n = 0 returns the oldest frame retained in the history,
// while n = timeStampHistorySize() - 1 returns the timestamp most recent frame.
- // FIXME: Returns most recent timestamp for n = 0 when called between markBeginningOfFrame and markEndOfFrame calls.
- base::TimeTicks timeStampOfRecentFrame(int n) const;
+ base::TimeTicks timeStampOfRecentFrame(size_t n) const;
// This is a heuristic that can be used to ignore frames in a reasonable way. Returns
// true if the given frame interval is too fast or too slow, based on constant thresholds.
bool isBadFrameInterval(base::TimeDelta intervalBetweenConsecutiveFrames) const;
- int droppedFrameCount() const { return m_droppedFrameCount; }
+ void getMinAndMaxFPS(double& minFPS, double& maxFPS) const;
+ double getAverageFPS() const;
private:
explicit FrameRateCounter(bool hasImplThread);
- base::TimeDelta frameInterval(int frameNumber) const;
- int frameIndex(int frameNumber) const;
- bool isBadFrame(int frameNumber) const;
+ base::TimeDelta recentFrameInterval(size_t n) const;
// Two thresholds (measured in seconds) that describe what is considered to be a "no-op frame" that should not be counted.
// - if the frame is too fast, then given our compositor implementation, the frame probably was a no-op and did not draw.
@@ -52,13 +51,9 @@ private:
// FIXME: Determine this threshold based on monitor refresh rate, crbug.com/138642.
static const double kDroppedFrameTime;
- static const int kTimeStampHistorySize = 130;
+ RingBuffer<base::TimeTicks, 130> m_ringBuffer;
bool m_hasImplThread;
-
- int m_currentFrameNumber;
- base::TimeTicks m_timeStampHistory[kTimeStampHistorySize];
-
int m_droppedFrameCount;
DISALLOW_COPY_AND_ASSIGN(FrameRateCounter);
« no previous file with comments | « cc/cc.gyp ('k') | cc/frame_rate_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698