[NaCl SDK]: use standard __BEGIN_DECLS macros in sys/select.h
[chromium-blink-merge.git] / cc / debug / rendering_stats.cc
blobb5989fc121285dc49483498ab3060f84ae9cc3d9
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"
7 namespace cc {
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 std::list<base::TimeDelta>::const_iterator iter;
22 for (iter = values.begin(); iter != values.end(); ++iter) {
23 list_value->AppendDouble(iter->InMillisecondsF());
27 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) {
28 values.insert(values.end(), other.values.begin(), other.values.end());
31 RenderingStats::MainThreadRenderingStats::MainThreadRenderingStats()
32 : frame_count(0), painted_pixel_count(0), recorded_pixel_count(0) {
35 RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() {
38 scoped_refptr<base::debug::ConvertableToTraceFormat>
39 RenderingStats::MainThreadRenderingStats::AsTraceableData() const {
40 scoped_refptr<base::debug::TracedValue> record_data =
41 new base::debug::TracedValue();
42 record_data->SetInteger("frame_count", frame_count);
43 record_data->SetDouble("paint_time", paint_time.InSecondsF());
44 record_data->SetInteger("painted_pixel_count", painted_pixel_count);
45 record_data->SetDouble("record_time", record_time.InSecondsF());
46 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count);
47 return record_data;
50 void RenderingStats::MainThreadRenderingStats::Add(
51 const MainThreadRenderingStats& other) {
52 frame_count += other.frame_count;
53 paint_time += other.paint_time;
54 painted_pixel_count += other.painted_pixel_count;
55 record_time += other.record_time;
56 recorded_pixel_count += other.recorded_pixel_count;
59 RenderingStats::ImplThreadRenderingStats::ImplThreadRenderingStats()
60 : frame_count(0),
61 rasterized_pixel_count(0),
62 visible_content_area(0),
63 approximated_visible_content_area(0) {
66 RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() {
69 scoped_refptr<base::debug::ConvertableToTraceFormat>
70 RenderingStats::ImplThreadRenderingStats::AsTraceableData() const {
71 scoped_refptr<base::debug::TracedValue> record_data =
72 new base::debug::TracedValue();
73 record_data->SetInteger("frame_count", frame_count);
74 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF());
75 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count);
76 record_data->SetInteger("visible_content_area", visible_content_area);
77 record_data->SetInteger("approximated_visible_content_area",
78 approximated_visible_content_area);
79 record_data->BeginArray("draw_duration_ms");
80 draw_duration.AddToTracedValue(record_data.get());
81 record_data->EndArray();
83 record_data->BeginArray("draw_duration_estimate_ms");
84 draw_duration_estimate.AddToTracedValue(record_data.get());
85 record_data->EndArray();
87 record_data->BeginArray("begin_main_frame_to_commit_duration_ms");
88 begin_main_frame_to_commit_duration.AddToTracedValue(record_data.get());
89 record_data->EndArray();
91 record_data->BeginArray("begin_main_frame_to_commit_duration_estimate_ms");
92 begin_main_frame_to_commit_duration_estimate.AddToTracedValue(
93 record_data.get());
94 record_data->EndArray();
96 record_data->BeginArray("commit_to_activate_duration_ms");
97 commit_to_activate_duration.AddToTracedValue(record_data.get());
98 record_data->EndArray();
100 record_data->BeginArray("commit_to_activate_duration_estimate_ms");
101 commit_to_activate_duration_estimate.AddToTracedValue(record_data.get());
102 record_data->EndArray();
103 return record_data;
106 void RenderingStats::ImplThreadRenderingStats::Add(
107 const ImplThreadRenderingStats& other) {
108 frame_count += other.frame_count;
109 rasterize_time += other.rasterize_time;
110 analysis_time += other.analysis_time;
111 rasterized_pixel_count += other.rasterized_pixel_count;
112 visible_content_area += other.visible_content_area;
113 approximated_visible_content_area += other.approximated_visible_content_area;
115 draw_duration.Add(other.draw_duration);
116 draw_duration_estimate.Add(other.draw_duration_estimate);
117 begin_main_frame_to_commit_duration.Add(
118 other.begin_main_frame_to_commit_duration);
119 begin_main_frame_to_commit_duration_estimate.Add(
120 other.begin_main_frame_to_commit_duration_estimate);
121 commit_to_activate_duration.Add(other.commit_to_activate_duration);
122 commit_to_activate_duration_estimate.Add(
123 other.commit_to_activate_duration_estimate);
126 void RenderingStats::Add(const RenderingStats& other) {
127 main_stats.Add(other.main_stats);
128 impl_stats.Add(other.impl_stats);
131 } // namespace cc