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

Side by Side Diff: ui/gfx/geometry/vector3d_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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/gfx/geometry/vector3d_f.h" 5 #include "ui/gfx/geometry/vector3d_f.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return static_cast<float>(std::sqrt(LengthSquared())); 43 return static_cast<float>(std::sqrt(LengthSquared()));
44 } 44 }
45 45
46 void Vector3dF::Scale(float x_scale, float y_scale, float z_scale) { 46 void Vector3dF::Scale(float x_scale, float y_scale, float z_scale) {
47 x_ *= x_scale; 47 x_ *= x_scale;
48 y_ *= y_scale; 48 y_ *= y_scale;
49 z_ *= z_scale; 49 z_ *= z_scale;
50 } 50 }
51 51
52 void Vector3dF::Cross(const Vector3dF& other) { 52 void Vector3dF::Cross(const Vector3dF& other) {
53 float x = y_ * other.z() - z_ * other.y(); 53 double dx = x_;
54 float y = z_ * other.x() - x_ * other.z(); 54 double dy = y_;
55 float z = x_ * other.y() - y_ * other.x(); 55 double dz = z_;
56 float x = static_cast<float>(dy * other.z() - dz * other.y());
57 float y = static_cast<float>(dz * other.x() - dx * other.z());
58 float z = static_cast<float>(dx * other.y() - dy * other.x());
56 x_ = x; 59 x_ = x;
57 y_ = y; 60 y_ = y;
58 z_ = z; 61 z_ = z;
59 } 62 }
60 63
61 float DotProduct(const Vector3dF& lhs, const Vector3dF& rhs) { 64 float DotProduct(const Vector3dF& lhs, const Vector3dF& rhs) {
62 return lhs.x() * rhs.x() + lhs.y() * rhs.y() + lhs.z() * rhs.z(); 65 return lhs.x() * rhs.x() + lhs.y() * rhs.y() + lhs.z() * rhs.z();
63 } 66 }
64 67
65 Vector3dF ScaleVector3d(const Vector3dF& v, 68 Vector3dF ScaleVector3d(const Vector3dF& v,
(...skipping 20 matching lines...) Expand all
86 89
87 // If the dot product of this cross product is normal, it means that the 90 // If the dot product of this cross product is normal, it means that the
88 // shortest angle between |base| and |other| was counterclockwise with respect 91 // shortest angle between |base| and |other| was counterclockwise with respect
89 // to the surface represented by |normal| and this angle must be reversed. 92 // to the surface represented by |normal| and this angle must be reversed.
90 if (gfx::DotProduct(cross, normal) > 0.0f) 93 if (gfx::DotProduct(cross, normal) > 0.0f)
91 angle = 360.0f - angle; 94 angle = 360.0f - angle;
92 return angle; 95 return angle;
93 } 96 }
94 97
95 } // namespace gfx 98 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698