OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_instrumentation.h" | 5 #include "cc/debug/rendering_stats_instrumentation.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 // static | 9 // static |
10 scoped_ptr<RenderingStatsInstrumentation> | 10 scoped_ptr<RenderingStatsInstrumentation> |
11 RenderingStatsInstrumentation::Create() { | 11 RenderingStatsInstrumentation::Create() { |
12 return make_scoped_ptr(new RenderingStatsInstrumentation()); | 12 return make_scoped_ptr(new RenderingStatsInstrumentation()); |
13 } | 13 } |
14 | 14 |
15 RenderingStatsInstrumentation::RenderingStatsInstrumentation() | 15 RenderingStatsInstrumentation::RenderingStatsInstrumentation() |
16 : record_rendering_stats_(false) { | 16 : record_rendering_stats_(false) { |
17 } | 17 } |
18 | 18 |
19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} | 19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} |
20 | 20 |
21 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { | 21 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { |
22 base::AutoLock scoped_lock(lock_); | 22 base::AutoLock scoped_lock(lock_); |
23 return rendering_stats_; | 23 RenderingStats rendering_stats; |
| 24 rendering_stats.main_stats = main_stats_accu_; |
| 25 rendering_stats.main_stats.Add(main_stats_); |
| 26 rendering_stats.impl_stats = impl_stats_accu_; |
| 27 rendering_stats.impl_stats.Add(impl_stats_); |
| 28 return rendering_stats; |
| 29 } |
| 30 |
| 31 void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() { |
| 32 main_stats_accu_.Add(main_stats_); |
| 33 main_stats_ = MainThreadRenderingStats(); |
| 34 } |
| 35 |
| 36 void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() { |
| 37 impl_stats_accu_.Add(impl_stats_); |
| 38 impl_stats_ = ImplThreadRenderingStats(); |
24 } | 39 } |
25 | 40 |
26 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { | 41 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { |
27 if (record_rendering_stats_) | 42 if (record_rendering_stats_) |
28 return base::TimeTicks::HighResNow(); | 43 return base::TimeTicks::HighResNow(); |
29 return base::TimeTicks(); | 44 return base::TimeTicks(); |
30 } | 45 } |
31 | 46 |
32 base::TimeDelta RenderingStatsInstrumentation::EndRecording( | 47 base::TimeDelta RenderingStatsInstrumentation::EndRecording( |
33 base::TimeTicks start_time) const { | 48 base::TimeTicks start_time) const { |
34 if (!start_time.is_null()) | 49 if (!start_time.is_null()) |
35 return base::TimeTicks::HighResNow() - start_time; | 50 return base::TimeTicks::HighResNow() - start_time; |
36 return base::TimeDelta(); | 51 return base::TimeDelta(); |
37 } | 52 } |
38 | 53 |
39 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() { | 54 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() { |
40 if (!record_rendering_stats_) | 55 if (!record_rendering_stats_) |
41 return; | 56 return; |
42 | 57 |
43 base::AutoLock scoped_lock(lock_); | 58 base::AutoLock scoped_lock(lock_); |
44 rendering_stats_.animation_frame_count++; | 59 main_stats_.animation_frame_count++; |
45 } | 60 } |
46 | 61 |
47 void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count) { | 62 void RenderingStatsInstrumentation::IncrementScreenFrameCount(int64 count) { |
48 if (!record_rendering_stats_) | 63 if (!record_rendering_stats_) |
49 return; | 64 return; |
50 | 65 |
51 base::AutoLock scoped_lock(lock_); | 66 base::AutoLock scoped_lock(lock_); |
52 rendering_stats_.screen_frame_count = count; | 67 impl_stats_.screen_frame_count += count; |
53 } | 68 } |
54 | 69 |
55 void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count) { | 70 void RenderingStatsInstrumentation::IncrementDroppedFrameCount(int64 count) { |
56 if (!record_rendering_stats_) | 71 if (!record_rendering_stats_) |
57 return; | 72 return; |
58 | 73 |
59 base::AutoLock scoped_lock(lock_); | 74 base::AutoLock scoped_lock(lock_); |
60 rendering_stats_.dropped_frame_count = count; | 75 impl_stats_.dropped_frame_count += count; |
61 } | 76 } |
62 | 77 |
63 void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) { | 78 void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) { |
64 if (!record_rendering_stats_) | 79 if (!record_rendering_stats_) |
65 return; | 80 return; |
66 | 81 |
67 base::AutoLock scoped_lock(lock_); | 82 base::AutoLock scoped_lock(lock_); |
68 rendering_stats_.total_commit_time += duration; | 83 main_stats_.commit_time += duration; |
69 rendering_stats_.total_commit_count++; | 84 main_stats_.commit_count++; |
70 } | 85 } |
71 | 86 |
72 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, | 87 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, |
73 int64 pixels) { | 88 int64 pixels) { |
74 if (!record_rendering_stats_) | 89 if (!record_rendering_stats_) |
75 return; | 90 return; |
76 | 91 |
77 base::AutoLock scoped_lock(lock_); | 92 base::AutoLock scoped_lock(lock_); |
78 rendering_stats_.total_paint_time += duration; | 93 main_stats_.paint_time += duration; |
79 rendering_stats_.total_pixels_painted += pixels; | 94 main_stats_.painted_pixel_count += pixels; |
80 } | 95 } |
81 | 96 |
82 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, | 97 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, |
83 int64 pixels) { | 98 int64 pixels) { |
84 if (!record_rendering_stats_) | 99 if (!record_rendering_stats_) |
85 return; | 100 return; |
86 | 101 |
87 base::AutoLock scoped_lock(lock_); | 102 base::AutoLock scoped_lock(lock_); |
88 rendering_stats_.total_record_time += duration; | 103 main_stats_.record_time += duration; |
89 rendering_stats_.total_pixels_recorded += pixels; | 104 main_stats_.recorded_pixel_count += pixels; |
90 } | 105 } |
91 | 106 |
92 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration, | 107 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration, |
93 base::TimeDelta best_duration, | 108 base::TimeDelta best_duration, |
94 int64 pixels, | 109 int64 pixels, |
95 bool is_in_pending_tree_now_bin) { | 110 bool is_in_pending_tree_now_bin) { |
96 if (!record_rendering_stats_) | 111 if (!record_rendering_stats_) |
97 return; | 112 return; |
98 | 113 |
99 base::AutoLock scoped_lock(lock_); | 114 base::AutoLock scoped_lock(lock_); |
100 rendering_stats_.total_rasterize_time += total_duration; | 115 impl_stats_.rasterize_time += total_duration; |
101 rendering_stats_.best_rasterize_time += best_duration; | 116 impl_stats_.best_rasterize_time += best_duration; |
102 rendering_stats_.total_pixels_rasterized += pixels; | 117 impl_stats_.rasterized_pixel_count += pixels; |
103 | 118 |
104 if (is_in_pending_tree_now_bin) { | 119 if (is_in_pending_tree_now_bin) { |
105 rendering_stats_.total_rasterize_time_for_now_bins_on_pending_tree += | 120 impl_stats_.rasterize_time_for_now_bins_on_pending_tree += |
106 total_duration; | 121 total_duration; |
107 } | 122 } |
108 } | 123 } |
109 | 124 |
110 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() { | 125 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() { |
111 if (!record_rendering_stats_) | 126 if (!record_rendering_stats_) |
112 return; | 127 return; |
113 | 128 |
114 base::AutoLock scoped_lock(lock_); | 129 base::AutoLock scoped_lock(lock_); |
115 rendering_stats_.num_impl_thread_scrolls++; | 130 impl_stats_.impl_thread_scroll_count++; |
116 } | 131 } |
117 | 132 |
118 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() { | 133 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() { |
119 if (!record_rendering_stats_) | 134 if (!record_rendering_stats_) |
120 return; | 135 return; |
121 | 136 |
122 base::AutoLock scoped_lock(lock_); | 137 base::AutoLock scoped_lock(lock_); |
123 rendering_stats_.num_main_thread_scrolls++; | 138 impl_stats_.main_thread_scroll_count++; |
124 } | 139 } |
125 | 140 |
126 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) { | 141 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) { |
127 if (!record_rendering_stats_) | 142 if (!record_rendering_stats_) |
128 return; | 143 return; |
129 | 144 |
130 base::AutoLock scoped_lock(lock_); | 145 base::AutoLock scoped_lock(lock_); |
131 rendering_stats_.num_layers_drawn += amount; | 146 impl_stats_.drawn_layer_count += amount; |
132 } | 147 } |
133 | 148 |
134 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) { | 149 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) { |
135 if (!record_rendering_stats_) | 150 if (!record_rendering_stats_) |
136 return; | 151 return; |
137 | 152 |
138 base::AutoLock scoped_lock(lock_); | 153 base::AutoLock scoped_lock(lock_); |
139 rendering_stats_.num_missing_tiles += amount; | 154 impl_stats_.missing_tile_count += amount; |
140 } | 155 } |
141 | 156 |
142 void RenderingStatsInstrumentation::AddDeferredImageDecode( | 157 void RenderingStatsInstrumentation::AddDeferredImageDecode( |
143 base::TimeDelta duration) { | 158 base::TimeDelta duration) { |
144 if (!record_rendering_stats_) | 159 if (!record_rendering_stats_) |
145 return; | 160 return; |
146 | 161 |
147 base::AutoLock scoped_lock(lock_); | 162 base::AutoLock scoped_lock(lock_); |
148 rendering_stats_.total_deferred_image_decode_time += duration; | 163 impl_stats_.deferred_image_decode_time += duration; |
149 rendering_stats_.total_deferred_image_decode_count++; | 164 impl_stats_.deferred_image_decode_count++; |
150 } | 165 } |
151 | 166 |
152 void RenderingStatsInstrumentation::AddImageGathering( | 167 void RenderingStatsInstrumentation::AddImageGathering( |
153 base::TimeDelta duration) { | 168 base::TimeDelta duration) { |
154 if (!record_rendering_stats_) | 169 if (!record_rendering_stats_) |
155 return; | 170 return; |
156 | 171 |
157 base::AutoLock scoped_lock(lock_); | 172 base::AutoLock scoped_lock(lock_); |
158 rendering_stats_.total_image_gathering_time += duration; | 173 main_stats_.image_gathering_time += duration; |
159 rendering_stats_.total_image_gathering_count++; | 174 main_stats_.image_gathering_count++; |
160 } | 175 } |
161 | 176 |
162 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() { | 177 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() { |
163 if (!record_rendering_stats_) | 178 if (!record_rendering_stats_) |
164 return; | 179 return; |
165 | 180 |
166 base::AutoLock scoped_lock(lock_); | 181 base::AutoLock scoped_lock(lock_); |
167 rendering_stats_.total_deferred_image_cache_hit_count++; | 182 impl_stats_.deferred_image_cache_hit_count++; |
168 } | 183 } |
169 | 184 |
170 void RenderingStatsInstrumentation::AddAnalysisResult( | 185 void RenderingStatsInstrumentation::AddAnalysisResult( |
171 base::TimeDelta duration, | 186 base::TimeDelta duration, |
172 bool is_solid_color) { | 187 bool is_solid_color) { |
173 if (!record_rendering_stats_) | 188 if (!record_rendering_stats_) |
174 return; | 189 return; |
175 | 190 |
176 base::AutoLock scoped_lock(lock_); | 191 base::AutoLock scoped_lock(lock_); |
177 rendering_stats_.total_tiles_analyzed++; | 192 impl_stats_.tile_analysis_count++; |
178 rendering_stats_.total_tile_analysis_time += duration; | 193 impl_stats_.tile_analysis_time += duration; |
179 if (is_solid_color) | 194 if (is_solid_color) |
180 rendering_stats_.solid_color_tiles_analyzed++; | 195 impl_stats_.solid_color_tile_analysis_count++; |
181 } | 196 } |
182 | 197 |
183 } // namespace cc | 198 } // namespace cc |
OLD | NEW |