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

Side by Side Diff: cc/trees/layer_sorter.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/trees/layer_sorter.h ('k') | cc/trees/layer_tree_host_common.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_sorter.h" 5 #include "cc/trees/layer_sorter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 // a value near machine epsilon and then increasing it until the flickering on 22 // a value near machine epsilon and then increasing it until the flickering on
23 // the test scene went away. 23 // the test scene went away.
24 const float k_layer_epsilon = 1e-4f; 24 const float k_layer_epsilon = 1e-4f;
25 25
26 inline static float PerpProduct(gfx::Vector2dF u, gfx::Vector2dF v) { 26 inline static float PerpProduct(gfx::Vector2dF u, gfx::Vector2dF v) {
27 return u.x() * v.y() - u.y() * v.x(); 27 return u.x() * v.y() - u.y() * v.x();
28 } 28 }
29 29
30 // Tests if two edges defined by their endpoints (a,b) and (c,d) intersect. 30 // Tests if two edges defined by their endpoints (a,b) and (c,d) intersect.
31 // Returns true and the point of intersection if they do and false otherwise. 31 // Returns true and the point of intersection if they do and false otherwise.
32 static bool EdgeEdgeTest(gfx::PointF a, 32 static bool EdgeEdgeTest(const gfx::PointF& a,
33 gfx::PointF b, 33 const gfx::PointF& b,
34 gfx::PointF c, 34 const gfx::PointF& c,
35 gfx::PointF d, 35 const gfx::PointF& d,
36 gfx::PointF* r) { 36 gfx::PointF* r) {
37 gfx::Vector2dF u = b - a; 37 gfx::Vector2dF u = b - a;
38 gfx::Vector2dF v = d - c; 38 gfx::Vector2dF v = d - c;
39 gfx::Vector2dF w = a - c; 39 gfx::Vector2dF w = a - c;
40 40
41 float denom = PerpProduct(u, v); 41 float denom = PerpProduct(u, v);
42 42
43 // If denom == 0 then the edges are parallel. While they could be overlapping 43 // If denom == 0 then the edges are parallel. While they could be overlapping
44 // we don't bother to check here as the we'll find their intersections from 44 // we don't bother to check here as the we'll find their intersections from
45 // the corner to quad tests. 45 // the corner to quad tests.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 transform_origin = c1; 236 transform_origin = c1;
237 } 237 }
238 238
239 LayerShape::~LayerShape() {} 239 LayerShape::~LayerShape() {}
240 240
241 // Returns the Z coordinate of a point on the layer that projects 241 // Returns the Z coordinate of a point on the layer that projects
242 // to point p which lies on the z = 0 plane. It does it by computing the 242 // to point p which lies on the z = 0 plane. It does it by computing the
243 // intersection of a line starting from p along the Z axis and the plane 243 // intersection of a line starting from p along the Z axis and the plane
244 // of the layer. 244 // of the layer.
245 float LayerShape::LayerZFromProjectedPoint(gfx::PointF p) const { 245 float LayerShape::LayerZFromProjectedPoint(const gfx::PointF& p) const {
246 gfx::Vector3dF z_axis(0.f, 0.f, 1.f); 246 gfx::Vector3dF z_axis(0.f, 0.f, 1.f);
247 gfx::Vector3dF w = gfx::Point3F(p) - transform_origin; 247 gfx::Vector3dF w = gfx::Point3F(p) - transform_origin;
248 248
249 float d = gfx::DotProduct(layer_normal, z_axis); 249 float d = gfx::DotProduct(layer_normal, z_axis);
250 float n = -gfx::DotProduct(layer_normal, w); 250 float n = -gfx::DotProduct(layer_normal, w);
251 251
252 // Check if layer is parallel to the z = 0 axis which will make it 252 // Check if layer is parallel to the z = 0 axis which will make it
253 // invisible and hence returning zero is fine. 253 // invisible and hence returning zero is fine.
254 if (!d) 254 if (!d)
255 return 0.f; 255 return 0.f;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 *it = sorted_list[count++]->layer; 460 *it = sorted_list[count++]->layer;
461 461
462 DVLOG(2) << "Sorting end ----"; 462 DVLOG(2) << "Sorting end ----";
463 463
464 nodes_.clear(); 464 nodes_.clear();
465 edges_.clear(); 465 edges_.clear();
466 active_edges_.clear(); 466 active_edges_.clear();
467 } 467 }
468 468
469 } // namespace cc 469 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_sorter.h ('k') | cc/trees/layer_tree_host_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698