cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / debug / rendering_stats_instrumentation.cc
blob2c5b2523b1009f933d32a181979bd0d7e9651f5a
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
3 // found in the LICENSE file.
5 #include "cc/debug/rendering_stats_instrumentation.h"
7 namespace cc {
9 // static
10 scoped_ptr<RenderingStatsInstrumentation>
11 RenderingStatsInstrumentation::Create() {
12 return make_scoped_ptr(new RenderingStatsInstrumentation());
15 RenderingStatsInstrumentation::RenderingStatsInstrumentation()
16 : record_rendering_stats_(false) {
19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {}
21 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() {
22 base::AutoLock scoped_lock(lock_);
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;
31 void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() {
32 main_stats_accu_.Add(main_stats_);
33 main_stats_ = MainThreadRenderingStats();
36 void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() {
37 impl_stats_accu_.Add(impl_stats_);
38 impl_stats_ = ImplThreadRenderingStats();
41 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const {
42 if (record_rendering_stats_)
43 return base::TimeTicks::HighResNow();
44 return base::TimeTicks();
47 base::TimeDelta RenderingStatsInstrumentation::EndRecording(
48 base::TimeTicks start_time) const {
49 if (!start_time.is_null())
50 return base::TimeTicks::HighResNow() - start_time;
51 return base::TimeDelta();
54 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() {
55 if (!record_rendering_stats_)
56 return;
58 base::AutoLock scoped_lock(lock_);
59 main_stats_.animation_frame_count++;
62 void RenderingStatsInstrumentation::IncrementScreenFrameCount(
63 int64 count, bool main_thread) {
64 if (!record_rendering_stats_)
65 return;
67 base::AutoLock scoped_lock(lock_);
68 if (main_thread)
69 main_stats_.screen_frame_count += count;
70 else
71 impl_stats_.screen_frame_count += count;
74 void RenderingStatsInstrumentation::IncrementDroppedFrameCount(int64 count) {
75 if (!record_rendering_stats_)
76 return;
78 base::AutoLock scoped_lock(lock_);
79 impl_stats_.dropped_frame_count += count;
82 void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) {
83 if (!record_rendering_stats_)
84 return;
86 base::AutoLock scoped_lock(lock_);
87 main_stats_.commit_time += duration;
88 main_stats_.commit_count++;
91 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration,
92 int64 pixels) {
93 if (!record_rendering_stats_)
94 return;
96 base::AutoLock scoped_lock(lock_);
97 main_stats_.paint_time += duration;
98 main_stats_.painted_pixel_count += pixels;
101 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration,
102 int64 pixels) {
103 if (!record_rendering_stats_)
104 return;
106 base::AutoLock scoped_lock(lock_);
107 main_stats_.record_time += duration;
108 main_stats_.recorded_pixel_count += pixels;
111 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration,
112 base::TimeDelta best_duration,
113 int64 pixels,
114 bool is_in_pending_tree_now_bin) {
115 if (!record_rendering_stats_)
116 return;
118 base::AutoLock scoped_lock(lock_);
119 impl_stats_.rasterize_time += total_duration;
120 impl_stats_.best_rasterize_time += best_duration;
121 impl_stats_.rasterized_pixel_count += pixels;
123 if (is_in_pending_tree_now_bin) {
124 impl_stats_.rasterize_time_for_now_bins_on_pending_tree +=
125 total_duration;
129 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() {
130 if (!record_rendering_stats_)
131 return;
133 base::AutoLock scoped_lock(lock_);
134 impl_stats_.impl_thread_scroll_count++;
137 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() {
138 if (!record_rendering_stats_)
139 return;
141 base::AutoLock scoped_lock(lock_);
142 impl_stats_.main_thread_scroll_count++;
145 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) {
146 if (!record_rendering_stats_)
147 return;
149 base::AutoLock scoped_lock(lock_);
150 impl_stats_.drawn_layer_count += amount;
153 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) {
154 if (!record_rendering_stats_)
155 return;
157 base::AutoLock scoped_lock(lock_);
158 impl_stats_.missing_tile_count += amount;
161 void RenderingStatsInstrumentation::AddDeferredImageDecode(
162 base::TimeDelta duration) {
163 if (!record_rendering_stats_)
164 return;
166 base::AutoLock scoped_lock(lock_);
167 impl_stats_.deferred_image_decode_time += duration;
168 impl_stats_.deferred_image_decode_count++;
171 void RenderingStatsInstrumentation::AddImageGathering(
172 base::TimeDelta duration) {
173 if (!record_rendering_stats_)
174 return;
176 base::AutoLock scoped_lock(lock_);
177 main_stats_.image_gathering_time += duration;
178 main_stats_.image_gathering_count++;
181 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() {
182 if (!record_rendering_stats_)
183 return;
185 base::AutoLock scoped_lock(lock_);
186 impl_stats_.deferred_image_cache_hit_count++;
189 void RenderingStatsInstrumentation::AddAnalysisResult(
190 base::TimeDelta duration,
191 bool is_solid_color) {
192 if (!record_rendering_stats_)
193 return;
195 base::AutoLock scoped_lock(lock_);
196 impl_stats_.tile_analysis_count++;
197 impl_stats_.tile_analysis_time += duration;
198 if (is_solid_color)
199 impl_stats_.solid_color_tile_analysis_count++;
202 } // namespace cc