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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months 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/debug/frame_timing_tracker.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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 11
12 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "cc/trees/proxy.h" 14 #include "cc/trees/proxy.h"
14 15
15 namespace cc { 16 namespace cc {
16 17
17 // The following constants are measured in seconds. 18 // The following constants are measured in seconds.
18 19
19 // Two thresholds (measured in seconds) that describe what is considered to be a 20 // Two thresholds (measured in seconds) that describe what is considered to be a
20 // "no-op frame" that should not be counted. 21 // "no-op frame" that should not be counted.
21 // - if the frame is too fast, then given our compositor implementation, the 22 // - if the frame is too fast, then given our compositor implementation, the
22 // frame probably was a no-op and did not draw. 23 // frame probably was a no-op and did not draw.
23 // - if the frame is too slow, then there is probably not animating content, so 24 // - if the frame is too slow, then there is probably not animating content, so
24 // we should not pollute the average. 25 // we should not pollute the average.
25 static const double kFrameTooFast = 1.0 / 70.0; 26 static const double kFrameTooFast = 1.0 / 70.0;
26 static const double kFrameTooSlow = 1.5; 27 static const double kFrameTooSlow = 1.5;
27 28
28 // If a frame takes longer than this threshold (measured in seconds) then we 29 // If a frame takes longer than this threshold (measured in seconds) then we
29 // (naively) assume that it missed a screen refresh; that is, we dropped a 30 // (naively) assume that it missed a screen refresh; that is, we dropped a
30 // frame. 31 // frame.
31 // TODO(brianderson): Determine this threshold based on monitor refresh rate, 32 // TODO(brianderson): Determine this threshold based on monitor refresh rate,
32 // crbug.com/138642. 33 // crbug.com/138642.
33 static const double kDroppedFrameTime = 1.0 / 50.0; 34 static const double kDroppedFrameTime = 1.0 / 50.0;
34 35
35 // static 36 // static
36 scoped_ptr<FrameRateCounter> FrameRateCounter::Create(bool has_impl_thread) { 37 std::unique_ptr<FrameRateCounter> FrameRateCounter::Create(
37 return make_scoped_ptr(new FrameRateCounter(has_impl_thread)); 38 bool has_impl_thread) {
39 return base::WrapUnique(new FrameRateCounter(has_impl_thread));
38 } 40 }
39 41
40 base::TimeDelta FrameRateCounter::RecentFrameInterval(size_t n) const { 42 base::TimeDelta FrameRateCounter::RecentFrameInterval(size_t n) const {
41 DCHECK_GT(n, 0u); 43 DCHECK_GT(n, 0u);
42 DCHECK_LT(n, ring_buffer_.BufferSize()); 44 DCHECK_LT(n, ring_buffer_.BufferSize());
43 return ring_buffer_.ReadBuffer(n) - ring_buffer_.ReadBuffer(n - 1); 45 return ring_buffer_.ReadBuffer(n) - ring_buffer_.ReadBuffer(n - 1);
44 } 46 }
45 47
46 FrameRateCounter::FrameRateCounter(bool has_impl_thread) 48 FrameRateCounter::FrameRateCounter(bool has_impl_thread)
47 : has_impl_thread_(has_impl_thread), dropped_frame_count_(0) {} 49 : has_impl_thread_(has_impl_thread), dropped_frame_count_(0) {}
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 143
142 if (frame_count) { 144 if (frame_count) {
143 DCHECK_GT(frame_times_total, 0.0); 145 DCHECK_GT(frame_times_total, 0.0);
144 average_fps = frame_count / frame_times_total; 146 average_fps = frame_count / frame_times_total;
145 } 147 }
146 148
147 return average_fps; 149 return average_fps;
148 } 150 }
149 151
150 } // namespace cc 152 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/frame_rate_counter.h ('k') | cc/debug/frame_timing_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698