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
3 // found in the LICENSE file.
5 #include "cc/debug/rendering_stats.h"
9 RenderingStats::TimeDeltaList::TimeDeltaList() {
12 RenderingStats::TimeDeltaList::~TimeDeltaList() {
15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value
) {
16 values
.push_back(value
);
19 void RenderingStats::TimeDeltaList::AddToTracedValue(
20 base::debug::TracedValue
* list_value
) const {
21 for (const auto& value
: values
) {
22 list_value
->AppendDouble(value
.InMillisecondsF());
26 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList
& other
) {
27 values
.insert(values
.end(), other
.values
.begin(), other
.values
.end());
30 base::TimeDelta
RenderingStats::TimeDeltaList::GetLastTimeDelta() const {
31 return values
.empty() ? base::TimeDelta() : values
.back();
34 RenderingStats::RenderingStats()
36 visible_content_area(0),
37 approximated_visible_content_area(0) {
40 RenderingStats::~RenderingStats() {
43 scoped_refptr
<base::debug::ConvertableToTraceFormat
>
44 RenderingStats::AsTraceableData() const {
45 scoped_refptr
<base::debug::TracedValue
> record_data
=
46 new base::debug::TracedValue();
47 record_data
->SetInteger("frame_count", frame_count
);
48 record_data
->SetInteger("visible_content_area", visible_content_area
);
49 record_data
->SetInteger("approximated_visible_content_area",
50 approximated_visible_content_area
);
51 record_data
->BeginArray("draw_duration_ms");
52 draw_duration
.AddToTracedValue(record_data
.get());
53 record_data
->EndArray();
55 record_data
->BeginArray("draw_duration_estimate_ms");
56 draw_duration_estimate
.AddToTracedValue(record_data
.get());
57 record_data
->EndArray();
59 record_data
->BeginArray("begin_main_frame_to_commit_duration_ms");
60 begin_main_frame_to_commit_duration
.AddToTracedValue(record_data
.get());
61 record_data
->EndArray();
63 record_data
->BeginArray("begin_main_frame_to_commit_duration_estimate_ms");
64 begin_main_frame_to_commit_duration_estimate
.AddToTracedValue(
66 record_data
->EndArray();
68 record_data
->BeginArray("commit_to_activate_duration_ms");
69 commit_to_activate_duration
.AddToTracedValue(record_data
.get());
70 record_data
->EndArray();
72 record_data
->BeginArray("commit_to_activate_duration_estimate_ms");
73 commit_to_activate_duration_estimate
.AddToTracedValue(record_data
.get());
74 record_data
->EndArray();
78 void RenderingStats::Add(const RenderingStats
& other
) {
79 frame_count
+= other
.frame_count
;
80 visible_content_area
+= other
.visible_content_area
;
81 approximated_visible_content_area
+= other
.approximated_visible_content_area
;
83 draw_duration
.Add(other
.draw_duration
);
84 draw_duration_estimate
.Add(other
.draw_duration_estimate
);
85 begin_main_frame_to_commit_duration
.Add(
86 other
.begin_main_frame_to_commit_duration
);
87 begin_main_frame_to_commit_duration_estimate
.Add(
88 other
.begin_main_frame_to_commit_duration_estimate
);
89 commit_to_activate_duration
.Add(other
.commit_to_activate_duration
);
90 commit_to_activate_duration_estimate
.Add(
91 other
.commit_to_activate_duration_estimate
);