Copy ldb files in ChromiumEnv for the purpose of backups.
[chromium-blink-merge.git] / cc / debug / overdraw_metrics.h
blob43bd19baa73e19d46457e59d0b4ada99048fa81b
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_OVERDRAW_METRICS_H_
6 #define CC_DEBUG_OVERDRAW_METRICS_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
11 namespace gfx {
12 class Rect;
13 class Transform;
16 namespace cc {
17 class LayerTreeHost;
18 class LayerTreeHostImpl;
20 class OverdrawMetrics {
21 public:
22 static scoped_ptr<OverdrawMetrics> Create(bool record_metrics_for_frame) {
23 return make_scoped_ptr(new OverdrawMetrics(record_metrics_for_frame));
26 // These methods are used for saving metrics during update/commit.
28 // Record pixels painted by WebKit into the texture updater, but does not mean
29 // the pixels were rasterized in main memory.
30 void DidPaint(gfx::Rect painted_rect);
31 // Records that an invalid tile was culled and did not need to be
32 // painted/uploaded, and did not contribute to other tiles needing to be
33 // painted.
34 void DidCullTilesForUpload(int count);
35 // Records pixels that were uploaded to texture memory.
36 void DidUpload(const gfx::Transform& transform_to_target,
37 gfx::Rect upload_rect,
38 gfx::Rect opaque_rect);
39 // Record contents texture(s) behind present using the given number of bytes.
40 void DidUseContentsTextureMemoryBytes(size_t contents_texture_use_bytes);
41 // Record RenderSurfaceImpl texture(s) being present using the given number of
42 // bytes.
43 void DidUseRenderSurfaceTextureMemoryBytes(size_t render_surface_use_bytes);
45 // These methods are used for saving metrics during draw.
47 // Record pixels that were not drawn to screen.
48 void DidCullForDrawing(const gfx::Transform& transform_to_target,
49 gfx::Rect before_cull_rect,
50 gfx::Rect after_cull_rect);
51 // Record pixels that were drawn to screen.
52 void DidDraw(const gfx::Transform& transform_to_target,
53 gfx::Rect after_cull_rect,
54 gfx::Rect opaque_rect);
56 void RecordMetrics(const LayerTreeHost* layer_tree_host) const;
57 void RecordMetrics(const LayerTreeHostImpl* layer_tree_host_impl) const;
59 // Accessors for tests.
60 float pixels_drawn_opaque() const { return pixels_drawn_opaque_; }
61 float pixels_drawn_translucent() const { return pixels_drawn_translucent_; }
62 float pixels_culled_for_drawing() const { return pixels_culled_for_drawing_; }
63 float pixels_painted() const { return pixels_painted_; }
64 float pixels_uploaded_opaque() const { return pixels_uploaded_opaque_; }
65 float pixels_uploaded_translucent() const {
66 return pixels_uploaded_translucent_;
68 int tiles_culled_for_upload() const { return tiles_culled_for_upload_; }
70 private:
71 enum MetricsType {
72 UpdateAndCommit,
73 DrawingToScreen
76 explicit OverdrawMetrics(bool record_metrics_for_frame);
78 template <typename LayerTreeHostType>
79 void RecordMetricsInternal(MetricsType metrics_type,
80 const LayerTreeHostType* layer_tree_host) const;
82 // When false this class is a giant no-op.
83 bool record_metrics_for_frame_;
85 // These values are used for saving metrics during update/commit.
87 // Count of pixels that were painted due to invalidation.
88 float pixels_painted_;
89 // Count of pixels uploaded to textures and known to be opaque.
90 float pixels_uploaded_opaque_;
91 // Count of pixels uploaded to textures and not known to be opaque.
92 float pixels_uploaded_translucent_;
93 // Count of tiles that were invalidated but not uploaded.
94 int tiles_culled_for_upload_;
95 // Count the number of bytes in contents textures.
96 uint64 contents_texture_use_bytes_;
97 // Count the number of bytes in RenderSurfaceImpl textures.
98 uint64 render_surface_texture_use_bytes_;
100 // These values are used for saving metrics during draw.
102 // Count of pixels that are opaque (and thus occlude). Ideally this is no more
103 // than wiewport width x height.
104 float pixels_drawn_opaque_;
105 // Count of pixels that are possibly translucent, and cannot occlude.
106 float pixels_drawn_translucent_;
107 // Count of pixels not drawn as they are occluded by somthing opaque.
108 float pixels_culled_for_drawing_;
110 DISALLOW_COPY_AND_ASSIGN(OverdrawMetrics);
113 } // namespace cc
115 #endif // CC_DEBUG_OVERDRAW_METRICS_H_