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::AddStats(const RenderingStats
& other
) {
40 if (!record_rendering_stats_
)
43 base::AutoLock
scoped_lock(lock_
);
44 rendering_stats_
.Add(other
);
47 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() {
48 if (!record_rendering_stats_
)
51 base::AutoLock
scoped_lock(lock_
);
52 rendering_stats_
.animation_frame_count
++;
55 void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count
) {
56 if (!record_rendering_stats_
)
59 base::AutoLock
scoped_lock(lock_
);
60 rendering_stats_
.screen_frame_count
= count
;
63 void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count
) {
64 if (!record_rendering_stats_
)
67 base::AutoLock
scoped_lock(lock_
);
68 rendering_stats_
.dropped_frame_count
= count
;
71 void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration
) {
72 if (!record_rendering_stats_
)
75 base::AutoLock
scoped_lock(lock_
);
76 rendering_stats_
.total_commit_time
+= duration
;
77 rendering_stats_
.total_commit_count
++;
80 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration
,
82 if (!record_rendering_stats_
)
85 base::AutoLock
scoped_lock(lock_
);
86 rendering_stats_
.total_paint_time
+= duration
;
87 rendering_stats_
.total_pixels_painted
+= pixels
;
90 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration
,
92 if (!record_rendering_stats_
)
95 base::AutoLock
scoped_lock(lock_
);
96 rendering_stats_
.total_record_time
+= duration
;
97 rendering_stats_
.total_pixels_recorded
+= pixels
;
100 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration
,
101 base::TimeDelta best_duration
,
103 bool is_in_pending_tree_now_bin
) {
104 if (!record_rendering_stats_
)
107 base::AutoLock
scoped_lock(lock_
);
108 rendering_stats_
.total_rasterize_time
+= total_duration
;
109 rendering_stats_
.best_rasterize_time
+= best_duration
;
110 rendering_stats_
.total_pixels_rasterized
+= pixels
;
112 if (is_in_pending_tree_now_bin
) {
113 rendering_stats_
.total_rasterize_time_for_now_bins_on_pending_tree
+=
118 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() {
119 if (!record_rendering_stats_
)
122 base::AutoLock
scoped_lock(lock_
);
123 rendering_stats_
.num_impl_thread_scrolls
++;
126 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() {
127 if (!record_rendering_stats_
)
130 base::AutoLock
scoped_lock(lock_
);
131 rendering_stats_
.num_main_thread_scrolls
++;
134 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount
) {
135 if (!record_rendering_stats_
)
138 base::AutoLock
scoped_lock(lock_
);
139 rendering_stats_
.num_layers_drawn
+= amount
;
142 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount
) {
143 if (!record_rendering_stats_
)
146 base::AutoLock
scoped_lock(lock_
);
147 rendering_stats_
.num_missing_tiles
+= amount
;
150 void RenderingStatsInstrumentation::AddDeferredImageDecode(
151 base::TimeDelta duration
) {
152 if (!record_rendering_stats_
)
155 base::AutoLock
scoped_lock(lock_
);
156 rendering_stats_
.total_deferred_image_decode_time
+= duration
;
157 rendering_stats_
.total_deferred_image_decode_count
++;
160 void RenderingStatsInstrumentation::AddImageGathering(
161 base::TimeDelta duration
) {
162 if (!record_rendering_stats_
)
165 base::AutoLock
scoped_lock(lock_
);
166 rendering_stats_
.total_image_gathering_time
+= duration
;
167 rendering_stats_
.total_image_gathering_count
++;
170 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() {
171 if (!record_rendering_stats_
)
174 base::AutoLock
scoped_lock(lock_
);
175 rendering_stats_
.total_deferred_image_cache_hit_count
++;
178 void RenderingStatsInstrumentation::AddTileAnalysisResult(
179 base::TimeDelta duration
,
180 bool is_solid_color
) {
181 if (!record_rendering_stats_
)
184 base::AutoLock
scoped_lock(lock_
);
185 rendering_stats_
.total_tiles_analyzed
++;
186 rendering_stats_
.total_tile_analysis_time
+= duration
;
188 rendering_stats_
.solid_color_tiles_analyzed
++;