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