| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "cc/debug/frame_rate_counter.h" | 5 #include "cc/debug/frame_rate_counter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 base::TimeDelta FrameRateCounter::RecentFrameInterval(size_t n) const { | 38 base::TimeDelta FrameRateCounter::RecentFrameInterval(size_t n) const { |
| 39 DCHECK_GT(n, 0u); | 39 DCHECK_GT(n, 0u); |
| 40 DCHECK_LT(n, ring_buffer_.BufferSize()); | 40 DCHECK_LT(n, ring_buffer_.BufferSize()); |
| 41 return ring_buffer_.ReadBuffer(n) - ring_buffer_.ReadBuffer(n - 1); | 41 return ring_buffer_.ReadBuffer(n) - ring_buffer_.ReadBuffer(n - 1); |
| 42 } | 42 } |
| 43 | 43 |
| 44 FrameRateCounter::FrameRateCounter(bool has_impl_thread) | 44 FrameRateCounter::FrameRateCounter(bool has_impl_thread) |
| 45 : has_impl_thread_(has_impl_thread), dropped_frame_count_(0) {} | 45 : has_impl_thread_(has_impl_thread), dropped_frame_count_(0) {} |
| 46 | 46 |
| 47 void FrameRateCounter::SaveTimeStamp(base::TimeTicks timestamp, bool software) { | 47 void FrameRateCounter::SaveTimeStamp(gfx::FrameTime timestamp, bool software) { |
| 48 ring_buffer_.SaveToBuffer(timestamp); | 48 ring_buffer_.SaveToBuffer(timestamp); |
| 49 | 49 |
| 50 // Check if frame interval can be computed. | 50 // Check if frame interval can be computed. |
| 51 if (ring_buffer_.CurrentIndex() < 2) | 51 if (ring_buffer_.CurrentIndex() < 2) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 base::TimeDelta frame_interval_seconds = | 54 base::TimeDelta frame_interval_seconds = |
| 55 RecentFrameInterval(ring_buffer_.BufferSize() - 1); | 55 RecentFrameInterval(ring_buffer_.BufferSize() - 1); |
| 56 | 56 |
| 57 if (has_impl_thread_ && ring_buffer_.CurrentIndex() > 0) { | 57 if (has_impl_thread_ && ring_buffer_.CurrentIndex() > 0) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 if (frame_count) { | 140 if (frame_count) { |
| 141 DCHECK_GT(frame_times_total, 0.0); | 141 DCHECK_GT(frame_times_total, 0.0); |
| 142 average_fps = frame_count / frame_times_total; | 142 average_fps = frame_count / frame_times_total; |
| 143 } | 143 } |
| 144 | 144 |
| 145 return average_fps; | 145 return average_fps; |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace cc | 148 } // namespace cc |
| OLD | NEW |