OLD | NEW |
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 CCOverdrawMetrics_h | 5 #ifndef CCOverdrawMetrics_h |
6 #define CCOverdrawMetrics_h | 6 #define CCOverdrawMetrics_h |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 | 9 |
10 namespace WebKit { | 10 namespace WebKit { |
11 class WebTransformationMatrix; | 11 class WebTransformationMatrix; |
12 } | 12 } |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 class IntRect; | 15 class IntRect; |
16 class CCLayerTreeHost; | 16 class LayerTreeHost; |
17 class CCLayerTreeHostImpl; | 17 class LayerTreeHostImpl; |
18 | 18 |
19 // FIXME: compute overdraw metrics only occasionally, not every frame. | 19 // FIXME: compute overdraw metrics only occasionally, not every frame. |
20 class CCOverdrawMetrics { | 20 class OverdrawMetrics { |
21 public: | 21 public: |
22 static scoped_ptr<CCOverdrawMetrics> create(bool recordMetricsForFrame) { re
turn make_scoped_ptr(new CCOverdrawMetrics(recordMetricsForFrame)); } | 22 static scoped_ptr<OverdrawMetrics> create(bool recordMetricsForFrame) { retu
rn make_scoped_ptr(new OverdrawMetrics(recordMetricsForFrame)); } |
23 | 23 |
24 // These methods are used for saving metrics during update/commit. | 24 // These methods are used for saving metrics during update/commit. |
25 | 25 |
26 // Record pixels painted by WebKit into the texture updater, but does not me
an the pixels were rasterized in main memory. | 26 // Record pixels painted by WebKit into the texture updater, but does not me
an the pixels were rasterized in main memory. |
27 void didPaint(const IntRect& paintedRect); | 27 void didPaint(const IntRect& paintedRect); |
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. | 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. |
29 void didCullTileForUpload(); | 29 void didCullTileForUpload(); |
30 // Records pixels that were uploaded to texture memory. | 30 // Records pixels that were uploaded to texture memory. |
31 void didUpload(const WebKit::WebTransformationMatrix& transformToTarget, con
st IntRect& uploadRect, const IntRect& opaqueRect); | 31 void didUpload(const WebKit::WebTransformationMatrix& transformToTarget, con
st IntRect& uploadRect, const IntRect& opaqueRect); |
32 // Record contents texture(s) behind present using the given number of bytes
. | 32 // Record contents texture(s) behind present using the given number of bytes
. |
33 void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes); | 33 void didUseContentsTextureMemoryBytes(size_t contentsTextureUseBytes); |
34 // Record RenderSurface texture(s) being present using the given number of b
ytes. | 34 // Record RenderSurfaceImpl texture(s) being present using the given number
of bytes. |
35 void didUseRenderSurfaceTextureMemoryBytes(size_t renderSurfaceUseBytes); | 35 void didUseRenderSurfaceTextureMemoryBytes(size_t renderSurfaceUseBytes); |
36 | 36 |
37 // These methods are used for saving metrics during draw. | 37 // These methods are used for saving metrics during draw. |
38 | 38 |
39 // Record pixels that were not drawn to screen. | 39 // Record pixels that were not drawn to screen. |
40 void didCullForDrawing(const WebKit::WebTransformationMatrix& transformToTar
get, const IntRect& beforeCullRect, const IntRect& afterCullRect); | 40 void didCullForDrawing(const WebKit::WebTransformationMatrix& transformToTar
get, const IntRect& beforeCullRect, const IntRect& afterCullRect); |
41 // Record pixels that were drawn to screen. | 41 // Record pixels that were drawn to screen. |
42 void didDraw(const WebKit::WebTransformationMatrix& transformToTarget, const
IntRect& afterCullRect, const IntRect& opaqueRect); | 42 void didDraw(const WebKit::WebTransformationMatrix& transformToTarget, const
IntRect& afterCullRect, const IntRect& opaqueRect); |
43 | 43 |
44 void recordMetrics(const CCLayerTreeHost*) const; | 44 void recordMetrics(const LayerTreeHost*) const; |
45 void recordMetrics(const CCLayerTreeHostImpl*) const; | 45 void recordMetrics(const LayerTreeHostImpl*) const; |
46 | 46 |
47 // Accessors for tests. | 47 // Accessors for tests. |
48 float pixelsDrawnOpaque() const { return m_pixelsDrawnOpaque; } | 48 float pixelsDrawnOpaque() const { return m_pixelsDrawnOpaque; } |
49 float pixelsDrawnTranslucent() const { return m_pixelsDrawnTranslucent; } | 49 float pixelsDrawnTranslucent() const { return m_pixelsDrawnTranslucent; } |
50 float pixelsCulledForDrawing() const { return m_pixelsCulledForDrawing; } | 50 float pixelsCulledForDrawing() const { return m_pixelsCulledForDrawing; } |
51 float pixelsPainted() const { return m_pixelsPainted; } | 51 float pixelsPainted() const { return m_pixelsPainted; } |
52 float pixelsUploadedOpaque() const { return m_pixelsUploadedOpaque; } | 52 float pixelsUploadedOpaque() const { return m_pixelsUploadedOpaque; } |
53 float pixelsUploadedTranslucent() const { return m_pixelsUploadedTranslucent
; } | 53 float pixelsUploadedTranslucent() const { return m_pixelsUploadedTranslucent
; } |
54 int tilesCulledForUpload() const { return m_tilesCulledForUpload; } | 54 int tilesCulledForUpload() const { return m_tilesCulledForUpload; } |
55 | 55 |
56 private: | 56 private: |
57 enum MetricsType { | 57 enum MetricsType { |
58 UpdateAndCommit, | 58 UpdateAndCommit, |
59 DrawingToScreen | 59 DrawingToScreen |
60 }; | 60 }; |
61 | 61 |
62 explicit CCOverdrawMetrics(bool recordMetricsForFrame); | 62 explicit OverdrawMetrics(bool recordMetricsForFrame); |
63 | 63 |
64 template<typename LayerTreeHostType> | 64 template<typename LayerTreeHostType> |
65 void recordMetricsInternal(MetricsType, const LayerTreeHostType*) const; | 65 void recordMetricsInternal(MetricsType, const LayerTreeHostType*) const; |
66 | 66 |
67 // When false this class is a giant no-op. | 67 // When false this class is a giant no-op. |
68 bool m_recordMetricsForFrame; | 68 bool m_recordMetricsForFrame; |
69 | 69 |
70 // These values are used for saving metrics during update/commit. | 70 // These values are used for saving metrics during update/commit. |
71 | 71 |
72 // Count of pixels that were painted due to invalidation. | 72 // Count of pixels that were painted due to invalidation. |
73 float m_pixelsPainted; | 73 float m_pixelsPainted; |
74 // Count of pixels uploaded to textures and known to be opaque. | 74 // Count of pixels uploaded to textures and known to be opaque. |
75 float m_pixelsUploadedOpaque; | 75 float m_pixelsUploadedOpaque; |
76 // Count of pixels uploaded to textures and not known to be opaque. | 76 // Count of pixels uploaded to textures and not known to be opaque. |
77 float m_pixelsUploadedTranslucent; | 77 float m_pixelsUploadedTranslucent; |
78 // Count of tiles that were invalidated but not uploaded. | 78 // Count of tiles that were invalidated but not uploaded. |
79 int m_tilesCulledForUpload; | 79 int m_tilesCulledForUpload; |
80 // Count the number of bytes in contents textures. | 80 // Count the number of bytes in contents textures. |
81 unsigned long long m_contentsTextureUseBytes; | 81 unsigned long long m_contentsTextureUseBytes; |
82 // Count the number of bytes in RenderSurface textures. | 82 // Count the number of bytes in RenderSurfaceImpl textures. |
83 unsigned long long m_renderSurfaceTextureUseBytes; | 83 unsigned long long m_renderSurfaceTextureUseBytes; |
84 | 84 |
85 // These values are used for saving metrics during draw. | 85 // These values are used for saving metrics during draw. |
86 | 86 |
87 // Count of pixels that are opaque (and thus occlude). Ideally this is no mo
re than wiewport width x height. | 87 // Count of pixels that are opaque (and thus occlude). Ideally this is no mo
re than wiewport width x height. |
88 float m_pixelsDrawnOpaque; | 88 float m_pixelsDrawnOpaque; |
89 // Count of pixels that are possibly translucent, and cannot occlude. | 89 // Count of pixels that are possibly translucent, and cannot occlude. |
90 float m_pixelsDrawnTranslucent; | 90 float m_pixelsDrawnTranslucent; |
91 // Count of pixels not drawn as they are occluded by somthing opaque. | 91 // Count of pixels not drawn as they are occluded by somthing opaque. |
92 float m_pixelsCulledForDrawing; | 92 float m_pixelsCulledForDrawing; |
93 }; | 93 }; |
94 | 94 |
95 } // namespace cc | 95 } // namespace cc |
96 | 96 |
97 #endif | 97 #endif |
OLD | NEW |