Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: cc/debug/frame_rate_counter.cc

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/debug/frame_rate_counter.h ('k') | cc/input/input_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « cc/debug/frame_rate_counter.h ('k') | cc/input/input_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698