#ifndef CC_DEBUG_PAINT_TIME_COUNTER_H_
#define CC_DEBUG_PAINT_TIME_COUNTER_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "cc/debug/ring_buffer.h"
namespace cc {
class PaintTimeCounter {
public:
static scoped_ptr<PaintTimeCounter> Create();
size_t HistorySize() const { return ring_buffer_.BufferSize(); }
base::TimeDelta GetPaintTimeOfRecentFrame(const size_t& n) const;
void SavePaintTime(const base::TimeDelta& total_paint_time);
void GetMinAndMaxPaintTime(base::TimeDelta* min, base::TimeDelta* max) const;
void ClearHistory();
typedef RingBuffer<base::TimeDelta, 200> RingBufferType;
RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); }
RingBufferType::Iterator End() const { return ring_buffer_.End(); }
private:
PaintTimeCounter();
RingBufferType ring_buffer_;
base::TimeDelta last_total_paint_time_;
bool can_save_paint_time_delta_;
DISALLOW_COPY_AND_ASSIGN(PaintTimeCounter);
};
}
#endif