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 #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 "FloatQuad.h" | 9 #include "FloatQuad.h" |
10 #include "IntRect.h" | 10 #include "IntRect.h" |
(...skipping 15 matching lines...) Expand all Loading... |
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 FloatPoint& p1, const FloatPoint& p2) | 36 static inline float wedgeProduct(const gfx::PointF& p1, const gfx::PointF& p2) |
37 { | 37 { |
38 return p1.x() * p2.y() - p1.y() * p2.x(); | 38 return p1.x() * p2.y() - p1.y() * p2.x(); |
39 } | 39 } |
40 | 40 |
41 // Calculates area of an arbitrary convex polygon with up to 8 points. | 41 // Calculates area of an arbitrary convex polygon with up to 8 points. |
42 static inline float polygonArea(const FloatPoint points[8], int numPoints) | 42 static inline float polygonArea(const gfx::PointF points[8], int numPoints) |
43 { | 43 { |
44 if (numPoints < 3) | 44 if (numPoints < 3) |
45 return 0; | 45 return 0; |
46 | 46 |
47 float area = 0; | 47 float area = 0; |
48 for (int i = 0; i < numPoints; ++i) | 48 for (int i = 0; i < numPoints; ++i) |
49 area += wedgeProduct(points[i], points[(i+1)%numPoints]); | 49 area += wedgeProduct(points[i], points[(i+1)%numPoints]); |
50 return fabs(0.5f * area); | 50 return fabs(0.5f * area); |
51 } | 51 } |
52 | 52 |
53 // Takes a given quad, maps it by the given transformation, and gives the area o
f the resulting polygon. | 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 FloatQuad& quad) | 54 static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, c
onst FloatQuad& quad) |
55 { | 55 { |
56 FloatPoint clippedQuad[8]; | 56 gfx::PointF clippedQuad[8]; |
57 int numVerticesInClippedQuad = 0; | 57 int numVerticesInClippedQuad = 0; |
58 MathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQ
uad); | 58 MathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQ
uad); |
59 return polygonArea(clippedQuad, numVerticesInClippedQuad); | 59 return polygonArea(clippedQuad, numVerticesInClippedQuad); |
60 } | 60 } |
61 | 61 |
62 void OverdrawMetrics::didPaint(const IntRect& paintedRect) | 62 void OverdrawMetrics::didPaint(const IntRect& paintedRect) |
63 { | 63 { |
64 if (!m_recordMetricsForFrame) | 64 if (!m_recordMetricsForFrame) |
65 return; | 65 return; |
66 | 66 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 { | 177 { |
178 // 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. |
179 TRACE_EVENT2("cc", "OverdrawPaintMetrics", "ContentsTextureBytes", m
_contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureUse
Bytes); | 179 TRACE_EVENT2("cc", "OverdrawPaintMetrics", "ContentsTextureBytes", m
_contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureUse
Bytes); |
180 } | 180 } |
181 break; | 181 break; |
182 } | 182 } |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 } // namespace cc | 186 } // namespace cc |
OLD | NEW |