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"
14 // RenderingStatsInstrumentation is shared among threads and manages conditional
15 // recording of rendering stats into a private RenderingStats instance.
16 class CC_EXPORT RenderingStatsInstrumentation
{
18 static scoped_ptr
<RenderingStatsInstrumentation
> Create();
19 virtual ~RenderingStatsInstrumentation();
21 RenderingStats
GetRenderingStats();
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
;
32 base::TimeTicks
StartRecording() const;
33 base::TimeDelta
EndRecording(base::TimeTicks start_time
) const;
35 // TODO(egraether): Remove after switching Layer::update() to use this class.
36 // Used in LayerTreeHost::paintLayerContents().
37 void AddStats(const RenderingStats
& other
);
39 void IncrementAnimationFrameCount();
40 void SetScreenFrameCount(int64 count
);
41 void SetDroppedFrameCount(int64 count
);
43 void AddCommit(base::TimeDelta duration
);
44 void AddPaint(base::TimeDelta duration
, int64 pixels
);
45 void AddRaster(base::TimeDelta duration
,
47 bool is_in_pending_tree_now_bin
);
49 void IncrementImplThreadScrolls();
50 void IncrementMainThreadScrolls();
52 void AddLayersDrawn(int64 amount
);
53 void AddMissingTiles(int64 amount
);
55 void AddDeferredImageDecode(base::TimeDelta duration
);
56 void AddImageGathering(base::TimeDelta duration
);
58 void IncrementDeferredImageCacheHitCount();
61 RenderingStatsInstrumentation();
64 RenderingStats rendering_stats_
;
65 bool record_rendering_stats_
;
69 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation
);
74 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_