cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / debug / rendering_stats_instrumentation.h
blob5f74f9e61328da328cd4174d303cf9fcca98b7b6
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 #ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
6 #define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/lock.h"
10 #include "cc/debug/rendering_stats.h"
12 namespace cc {
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();
21 // Return current main thread rendering stats.
22 MainThreadRenderingStats GetMainThreadRenderingStats() {
23 return main_stats_;
25 // Return current impl thread rendering stats.
26 ImplThreadRenderingStats GetImplThreadRenderingStats() {
27 return impl_stats_;
29 // Return the accumulated, combined rendering stats.
30 RenderingStats GetRenderingStats();
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();
39 // Issue trace event for current main thread rendering stats.
40 void IssueTraceEventForMainThreadStats() {
41 main_stats_.IssueTraceEvent();
43 // Issue trace event for current impl thread rendering stats.
44 void IssueTraceEventForImplThreadStats() {
45 impl_stats_.IssueTraceEvent();
48 // 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
50 // it's value during runtime.
51 bool record_rendering_stats() const { return record_rendering_stats_; }
52 void set_record_rendering_stats(bool record_rendering_stats) {
53 if (record_rendering_stats_ != record_rendering_stats)
54 record_rendering_stats_ = record_rendering_stats;
57 base::TimeTicks StartRecording() const;
58 base::TimeDelta EndRecording(base::TimeTicks start_time) const;
60 void IncrementAnimationFrameCount();
61 void IncrementScreenFrameCount(int64 count, bool main_thread);
62 void IncrementDroppedFrameCount(int64 count);
64 void AddCommit(base::TimeDelta duration);
65 void AddPaint(base::TimeDelta duration, int64 pixels);
66 void AddRecord(base::TimeDelta duration, int64 pixels);
67 void AddRaster(base::TimeDelta total_duraction,
68 base::TimeDelta best_duration,
69 int64 pixels,
70 bool is_in_pending_tree_now_bin);
72 void IncrementImplThreadScrolls();
73 void IncrementMainThreadScrolls();
75 void AddLayersDrawn(int64 amount);
76 void AddMissingTiles(int64 amount);
78 void AddDeferredImageDecode(base::TimeDelta duration);
79 void AddImageGathering(base::TimeDelta duration);
81 void IncrementDeferredImageCacheHitCount();
83 void AddAnalysisResult(base::TimeDelta duration, bool is_solid_color);
85 protected:
86 RenderingStatsInstrumentation();
88 private:
89 MainThreadRenderingStats main_stats_;
90 MainThreadRenderingStats main_stats_accu_;
91 ImplThreadRenderingStats impl_stats_;
92 ImplThreadRenderingStats impl_stats_accu_;
94 bool record_rendering_stats_;
96 base::Lock lock_;
98 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation);
101 } // namespace cc
103 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_