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

Unified Diff: cc/math_util.cc

Issue 11774005: Migrate more functions from MathUtil to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try to fix double/float conversion errors Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/math_util.h ('k') | cc/math_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/math_util.cc
diff --git a/cc/math_util.cc b/cc/math_util.cc
index 8796504e2465387c2e0e8fa74d203ba5324fb6b9..481c4d69fd37db0cead1d156211ab80322e2a395 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -357,27 +357,6 @@ gfx::PointF MathUtil::projectPoint(const gfx::Transform& transform, const gfx::P
return h.cartesianPoint2d();
}
-void MathUtil::flattenTransformTo2d(gfx::Transform& transform)
-{
- // Set both the 3rd row and 3rd column to (0, 0, 1, 0).
- //
- // One useful interpretation of doing this operation:
- // - For x and y values, the new transform behaves effectively like an orthographic
- // projection was added to the matrix sequence.
- // - For z values, the new transform overrides any effect that the transform had on
- // z, and instead it preserves the z value for any points that are transformed.
- // - Because of linearity of transforms, this flattened transform also preserves the
- // effect that any subsequent (post-multiplied) transforms would have on z values.
- //
- transform.matrix().setDouble(2, 0, 0);
- transform.matrix().setDouble(2, 1, 0);
- transform.matrix().setDouble(0, 2, 0);
- transform.matrix().setDouble(1, 2, 0);
- transform.matrix().setDouble(2, 2, 1);
- transform.matrix().setDouble(3, 2, 0);
- transform.matrix().setDouble(2, 3, 0);
-}
-
static inline float scaleOnAxis(double a, double b, double c)
{
return std::sqrt(a * a + b * b + c * c);
@@ -406,86 +385,4 @@ gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
}
-void MathUtil::rotateEulerAngles(gfx::Transform* transform, double eulerX, double eulerY, double eulerZ)
-{
- // TODO (shawnsingh): make this implementation faster and more accurate by
- // hard-coding each matrix instead of calling RotateAbout().
- gfx::Transform rotationAboutX;
- gfx::Transform rotationAboutY;
- gfx::Transform rotationAboutZ;
-
- rotationAboutX.RotateAboutXAxis(eulerX);
- rotationAboutY.RotateAboutYAxis(eulerY);
- rotationAboutZ.RotateAboutZAxis(eulerZ);
-
- gfx::Transform composite = rotationAboutZ * rotationAboutY * rotationAboutX;
- transform->PreconcatTransform(composite);
-}
-
-gfx::Transform MathUtil::to2dTransform(const gfx::Transform& transform)
-{
- gfx::Transform result = transform;
- SkMatrix44& matrix = result.matrix();
- matrix.setDouble(0, 2, 0);
- matrix.setDouble(1, 2, 0);
- matrix.setDouble(2, 2, 1);
- matrix.setDouble(3, 2, 0);
-
- matrix.setDouble(2, 0, 0);
- matrix.setDouble(2, 1, 0);
- matrix.setDouble(2, 3, 0);
-
- return result;
-}
-
-gfx::Transform MathUtil::createGfxTransform(double m11, double m12, double m13, double m14,
- double m21, double m22, double m23, double m24,
- double m31, double m32, double m33, double m34,
- double m41, double m42, double m43, double m44)
-{
- gfx::Transform result;
- SkMatrix44& matrix = result.matrix();
-
- // Initialize column 1
- matrix.setDouble(0, 0, m11);
- matrix.setDouble(1, 0, m12);
- matrix.setDouble(2, 0, m13);
- matrix.setDouble(3, 0, m14);
-
- // Initialize column 2
- matrix.setDouble(0, 1, m21);
- matrix.setDouble(1, 1, m22);
- matrix.setDouble(2, 1, m23);
- matrix.setDouble(3, 1, m24);
-
- // Initialize column 3
- matrix.setDouble(0, 2, m31);
- matrix.setDouble(1, 2, m32);
- matrix.setDouble(2, 2, m33);
- matrix.setDouble(3, 2, m34);
-
- // Initialize column 4
- matrix.setDouble(0, 3, m41);
- matrix.setDouble(1, 3, m42);
- matrix.setDouble(2, 3, m43);
- matrix.setDouble(3, 3, m44);
-
- return result;
-}
-
-gfx::Transform MathUtil::createGfxTransform(double a, double b, double c,
- double d, double e, double f)
-{
- gfx::Transform result;
- SkMatrix44& matrix = result.matrix();
- matrix.setDouble(0, 0, a);
- matrix.setDouble(1, 0, b);
- matrix.setDouble(0, 1, c);
- matrix.setDouble(1, 1, d);
- matrix.setDouble(0, 3, e);
- matrix.setDouble(1, 3, f);
-
- return result;
-}
-
} // namespace cc
« no previous file with comments | « cc/math_util.h ('k') | cc/math_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698