Index: cc/trees/layer_sorter.cc |
diff --git a/cc/trees/layer_sorter.cc b/cc/trees/layer_sorter.cc |
index 8f3454e8514957ff47c5d194b62b4e65e64efa63..e171fe01120f6389931b1acb403581968e7126db 100644 |
--- a/cc/trees/layer_sorter.cc |
+++ b/cc/trees/layer_sorter.cc |
@@ -22,6 +22,11 @@ |
// a value near machine epsilon and then increasing it until the flickering on |
// the test scene went away. |
const float k_layer_epsilon = 1e-4f; |
+ |
+inline static float PerpProduct(const gfx::Vector2dF& u, |
+ const gfx::Vector2dF& v) { |
+ return u.x() * v.y() - u.y() * v.x(); |
+} |
// Tests if two edges defined by their endpoints (a,b) and (c,d) intersect. |
// Returns true and the point of intersection if they do and false otherwise. |
@@ -34,7 +39,7 @@ |
gfx::Vector2dF v = d - c; |
gfx::Vector2dF w = a - c; |
- float denom = static_cast<float>(gfx::CrossProduct(u, v)); |
+ float denom = PerpProduct(u, v); |
// If denom == 0 then the edges are parallel. While they could be overlapping |
// we don't bother to check here as the we'll find their intersections from |
@@ -42,11 +47,11 @@ |
if (!denom) |
return false; |
- float s = static_cast<float>(gfx::CrossProduct(v, w)) / denom; |
+ float s = PerpProduct(v, w) / denom; |
if (s < 0.f || s > 1.f) |
return false; |
- float t = static_cast<float>(gfx::CrossProduct(u, w)) / denom; |
+ float t = PerpProduct(u, w) / denom; |
if (t < 0.f || t > 1.f) |
return false; |