Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: cc/overdraw_metrics.h

Issue 12728002: cc: Chromify the OverdrawMetrics class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/occlusion_tracker.cc ('k') | cc/overdraw_metrics.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_OVERDRAW_METRICS_H_ 5 #ifndef CC_OVERDRAW_METRICS_H_
6 #define CC_OVERDRAW_METRICS_H_ 6 #define CC_OVERDRAW_METRICS_H_
7 7
8 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 10
10 namespace gfx { 11 namespace gfx {
11 class Rect; 12 class Rect;
12 class Transform; 13 class Transform;
13 } 14 }
14 15
15 namespace cc { 16 namespace cc {
16 class LayerTreeHost; 17 class LayerTreeHost;
17 class LayerTreeHostImpl; 18 class LayerTreeHostImpl;
18 19
19 // FIXME: compute overdraw metrics only occasionally, not every frame.
20 class OverdrawMetrics { 20 class OverdrawMetrics {
21 public: 21 public:
22 static scoped_ptr<OverdrawMetrics> create(bool recordMetricsForFrame) { retu rn make_scoped_ptr(new OverdrawMetrics(recordMetricsForFrame)); } 22 static scoped_ptr<OverdrawMetrics> Create(bool record_metrics_for_frame) {
23 return make_scoped_ptr(new OverdrawMetrics(record_metrics_for_frame));
24 }
23 25
24 // These methods are used for saving metrics during update/commit. 26 // These methods are used for saving metrics during update/commit.
25 27
26 // Record pixels painted by WebKit into the texture updater, but does not me an the pixels were rasterized in main memory. 28 // Record pixels painted by WebKit into the texture updater, but does not mean
27 void didPaint(const gfx::Rect& paintedRect); 29 // the pixels were rasterized in main memory.
28 // Records that an invalid tile was culled and did not need to be painted/up loaded, and did not contribute to other tiles needing to be painted. 30 void DidPaint(gfx::Rect painted_rect);
29 void didCullTilesForUpload(int count); 31 // Records that an invalid tile was culled and did not need to be
30 // Records pixels that were uploaded to texture memory. 32 // painted/uploaded, and did not contribute to other tiles needing to be
31 void didUpload(const gfx::Transform& transformToTarget, const gfx::Rect& upl oadRect, const gfx::Rect& opaqueRect); 33 // painted.
32 // Record contents texture(s) behind present using the given number of bytes . 34 void DidCullTilesForUpload(int count);
33 void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes); 35 // Records pixels that were uploaded to texture memory.
34 // Record RenderSurfaceImpl texture(s) being present using the given number of bytes. 36 void DidUpload(const gfx::Transform& transform_to_target,
35 void didUseRenderSurfaceTextureMemoryBytes(size_t renderSurfaceUseBytes); 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);
36 44
37 // These methods are used for saving metrics during draw. 45 // These methods are used for saving metrics during draw.
38 46
39 // Record pixels that were not drawn to screen. 47 // Record pixels that were not drawn to screen.
40 void didCullForDrawing(const gfx::Transform& transformToTarget, const gfx::R ect& beforeCullRect, const gfx::Rect& afterCullRect); 48 void DidCullForDrawing(const gfx::Transform& transform_to_target,
41 // Record pixels that were drawn to screen. 49 gfx::Rect before_cull_rect,
42 void didDraw(const gfx::Transform& transformToTarget, const gfx::Rect& after CullRect, const gfx::Rect& opaqueRect); 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);
43 55
44 void recordMetrics(const LayerTreeHost*) const; 56 void RecordMetrics(const LayerTreeHost* layer_tree_host) const;
45 void recordMetrics(const LayerTreeHostImpl*) const; 57 void RecordMetrics(const LayerTreeHostImpl* layer_tree_host_impl) const;
46 58
47 // Accessors for tests. 59 // Accessors for tests.
48 float pixelsDrawnOpaque() const { return m_pixelsDrawnOpaque; } 60 float pixels_drawn_opaque() const { return pixels_drawn_opaque_; }
49 float pixelsDrawnTranslucent() const { return m_pixelsDrawnTranslucent; } 61 float pixels_drawn_translucent() const { return pixels_drawn_translucent_; }
50 float pixelsCulledForDrawing() const { return m_pixelsCulledForDrawing; } 62 float pixels_culled_for_drawing() const { return pixels_culled_for_drawing_; }
51 float pixelsPainted() const { return m_pixelsPainted; } 63 float pixels_painted() const { return pixels_painted_; }
52 float pixelsUploadedOpaque() const { return m_pixelsUploadedOpaque; } 64 float pixels_uploaded_opaque() const { return pixels_uploaded_opaque_; }
53 float pixelsUploadedTranslucent() const { return m_pixelsUploadedTranslucent ; } 65 float pixels_uploaded_translucent() const {
54 int tilesCulledForUpload() const { return m_tilesCulledForUpload; } 66 return pixels_uploaded_translucent_;
67 }
68 int tiles_culled_for_upload() const { return tiles_culled_for_upload_; }
55 69
56 private: 70 private:
57 enum MetricsType { 71 enum MetricsType {
58 UpdateAndCommit, 72 UpdateAndCommit,
59 DrawingToScreen 73 DrawingToScreen
60 }; 74 };
61 75
62 explicit OverdrawMetrics(bool recordMetricsForFrame); 76 explicit OverdrawMetrics(bool record_metrics_for_frame);
63 77
64 template<typename LayerTreeHostType> 78 template <typename LayerTreeHostType>
65 void recordMetricsInternal(MetricsType, const LayerTreeHostType*) const; 79 void RecordMetricsInternal(MetricsType metrics_type,
80 const LayerTreeHostType* layer_tree_host) const;
66 81
67 // When false this class is a giant no-op. 82 // When false this class is a giant no-op.
68 bool m_recordMetricsForFrame; 83 bool record_metrics_for_frame_;
69 84
70 // These values are used for saving metrics during update/commit. 85 // These values are used for saving metrics during update/commit.
71 86
72 // Count of pixels that were painted due to invalidation. 87 // Count of pixels that were painted due to invalidation.
73 float m_pixelsPainted; 88 float pixels_painted_;
74 // Count of pixels uploaded to textures and known to be opaque. 89 // Count of pixels uploaded to textures and known to be opaque.
75 float m_pixelsUploadedOpaque; 90 float pixels_uploaded_opaque_;
76 // Count of pixels uploaded to textures and not known to be opaque. 91 // Count of pixels uploaded to textures and not known to be opaque.
77 float m_pixelsUploadedTranslucent; 92 float pixels_uploaded_translucent_;
78 // Count of tiles that were invalidated but not uploaded. 93 // Count of tiles that were invalidated but not uploaded.
79 int m_tilesCulledForUpload; 94 int tiles_culled_for_upload_;
80 // Count the number of bytes in contents textures. 95 // Count the number of bytes in contents textures.
81 unsigned long long m_contentsTextureUseBytes; 96 unsigned long long contents_texture_use_bytes_;
82 // Count the number of bytes in RenderSurfaceImpl textures. 97 // Count the number of bytes in RenderSurfaceImpl textures.
83 unsigned long long m_renderSurfaceTextureUseBytes; 98 unsigned long long render_surface_texture_use_bytes_;
84 99
85 // These values are used for saving metrics during draw. 100 // These values are used for saving metrics during draw.
86 101
87 // Count of pixels that are opaque (and thus occlude). Ideally this is no mo re than wiewport width x height. 102 // Count of pixels that are opaque (and thus occlude). Ideally this is no more
88 float m_pixelsDrawnOpaque; 103 // than wiewport width x height.
89 // Count of pixels that are possibly translucent, and cannot occlude. 104 float pixels_drawn_opaque_;
90 float m_pixelsDrawnTranslucent; 105 // Count of pixels that are possibly translucent, and cannot occlude.
91 // Count of pixels not drawn as they are occluded by somthing opaque. 106 float pixels_drawn_translucent_;
92 float m_pixelsCulledForDrawing; 107 // Count of pixels not drawn as they are occluded by somthing opaque.
108 float pixels_culled_for_drawing_;
109
110 DISALLOW_COPY_AND_ASSIGN(OverdrawMetrics);
93 }; 111 };
94 112
95 } // namespace cc 113 } // namespace cc
96 114
97 #endif // CC_OVERDRAW_METRICS_H_ 115 #endif // CC_OVERDRAW_METRICS_H_
OLDNEW
« no previous file with comments | « cc/occlusion_tracker.cc ('k') | cc/overdraw_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698