Home | History | Annotate | Download | only in debug
      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   base::TimeDelta analysis_time;
     53   int64 rasterized_pixel_count;
     54 
     55   ImplThreadRenderingStats();
     56   scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const;
     57   void Add(const ImplThreadRenderingStats& other);
     58 };
     59 
     60 struct CC_EXPORT RenderingStats {
     61   typedef RenderingStatsEnumerator Enumerator;
     62 
     63   MainThreadRenderingStats main_stats;
     64   ImplThreadRenderingStats impl_stats;
     65 
     66   // Outputs the fields in this structure to the provided enumerator.
     67   void EnumerateFields(Enumerator* enumerator) const;
     68 
     69   // Add fields of |other| to the fields in this structure.
     70   void Add(const RenderingStats& other);
     71 };
     72 
     73 }  // namespace cc
     74 
     75 #endif  // CC_DEBUG_RENDERING_STATS_H_
     76