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/rendering_stats.h" | 5 #include "cc/debug/rendering_stats.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 RenderingStats::TimeDeltaList::TimeDeltaList() { | 9 RenderingStats::TimeDeltaList::TimeDeltaList() { |
10 } | 10 } |
11 | 11 |
12 RenderingStats::TimeDeltaList::~TimeDeltaList() { | 12 RenderingStats::TimeDeltaList::~TimeDeltaList() { |
13 } | 13 } |
14 | 14 |
15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { | 15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { |
16 values.push_back(value); | 16 values.push_back(value); |
17 } | 17 } |
18 | 18 |
19 void RenderingStats::TimeDeltaList::AddToTracedValue( | 19 void RenderingStats::TimeDeltaList::AddToTracedValue( |
| 20 const char* name, |
20 base::debug::TracedValue* list_value) const { | 21 base::debug::TracedValue* list_value) const { |
| 22 list_value->BeginArray(name); |
21 for (const auto& value : values) { | 23 for (const auto& value : values) { |
22 list_value->AppendDouble(value.InMillisecondsF()); | 24 list_value->AppendDouble(value.InMillisecondsF()); |
23 } | 25 } |
| 26 list_value->EndArray(); |
24 } | 27 } |
25 | 28 |
26 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) { | 29 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) { |
27 values.insert(values.end(), other.values.begin(), other.values.end()); | 30 values.insert(values.end(), other.values.begin(), other.values.end()); |
28 } | 31 } |
29 | 32 |
30 base::TimeDelta RenderingStats::TimeDeltaList::GetLastTimeDelta() const { | 33 base::TimeDelta RenderingStats::TimeDeltaList::GetLastTimeDelta() const { |
31 return values.empty() ? base::TimeDelta() : values.back(); | 34 return values.empty() ? base::TimeDelta() : values.back(); |
32 } | 35 } |
33 | 36 |
34 RenderingStats::RenderingStats() | 37 RenderingStats::RenderingStats() |
35 : frame_count(0), | 38 : frame_count(0), |
36 visible_content_area(0), | 39 visible_content_area(0), |
37 approximated_visible_content_area(0) { | 40 approximated_visible_content_area(0) { |
38 } | 41 } |
39 | 42 |
40 RenderingStats::~RenderingStats() { | 43 RenderingStats::~RenderingStats() { |
41 } | 44 } |
42 | 45 |
43 scoped_refptr<base::debug::ConvertableToTraceFormat> | 46 scoped_refptr<base::debug::ConvertableToTraceFormat> |
44 RenderingStats::AsTraceableData() const { | 47 RenderingStats::AsTraceableData() const { |
45 scoped_refptr<base::debug::TracedValue> record_data = | 48 scoped_refptr<base::debug::TracedValue> record_data = |
46 new base::debug::TracedValue(); | 49 new base::debug::TracedValue(); |
47 record_data->SetInteger("frame_count", frame_count); | 50 record_data->SetInteger("frame_count", frame_count); |
48 record_data->SetInteger("visible_content_area", visible_content_area); | 51 record_data->SetInteger("visible_content_area", visible_content_area); |
49 record_data->SetInteger("approximated_visible_content_area", | 52 record_data->SetInteger("approximated_visible_content_area", |
50 approximated_visible_content_area); | 53 approximated_visible_content_area); |
51 record_data->BeginArray("draw_duration_ms"); | 54 draw_duration.AddToTracedValue("draw_duration_ms", record_data.get()); |
52 draw_duration.AddToTracedValue(record_data.get()); | |
53 record_data->EndArray(); | |
54 | 55 |
55 record_data->BeginArray("draw_duration_estimate_ms"); | 56 draw_duration_estimate.AddToTracedValue("draw_duration_estimate_ms", |
56 draw_duration_estimate.AddToTracedValue(record_data.get()); | 57 record_data.get()); |
57 record_data->EndArray(); | |
58 | 58 |
59 record_data->BeginArray("begin_main_frame_to_commit_duration_ms"); | 59 begin_main_frame_to_commit_duration.AddToTracedValue( |
60 begin_main_frame_to_commit_duration.AddToTracedValue(record_data.get()); | 60 "begin_main_frame_to_commit_duration_ms", record_data.get()); |
61 record_data->EndArray(); | |
62 | 61 |
63 record_data->BeginArray("begin_main_frame_to_commit_duration_estimate_ms"); | |
64 begin_main_frame_to_commit_duration_estimate.AddToTracedValue( | 62 begin_main_frame_to_commit_duration_estimate.AddToTracedValue( |
65 record_data.get()); | 63 "begin_main_frame_to_commit_duration_estimate_ms", record_data.get()); |
66 record_data->EndArray(); | |
67 | 64 |
68 record_data->BeginArray("commit_to_activate_duration_ms"); | 65 commit_to_activate_duration.AddToTracedValue("commit_to_activate_duration_ms", |
69 commit_to_activate_duration.AddToTracedValue(record_data.get()); | 66 record_data.get()); |
70 record_data->EndArray(); | |
71 | 67 |
72 record_data->BeginArray("commit_to_activate_duration_estimate_ms"); | 68 commit_to_activate_duration_estimate.AddToTracedValue( |
73 commit_to_activate_duration_estimate.AddToTracedValue(record_data.get()); | 69 "commit_to_activate_duration_estimate_ms", record_data.get()); |
74 record_data->EndArray(); | |
75 return record_data; | 70 return record_data; |
76 } | 71 } |
77 | 72 |
78 void RenderingStats::Add(const RenderingStats& other) { | 73 void RenderingStats::Add(const RenderingStats& other) { |
79 frame_count += other.frame_count; | 74 frame_count += other.frame_count; |
80 visible_content_area += other.visible_content_area; | 75 visible_content_area += other.visible_content_area; |
81 approximated_visible_content_area += other.approximated_visible_content_area; | 76 approximated_visible_content_area += other.approximated_visible_content_area; |
82 | 77 |
83 draw_duration.Add(other.draw_duration); | 78 draw_duration.Add(other.draw_duration); |
84 draw_duration_estimate.Add(other.draw_duration_estimate); | 79 draw_duration_estimate.Add(other.draw_duration_estimate); |
85 begin_main_frame_to_commit_duration.Add( | 80 begin_main_frame_to_commit_duration.Add( |
86 other.begin_main_frame_to_commit_duration); | 81 other.begin_main_frame_to_commit_duration); |
87 begin_main_frame_to_commit_duration_estimate.Add( | 82 begin_main_frame_to_commit_duration_estimate.Add( |
88 other.begin_main_frame_to_commit_duration_estimate); | 83 other.begin_main_frame_to_commit_duration_estimate); |
89 commit_to_activate_duration.Add(other.commit_to_activate_duration); | 84 commit_to_activate_duration.Add(other.commit_to_activate_duration); |
90 commit_to_activate_duration_estimate.Add( | 85 commit_to_activate_duration_estimate.Add( |
91 other.commit_to_activate_duration_estimate); | 86 other.commit_to_activate_duration_estimate); |
92 } | 87 } |
93 | 88 |
94 } // namespace cc | 89 } // namespace cc |
OLD | NEW |