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

Side by Side Diff: cc/paint_time_counter.cc

Issue 12209022: cc: add rasterize time to continuous painting graph data in impl-side-painting (Closed) Base URL: http://git.chromium.org/chromium/src.git@raster
Patch Set: Created 7 years, 10 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
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/paint_time_counter.h" 5 #include "cc/paint_time_counter.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 // static 9 // static
10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() { 10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() {
11 return make_scoped_ptr(new PaintTimeCounter()); 11 return make_scoped_ptr(new PaintTimeCounter());
12 } 12 }
13 13
14 PaintTimeCounter::PaintTimeCounter() { 14 PaintTimeCounter::PaintTimeCounter()
15 : last_frame_number(-2) {
15 } 16 }
16 17
17 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame( 18 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame(
18 const size_t& n) const { 19 const size_t& n) const {
19 DCHECK(n < ring_buffer_.BufferSize()); 20 DCHECK(n < ring_buffer_.BufferSize());
20 21
21 if (ring_buffer_.IsFilledIndex(n)) 22 if (ring_buffer_.IsFilledIndex(n))
22 return ring_buffer_.ReadBuffer(n); 23 return ring_buffer_.ReadBuffer(n);
23 24
24 return base::TimeDelta(); 25 return base::TimeDelta();
25 } 26 }
26 27
27 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) { 28 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time,
29 const int& frame_number) {
28 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_; 30 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_;
29 31
30 if (paint_time.InMillisecondsF() > 0) 32 if (paint_time.InMillisecondsF() > 0 && frame_number == last_frame_number + 1)
31 ring_buffer_.SaveToBuffer(paint_time); 33 ring_buffer_.SaveToBuffer(paint_time);
32 34
33 last_total_paint_time_ = total_paint_time; 35 last_total_paint_time_ = total_paint_time;
36 last_frame_number = frame_number;
34 } 37 }
35 38
36 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, 39 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min,
37 base::TimeDelta* max) const { 40 base::TimeDelta* max) const {
38 *min = base::TimeDelta::FromDays(1); 41 *min = base::TimeDelta::FromDays(1);
39 *max = base::TimeDelta(); 42 *max = base::TimeDelta();
40 43
41 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) { 44 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
42 if (ring_buffer_.IsFilledIndex(i)) { 45 if (ring_buffer_.IsFilledIndex(i)) {
43 base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i); 46 base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i);
44 47
45 if (paint_time < *min) 48 if (paint_time < *min)
46 *min = paint_time; 49 *min = paint_time;
47 if (paint_time > *max) 50 if (paint_time > *max)
48 *max = paint_time; 51 *max = paint_time;
49 } 52 }
50 } 53 }
51 54
52 if (*min > *max) 55 if (*min > *max)
53 *min = *max; 56 *min = *max;
54 } 57 }
55 58
56 } // namespace cc 59 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698