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

Side by Side Diff: cc/overdraw_metrics.cc

Issue 11364132: Revert 166464 - Turn overdraw metrics on only when about:tracing is recording. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/layer_tree_host_impl.cc ('k') | cc/quad_culler_unittest.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 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/overdraw_metrics.h" 7 #include "cc/overdraw_metrics.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 15 matching lines...) Expand all
26 , m_pixelsUploadedTranslucent(0) 26 , m_pixelsUploadedTranslucent(0)
27 , m_tilesCulledForUpload(0) 27 , m_tilesCulledForUpload(0)
28 , m_contentsTextureUseBytes(0) 28 , m_contentsTextureUseBytes(0)
29 , m_renderSurfaceTextureUseBytes(0) 29 , m_renderSurfaceTextureUseBytes(0)
30 , m_pixelsDrawnOpaque(0) 30 , m_pixelsDrawnOpaque(0)
31 , m_pixelsDrawnTranslucent(0) 31 , m_pixelsDrawnTranslucent(0)
32 , m_pixelsCulledForDrawing(0) 32 , m_pixelsCulledForDrawing(0)
33 { 33 {
34 } 34 }
35 35
36 static inline float wedgeProduct(const gfx::PointF& p1, const gfx::PointF& p2)
37 {
38 return p1.x() * p2.y() - p1.y() * p2.x();
39 }
40
41 // Calculates area of an arbitrary convex polygon with up to 8 points.
42 static inline float polygonArea(const gfx::PointF points[8], int numPoints)
43 {
44 if (numPoints < 3)
45 return 0;
46
47 float area = 0;
48 for (int i = 0; i < numPoints; ++i)
49 area += wedgeProduct(points[i], points[(i+1)%numPoints]);
50 return fabs(0.5f * area);
51 }
52
53 // Takes a given quad, maps it by the given transformation, and gives the area o f the resulting polygon.
54 static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, c onst gfx::QuadF& quad)
55 {
56 gfx::PointF clippedQuad[8];
57 int numVerticesInClippedQuad = 0;
58 MathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQ uad);
59 return polygonArea(clippedQuad, numVerticesInClippedQuad);
60 }
61
36 void OverdrawMetrics::didPaint(const gfx::Rect& paintedRect) 62 void OverdrawMetrics::didPaint(const gfx::Rect& paintedRect)
37 { 63 {
38 if (!m_recordMetricsForFrame) 64 if (!m_recordMetricsForFrame)
39 return; 65 return;
40 66
41 m_pixelsPainted += static_cast<float>(paintedRect.width()) * paintedRect.hei ght(); 67 m_pixelsPainted += static_cast<float>(paintedRect.width()) * paintedRect.hei ght();
42 } 68 }
43 69
44 void OverdrawMetrics::didCullTilesForUpload(int count) 70 void OverdrawMetrics::didCullTilesForUpload(int count)
45 { 71 {
46 if (m_recordMetricsForFrame) 72 if (m_recordMetricsForFrame)
47 m_tilesCulledForUpload += count; 73 m_tilesCulledForUpload += count;
48 } 74 }
49 75
50 void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget , const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect) 76 void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget , const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect)
51 { 77 {
52 if (!m_recordMetricsForFrame) 78 if (!m_recordMetricsForFrame)
53 return; 79 return;
54 80
55 gfx::Rect uploadOpaqueRect = gfx::IntersectRects(opaqueRect, uploadRect); 81 float uploadArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(uploadRect ));
56 82 float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx: :IntersectRects(opaqueRect, uploadRect)));
57 float uploadArea = static_cast<float>(uploadRect.width()) * uploadRect.heigh t();
58 float uploadOpaqueArea = static_cast<float>(uploadOpaqueRect.width()) * uplo adOpaqueRect.height();
59 83
60 m_pixelsUploadedOpaque += uploadOpaqueArea; 84 m_pixelsUploadedOpaque += uploadOpaqueArea;
61 m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea; 85 m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea;
62 } 86 }
63 87
64 void OverdrawMetrics::didUseContentsTextureMemoryBytes(size_t contentsTextureUse Bytes) 88 void OverdrawMetrics::didUseContentsTextureMemoryBytes(size_t contentsTextureUse Bytes)
65 { 89 {
66 if (!m_recordMetricsForFrame) 90 if (!m_recordMetricsForFrame)
67 return; 91 return;
68 92
69 m_contentsTextureUseBytes += contentsTextureUseBytes; 93 m_contentsTextureUseBytes += contentsTextureUseBytes;
70 } 94 }
71 95
72 void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface UseBytes) 96 void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface UseBytes)
73 { 97 {
74 if (!m_recordMetricsForFrame) 98 if (!m_recordMetricsForFrame)
75 return; 99 return;
76 100
77 m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes; 101 m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes;
78 } 102 }
79 103
80 void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform ToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect) 104 void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform ToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect)
81 { 105 {
82 if (!m_recordMetricsForFrame) 106 if (!m_recordMetricsForFrame)
83 return; 107 return;
84 108
85 float beforeCullArea = static_cast<float>(beforeCullRect.width()) * beforeCu llRect.height(); 109 float beforeCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(before CullRect));
86 float afterCullArea = static_cast<float>(afterCullRect.width()) * afterCullR ect.height(); 110 float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCu llRect));
87 111
88 m_pixelsCulledForDrawing += beforeCullArea - afterCullArea; 112 m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
89 } 113 }
90 114
91 void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect) 115 void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect)
92 { 116 {
93 if (!m_recordMetricsForFrame) 117 if (!m_recordMetricsForFrame)
94 return; 118 return;
95 119
96 gfx::Rect afterCullOpaqueRect = gfx::IntersectRects(opaqueRect, afterCullRec t); 120 float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCu llRect));
97 121 float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(g fx::IntersectRects(opaqueRect, afterCullRect)));
98 float afterCullArea = static_cast<float>(afterCullRect.width()) * afterCullR ect.height();
99 float afterCullOpaqueArea = static_cast<float>(afterCullOpaqueRect.width()) * afterCullOpaqueRect.height();
100 122
101 m_pixelsDrawnOpaque += afterCullOpaqueArea; 123 m_pixelsDrawnOpaque += afterCullOpaqueArea;
102 m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea; 124 m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea;
103 } 125 }
104 126
105 void OverdrawMetrics::recordMetrics(const LayerTreeHost* layerTreeHost) const 127 void OverdrawMetrics::recordMetrics(const LayerTreeHost* layerTreeHost) const
106 { 128 {
107 if (m_recordMetricsForFrame) 129 if (m_recordMetricsForFrame)
108 recordMetricsInternal<LayerTreeHost>(UpdateAndCommit, layerTreeHost); 130 recordMetricsInternal<LayerTreeHost>(UpdateAndCommit, layerTreeHost);
109 } 131 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 { 177 {
156 // This must be in a different scope than the TRACE_EVENTs above. 178 // This must be in a different scope than the TRACE_EVENTs above.
157 TRACE_EVENT2("cc", "OverdrawPaintMetrics", "ContentsTextureBytes", m _contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureUse Bytes); 179 TRACE_EVENT2("cc", "OverdrawPaintMetrics", "ContentsTextureBytes", m _contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureUse Bytes);
158 } 180 }
159 break; 181 break;
160 } 182 }
161 } 183 }
162 } 184 }
163 185
164 } // namespace cc 186 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/quad_culler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698