Index: cc/paint_time_counter.cc |
diff --git a/cc/paint_time_counter.cc b/cc/paint_time_counter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bf6d344c446a06fec8091bc289103836c9b88935 |
--- /dev/null |
+++ b/cc/paint_time_counter.cc |
@@ -0,0 +1,52 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "cc/paint_time_counter.h" |
+ |
+#include <limits> |
+ |
+namespace cc { |
+ |
+// static |
+scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() { |
+ return make_scoped_ptr(new PaintTimeCounter()); |
+} |
+ |
+PaintTimeCounter::PaintTimeCounter() { |
+} |
+ |
+double PaintTimeCounter::GetPaintTimeOfRecentFrame(int n) const { |
+ DCHECK(n >= 0); |
+ DCHECK(n < ring_buffer_.BufferSize()); |
+ |
+ if (ring_buffer_.IsFilledIndex(n)) |
+ return ring_buffer_.ReadBuffer(n); |
+ |
+ return 0; |
+} |
+ |
+void PaintTimeCounter::SavePaintTime(double total_paint_time) { |
+ double paint_time = total_paint_time - last_paint_time_; |
+ |
+ if (paint_time > 0) |
+ ring_buffer_.SaveToBuffer(paint_time); |
+ |
+ last_paint_time_ = total_paint_time; |
+} |
+ |
+void PaintTimeCounter::GetMinAndMaxPaintTime(double& min, double& max) const { |
reveman
2013/01/11 16:10:49
chromium style doesn't allow using references for
|
+ min = std::numeric_limits<double>::max(); |
+ max = 0; |
+ |
+ for (int i = ring_buffer_.BufferSize() - 1; i > 0 && ring_buffer_.IsFilledIndex(i); --i) { |
reveman
2013/01/11 16:10:49
nit: lines should not be >= 80 characters.
danakj
2013/01/11 16:39:09
s/>=/>/
"Each line of text in your code should be
|
+ double paint_time = ring_buffer_.ReadBuffer(i); |
+ min = std::min(paint_time, min); |
+ max = std::max(paint_time, max); |
+ } |
+ |
+ if (min > max) |
+ min = max; |
+} |
+ |
+} // namespace cc |