OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/debug/rendering_stats_instrumentation.h" | 5 #include "cc/debug/rendering_stats_instrumentation.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 // static | 9 // static |
10 scoped_ptr<RenderingStatsInstrumentation> | 10 scoped_ptr<RenderingStatsInstrumentation> |
11 RenderingStatsInstrumentation::Create() { | 11 RenderingStatsInstrumentation::Create() { |
12 return make_scoped_ptr(new RenderingStatsInstrumentation()); | 12 return make_scoped_ptr(new RenderingStatsInstrumentation()); |
13 } | 13 } |
14 | 14 |
15 RenderingStatsInstrumentation::RenderingStatsInstrumentation() | 15 RenderingStatsInstrumentation::RenderingStatsInstrumentation() |
16 : record_rendering_stats_(false) { | 16 : record_rendering_stats_(false) { |
17 } | 17 } |
18 | 18 |
19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} | 19 RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} |
20 | 20 |
21 MainThreadRenderingStats | 21 MainThreadRenderingStats |
22 RenderingStatsInstrumentation::main_thread_rendering_stats() { | 22 RenderingStatsInstrumentation::main_thread_rendering_stats() { |
23 base::AutoLock scoped_lock(lock_); | 23 base::AutoLock scoped_lock(lock_); |
24 return main_stats_; | 24 return main_thread_rendering_stats_; |
25 } | 25 } |
26 | 26 |
27 ImplThreadRenderingStats | 27 ImplThreadRenderingStats |
28 RenderingStatsInstrumentation::impl_thread_rendering_stats() { | 28 RenderingStatsInstrumentation::impl_thread_rendering_stats() { |
29 base::AutoLock scoped_lock(lock_); | 29 base::AutoLock scoped_lock(lock_); |
30 return impl_stats_; | 30 return impl_thread_rendering_stats_; |
31 } | 31 } |
32 | 32 |
33 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { | 33 RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { |
34 base::AutoLock scoped_lock(lock_); | 34 base::AutoLock scoped_lock(lock_); |
35 RenderingStats rendering_stats; | 35 RenderingStats rendering_stats; |
36 rendering_stats.main_stats = main_stats_accu_; | 36 rendering_stats.main_stats = main_thread_rendering_stats_accu_; |
37 rendering_stats.main_stats.Add(main_stats_); | 37 rendering_stats.main_stats.Add(main_thread_rendering_stats_); |
38 rendering_stats.impl_stats = impl_stats_accu_; | 38 rendering_stats.impl_stats = impl_thread_rendering_stats_accu_; |
39 rendering_stats.impl_stats.Add(impl_stats_); | 39 rendering_stats.impl_stats.Add(impl_thread_rendering_stats_); |
40 return rendering_stats; | 40 return rendering_stats; |
41 } | 41 } |
42 | 42 |
43 void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() { | 43 void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() { |
44 base::AutoLock scoped_lock(lock_); | 44 base::AutoLock scoped_lock(lock_); |
45 main_stats_accu_.Add(main_stats_); | 45 main_thread_rendering_stats_accu_.Add(main_thread_rendering_stats_); |
46 main_stats_ = MainThreadRenderingStats(); | 46 main_thread_rendering_stats_ = MainThreadRenderingStats(); |
47 } | 47 } |
48 | 48 |
49 void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() { | 49 void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() { |
50 base::AutoLock scoped_lock(lock_); | 50 base::AutoLock scoped_lock(lock_); |
51 impl_stats_accu_.Add(impl_stats_); | 51 impl_thread_rendering_stats_accu_.Add(impl_thread_rendering_stats_); |
52 impl_stats_ = ImplThreadRenderingStats(); | 52 impl_thread_rendering_stats_ = ImplThreadRenderingStats(); |
53 } | 53 } |
54 | 54 |
55 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { | 55 base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { |
56 if (record_rendering_stats_) { | 56 if (record_rendering_stats_) { |
57 if (base::TimeTicks::IsThreadNowSupported()) | 57 if (base::TimeTicks::IsThreadNowSupported()) |
58 return base::TimeTicks::ThreadNow(); | 58 return base::TimeTicks::ThreadNow(); |
59 return base::TimeTicks::HighResNow(); | 59 return base::TimeTicks::HighResNow(); |
60 } | 60 } |
61 return base::TimeTicks(); | 61 return base::TimeTicks(); |
62 } | 62 } |
63 | 63 |
64 base::TimeDelta RenderingStatsInstrumentation::EndRecording( | 64 base::TimeDelta RenderingStatsInstrumentation::EndRecording( |
65 base::TimeTicks start_time) const { | 65 base::TimeTicks start_time) const { |
66 if (!start_time.is_null()) { | 66 if (!start_time.is_null()) { |
67 if (base::TimeTicks::IsThreadNowSupported()) | 67 if (base::TimeTicks::IsThreadNowSupported()) |
68 return base::TimeTicks::ThreadNow() - start_time; | 68 return base::TimeTicks::ThreadNow() - start_time; |
69 return base::TimeTicks::HighResNow() - start_time; | 69 return base::TimeTicks::HighResNow() - start_time; |
70 } | 70 } |
71 return base::TimeDelta(); | 71 return base::TimeDelta(); |
72 } | 72 } |
73 | 73 |
74 void RenderingStatsInstrumentation::IncrementFrameCount(int64 count, | 74 void RenderingStatsInstrumentation::IncrementFrameCount(int64 count, |
75 bool main_thread) { | 75 bool main_thread) { |
76 if (!record_rendering_stats_) | 76 if (!record_rendering_stats_) |
77 return; | 77 return; |
78 | 78 |
79 base::AutoLock scoped_lock(lock_); | 79 base::AutoLock scoped_lock(lock_); |
80 if (main_thread) | 80 if (main_thread) |
81 main_stats_.frame_count += count; | 81 main_thread_rendering_stats_.frame_count += count; |
82 else | 82 else |
83 impl_stats_.frame_count += count; | 83 impl_thread_rendering_stats_.frame_count += count; |
84 } | 84 } |
85 | 85 |
86 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, | 86 void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, |
87 int64 pixels) { | 87 int64 pixels) { |
88 if (!record_rendering_stats_) | 88 if (!record_rendering_stats_) |
89 return; | 89 return; |
90 | 90 |
91 base::AutoLock scoped_lock(lock_); | 91 base::AutoLock scoped_lock(lock_); |
92 main_stats_.paint_time += duration; | 92 main_thread_rendering_stats_.paint_time += duration; |
93 main_stats_.painted_pixel_count += pixels; | 93 main_thread_rendering_stats_.painted_pixel_count += pixels; |
94 } | 94 } |
95 | 95 |
96 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, | 96 void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, |
97 int64 pixels) { | 97 int64 pixels) { |
98 if (!record_rendering_stats_) | 98 if (!record_rendering_stats_) |
99 return; | 99 return; |
100 | 100 |
101 base::AutoLock scoped_lock(lock_); | 101 base::AutoLock scoped_lock(lock_); |
102 main_stats_.record_time += duration; | 102 main_thread_rendering_stats_.record_time += duration; |
103 main_stats_.recorded_pixel_count += pixels; | 103 main_thread_rendering_stats_.recorded_pixel_count += pixels; |
104 } | 104 } |
105 | 105 |
106 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, | 106 void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, |
107 int64 pixels) { | 107 int64 pixels) { |
108 if (!record_rendering_stats_) | 108 if (!record_rendering_stats_) |
109 return; | 109 return; |
110 | 110 |
111 base::AutoLock scoped_lock(lock_); | 111 base::AutoLock scoped_lock(lock_); |
112 impl_stats_.rasterize_time += duration; | 112 impl_thread_rendering_stats_.rasterize_time += duration; |
113 impl_stats_.rasterized_pixel_count += pixels; | 113 impl_thread_rendering_stats_.rasterized_pixel_count += pixels; |
114 } | 114 } |
115 | 115 |
116 void RenderingStatsInstrumentation::AddAnalysis(base::TimeDelta duration, | 116 void RenderingStatsInstrumentation::AddAnalysis(base::TimeDelta duration, |
117 int64 pixels) { | 117 int64 pixels) { |
118 if (!record_rendering_stats_) | 118 if (!record_rendering_stats_) |
119 return; | 119 return; |
120 | 120 |
121 base::AutoLock scoped_lock(lock_); | 121 base::AutoLock scoped_lock(lock_); |
122 impl_stats_.analysis_time += duration; | 122 impl_thread_rendering_stats_.analysis_time += duration; |
123 } | 123 } |
124 | 124 |
125 void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { | 125 void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { |
126 if (!record_rendering_stats_) | 126 if (!record_rendering_stats_) |
127 return; | 127 return; |
128 | 128 |
129 base::AutoLock scoped_lock(lock_); | 129 base::AutoLock scoped_lock(lock_); |
130 impl_stats_.visible_content_area += area; | 130 impl_thread_rendering_stats_.visible_content_area += area; |
131 } | 131 } |
132 | 132 |
133 void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( | 133 void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( |
134 int64 area) { | 134 int64 area) { |
135 if (!record_rendering_stats_) | 135 if (!record_rendering_stats_) |
136 return; | 136 return; |
137 | 137 |
138 base::AutoLock scoped_lock(lock_); | 138 base::AutoLock scoped_lock(lock_); |
139 impl_stats_.approximated_visible_content_area += area; | 139 impl_thread_rendering_stats_.approximated_visible_content_area += area; |
140 } | 140 } |
141 | 141 |
142 } // namespace cc | 142 } // namespace cc |
OLD | NEW |