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(
21 base::trace_event::TracedValue
* list_value
) const {
22 list_value
->BeginArray(name
);
23 for (const auto& value
: values
) {
24 list_value
->AppendDouble(value
.InMillisecondsF());
26 list_value
->EndArray();
29 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList
& other
) {
30 values
.insert(values
.end(), other
.values
.begin(), other
.values
.end());
33 base::TimeDelta
RenderingStats::TimeDeltaList::GetLastTimeDelta() const {
34 return values
.empty() ? base::TimeDelta() : values
.back();
37 RenderingStats::RenderingStats()
39 visible_content_area(0),
40 approximated_visible_content_area(0),
41 checkerboarded_visible_content_area(0) {
44 RenderingStats::~RenderingStats() {
47 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
>
48 RenderingStats::AsTraceableData() const {
49 scoped_refptr
<base::trace_event::TracedValue
> record_data
=
50 new base::trace_event::TracedValue();
51 record_data
->SetInteger("frame_count", frame_count
);
52 record_data
->SetInteger("visible_content_area", visible_content_area
);
53 record_data
->SetInteger("approximated_visible_content_area",
54 approximated_visible_content_area
);
55 record_data
->SetInteger("checkerboarded_visible_content_area",
56 checkerboarded_visible_content_area
);
57 draw_duration
.AddToTracedValue("draw_duration_ms", record_data
.get());
59 draw_duration_estimate
.AddToTracedValue("draw_duration_estimate_ms",
62 begin_main_frame_to_commit_duration
.AddToTracedValue(
63 "begin_main_frame_to_commit_duration_ms", record_data
.get());
65 begin_main_frame_to_commit_duration_estimate
.AddToTracedValue(
66 "begin_main_frame_to_commit_duration_estimate_ms", record_data
.get());
68 commit_to_activate_duration
.AddToTracedValue("commit_to_activate_duration_ms",
71 commit_to_activate_duration_estimate
.AddToTracedValue(
72 "commit_to_activate_duration_estimate_ms", record_data
.get());
76 void RenderingStats::Add(const RenderingStats
& other
) {
77 frame_count
+= other
.frame_count
;
78 visible_content_area
+= other
.visible_content_area
;
79 approximated_visible_content_area
+= other
.approximated_visible_content_area
;
80 checkerboarded_visible_content_area
+=
81 other
.checkerboarded_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
);