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
12namespace cc {
13
14struct CC_EXPORT RenderingStats {
15  int64 animation_frame_count;
16  int64 screen_frame_count;
17  int64 dropped_frame_count;
18  base::TimeDelta total_paint_time;
19  base::TimeDelta total_record_time;
20  base::TimeDelta total_rasterize_time;
21  base::TimeDelta total_rasterize_time_for_now_bins_on_pending_tree;
22  base::TimeDelta total_commit_time;
23  base::TimeDelta best_rasterize_time;
24  int64 total_commit_count;
25  int64 total_pixels_painted;
26  int64 total_pixels_recorded;
27  int64 total_pixels_rasterized;
28  int64 num_impl_thread_scrolls;
29  int64 num_main_thread_scrolls;
30  int64 num_layers_drawn;
31  int64 num_missing_tiles;
32  int64 total_deferred_image_decode_count;
33  int64 total_deferred_image_cache_hit_count;
34  int64 total_image_gathering_count;
35  int64 total_tiles_analyzed;
36  int64 solid_color_tiles_analyzed;
37  base::TimeDelta total_deferred_image_decode_time;
38  base::TimeDelta total_image_gathering_time;
39  base::TimeDelta total_tile_analysis_time;
40  // Note: when adding new members, please remember to update EnumerateFields
41  // and Add in rendering_stats.cc.
42
43  RenderingStats();
44
45  // In conjunction with EnumerateFields, this allows the embedder to
46  // enumerate the values in this structure without
47  // having to embed references to its specific member variables. This
48  // simplifies the addition of new fields to this type.
49  class Enumerator {
50   public:
51    virtual void AddInt64(const char* name, int64 value) = 0;
52    virtual void AddDouble(const char* name, double value) = 0;
53    virtual void AddInt(const char* name, int value) = 0;
54    virtual void AddTimeDeltaInSecondsF(const char* name,
55                                        const base::TimeDelta& value) = 0;
56
57   protected:
58    virtual ~Enumerator() {}
59  };
60
61  // Outputs the fields in this structure to the provided enumerator.
62  void EnumerateFields(Enumerator* enumerator) const;
63
64  // Add fields of |other| to the fields in this structure.
65  void Add(const RenderingStats& other);
66};
67
68}  // namespace cc
69
70#endif  // CC_DEBUG_RENDERING_STATS_H_
71