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::AddRaster(base::TimeDelta duration
,
92 bool is_in_pending_tree_now_bin
) {
93 if (!record_rendering_stats_
)
96 base::AutoLock
scoped_lock(lock_
);
97 rendering_stats_
.total_rasterize_time
+= duration
;
98 rendering_stats_
.total_pixels_rasterized
+= pixels
;
100 if (is_in_pending_tree_now_bin
) {
101 rendering_stats_
.total_rasterize_time_for_now_bins_on_pending_tree
+=
106 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() {
107 if (!record_rendering_stats_
)
110 base::AutoLock
scoped_lock(lock_
);
111 rendering_stats_
.num_impl_thread_scrolls
++;
114 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() {
115 if (!record_rendering_stats_
)
118 base::AutoLock
scoped_lock(lock_
);
119 rendering_stats_
.num_main_thread_scrolls
++;
122 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount
) {
123 if (!record_rendering_stats_
)
126 base::AutoLock
scoped_lock(lock_
);
127 rendering_stats_
.num_layers_drawn
+= amount
;
130 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount
) {
131 if (!record_rendering_stats_
)
134 base::AutoLock
scoped_lock(lock_
);
135 rendering_stats_
.num_missing_tiles
+= amount
;
138 void RenderingStatsInstrumentation::AddDeferredImageDecode(
139 base::TimeDelta duration
) {
140 if (!record_rendering_stats_
)
143 base::AutoLock
scoped_lock(lock_
);
144 rendering_stats_
.total_deferred_image_decode_time
+= duration
;
145 rendering_stats_
.total_deferred_image_decode_count
++;
148 void RenderingStatsInstrumentation::AddImageGathering(
149 base::TimeDelta duration
) {
150 if (!record_rendering_stats_
)
153 base::AutoLock
scoped_lock(lock_
);
154 rendering_stats_
.total_image_gathering_time
+= duration
;
155 rendering_stats_
.total_image_gathering_count
++;
158 void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() {
159 if (!record_rendering_stats_
)
162 base::AutoLock
scoped_lock(lock_
);
163 rendering_stats_
.total_deferred_image_cache_hit_count
++;