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" |
5 #include "cc/debug/rendering_stats.h" | 6 #include "cc/debug/rendering_stats.h" |
6 | 7 |
7 namespace cc { | 8 namespace cc { |
8 | 9 |
9 RenderingStats::RenderingStats() | 10 MainThreadRenderingStats::MainThreadRenderingStats() |
10 : animation_frame_count(0), | 11 : animation_frame_count(0), |
11 screen_frame_count(0), | 12 screen_frame_count(0), |
| 13 commit_count(0), |
| 14 painted_pixel_count(0), |
| 15 recorded_pixel_count(0), |
| 16 image_gathering_count(0) {} |
| 17 |
| 18 ImplThreadRenderingStats::ImplThreadRenderingStats() |
| 19 : screen_frame_count(0), |
12 dropped_frame_count(0), | 20 dropped_frame_count(0), |
13 total_commit_count(0), | 21 rasterized_pixel_count(0), |
14 total_pixels_painted(0), | 22 impl_thread_scroll_count(0), |
15 total_pixels_recorded(0), | 23 main_thread_scroll_count(0), |
16 total_pixels_rasterized(0), | 24 drawn_layer_count(0), |
17 num_impl_thread_scrolls(0), | 25 missing_tile_count(0), |
18 num_main_thread_scrolls(0), | 26 deferred_image_decode_count(0), |
19 num_layers_drawn(0), | 27 deferred_image_cache_hit_count(0), |
20 num_missing_tiles(0), | 28 tile_analysis_count(0), |
21 total_deferred_image_decode_count(0), | 29 solid_color_tile_analysis_count(0) {} |
22 total_deferred_image_cache_hit_count(0), | 30 |
23 total_image_gathering_count(0), | 31 void MainThreadRenderingStats::EnumerateFields( |
24 total_tiles_analyzed(0), | 32 RenderingStatsEnumerator* enumerator) const { |
25 solid_color_tiles_analyzed(0) {} | 33 enumerator->AddInt64("numAnimationFrames", animation_frame_count); |
| 34 enumerator->AddInt64("numFramesSentToScreen", screen_frame_count); |
| 35 enumerator->AddDouble("totalPaintTimeInSeconds", |
| 36 paint_time.InSecondsF()); |
| 37 enumerator->AddDouble("totalRecordTimeInSeconds", |
| 38 record_time.InSecondsF()); |
| 39 enumerator->AddDouble("totalCommitTimeInSeconds", |
| 40 commit_time.InSecondsF()); |
| 41 enumerator->AddInt64("totalCommitCount", commit_count); |
| 42 enumerator->AddInt64("totalPixelsPainted", painted_pixel_count); |
| 43 enumerator->AddInt64("totalPixelsRecorded", recorded_pixel_count); |
| 44 enumerator->AddInt64("totalImageGatheringCount", |
| 45 image_gathering_count); |
| 46 enumerator->AddDouble("totalImageGatheringTimeInSeconds", |
| 47 image_gathering_time.InSecondsF()); |
| 48 } |
| 49 |
| 50 void ImplThreadRenderingStats::EnumerateFields( |
| 51 RenderingStatsEnumerator* enumerator) const { |
| 52 enumerator->AddInt64("numFramesSentToScreen", screen_frame_count); |
| 53 enumerator->AddInt64("droppedFrameCount", dropped_frame_count); |
| 54 enumerator->AddDouble("totalRasterizeTimeInSeconds", |
| 55 rasterize_time.InSecondsF()); |
| 56 enumerator->AddDouble( |
| 57 "totalRasterizeTimeForNowBinsOnPendingTree", |
| 58 rasterize_time_for_now_bins_on_pending_tree.InSecondsF()); |
| 59 enumerator->AddDouble("bestRasterizeTimeInSeconds", |
| 60 best_rasterize_time.InSecondsF()); |
| 61 enumerator->AddInt64("totalPixelsRasterized", rasterized_pixel_count); |
| 62 enumerator->AddInt64("numImplThreadScrolls", impl_thread_scroll_count); |
| 63 enumerator->AddInt64("numMainThreadScrolls", main_thread_scroll_count); |
| 64 enumerator->AddInt64("numLayersDrawn", drawn_layer_count); |
| 65 enumerator->AddInt64("numMissingTiles", missing_tile_count); |
| 66 enumerator->AddInt64("totalDeferredImageDecodeCount", |
| 67 deferred_image_decode_count); |
| 68 enumerator->AddInt64("totalTilesAnalyzed", tile_analysis_count); |
| 69 enumerator->AddInt64("solidColorTilesAnalyzed", |
| 70 solid_color_tile_analysis_count); |
| 71 enumerator->AddInt64("totalDeferredImageCacheHitCount", |
| 72 deferred_image_cache_hit_count); |
| 73 enumerator->AddDouble("totalDeferredImageDecodeTimeInSeconds", |
| 74 deferred_image_decode_time.InSecondsF()); |
| 75 enumerator->AddDouble("totalTileAnalysisTimeInSeconds", |
| 76 tile_analysis_time.InSecondsF()); |
| 77 } |
26 | 78 |
27 void RenderingStats::EnumerateFields(Enumerator* enumerator) const { | 79 void RenderingStats::EnumerateFields(Enumerator* enumerator) const { |
28 enumerator->AddInt64("numAnimationFrames", animation_frame_count); | 80 main_stats.EnumerateFields(enumerator); |
29 enumerator->AddInt64("numFramesSentToScreen", screen_frame_count); | 81 impl_stats.EnumerateFields(enumerator); |
30 enumerator->AddInt64("droppedFrameCount", dropped_frame_count); | 82 } |
31 enumerator->AddDouble("totalPaintTimeInSeconds", | 83 |
32 total_paint_time.InSecondsF()); | 84 scoped_ptr<base::debug::ConvertableToTraceFormat> |
33 enumerator->AddDouble("totalRecordTimeInSeconds", | 85 MainThreadRenderingStats::AsTraceableData() const { |
34 total_record_time.InSecondsF()); | 86 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
35 enumerator->AddDouble("totalRasterizeTimeInSeconds", | 87 record_data->SetInteger("animation_frame_count", |
36 total_rasterize_time.InSecondsF()); | 88 animation_frame_count); |
37 enumerator->AddDouble( | 89 record_data->SetInteger("screen_frame_count", |
38 "totalRasterizeTimeForNowBinsOnPendingTree", | 90 screen_frame_count); |
39 total_rasterize_time_for_now_bins_on_pending_tree.InSecondsF()); | 91 record_data->SetDouble("paint_time", |
40 enumerator->AddDouble("totalCommitTimeInSeconds", | 92 paint_time.InSecondsF()); |
41 total_commit_time.InSecondsF()); | 93 record_data->SetDouble("record_time", |
42 enumerator->AddDouble("bestRasterizeTimeInSeconds", | 94 record_time.InSecondsF()); |
43 best_rasterize_time.InSecondsF()); | 95 record_data->SetDouble("commit_time", |
44 enumerator->AddInt64("totalCommitCount", total_commit_count); | 96 commit_time.InSecondsF()); |
45 enumerator->AddInt64("totalPixelsPainted", total_pixels_painted); | 97 record_data->SetInteger("commit_count", |
46 enumerator->AddInt64("totalPixelsRecorded", total_pixels_recorded); | 98 commit_count); |
47 enumerator->AddInt64("totalPixelsRasterized", total_pixels_rasterized); | 99 record_data->SetInteger("painted_pixel_count", |
48 enumerator->AddInt64("numImplThreadScrolls", num_impl_thread_scrolls); | 100 painted_pixel_count); |
49 enumerator->AddInt64("numMainThreadScrolls", num_main_thread_scrolls); | 101 record_data->SetInteger("recorded_pixel_count", |
50 enumerator->AddInt64("numLayersDrawn", num_layers_drawn); | 102 recorded_pixel_count); |
51 enumerator->AddInt64("numMissingTiles", num_missing_tiles); | 103 record_data->SetInteger("image_gathering_count", |
52 enumerator->AddInt64("totalDeferredImageDecodeCount", | 104 image_gathering_count); |
53 total_deferred_image_decode_count); | 105 return TracedValue::FromValue(record_data.release()); |
54 enumerator->AddInt64("totalTilesAnalyzed", total_tiles_analyzed); | 106 } |
55 enumerator->AddInt64("solidColorTilesAnalyzed", | 107 |
56 solid_color_tiles_analyzed); | 108 scoped_ptr<base::debug::ConvertableToTraceFormat> |
57 enumerator->AddInt64("totalDeferredImageCacheHitCount", | 109 ImplThreadRenderingStats::AsTraceableData() const { |
58 total_deferred_image_cache_hit_count); | 110 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
59 enumerator->AddInt64("totalImageGatheringCount", | 111 record_data->SetInteger("screen_frame_count", |
60 total_image_gathering_count); | 112 screen_frame_count); |
61 enumerator->AddDouble("totalDeferredImageDecodeTimeInSeconds", | 113 record_data->SetInteger("dropped_frame_count", |
62 total_deferred_image_decode_time.InSecondsF()); | 114 dropped_frame_count); |
63 enumerator->AddDouble("totalImageGatheringTimeInSeconds", | 115 record_data->SetDouble("rasterize_time", |
64 total_image_gathering_time.InSecondsF()); | 116 rasterize_time.InSecondsF()); |
65 enumerator->AddDouble("totalTileAnalysisTimeInSeconds", | 117 record_data->SetDouble( |
66 total_tile_analysis_time.InSecondsF()); | 118 "rasterize_time_for_now_bins_on_pending_tree", |
| 119 rasterize_time_for_now_bins_on_pending_tree.InSecondsF()); |
| 120 record_data->SetDouble("best_rasterize_time", |
| 121 best_rasterize_time.InSecondsF()); |
| 122 record_data->SetInteger("rasterized_pixel_count", |
| 123 rasterized_pixel_count); |
| 124 record_data->SetInteger("impl_thread_scroll_count", |
| 125 impl_thread_scroll_count); |
| 126 record_data->SetInteger("main_thread_scroll_count", |
| 127 main_thread_scroll_count); |
| 128 record_data->SetInteger("drawn_layer_count", |
| 129 drawn_layer_count); |
| 130 record_data->SetInteger("missing_tile_count", |
| 131 missing_tile_count); |
| 132 record_data->SetInteger("deferred_image_decode_count", |
| 133 deferred_image_decode_count); |
| 134 record_data->SetInteger("deferred_image_cache_hit_count", |
| 135 deferred_image_cache_hit_count); |
| 136 record_data->SetInteger("tile_analysis_count", |
| 137 tile_analysis_count); |
| 138 record_data->SetInteger("solid_color_tile_analysis_count", |
| 139 solid_color_tile_analysis_count); |
| 140 record_data->SetDouble("deferred_image_decode_time", |
| 141 deferred_image_decode_time.InSecondsF()); |
| 142 record_data->SetDouble("tile_analysis_time", |
| 143 tile_analysis_time.InSecondsF()); |
| 144 return TracedValue::FromValue(record_data.release()); |
| 145 } |
| 146 |
| 147 |
| 148 void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) { |
| 149 animation_frame_count += other.animation_frame_count; |
| 150 screen_frame_count += other.screen_frame_count; |
| 151 paint_time += other.paint_time; |
| 152 record_time += other.record_time; |
| 153 commit_time += other.commit_time; |
| 154 commit_count += other.commit_count; |
| 155 painted_pixel_count += other.painted_pixel_count; |
| 156 recorded_pixel_count += other.recorded_pixel_count; |
| 157 image_gathering_count += other.image_gathering_count; |
| 158 image_gathering_time += other.image_gathering_time; |
| 159 } |
| 160 |
| 161 void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) { |
| 162 screen_frame_count += other.screen_frame_count; |
| 163 dropped_frame_count += other.dropped_frame_count; |
| 164 rasterize_time += other.rasterize_time; |
| 165 rasterize_time_for_now_bins_on_pending_tree += |
| 166 other.rasterize_time_for_now_bins_on_pending_tree; |
| 167 best_rasterize_time += other.best_rasterize_time; |
| 168 rasterized_pixel_count += other.rasterized_pixel_count; |
| 169 impl_thread_scroll_count += other.impl_thread_scroll_count; |
| 170 main_thread_scroll_count += other.main_thread_scroll_count; |
| 171 drawn_layer_count += other.drawn_layer_count; |
| 172 missing_tile_count += other.missing_tile_count; |
| 173 deferred_image_decode_count += other.deferred_image_decode_count; |
| 174 deferred_image_cache_hit_count += other.deferred_image_cache_hit_count; |
| 175 deferred_image_decode_time += other.deferred_image_decode_time; |
| 176 tile_analysis_count += other.tile_analysis_count; |
| 177 solid_color_tile_analysis_count += other.solid_color_tile_analysis_count; |
| 178 tile_analysis_time += other.tile_analysis_time; |
67 } | 179 } |
68 | 180 |
69 void RenderingStats::Add(const RenderingStats& other) { | 181 void RenderingStats::Add(const RenderingStats& other) { |
70 animation_frame_count += other.animation_frame_count; | 182 main_stats.Add(other.main_stats); |
71 screen_frame_count += other.screen_frame_count; | 183 impl_stats.Add(other.impl_stats); |
72 dropped_frame_count += other.dropped_frame_count; | |
73 total_paint_time += other.total_paint_time; | |
74 total_record_time += other.total_record_time; | |
75 total_rasterize_time += other.total_rasterize_time; | |
76 total_rasterize_time_for_now_bins_on_pending_tree += | |
77 other.total_rasterize_time_for_now_bins_on_pending_tree; | |
78 total_commit_time += other.total_commit_time; | |
79 best_rasterize_time += other.best_rasterize_time; | |
80 total_commit_count += other.total_commit_count; | |
81 total_pixels_painted += other.total_pixels_painted; | |
82 total_pixels_recorded += other.total_pixels_recorded; | |
83 total_pixels_rasterized += other.total_pixels_rasterized; | |
84 num_impl_thread_scrolls += other.num_impl_thread_scrolls; | |
85 num_main_thread_scrolls += other.num_main_thread_scrolls; | |
86 num_layers_drawn += other.num_layers_drawn; | |
87 num_missing_tiles += other.num_missing_tiles; | |
88 total_deferred_image_decode_count += other.total_deferred_image_decode_count; | |
89 total_deferred_image_cache_hit_count += | |
90 other.total_deferred_image_cache_hit_count; | |
91 total_image_gathering_count += other.total_image_gathering_count; | |
92 total_deferred_image_decode_time += other.total_deferred_image_decode_time; | |
93 total_image_gathering_time += other.total_image_gathering_time; | |
94 total_tiles_analyzed += other.total_tiles_analyzed; | |
95 solid_color_tiles_analyzed += other.solid_color_tiles_analyzed; | |
96 total_tile_analysis_time += other.total_tile_analysis_time; | |
97 } | 184 } |
98 | 185 |
99 } // namespace cc | 186 } // namespace cc |
OLD | NEW |