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. 4 5 #ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ 6 #define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "base/synchronization/lock.h" 10 #include "cc/debug/rendering_stats.h" 11 12 namespace cc { 13 14 // RenderingStatsInstrumentation is shared among threads and manages conditional 15 // recording of rendering stats into a private RenderingStats instance. 16 class CC_EXPORT RenderingStatsInstrumentation { 17 public: 18 static scoped_ptr<RenderingStatsInstrumentation> Create(); 19 virtual ~RenderingStatsInstrumentation(); 20 21 RenderingStats GetRenderingStats(); 22 23 // 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 25 // it's value during runtime. 26 bool record_rendering_stats() const { return record_rendering_stats_; } 27 void set_record_rendering_stats(bool record_rendering_stats) { 28 if (record_rendering_stats_ != record_rendering_stats) 29 record_rendering_stats_ = record_rendering_stats; 30 } 31 32 base::TimeTicks StartRecording() const; 33 base::TimeDelta EndRecording(base::TimeTicks start_time) const; 34 35 void IncrementAnimationFrameCount(); 36 void SetScreenFrameCount(int64 count); 37 void SetDroppedFrameCount(int64 count); 38 39 void AddCommit(base::TimeDelta duration); 40 void AddPaint(base::TimeDelta duration, int64 pixels); 41 void AddRecord(base::TimeDelta duration, int64 pixels); 42 void AddRaster(base::TimeDelta total_duraction, 43 base::TimeDelta best_duration, 44 int64 pixels, 45 bool is_in_pending_tree_now_bin); 46 47 void IncrementImplThreadScrolls(); 48 void IncrementMainThreadScrolls(); 49 50 void AddLayersDrawn(int64 amount); 51 void AddMissingTiles(int64 amount); 52 53 void AddDeferredImageDecode(base::TimeDelta duration); 54 void AddImageGathering(base::TimeDelta duration); 55 56 void IncrementDeferredImageCacheHitCount(); 57 58 void AddAnalysisResult(base::TimeDelta duration, bool is_solid_color); 59 60 protected: 61 RenderingStatsInstrumentation(); 62 63 private: 64 RenderingStats rendering_stats_; 65 bool record_rendering_stats_; 66 67 base::Lock lock_; 68 69 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation); 70 }; 71 72 } // namespace cc 73 74 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_ 75