Chromium Code Reviews| Index: cc/paint_time_counter.cc |
| diff --git a/cc/paint_time_counter.cc b/cc/paint_time_counter.cc |
| index 25b1bc677e9a7829cdf844a75d5c17588deeb5d4..243a4343ab460c18c66ae5e7078f25f097c09442 100644 |
| --- a/cc/paint_time_counter.cc |
| +++ b/cc/paint_time_counter.cc |
| @@ -11,7 +11,9 @@ scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() { |
| return make_scoped_ptr(new PaintTimeCounter()); |
| } |
| -PaintTimeCounter::PaintTimeCounter() { |
| +PaintTimeCounter::PaintTimeCounter() |
| + : can_save_paint_time_delta(false), |
| + can_save_rasterize_time_delta(false) { |
| } |
| base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame( |
| @@ -19,18 +21,35 @@ base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame( |
| DCHECK(n < ring_buffer_.BufferSize()); |
| if (ring_buffer_.IsFilledIndex(n)) |
| - return ring_buffer_.ReadBuffer(n); |
| + return ring_buffer_.ReadBuffer(n).time(); |
| return base::TimeDelta(); |
| } |
| -void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) { |
| - base::TimeDelta paint_time = total_paint_time - last_total_paint_time_; |
| - |
| - if (paint_time.InMillisecondsF() > 0) |
| - ring_buffer_.SaveToBuffer(paint_time); |
| +void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time, |
| + const int& commit_number) { |
| + if (can_save_paint_time_delta) { |
|
egraether
2013/02/13 20:28:07
These checks that no entry gets saved, when it's n
|
| + Entry entry; |
| + entry.commit_number = commit_number; |
| + entry.paint_time = total_paint_time - last_total_paint_time_; |
| + ring_buffer_.SaveToBuffer(entry); |
| + } |
| last_total_paint_time_ = total_paint_time; |
| + can_save_paint_time_delta = true; |
| +} |
| + |
| +void PaintTimeCounter::SaveRasterizeTime( |
| + const base::TimeDelta& total_rasterize_time, |
| + const int& commit_number) { |
| + if (can_save_rasterize_time_delta) { |
| + Entry entry = ring_buffer_.MutableReadBuffer(ring_buffer_.BufferSize() - 1); |
| + DCHECK(commit_number == entry.commit_number); |
|
egraether
2013/02/13 20:28:07
This checks whether the assumption that rasterize
|
| + entry.rasterize_time = total_rasterize_time - last_total_rasterize_time_; |
| + } |
| + |
| + last_total_rasterize_time_ = total_rasterize_time; |
| + can_save_rasterize_time_delta = true; |
| } |
| void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, |
| @@ -40,7 +59,7 @@ void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, |
| for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) { |
| if (ring_buffer_.IsFilledIndex(i)) { |
| - base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i); |
| + base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i).time(); |
| if (paint_time < *min) |
| *min = paint_time; |
| @@ -53,4 +72,10 @@ void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, |
| *min = *max; |
| } |
| +void PaintTimeCounter::ClearHistory() { |
| + ring_buffer_.Clear(); |
| + can_save_paint_time_delta = false; |
| + can_save_rasterize_time_delta = false; |
| +} |
| + |
| } // namespace cc |