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

Unified Diff: ui/gfx/geometry/quad_f.cc

Issue 2504583003: Fix QuadF::ContainsPoint and gfx::CrossProduct on arm64 (Closed)
Patch Set: quadtest: . Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/geometry/quad_unittest.cc » ('j') | ui/gfx/geometry/vector3d_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/quad_f.cc
diff --git a/ui/gfx/geometry/quad_f.cc b/ui/gfx/geometry/quad_f.cc
index 1fcb464948007971b66602b58c5b2e57478b27b2..8ed8b91700fbdce1e264d8591ccdd5360bc7b66b 100644
--- a/ui/gfx/geometry/quad_f.cc
+++ b/ui/gfx/geometry/quad_f.cc
@@ -76,10 +76,17 @@ static inline bool PointIsInTriangle(const PointF& point,
Vector2dF r32 = r2 - r3;
Vector2dF r3p = point - r3;
- float denom = r32.y() * r31.x() - r32.x() * r31.y();
- float u = (r32.y() * r3p.x() - r32.x() * r3p.y()) / denom;
- float v = (r31.x() * r3p.y() - r31.y() * r3p.x()) / denom;
- float w = 1.f - u - v;
+ // Promote to doubles so all the math below is done with doubles, because
+ // otherwise it gets incorrect results on arm64.
+ double r31x = r31.x();
+ double r31y = r31.y();
+ double r32x = r32.x();
+ double r32y = r32.y();
+
+ double denom = r32y * r31x - r32x * r31y;
+ double u = (r32y * r3p.x() - r32x * r3p.y()) / denom;
+ double v = (r31x * r3p.y() - r31y * r3p.x()) / denom;
+ double w = 1.0 - u - v;
// Use the barycentric coordinates to test if |point| is inside the
// triangle (r1, r2, r2).
« no previous file with comments | « no previous file | ui/gfx/geometry/quad_unittest.cc » ('j') | ui/gfx/geometry/vector3d_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698