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"
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 return rendering_stats_
;
26 base::TimeTicks
RenderingStatsInstrumentation::StartRecording() const {
27 if (record_rendering_stats_
)
28 return base::TimeTicks::HighResNow();
29 return base::TimeTicks();
32 base::TimeDelta
RenderingStatsInstrumentation::EndRecording(
33 base::TimeTicks start_time
) const {
34 if (!start_time
.is_null())
35 return base::TimeTicks::HighResNow() - start_time
;
36 return base::TimeDelta();
39 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() {
40 if (!record_rendering_stats_
)
43 base::AutoLock
scoped_lock(lock_
);
44 rendering_stats_
.animation_frame_count
++;
47 void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count
) {
48 if (!record_rendering_stats_
)
51 base::AutoLock
scoped_lock(lock_
);
52 rendering_stats_
.screen_frame_count
= count
;
55 void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count
) {
56 if (!record_rendering_stats_
)
59 base::AutoLock
scoped_lock(lock_
);
60 rendering_stats_
.dropped_frame_count
= count
;
63 void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration
) {
64 if (!record_rendering_stats_
)
67 base::AutoLock
scoped_lock(lock_
);
68 rendering_stats_
.total_commit_time
+= duration
;
69 rendering_stats_
.total_commit_count
++;
72 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration
,
74 if (!record_rendering_stats_
)
77 base::AutoLock
scoped_lock(lock_
);
78 rendering_stats_
.total_paint_time
+= duration
;
79 rendering_stats_
.total_pixels_painted
+= pixels
;
82 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration
,
84 if (!record_rendering_stats_
)
87 base::AutoLock
scoped_lock(lock_
);
88 rendering_stats_
.total_record_time
+= duration
;
89 rendering_stats_
.total_pixels_recorded
+= pixels
;
92 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration
,
93 base::TimeDelta best_duration
,
95 bool is_in_pending_tree_now_bin
) {
96 if (!record_rendering_stats_
)
99 base::AutoLock
scoped_lock(lock_
);
100 rendering_stats_
.total_rasterize_time
+= total_duration
;
101 rendering_stats_
.best_rasterize_time
+= best_duration
;
102 rendering_stats_
.total_pixels_rasterized
+= pixels
;
104 if (is_in_pending_tree_now_bin
) {
105 rendering_stats_
.total_rasterize_time_for_now_bins_on_pending_tree
+=
110 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() {
111 if (!record_rendering_stats_
)
114 base::AutoLock
scoped_lock(lock_
);
115 rendering_stats_
.num_impl_thread_scrolls
++;
118 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() {
119 if (!record_rendering_stats_
)
122 base::AutoLock
scoped_lock(lock_
);
123 rendering_stats_
.num_main_thread_scrolls
++;
126 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount
) {
127 if (!record_rendering_stats_
)
130 base::AutoLock
scoped_lock(lock_
);
131 rendering_stats_
.num_layers_drawn
+= amount
;
134 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount
) {
135 if (!record_rendering_stats_
)
138 base::AutoLock
scoped_lock(lock_
);
139 rendering_stats_
.num_missing_tiles
+= amount
;
142 void RenderingStatsInstrumentation::AddDeferredImageDecode(
143 base::TimeDelta duration
) {
144 if (!record_rendering_stats_
)
147 base::AutoLock
scoped_lock(lock_
);
148 rendering_stats_
.total_deferred_image_decode_time
+= duration
;
149 rendering_stats_
.total_deferred_image_decode_count
++;
152 void RenderingStatsInstrumentation::AddImageGathering(
153 base::TimeDelta duration
) {
154 if (!record_rendering_stats_
)
157 base::AutoLock
scoped_lock(lock_
);
158 rendering_stats_
.total_image_gathering_time
+= duration
;
159 rendering_stats_
.total_image_gathering_count
++;
162 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() {
163 if (!record_rendering_stats_
)
166 base::AutoLock
scoped_lock(lock_
);
167 rendering_stats_
.total_deferred_image_cache_hit_count
++;
170 void RenderingStatsInstrumentation::AddTileAnalysisResult(
171 base::TimeDelta duration
,
172 bool is_solid_color
) {
173 if (!record_rendering_stats_
)
176 base::AutoLock
scoped_lock(lock_
);
177 rendering_stats_
.total_tiles_analyzed
++;
178 rendering_stats_
.total_tile_analysis_time
+= duration
;
180 rendering_stats_
.solid_color_tiles_analyzed
++;