1 // Copyright 2012 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_H_
6 #define CC_DEBUG_RENDERING_STATS_H_
8 #include "base/basictypes.h"
9 #include "base/time/time.h"
10 #include "cc/base/cc_export.h"
11 #include "cc/debug/traced_value.h"
15 // In conjunction with EnumerateFields, this allows the embedder to
16 // enumerate the values in this structure without
17 // having to embed references to its specific member variables. This
18 // simplifies the addition of new fields to this type.
19 class RenderingStatsEnumerator
{
21 virtual void AddInt64(const char* name
, int64 value
) = 0;
22 virtual void AddDouble(const char* name
, double value
) = 0;
23 virtual void AddInt(const char* name
, int value
) = 0;
24 virtual void AddTimeDeltaInSecondsF(const char* name
,
25 const base::TimeDelta
& value
) = 0;
28 virtual ~RenderingStatsEnumerator() {}
31 struct CC_EXPORT MainThreadRenderingStats
{
32 // Note: when adding new members, please remember to update EnumerateFields
33 // and Add in rendering_stats.cc.
36 base::TimeDelta paint_time
;
37 int64 painted_pixel_count
;
38 base::TimeDelta record_time
;
39 int64 recorded_pixel_count
;
41 MainThreadRenderingStats();
42 scoped_refptr
<base::debug::ConvertableToTraceFormat
> AsTraceableData() const;
43 void Add(const MainThreadRenderingStats
& other
);
46 struct CC_EXPORT ImplThreadRenderingStats
{
47 // Note: when adding new members, please remember to update EnumerateFields
48 // and Add in rendering_stats.cc.
51 base::TimeDelta rasterize_time
;
52 int64 rasterized_pixel_count
;
54 ImplThreadRenderingStats();
55 scoped_refptr
<base::debug::ConvertableToTraceFormat
> AsTraceableData() const;
56 void Add(const ImplThreadRenderingStats
& other
);
59 struct CC_EXPORT RenderingStats
{
60 typedef RenderingStatsEnumerator Enumerator
;
62 MainThreadRenderingStats main_stats
;
63 ImplThreadRenderingStats impl_stats
;
65 // Outputs the fields in this structure to the provided enumerator.
66 void EnumerateFields(Enumerator
* enumerator
) const;
68 // Add fields of |other| to the fields in this structure.
69 void Add(const RenderingStats
& other
);
74 #endif // CC_DEBUG_RENDERING_STATS_H_