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 #ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ | 5 #ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ |
6 #define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ | 6 #define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "cc/debug/rendering_stats.h" | 10 #include "cc/debug/rendering_stats.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 // RenderingStatsInstrumentation is shared among threads and manages conditional | 14 // RenderingStatsInstrumentation is shared among threads and manages conditional |
15 // recording of rendering stats into a private RenderingStats instance. | 15 // recording of rendering stats into a private RenderingStats instance. |
16 class CC_EXPORT RenderingStatsInstrumentation { | 16 class CC_EXPORT RenderingStatsInstrumentation { |
17 public: | 17 public: |
18 static scoped_ptr<RenderingStatsInstrumentation> Create(); | 18 static scoped_ptr<RenderingStatsInstrumentation> Create(); |
19 virtual ~RenderingStatsInstrumentation(); | 19 virtual ~RenderingStatsInstrumentation(); |
20 | 20 |
| 21 // Return current main thread rendering stats. |
| 22 MainThreadRenderingStats GetMainThreadRenderingStats() { |
| 23 return main_stats_; |
| 24 } |
| 25 // Return current impl thread rendering stats. |
| 26 ImplThreadRenderingStats GetImplThreadRenderingStats() { |
| 27 return impl_stats_; |
| 28 } |
| 29 // Return the accumulated, combined rendering stats. |
21 RenderingStats GetRenderingStats(); | 30 RenderingStats GetRenderingStats(); |
22 | 31 |
| 32 // Add current main thread rendering stats to accumulator and |
| 33 // clear current stats |
| 34 void AccumulateAndClearMainThreadStats(); |
| 35 // Add current impl thread rendering stats to accumulator and |
| 36 // clear current stats |
| 37 void AccumulateAndClearImplThreadStats(); |
| 38 |
23 // Read and write access to the record_rendering_stats_ flag is not locked to | 39 // Read and write access to the record_rendering_stats_ flag is not locked to |
24 // improve performance. The flag is commonly turned off and hardly changes | 40 // improve performance. The flag is commonly turned off and hardly changes |
25 // it's value during runtime. | 41 // it's value during runtime. |
26 bool record_rendering_stats() const { return record_rendering_stats_; } | 42 bool record_rendering_stats() const { return record_rendering_stats_; } |
27 void set_record_rendering_stats(bool record_rendering_stats) { | 43 void set_record_rendering_stats(bool record_rendering_stats) { |
28 if (record_rendering_stats_ != record_rendering_stats) | 44 if (record_rendering_stats_ != record_rendering_stats) |
29 record_rendering_stats_ = record_rendering_stats; | 45 record_rendering_stats_ = record_rendering_stats; |
30 } | 46 } |
31 | 47 |
32 base::TimeTicks StartRecording() const; | 48 base::TimeTicks StartRecording() const; |
33 base::TimeDelta EndRecording(base::TimeTicks start_time) const; | 49 base::TimeDelta EndRecording(base::TimeTicks start_time) const; |
34 | 50 |
35 void IncrementAnimationFrameCount(); | 51 void IncrementAnimationFrameCount(); |
36 void SetScreenFrameCount(int64 count); | 52 void IncrementScreenFrameCount(int64 count); |
37 void SetDroppedFrameCount(int64 count); | 53 void IncrementDroppedFrameCount(int64 count); |
38 | 54 |
39 void AddCommit(base::TimeDelta duration); | 55 void AddCommit(base::TimeDelta duration); |
40 void AddPaint(base::TimeDelta duration, int64 pixels); | 56 void AddPaint(base::TimeDelta duration, int64 pixels); |
41 void AddRecord(base::TimeDelta duration, int64 pixels); | 57 void AddRecord(base::TimeDelta duration, int64 pixels); |
42 void AddRaster(base::TimeDelta total_duraction, | 58 void AddRaster(base::TimeDelta total_duraction, |
43 base::TimeDelta best_duration, | 59 base::TimeDelta best_duration, |
44 int64 pixels, | 60 int64 pixels, |
45 bool is_in_pending_tree_now_bin); | 61 bool is_in_pending_tree_now_bin); |
46 | 62 |
47 void IncrementImplThreadScrolls(); | 63 void IncrementImplThreadScrolls(); |
48 void IncrementMainThreadScrolls(); | 64 void IncrementMainThreadScrolls(); |
49 | 65 |
50 void AddLayersDrawn(int64 amount); | 66 void AddLayersDrawn(int64 amount); |
51 void AddMissingTiles(int64 amount); | 67 void AddMissingTiles(int64 amount); |
52 | 68 |
53 void AddDeferredImageDecode(base::TimeDelta duration); | 69 void AddDeferredImageDecode(base::TimeDelta duration); |
54 void AddImageGathering(base::TimeDelta duration); | 70 void AddImageGathering(base::TimeDelta duration); |
55 | 71 |
56 void IncrementDeferredImageCacheHitCount(); | 72 void IncrementDeferredImageCacheHitCount(); |
57 | 73 |
58 void AddAnalysisResult(base::TimeDelta duration, bool is_solid_color); | 74 void AddAnalysisResult(base::TimeDelta duration, bool is_solid_color); |
59 | 75 |
60 protected: | 76 protected: |
61 RenderingStatsInstrumentation(); | 77 RenderingStatsInstrumentation(); |
62 | 78 |
63 private: | 79 private: |
64 RenderingStats rendering_stats_; | 80 MainThreadRenderingStats main_stats_; |
| 81 MainThreadRenderingStats main_stats_accu_; |
| 82 ImplThreadRenderingStats impl_stats_; |
| 83 ImplThreadRenderingStats impl_stats_accu_; |
| 84 |
65 bool record_rendering_stats_; | 85 bool record_rendering_stats_; |
66 | 86 |
67 base::Lock lock_; | 87 base::Lock lock_; |
68 | 88 |
69 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation); | 89 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation); |
70 }; | 90 }; |
71 | 91 |
72 } // namespace cc | 92 } // namespace cc |
73 | 93 |
74 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ | 94 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ |
OLD | NEW |