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

Side by Side Diff: cc/CCOverdrawMetrics.cpp

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/CCOverdrawMetrics.h ('k') | cc/CCPageScaleAnimation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "config.h"
6
7 #if USE(ACCELERATED_COMPOSITING)
8
9 #include "CCOverdrawMetrics.h"
10
11 #include "CCLayerTreeHost.h"
12 #include "CCLayerTreeHostImpl.h"
13 #include "CCMathUtil.h"
14 #include "FloatQuad.h"
15 #include "IntRect.h"
16 #include "TraceEvent.h"
17 #include <public/Platform.h>
18 #include <public/WebTransformationMatrix.h>
19
20 using WebKit::WebTransformationMatrix;
21
22 namespace cc {
23
24 CCOverdrawMetrics::CCOverdrawMetrics(bool recordMetricsForFrame)
25 : m_recordMetricsForFrame(recordMetricsForFrame)
26 , m_pixelsPainted(0)
27 , m_pixelsUploadedOpaque(0)
28 , m_pixelsUploadedTranslucent(0)
29 , m_tilesCulledForUpload(0)
30 , m_contentsTextureUseBytes(0)
31 , m_renderSurfaceTextureUseBytes(0)
32 , m_pixelsDrawnOpaque(0)
33 , m_pixelsDrawnTranslucent(0)
34 , m_pixelsCulledForDrawing(0)
35 {
36 }
37
38 static inline float wedgeProduct(const FloatPoint& p1, const FloatPoint& p2)
39 {
40 return p1.x() * p2.y() - p1.y() * p2.x();
41 }
42
43 // Calculates area of an arbitrary convex polygon with up to 8 points.
44 static inline float polygonArea(const FloatPoint points[8], int numPoints)
45 {
46 if (numPoints < 3)
47 return 0;
48
49 float area = 0;
50 for (int i = 0; i < numPoints; ++i)
51 area += wedgeProduct(points[i], points[(i+1)%numPoints]);
52 return fabs(0.5f * area);
53 }
54
55 // Takes a given quad, maps it by the given transformation, and gives the area o f the resulting polygon.
56 static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, c onst FloatQuad& quad)
57 {
58 FloatPoint clippedQuad[8];
59 int numVerticesInClippedQuad = 0;
60 CCMathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippe dQuad);
61 return polygonArea(clippedQuad, numVerticesInClippedQuad);
62 }
63
64 void CCOverdrawMetrics::didPaint(const IntRect& paintedRect)
65 {
66 if (!m_recordMetricsForFrame)
67 return;
68
69 m_pixelsPainted += static_cast<float>(paintedRect.width()) * paintedRect.hei ght();
70 }
71
72 void CCOverdrawMetrics::didCullTileForUpload()
73 {
74 if (m_recordMetricsForFrame)
75 ++m_tilesCulledForUpload;
76 }
77
78 void CCOverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarg et, const IntRect& uploadRect, const IntRect& opaqueRect)
79 {
80 if (!m_recordMetricsForFrame)
81 return;
82
83 float uploadArea = areaOfMappedQuad(transformToTarget, FloatQuad(uploadRect) );
84 float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, FloatQuad(inter section(opaqueRect, uploadRect)));
85
86 m_pixelsUploadedOpaque += uploadOpaqueArea;
87 m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea;
88 }
89
90 void CCOverdrawMetrics::didUseContentsTextureMemoryBytes(size_t contentsTextureU seBytes)
91 {
92 if (!m_recordMetricsForFrame)
93 return;
94
95 m_contentsTextureUseBytes += contentsTextureUseBytes;
96 }
97
98 void CCOverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurfa ceUseBytes)
99 {
100 if (!m_recordMetricsForFrame)
101 return;
102
103 m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes;
104 }
105
106 void CCOverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transfo rmToTarget, const IntRect& beforeCullRect, const IntRect& afterCullRect)
107 {
108 if (!m_recordMetricsForFrame)
109 return;
110
111 float beforeCullArea = areaOfMappedQuad(transformToTarget, FloatQuad(beforeC ullRect));
112 float afterCullArea = areaOfMappedQuad(transformToTarget, FloatQuad(afterCul lRect));
113
114 m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
115 }
116
117 void CCOverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget , const IntRect& afterCullRect, const IntRect& opaqueRect)
118 {
119 if (!m_recordMetricsForFrame)
120 return;
121
122 float afterCullArea = areaOfMappedQuad(transformToTarget, FloatQuad(afterCul lRect));
123 float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, FloatQuad(in tersection(opaqueRect, afterCullRect)));
124
125 m_pixelsDrawnOpaque += afterCullOpaqueArea;
126 m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea;
127 }
128
129 void CCOverdrawMetrics::recordMetrics(const CCLayerTreeHost* layerTreeHost) cons t
130 {
131 if (m_recordMetricsForFrame)
132 recordMetricsInternal<CCLayerTreeHost>(UpdateAndCommit, layerTreeHost);
133 }
134
135 void CCOverdrawMetrics::recordMetrics(const CCLayerTreeHostImpl* layerTreeHost) const
136 {
137 if (m_recordMetricsForFrame)
138 recordMetricsInternal<CCLayerTreeHostImpl>(DrawingToScreen, layerTreeHos t);
139 }
140
141 template<typename LayerTreeHostType>
142 void CCOverdrawMetrics::recordMetricsInternal(MetricsType metricsType, const Lay erTreeHostType* layerTreeHost) const
143 {
144 // This gives approximately 10x the percentage of pixels to fill the viewpor t once.
145 float normalization = 1000.f / (layerTreeHost->deviceViewportSize().width() * layerTreeHost->deviceViewportSize().height());
146 // This gives approximately 100x the percentage of tiles to fill the viewpor t once, if all tiles were 256x256.
147 float tileNormalization = 10000.f / (layerTreeHost->deviceViewportSize().wid th() / 256.f * layerTreeHost->deviceViewportSize().height() / 256.f);
148 // This gives approximately 10x the percentage of bytes to fill the viewport once, assuming 4 bytes per pixel.
149 float byteNormalization = normalization / 4;
150
151 switch (metricsType) {
152 case DrawingToScreen:
153 WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCount Opaque_Draw", static_cast<int>(normalization * m_pixelsDrawnOpaque), 100, 100000 0, 50);
154 WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCount Translucent_Draw", static_cast<int>(normalization * m_pixelsDrawnTranslucent), 1 00, 1000000, 50);
155 WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCount Culled_Draw", static_cast<int>(normalization * m_pixelsCulledForDrawing), 100, 1 000000, 50);
156
157 {
158 TRACE_COUNTER_ID1("cc", "DrawPixelsCulled", layerTreeHost, m_pixelsC ulledForDrawing);
159 TRACE_EVENT2("cc", "CCOverdrawMetrics", "PixelsDrawnOpaque", m_pixel sDrawnOpaque, "PixelsDrawnTranslucent", m_pixelsDrawnTranslucent);
160 }
161 break;
162 case UpdateAndCommit:
163 WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCount Painted", static_cast<int>(normalization * m_pixelsPainted), 100, 1000000, 50);
164 WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCount Opaque_Upload", static_cast<int>(normalization * m_pixelsUploadedOpaque), 100, 1 000000, 50);
165 WebKit::Platform::current()->histogramCustomCounts("Renderer4.pixelCount Translucent_Upload", static_cast<int>(normalization * m_pixelsUploadedTranslucen t), 100, 1000000, 50);
166 WebKit::Platform::current()->histogramCustomCounts("Renderer4.tileCountC ulled_Upload", static_cast<int>(tileNormalization * m_tilesCulledForUpload), 100 , 10000000, 50);
167 WebKit::Platform::current()->histogramCustomCounts("Renderer4.renderSurf aceTextureBytes_ViewportScaled", static_cast<int>(byteNormalization * m_renderSu rfaceTextureUseBytes), 10, 1000000, 50);
168 WebKit::Platform::current()->histogramCustomCounts("Renderer4.renderSurf aceTextureBytes_Unscaled", static_cast<int>(m_renderSurfaceTextureUseBytes / 100 0), 1000, 100000000, 50);
169 WebKit::Platform::current()->histogramCustomCounts("Renderer4.contentsTe xtureBytes_ViewportScaled", static_cast<int>(byteNormalization * m_contentsTextu reUseBytes), 10, 1000000, 50);
170 WebKit::Platform::current()->histogramCustomCounts("Renderer4.contentsTe xtureBytes_Unscaled", static_cast<int>(m_contentsTextureUseBytes / 1000), 1000, 100000000, 50);
171
172 {
173 TRACE_COUNTER_ID1("cc", "UploadTilesCulled", layerTreeHost, m_tilesC ulledForUpload);
174 TRACE_EVENT2("cc", "CCOverdrawMetrics", "PixelsUploadedOpaque", m_pi xelsUploadedOpaque, "PixelsUploadedTranslucent", m_pixelsUploadedTranslucent);
175 }
176 {
177 // This must be in a different scope than the TRACE_EVENT2 above.
178 TRACE_EVENT1("cc", "CCOverdrawPaintMetrics", "PixelsPainted", m_pixe lsPainted);
179 }
180 {
181 // This must be in a different scope than the TRACE_EVENTs above.
182 TRACE_EVENT2("cc", "CCOverdrawPaintMetrics", "ContentsTextureBytes", m_contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureU seBytes);
183 }
184 break;
185 }
186 }
187
188 } // namespace cc
189
190 #endif
OLDNEW
« no previous file with comments | « cc/CCOverdrawMetrics.h ('k') | cc/CCPageScaleAnimation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698