cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / debug / rendering_stats.cc
blob64cf69e0fe399b6adbf5d7f1f70f6415b9a0f024
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 "base/values.h"
6 #include "cc/debug/rendering_stats.h"
8 namespace cc {
10 MainThreadRenderingStats::MainThreadRenderingStats()
11 : animation_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) {}
18 ImplThreadRenderingStats::ImplThreadRenderingStats()
19 : screen_frame_count(0),
20 dropped_frame_count(0),
21 rasterized_pixel_count(0),
22 impl_thread_scroll_count(0),
23 main_thread_scroll_count(0),
24 drawn_layer_count(0),
25 missing_tile_count(0),
26 deferred_image_decode_count(0),
27 deferred_image_cache_hit_count(0),
28 tile_analysis_count(0),
29 solid_color_tile_analysis_count(0) {}
31 void RenderingStats::EnumerateFields(Enumerator* enumerator) const {
32 enumerator->AddInt64("numAnimationFrames",
33 main_stats.animation_frame_count);
34 enumerator->AddInt64("numFramesSentToScreen", main_stats.screen_frame_count +
35 impl_stats.screen_frame_count);
36 enumerator->AddDouble("totalPaintTimeInSeconds",
37 main_stats.paint_time.InSecondsF());
38 enumerator->AddDouble("totalRecordTimeInSeconds",
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);
50 enumerator->AddDouble("totalRasterizeTimeInSeconds",
51 impl_stats.rasterize_time.InSecondsF());
52 enumerator->AddDouble(
53 "totalRasterizeTimeForNowBinsOnPendingTree",
54 impl_stats.rasterize_time_for_now_bins_on_pending_tree.InSecondsF());
55 enumerator->AddDouble("bestRasterizeTimeInSeconds",
56 impl_stats.best_rasterize_time.InSecondsF());
57 enumerator->AddInt64("totalPixelsRasterized",
58 impl_stats.rasterized_pixel_count);
59 enumerator->AddInt64("numImplThreadScrolls",
60 impl_stats.impl_thread_scroll_count);
61 enumerator->AddInt64("numMainThreadScrolls",
62 impl_stats.main_thread_scroll_count);
63 enumerator->AddInt64("numLayersDrawn", impl_stats.drawn_layer_count);
64 enumerator->AddInt64("numMissingTiles", impl_stats.missing_tile_count);
65 enumerator->AddInt64("totalDeferredImageDecodeCount",
66 impl_stats.deferred_image_decode_count);
67 enumerator->AddInt64("totalTilesAnalyzed", impl_stats.tile_analysis_count);
68 enumerator->AddInt64("solidColorTilesAnalyzed",
69 impl_stats.solid_color_tile_analysis_count);
70 enumerator->AddInt64("totalDeferredImageCacheHitCount",
71 impl_stats.deferred_image_cache_hit_count);
72 enumerator->AddDouble("totalDeferredImageDecodeTimeInSeconds",
73 impl_stats.deferred_image_decode_time.InSecondsF());
74 enumerator->AddDouble("totalTileAnalysisTimeInSeconds",
75 impl_stats.tile_analysis_time.InSecondsF());
78 void MainThreadRenderingStats::IssueTraceEvent() const {
79 TRACE_EVENT_INSTANT1("benchmark",
80 "MainThreadRenderingStats::IssueTraceEvent",
81 TRACE_EVENT_SCOPE_THREAD,
82 "data", AsTraceableData());
85 scoped_ptr<base::debug::ConvertableToTraceFormat>
86 MainThreadRenderingStats::AsTraceableData() const {
87 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
88 record_data->SetInteger("animation_frame_count",
89 animation_frame_count);
90 record_data->SetInteger("screen_frame_count",
91 screen_frame_count);
92 record_data->SetDouble("paint_time",
93 paint_time.InSecondsF());
94 record_data->SetDouble("record_time",
95 record_time.InSecondsF());
96 record_data->SetDouble("commit_time",
97 commit_time.InSecondsF());
98 record_data->SetInteger("commit_count",
99 commit_count);
100 record_data->SetInteger("painted_pixel_count",
101 painted_pixel_count);
102 record_data->SetInteger("recorded_pixel_count",
103 recorded_pixel_count);
104 record_data->SetInteger("image_gathering_count",
105 image_gathering_count);
106 record_data->SetDouble("image_gathering_time",
107 image_gathering_time.InSecondsF());
108 return TracedValue::FromValue(record_data.release());
111 void ImplThreadRenderingStats::IssueTraceEvent() const {
112 TRACE_EVENT_INSTANT1("benchmark",
113 "ImplThreadRenderingStats::IssueTraceEvent",
114 TRACE_EVENT_SCOPE_THREAD,
115 "data", AsTraceableData());
118 scoped_ptr<base::debug::ConvertableToTraceFormat>
119 ImplThreadRenderingStats::AsTraceableData() const {
120 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
121 record_data->SetInteger("screen_frame_count",
122 screen_frame_count);
123 record_data->SetInteger("dropped_frame_count",
124 dropped_frame_count);
125 record_data->SetDouble("rasterize_time",
126 rasterize_time.InSecondsF());
127 record_data->SetDouble(
128 "rasterize_time_for_now_bins_on_pending_tree",
129 rasterize_time_for_now_bins_on_pending_tree.InSecondsF());
130 record_data->SetDouble("best_rasterize_time",
131 best_rasterize_time.InSecondsF());
132 record_data->SetInteger("rasterized_pixel_count",
133 rasterized_pixel_count);
134 record_data->SetInteger("impl_thread_scroll_count",
135 impl_thread_scroll_count);
136 record_data->SetInteger("main_thread_scroll_count",
137 main_thread_scroll_count);
138 record_data->SetInteger("drawn_layer_count",
139 drawn_layer_count);
140 record_data->SetInteger("missing_tile_count",
141 missing_tile_count);
142 record_data->SetInteger("deferred_image_decode_count",
143 deferred_image_decode_count);
144 record_data->SetInteger("deferred_image_cache_hit_count",
145 deferred_image_cache_hit_count);
146 record_data->SetInteger("tile_analysis_count",
147 tile_analysis_count);
148 record_data->SetInteger("solid_color_tile_analysis_count",
149 solid_color_tile_analysis_count);
150 record_data->SetDouble("deferred_image_decode_time",
151 deferred_image_decode_time.InSecondsF());
152 record_data->SetDouble("tile_analysis_time",
153 tile_analysis_time.InSecondsF());
154 return TracedValue::FromValue(record_data.release());
158 void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) {
159 animation_frame_count += other.animation_frame_count;
160 screen_frame_count += other.screen_frame_count;
161 paint_time += other.paint_time;
162 record_time += other.record_time;
163 commit_time += other.commit_time;
164 commit_count += other.commit_count;
165 painted_pixel_count += other.painted_pixel_count;
166 recorded_pixel_count += other.recorded_pixel_count;
167 image_gathering_count += other.image_gathering_count;
168 image_gathering_time += other.image_gathering_time;
171 void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) {
172 screen_frame_count += other.screen_frame_count;
173 dropped_frame_count += other.dropped_frame_count;
174 rasterize_time += other.rasterize_time;
175 rasterize_time_for_now_bins_on_pending_tree +=
176 other.rasterize_time_for_now_bins_on_pending_tree;
177 best_rasterize_time += other.best_rasterize_time;
178 rasterized_pixel_count += other.rasterized_pixel_count;
179 impl_thread_scroll_count += other.impl_thread_scroll_count;
180 main_thread_scroll_count += other.main_thread_scroll_count;
181 drawn_layer_count += other.drawn_layer_count;
182 missing_tile_count += other.missing_tile_count;
183 deferred_image_decode_count += other.deferred_image_decode_count;
184 deferred_image_cache_hit_count += other.deferred_image_cache_hit_count;
185 deferred_image_decode_time += other.deferred_image_decode_time;
186 tile_analysis_count += other.tile_analysis_count;
187 solid_color_tile_analysis_count += other.solid_color_tile_analysis_count;
188 tile_analysis_time += other.tile_analysis_time;
191 void RenderingStats::Add(const RenderingStats& other) {
192 main_stats.Add(other.main_stats);
193 impl_stats.Add(other.impl_stats);
196 } // namespace cc