| 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. | 21 // Return current main thread rendering stats. |
| 22 MainThreadRenderingStats GetMainThreadRenderingStats() { | 22 const MainThreadRenderingStats& main_thread_rendering_stats() { |
| 23 return main_stats_; | 23 return main_stats_; |
| 24 } | 24 } |
| 25 // Return current impl thread rendering stats. | 25 // Return current impl thread rendering stats. |
| 26 ImplThreadRenderingStats GetImplThreadRenderingStats() { | 26 const ImplThreadRenderingStats& impl_thread_rendering_stats() { |
| 27 return impl_stats_; | 27 return impl_stats_; |
| 28 } | 28 } |
| 29 // Return the accumulated, combined rendering stats. | 29 // Return the accumulated, combined rendering stats. |
| 30 RenderingStats GetRenderingStats(); | 30 RenderingStats GetRenderingStats(); |
| 31 | 31 |
| 32 // Add current main thread rendering stats to accumulator and | 32 // Add current main thread rendering stats to accumulator and |
| 33 // clear current stats. | 33 // clear current stats. |
| 34 void AccumulateAndClearMainThreadStats(); | 34 void AccumulateAndClearMainThreadStats(); |
| 35 // Add current impl thread rendering stats to accumulator and | 35 // Add current impl thread rendering stats to accumulator and |
| 36 // clear current stats. | 36 // clear current stats. |
| 37 void AccumulateAndClearImplThreadStats(); | 37 void AccumulateAndClearImplThreadStats(); |
| 38 | 38 |
| 39 // Issue trace event for current main thread rendering stats. | |
| 40 void IssueTraceEventForMainThreadStats() { | |
| 41 main_stats_.IssueTraceEvent(); | |
| 42 } | |
| 43 // Issue trace event for current impl thread rendering stats. | |
| 44 void IssueTraceEventForImplThreadStats() { | |
| 45 impl_stats_.IssueTraceEvent(); | |
| 46 } | |
| 47 | |
| 48 // 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 |
| 49 // improve performance. The flag is commonly turned off and hardly changes | 40 // improve performance. The flag is commonly turned off and hardly changes |
| 50 // it's value during runtime. | 41 // it's value during runtime. |
| 51 bool record_rendering_stats() const { return record_rendering_stats_; } | 42 bool record_rendering_stats() const { return record_rendering_stats_; } |
| 52 void set_record_rendering_stats(bool record_rendering_stats) { | 43 void set_record_rendering_stats(bool record_rendering_stats) { |
| 53 if (record_rendering_stats_ != record_rendering_stats) | 44 if (record_rendering_stats_ != record_rendering_stats) |
| 54 record_rendering_stats_ = record_rendering_stats; | 45 record_rendering_stats_ = record_rendering_stats; |
| 55 } | 46 } |
| 56 | 47 |
| 57 base::TimeTicks StartRecording() const; | 48 base::TimeTicks StartRecording() const; |
| 58 base::TimeDelta EndRecording(base::TimeTicks start_time) const; | 49 base::TimeDelta EndRecording(base::TimeTicks start_time) const; |
| 59 | 50 |
| 60 void IncrementFrameCount(int64 count, bool main_thread); | 51 void IncrementFrameCount(int64 count, bool main_thread); |
| 61 void AddPaint(base::TimeDelta duration, int64 pixels); | 52 void AddPaint(base::TimeDelta duration, int64 pixels); |
| 62 void AddRecord(base::TimeDelta duration, int64 pixels); | 53 void AddRecord(base::TimeDelta duration, int64 pixels); |
| 63 void AddRaster(base::TimeDelta duration, int64 pixels); | 54 void AddRaster(base::TimeDelta duration, int64 pixels); |
| 64 | 55 |
| 65 protected: | 56 protected: |
| 66 RenderingStatsInstrumentation(); | 57 RenderingStatsInstrumentation(); |
| 67 | 58 |
| 68 private: | 59 private: |
| 60 // TODO(ernstm): rename to *_thread_rendering_stats_* |
| 69 MainThreadRenderingStats main_stats_; | 61 MainThreadRenderingStats main_stats_; |
| 70 MainThreadRenderingStats main_stats_accu_; | 62 MainThreadRenderingStats main_stats_accu_; |
| 71 ImplThreadRenderingStats impl_stats_; | 63 ImplThreadRenderingStats impl_stats_; |
| 72 ImplThreadRenderingStats impl_stats_accu_; | 64 ImplThreadRenderingStats impl_stats_accu_; |
| 73 | 65 |
| 74 bool record_rendering_stats_; | 66 bool record_rendering_stats_; |
| 75 | 67 |
| 76 base::Lock lock_; | 68 base::Lock lock_; |
| 77 | 69 |
| 78 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation); | 70 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation); |
| 79 }; | 71 }; |
| 80 | 72 |
| 81 } // namespace cc | 73 } // namespace cc |
| 82 | 74 |
| 83 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ | 75 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ |
| OLD | NEW |