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

Side by Side Diff: cc/overdraw_metrics.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to tip of tree and addressed feedback Created 8 years 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
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 "cc/overdraw_metrics.h" 5 #include "cc/overdraw_metrics.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "cc/layer_tree_host.h" 9 #include "cc/layer_tree_host.h"
10 #include "cc/layer_tree_host_impl.h" 10 #include "cc/layer_tree_host_impl.h"
11 #include "cc/math_util.h" 11 #include "cc/math_util.h"
12 #include "ui/gfx/quad_f.h" 12 #include "ui/gfx/quad_f.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 #include <public/WebTransformationMatrix.h> 14 #include "ui/gfx/transform.h"
15 15
16 using WebKit::WebTransformationMatrix; 16 using gfx::Transform;
17 17
18 namespace cc { 18 namespace cc {
19 19
20 OverdrawMetrics::OverdrawMetrics(bool recordMetricsForFrame) 20 OverdrawMetrics::OverdrawMetrics(bool recordMetricsForFrame)
21 : m_recordMetricsForFrame(recordMetricsForFrame) 21 : m_recordMetricsForFrame(recordMetricsForFrame)
22 , m_pixelsPainted(0) 22 , m_pixelsPainted(0)
23 , m_pixelsUploadedOpaque(0) 23 , m_pixelsUploadedOpaque(0)
24 , m_pixelsUploadedTranslucent(0) 24 , m_pixelsUploadedTranslucent(0)
25 , m_tilesCulledForUpload(0) 25 , m_tilesCulledForUpload(0)
26 , m_contentsTextureUseBytes(0) 26 , m_contentsTextureUseBytes(0)
(...skipping 15 matching lines...) Expand all
42 if (numPoints < 3) 42 if (numPoints < 3)
43 return 0; 43 return 0;
44 44
45 float area = 0; 45 float area = 0;
46 for (int i = 0; i < numPoints; ++i) 46 for (int i = 0; i < numPoints; ++i)
47 area += wedgeProduct(points[i], points[(i+1)%numPoints]); 47 area += wedgeProduct(points[i], points[(i+1)%numPoints]);
48 return fabs(0.5f * area); 48 return fabs(0.5f * area);
49 } 49 }
50 50
51 // Takes a given quad, maps it by the given transformation, and gives the area o f the resulting polygon. 51 // Takes a given quad, maps it by the given transformation, and gives the area o f the resulting polygon.
52 static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, c onst gfx::QuadF& quad) 52 static inline float areaOfMappedQuad(const Transform& transform, const gfx::Quad F& quad)
53 { 53 {
54 gfx::PointF clippedQuad[8]; 54 gfx::PointF clippedQuad[8];
55 int numVerticesInClippedQuad = 0; 55 int numVerticesInClippedQuad = 0;
56 MathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQ uad); 56 MathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQ uad);
57 return polygonArea(clippedQuad, numVerticesInClippedQuad); 57 return polygonArea(clippedQuad, numVerticesInClippedQuad);
58 } 58 }
59 59
60 void OverdrawMetrics::didPaint(const gfx::Rect& paintedRect) 60 void OverdrawMetrics::didPaint(const gfx::Rect& paintedRect)
61 { 61 {
62 if (!m_recordMetricsForFrame) 62 if (!m_recordMetricsForFrame)
63 return; 63 return;
64 64
65 m_pixelsPainted += static_cast<float>(paintedRect.width()) * paintedRect.hei ght(); 65 m_pixelsPainted += static_cast<float>(paintedRect.width()) * paintedRect.hei ght();
66 } 66 }
67 67
68 void OverdrawMetrics::didCullTilesForUpload(int count) 68 void OverdrawMetrics::didCullTilesForUpload(int count)
69 { 69 {
70 if (m_recordMetricsForFrame) 70 if (m_recordMetricsForFrame)
71 m_tilesCulledForUpload += count; 71 m_tilesCulledForUpload += count;
72 } 72 }
73 73
74 void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget , const gfx::Rect& uploadRect, const gfx::Rect& opaqueRect) 74 void OverdrawMetrics::didUpload(const Transform& transformToTarget, const gfx::R ect& uploadRect, const gfx::Rect& opaqueRect)
75 { 75 {
76 if (!m_recordMetricsForFrame) 76 if (!m_recordMetricsForFrame)
77 return; 77 return;
78 78
79 float uploadArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(uploadRect )); 79 float uploadArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(uploadRect ));
80 float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx: :IntersectRects(opaqueRect, uploadRect))); 80 float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx: :IntersectRects(opaqueRect, uploadRect)));
81 81
82 m_pixelsUploadedOpaque += uploadOpaqueArea; 82 m_pixelsUploadedOpaque += uploadOpaqueArea;
83 m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea; 83 m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea;
84 } 84 }
85 85
86 void OverdrawMetrics::didUseContentsTextureMemoryBytes(size_t contentsTextureUse Bytes) 86 void OverdrawMetrics::didUseContentsTextureMemoryBytes(size_t contentsTextureUse Bytes)
87 { 87 {
88 if (!m_recordMetricsForFrame) 88 if (!m_recordMetricsForFrame)
89 return; 89 return;
90 90
91 m_contentsTextureUseBytes += contentsTextureUseBytes; 91 m_contentsTextureUseBytes += contentsTextureUseBytes;
92 } 92 }
93 93
94 void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface UseBytes) 94 void OverdrawMetrics::didUseRenderSurfaceTextureMemoryBytes(size_t renderSurface UseBytes)
95 { 95 {
96 if (!m_recordMetricsForFrame) 96 if (!m_recordMetricsForFrame)
97 return; 97 return;
98 98
99 m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes; 99 m_renderSurfaceTextureUseBytes += renderSurfaceUseBytes;
100 } 100 }
101 101
102 void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform ToTarget, const gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect) 102 void OverdrawMetrics::didCullForDrawing(const Transform& transformToTarget, cons t gfx::Rect& beforeCullRect, const gfx::Rect& afterCullRect)
103 { 103 {
104 if (!m_recordMetricsForFrame) 104 if (!m_recordMetricsForFrame)
105 return; 105 return;
106 106
107 float beforeCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(before CullRect)); 107 float beforeCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(before CullRect));
108 float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCu llRect)); 108 float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCu llRect));
109 109
110 m_pixelsCulledForDrawing += beforeCullArea - afterCullArea; 110 m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
111 } 111 }
112 112
113 void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget, const gfx::Rect& afterCullRect, const gfx::Rect& opaqueRect) 113 void OverdrawMetrics::didDraw(const Transform& transformToTarget, const gfx::Rec t& afterCullRect, const gfx::Rect& opaqueRect)
114 { 114 {
115 if (!m_recordMetricsForFrame) 115 if (!m_recordMetricsForFrame)
116 return; 116 return;
117 117
118 float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCu llRect)); 118 float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCu llRect));
119 float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(g fx::IntersectRects(opaqueRect, afterCullRect))); 119 float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(g fx::IntersectRects(opaqueRect, afterCullRect)));
120 120
121 m_pixelsDrawnOpaque += afterCullOpaqueArea; 121 m_pixelsDrawnOpaque += afterCullOpaqueArea;
122 m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea; 122 m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea;
123 } 123 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 { 175 {
176 // This must be in a different scope than the TRACE_EVENTs above. 176 // This must be in a different scope than the TRACE_EVENTs above.
177 TRACE_EVENT2("cc", "OverdrawPaintMetrics", "ContentsTextureBytes", m _contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureUse Bytes); 177 TRACE_EVENT2("cc", "OverdrawPaintMetrics", "ContentsTextureBytes", m _contentsTextureUseBytes, "RenderSurfaceTextureBytes", m_renderSurfaceTextureUse Bytes);
178 } 178 }
179 break; 179 break;
180 } 180 }
181 } 181 }
182 } 182 }
183 183
184 } // namespace cc 184 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698