Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/paint_time_counter.h" | |
| 6 | |
| 7 #include <limits> | |
| 8 | |
| 9 namespace cc { | |
| 10 | |
| 11 // static | |
| 12 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() { | |
| 13 return make_scoped_ptr(new PaintTimeCounter()); | |
| 14 } | |
| 15 | |
| 16 PaintTimeCounter::PaintTimeCounter() { | |
| 17 } | |
| 18 | |
| 19 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame(const size_t& n) con st { | |
|
reveman
2013/01/16 22:48:04
nit: line not <= 80 characters long.
| |
| 20 DCHECK(n < ring_buffer_.BufferSize()); | |
| 21 | |
| 22 if (ring_buffer_.IsFilledIndex(n)) | |
| 23 return ring_buffer_.ReadBuffer(n); | |
| 24 | |
| 25 return base::TimeDelta(); | |
| 26 } | |
| 27 | |
| 28 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) { | |
| 29 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_; | |
| 30 | |
| 31 if (paint_time.InMillisecondsF() > 0) | |
| 32 ring_buffer_.SaveToBuffer(paint_time); | |
| 33 | |
| 34 last_total_paint_time_ = total_paint_time; | |
| 35 } | |
| 36 | |
| 37 void PaintTimeCounter::GetMinAndMaxPaintTimeInMilliseconds(double* min, double* max) const { | |
|
reveman
2013/01/16 22:48:04
nit: line not <= 80 characters long.
| |
| 38 *min = std::numeric_limits<double>::max(); | |
| 39 *max = 0; | |
| 40 | |
| 41 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) { | |
|
egraether
2013/01/16 19:31:56
Loops in increasing direction because the iterator
| |
| 42 if (ring_buffer_.IsFilledIndex(i)) { | |
| 43 double paint_time = ring_buffer_.ReadBuffer(i).InMillisecondsF(); | |
| 44 *min = std::min(paint_time, *min); | |
| 45 *max = std::max(paint_time, *max); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 if (*min > *max) | |
| 50 *min = *max; | |
| 51 } | |
| 52 | |
| 53 } // namespace cc | |
| OLD | NEW |