Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / cc / debug / rendering_stats_instrumentation.cc
blobe23ce95569db143f9018a6c936f6a5ce65e193be
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 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_)
41 return;
43 base::AutoLock scoped_lock(lock_);
44 rendering_stats_.Add(other);
47 void RenderingStatsInstrumentation::IncrementAnimationFrameCount() {
48 if (!record_rendering_stats_)
49 return;
51 base::AutoLock scoped_lock(lock_);
52 rendering_stats_.animation_frame_count++;
55 void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count) {
56 if (!record_rendering_stats_)
57 return;
59 base::AutoLock scoped_lock(lock_);
60 rendering_stats_.screen_frame_count = count;
63 void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count) {
64 if (!record_rendering_stats_)
65 return;
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_)
73 return;
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,
81 int64 pixels) {
82 if (!record_rendering_stats_)
83 return;
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,
91 int64 pixels) {
92 if (!record_rendering_stats_)
93 return;
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,
102 int64 pixels,
103 bool is_in_pending_tree_now_bin) {
104 if (!record_rendering_stats_)
105 return;
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 +=
114 total_duration;
118 void RenderingStatsInstrumentation::IncrementImplThreadScrolls() {
119 if (!record_rendering_stats_)
120 return;
122 base::AutoLock scoped_lock(lock_);
123 rendering_stats_.num_impl_thread_scrolls++;
126 void RenderingStatsInstrumentation::IncrementMainThreadScrolls() {
127 if (!record_rendering_stats_)
128 return;
130 base::AutoLock scoped_lock(lock_);
131 rendering_stats_.num_main_thread_scrolls++;
134 void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) {
135 if (!record_rendering_stats_)
136 return;
138 base::AutoLock scoped_lock(lock_);
139 rendering_stats_.num_layers_drawn += amount;
142 void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) {
143 if (!record_rendering_stats_)
144 return;
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_)
153 return;
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_)
163 return;
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_)
172 return;
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_)
182 return;
184 base::AutoLock scoped_lock(lock_);
185 rendering_stats_.total_tiles_analyzed++;
186 rendering_stats_.total_tile_analysis_time += duration;
187 if (is_solid_color)
188 rendering_stats_.solid_color_tiles_analyzed++;
191 } // namespace cc