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 "base/values.h" | |
6 #include "cc/debug/rendering_stats.h" | 5 #include "cc/debug/rendering_stats.h" |
7 | 6 |
8 namespace cc { | 7 namespace cc { |
9 | 8 |
10 MainThreadRenderingStats::MainThreadRenderingStats() | 9 RenderingStats::TimeDeltaList::TimeDeltaList() { |
11 : frame_count(0), | 10 } |
12 painted_pixel_count(0), | 11 |
13 recorded_pixel_count(0) {} | 12 RenderingStats::TimeDeltaList::~TimeDeltaList() { |
| 13 } |
| 14 |
| 15 void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { |
| 16 values.push_back(value); |
| 17 } |
| 18 |
| 19 scoped_ptr<base::ListValue> |
| 20 RenderingStats::TimeDeltaList::AsListValueInMilliseconds() const { |
| 21 scoped_ptr<base::ListValue> list_value(new base::ListValue); |
| 22 std::list<base::TimeDelta>::const_iterator iter; |
| 23 for (iter = values.begin(); iter != values.end(); ++iter) { |
| 24 list_value->AppendDouble(iter->InMillisecondsF()); |
| 25 } |
| 26 return list_value.Pass(); |
| 27 } |
| 28 |
| 29 void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) { |
| 30 values.insert(values.end(), other.values.begin(), other.values.end()); |
| 31 } |
| 32 |
| 33 RenderingStats::MainThreadRenderingStats::MainThreadRenderingStats() |
| 34 : frame_count(0), painted_pixel_count(0), recorded_pixel_count(0) { |
| 35 } |
| 36 |
| 37 RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() { |
| 38 } |
14 | 39 |
15 scoped_refptr<base::debug::ConvertableToTraceFormat> | 40 scoped_refptr<base::debug::ConvertableToTraceFormat> |
16 MainThreadRenderingStats::AsTraceableData() const { | 41 RenderingStats::MainThreadRenderingStats::AsTraceableData() const { |
17 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 42 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
18 record_data->SetInteger("frame_count", frame_count); | 43 record_data->SetInteger("frame_count", frame_count); |
19 record_data->SetDouble("paint_time", paint_time.InSecondsF()); | 44 record_data->SetDouble("paint_time", paint_time.InSecondsF()); |
20 record_data->SetInteger("painted_pixel_count", painted_pixel_count); | 45 record_data->SetInteger("painted_pixel_count", painted_pixel_count); |
21 record_data->SetDouble("record_time", record_time.InSecondsF()); | 46 record_data->SetDouble("record_time", record_time.InSecondsF()); |
22 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); | 47 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); |
23 return TracedValue::FromValue(record_data.release()); | 48 return TracedValue::FromValue(record_data.release()); |
24 } | 49 } |
25 | 50 |
26 void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) { | 51 void RenderingStats::MainThreadRenderingStats::Add( |
| 52 const MainThreadRenderingStats& other) { |
27 frame_count += other.frame_count; | 53 frame_count += other.frame_count; |
28 paint_time += other.paint_time; | 54 paint_time += other.paint_time; |
29 painted_pixel_count += other.painted_pixel_count; | 55 painted_pixel_count += other.painted_pixel_count; |
30 record_time += other.record_time; | 56 record_time += other.record_time; |
31 recorded_pixel_count += other.recorded_pixel_count; | 57 recorded_pixel_count += other.recorded_pixel_count; |
32 } | 58 } |
33 | 59 |
34 ImplThreadRenderingStats::ImplThreadRenderingStats() | 60 RenderingStats::ImplThreadRenderingStats::ImplThreadRenderingStats() |
35 : frame_count(0), | 61 : frame_count(0), |
36 rasterized_pixel_count(0), | 62 rasterized_pixel_count(0), |
37 visible_content_area(0), | 63 visible_content_area(0), |
38 approximated_visible_content_area(0) { | 64 approximated_visible_content_area(0) { |
39 } | 65 } |
40 | 66 |
| 67 RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() { |
| 68 } |
| 69 |
41 scoped_refptr<base::debug::ConvertableToTraceFormat> | 70 scoped_refptr<base::debug::ConvertableToTraceFormat> |
42 ImplThreadRenderingStats::AsTraceableData() const { | 71 RenderingStats::ImplThreadRenderingStats::AsTraceableData() const { |
43 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 72 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
44 record_data->SetInteger("frame_count", frame_count); | 73 record_data->SetInteger("frame_count", frame_count); |
45 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); | 74 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); |
46 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count); | 75 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count); |
47 record_data->SetInteger("visible_content_area", visible_content_area); | 76 record_data->SetInteger("visible_content_area", visible_content_area); |
48 record_data->SetInteger("approximated_visible_content_area", | 77 record_data->SetInteger("approximated_visible_content_area", |
49 approximated_visible_content_area); | 78 approximated_visible_content_area); |
| 79 record_data->Set("draw_duration_ms", |
| 80 draw_duration.AsListValueInMilliseconds().release()); |
| 81 record_data->Set( |
| 82 "draw_duration_estimate_ms", |
| 83 draw_duration_estimate.AsListValueInMilliseconds().release()); |
| 84 record_data->Set( |
| 85 "begin_main_frame_to_commit_duration_ms", |
| 86 begin_main_frame_to_commit_duration.AsListValueInMilliseconds() |
| 87 .release()); |
| 88 record_data->Set( |
| 89 "begin_main_frame_to_commit_duration_estimate_ms", |
| 90 begin_main_frame_to_commit_duration_estimate.AsListValueInMilliseconds() |
| 91 .release()); |
| 92 record_data->Set( |
| 93 "commit_to_activate_duration_ms", |
| 94 commit_to_activate_duration.AsListValueInMilliseconds().release()); |
| 95 record_data->Set( |
| 96 "commit_to_activate_duration_estimate_ms", |
| 97 commit_to_activate_duration_estimate.AsListValueInMilliseconds() |
| 98 .release()); |
50 return TracedValue::FromValue(record_data.release()); | 99 return TracedValue::FromValue(record_data.release()); |
51 } | 100 } |
52 | 101 |
53 void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) { | 102 void RenderingStats::ImplThreadRenderingStats::Add( |
| 103 const ImplThreadRenderingStats& other) { |
54 frame_count += other.frame_count; | 104 frame_count += other.frame_count; |
55 rasterize_time += other.rasterize_time; | 105 rasterize_time += other.rasterize_time; |
56 analysis_time += other.analysis_time; | 106 analysis_time += other.analysis_time; |
57 rasterized_pixel_count += other.rasterized_pixel_count; | 107 rasterized_pixel_count += other.rasterized_pixel_count; |
58 visible_content_area += other.visible_content_area; | 108 visible_content_area += other.visible_content_area; |
59 approximated_visible_content_area += other.approximated_visible_content_area; | 109 approximated_visible_content_area += other.approximated_visible_content_area; |
| 110 |
| 111 draw_duration.Add(other.draw_duration); |
| 112 draw_duration_estimate.Add(other.draw_duration_estimate); |
| 113 begin_main_frame_to_commit_duration.Add( |
| 114 other.begin_main_frame_to_commit_duration); |
| 115 begin_main_frame_to_commit_duration_estimate.Add( |
| 116 other.begin_main_frame_to_commit_duration_estimate); |
| 117 commit_to_activate_duration.Add(other.commit_to_activate_duration); |
| 118 commit_to_activate_duration_estimate.Add( |
| 119 other.commit_to_activate_duration_estimate); |
60 } | 120 } |
61 | 121 |
62 void RenderingStats::Add(const RenderingStats& other) { | 122 void RenderingStats::Add(const RenderingStats& other) { |
63 main_stats.Add(other.main_stats); | 123 main_stats.Add(other.main_stats); |
64 impl_stats.Add(other.impl_stats); | 124 impl_stats.Add(other.impl_stats); |
65 } | 125 } |
66 | 126 |
67 } // namespace cc | 127 } // namespace cc |
OLD | NEW |