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

Side by Side Diff: cc/debug/overdraw_metrics.cc

Issue 139233002: [#4] Pass gfx structs by const ref (gfx::PointF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected as per review comments! Created 6 years, 11 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
« no previous file with comments | « cc/base/math_util.cc ('k') | cc/layers/layer.h » ('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 "cc/debug/overdraw_metrics.h" 5 #include "cc/debug/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/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/trees/layer_tree_host.h" 10 #include "cc/trees/layer_tree_host.h"
11 #include "cc/trees/layer_tree_host_impl.h" 11 #include "cc/trees/layer_tree_host_impl.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 "ui/gfx/transform.h" 14 #include "ui/gfx/transform.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 OverdrawMetrics::OverdrawMetrics(bool record_metrics_for_frame) 18 OverdrawMetrics::OverdrawMetrics(bool record_metrics_for_frame)
19 : record_metrics_for_frame_(record_metrics_for_frame), 19 : record_metrics_for_frame_(record_metrics_for_frame),
20 pixels_painted_(0), 20 pixels_painted_(0),
21 pixels_uploaded_opaque_(0), 21 pixels_uploaded_opaque_(0),
22 pixels_uploaded_translucent_(0), 22 pixels_uploaded_translucent_(0),
23 tiles_culled_for_upload_(0), 23 tiles_culled_for_upload_(0),
24 contents_texture_use_bytes_(0), 24 contents_texture_use_bytes_(0),
25 render_surface_texture_use_bytes_(0), 25 render_surface_texture_use_bytes_(0),
26 pixels_drawn_opaque_(0), 26 pixels_drawn_opaque_(0),
27 pixels_drawn_translucent_(0), 27 pixels_drawn_translucent_(0),
28 pixels_culled_for_drawing_(0) {} 28 pixels_culled_for_drawing_(0) {}
29 29
30 static inline float WedgeProduct(gfx::PointF p1, gfx::PointF p2) { 30 static inline float WedgeProduct(const gfx::PointF& p1, const gfx::PointF& p2) {
31 return p1.x() * p2.y() - p1.y() * p2.x(); 31 return p1.x() * p2.y() - p1.y() * p2.x();
32 } 32 }
33 33
34 // Calculates area of an arbitrary convex polygon with up to 8 points. 34 // Calculates area of an arbitrary convex polygon with up to 8 points.
35 static inline float PolygonArea(gfx::PointF points[8], int num_points) { 35 static inline float PolygonArea(const gfx::PointF (&points)[8],
36 int num_points) {
36 if (num_points < 3) 37 if (num_points < 3)
37 return 0; 38 return 0;
38 39
39 float area = 0; 40 float area = 0;
40 for (int i = 0; i < num_points; ++i) 41 for (int i = 0; i < num_points; ++i)
41 area += WedgeProduct(points[i], points[(i+1)%num_points]); 42 area += WedgeProduct(points[i], points[(i+1)%num_points]);
42 return std::abs(0.5f * area); 43 return std::abs(0.5f * area);
43 } 44 }
44 45
45 // Takes a given quad, maps it by the given transformation, and gives the area 46 // Takes a given quad, maps it by the given transformation, and gives the area
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 contents_texture_use_bytes_, 260 contents_texture_use_bytes_,
260 "RenderSurfaceTextureBytes", 261 "RenderSurfaceTextureBytes",
261 render_surface_texture_use_bytes_); 262 render_surface_texture_use_bytes_);
262 } 263 }
263 break; 264 break;
264 } 265 }
265 } 266 }
266 } 267 }
267 268
268 } // namespace cc 269 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util.cc ('k') | cc/layers/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698