| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PAINT_TIME_COUNTER_H_ | 5 #ifndef CC_PAINT_TIME_COUNTER_H_ |
| 6 #define CC_PAINT_TIME_COUNTER_H_ | 6 #define CC_PAINT_TIME_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 #include "cc/ring_buffer.h" | 11 #include "cc/ring_buffer.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 // Maintains a history of paint times for each frame | 15 // Maintains a history of paint times for each frame |
| 16 class PaintTimeCounter { | 16 class PaintTimeCounter { |
| 17 public: | 17 public: |
| 18 static scoped_ptr<PaintTimeCounter> create(); | 18 static scoped_ptr<PaintTimeCounter> create(); |
| 19 | 19 |
| 20 size_t HistorySize() const { return ring_buffer_.BufferSize(); } | 20 size_t HistorySize() const { return ring_buffer_.BufferSize(); } |
| 21 | 21 |
| 22 // n = 0 returns the oldest and | 22 // n = 0 returns the oldest and |
| 23 // n = PaintTimeHistorySize() - 1 the most recent paint time. | 23 // n = PaintTimeHistorySize() - 1 the most recent paint time. |
| 24 base::TimeDelta GetPaintTimeOfRecentFrame(const size_t& n) const; | 24 base::TimeDelta GetPaintTimeOfRecentFrame(const size_t& n) const; |
| 25 | 25 |
| 26 void SavePaintTime(const base::TimeDelta& total_paint_time); | 26 void SavePaintTime(const base::TimeDelta& total_paint_time, |
| 27 const int& frame_number); |
| 27 void GetMinAndMaxPaintTime(base::TimeDelta* min, base::TimeDelta* max) const; | 28 void GetMinAndMaxPaintTime(base::TimeDelta* min, base::TimeDelta* max) const; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 PaintTimeCounter(); | 31 PaintTimeCounter(); |
| 31 | 32 |
| 32 RingBuffer<base::TimeDelta, 80> ring_buffer_; | 33 RingBuffer<base::TimeDelta, 80> ring_buffer_; |
| 33 base::TimeDelta last_total_paint_time_; | 34 base::TimeDelta last_total_paint_time_; |
| 35 int last_frame_number; |
| 34 | 36 |
| 35 DISALLOW_COPY_AND_ASSIGN(PaintTimeCounter); | 37 DISALLOW_COPY_AND_ASSIGN(PaintTimeCounter); |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 } // namespace cc | 40 } // namespace cc |
| 39 | 41 |
| 40 #endif // CC_PAINT_TIME_COUNTER_H_ | 42 #endif // CC_PAINT_TIME_COUNTER_H_ |
| OLD | NEW |