- add sources.
[platform/framework/web/crosswalk.git] / src / cc / debug / rendering_stats.h
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.
4
5 #ifndef CC_DEBUG_RENDERING_STATS_H_
6 #define CC_DEBUG_RENDERING_STATS_H_
7
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"
12
13 namespace cc {
14
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 {
20  public:
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;
26
27  protected:
28   virtual ~RenderingStatsEnumerator() {}
29 };
30
31 struct CC_EXPORT MainThreadRenderingStats {
32   // Note: when adding new members, please remember to update EnumerateFields
33   // and Add in rendering_stats.cc.
34
35   int64 frame_count;
36   base::TimeDelta paint_time;
37   int64 painted_pixel_count;
38   base::TimeDelta record_time;
39   int64 recorded_pixel_count;
40
41   MainThreadRenderingStats();
42   scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const;
43   void Add(const MainThreadRenderingStats& other);
44 };
45
46 struct CC_EXPORT ImplThreadRenderingStats {
47   // Note: when adding new members, please remember to update EnumerateFields
48   // and Add in rendering_stats.cc.
49
50   int64 frame_count;
51   base::TimeDelta rasterize_time;
52   int64 rasterized_pixel_count;
53
54   ImplThreadRenderingStats();
55   scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const;
56   void Add(const ImplThreadRenderingStats& other);
57 };
58
59 struct CC_EXPORT RenderingStats {
60   typedef RenderingStatsEnumerator Enumerator;
61
62   MainThreadRenderingStats main_stats;
63   ImplThreadRenderingStats impl_stats;
64
65   // Outputs the fields in this structure to the provided enumerator.
66   void EnumerateFields(Enumerator* enumerator) const;
67
68   // Add fields of |other| to the fields in this structure.
69   void Add(const RenderingStats& other);
70 };
71
72 }  // namespace cc
73
74 #endif  // CC_DEBUG_RENDERING_STATS_H_