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

Unified Diff: ui/gfx/transform_unittest.cc

Issue 1325803002: Apply skew on both axes together rather than sequentially on Compositor thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test for skewY Created 5 years, 3 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 | « ui/gfx/transform.cc ('k') | ui/gfx/transform_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/transform_unittest.cc
diff --git a/ui/gfx/transform_unittest.cc b/ui/gfx/transform_unittest.cc
index eb0b2fdcc69980f4f704e84d3f2fc4fa1c2f3146..81333a39f6e62256b272fc49749f75e3bd690897 100644
--- a/ui/gfx/transform_unittest.cc
+++ b/ui/gfx/transform_unittest.cc
@@ -777,12 +777,10 @@ TEST(XFormTest, BlendSkew) {
Transform from;
for (int i = 0; i < 2; ++i) {
Transform to;
- to.SkewX(10);
- to.SkewY(5);
+ to.Skew(10, 5);
double t = i;
Transform expected;
- expected.SkewX(t * 10);
- expected.SkewY(t * 5);
+ expected.Skew(t * 10, t * 5);
EXPECT_TRUE(to.Blend(from, t));
EXPECT_TRUE(MatricesAreNearlyEqual(expected, to));
}
@@ -792,10 +790,10 @@ TEST(XFormTest, ExtrapolateSkew) {
Transform from;
for (int i = -1; i < 2; ++i) {
Transform to;
- to.SkewX(20);
+ to.Skew(20, 0);
double t = i;
Transform expected;
- expected.SkewX(t * 20);
+ expected.Skew(t * 20, t * 0);
EXPECT_TRUE(to.Blend(from, t));
EXPECT_TRUE(MatricesAreNearlyEqual(expected, to));
}
@@ -906,18 +904,19 @@ TEST(XFormTest, VerifyBlendForScale) {
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
}
-TEST(XFormTest, VerifyBlendForSkewX) {
+TEST(XFormTest, VerifyBlendForSkew) {
+ // Along X axis only
Transform from;
- from.SkewX(0.0);
+ from.Skew(0.0, 0.0);
Transform to;
- to.SkewX(45.0);
+ to.Skew(45.0, 0.0);
to.Blend(from, 0.0);
EXPECT_EQ(from, to);
to = Transform();
- to.SkewX(45.0);
+ to.Skew(45.0, 0.0);
to.Blend(from, 0.5);
EXPECT_ROW1_EQ(1.0f, 0.5f, 0.0f, 0.0f, to);
EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to);
@@ -925,7 +924,7 @@ TEST(XFormTest, VerifyBlendForSkewX) {
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
to = Transform();
- to.SkewX(45.0);
+ to.Skew(45.0, 0.0);
to.Blend(from, 0.25);
EXPECT_ROW1_EQ(1.0f, 0.25f, 0.0f, 0.0f, to);
EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to);
@@ -933,15 +932,13 @@ TEST(XFormTest, VerifyBlendForSkewX) {
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
to = Transform();
- to.SkewX(45.0);
+ to.Skew(45.0, 0.0);
to.Blend(from, 1.0);
EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, to);
EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to);
EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
-}
-TEST(XFormTest, VerifyBlendForSkewY) {
// NOTE CAREFULLY: Decomposition of skew and rotation terms of the matrix
// is inherently underconstrained, and so it does not always compute the
// originally intended skew parameters. The current implementation uses QR
@@ -952,24 +949,24 @@ TEST(XFormTest, VerifyBlendForSkewY) {
// very often, so to get any test coverage, the compromise is to verify the
// exact matrix that the.Blend() operation produces.
//
- // This problem also potentially exists for skewX, but the current QR
- // decomposition implementation just happens to decompose those test
- // matrices intuitively.
+ // This problem also potentially exists for skew along the X axis, but the
+ // current QR decomposition implementation just happens to decompose those
+ // test matrices intuitively.
//
// Unfortunately, this case suffers from uncomfortably large precision
// error.
- Transform from;
- from.SkewY(0.0);
+ from = Transform();
+ from.Skew(0.0, 0.0);
- Transform to;
+ to = Transform();
- to.SkewY(45.0);
+ to.Skew(0.0, 45.0);
to.Blend(from, 0.0);
EXPECT_EQ(from, to);
to = Transform();
- to.SkewY(45.0);
+ to.Skew(0.0, 45.0);
to.Blend(from, 0.25);
EXPECT_ROW1_NEAR(1.0823489449280947471976333,
0.0464370719145053845178239,
@@ -987,7 +984,7 @@ TEST(XFormTest, VerifyBlendForSkewY) {
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
to = Transform();
- to.SkewY(45.0);
+ to.Skew(0.0, 45.0);
to.Blend(from, 0.5);
EXPECT_ROW1_NEAR(1.1152212925809066312865525,
0.0676495144007326631996335,
@@ -1005,7 +1002,7 @@ TEST(XFormTest, VerifyBlendForSkewY) {
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
to = Transform();
- to.SkewY(45.0);
+ to.Skew(0.0, 45.0);
to.Blend(from, 1.0);
EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD);
EXPECT_ROW2_NEAR(1.0, 1.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD);
@@ -1224,7 +1221,7 @@ TEST(XFormTest, VerifyBlendForCompositeTransform) {
expectedEndOfAnimation.ApplyPerspectiveDepth(1.0);
expectedEndOfAnimation.Translate3d(10.0, 20.0, 30.0);
expectedEndOfAnimation.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 25.0);
- expectedEndOfAnimation.SkewY(45.0);
+ expectedEndOfAnimation.Skew(0.0, 45.0);
expectedEndOfAnimation.Scale3d(6.0, 7.0, 8.0);
to = expectedEndOfAnimation;
@@ -1929,44 +1926,41 @@ TEST(XFormTest, verifyRotateAboutForDegenerateAxis) {
EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, A);
}
-TEST(XFormTest, verifySkewX) {
+TEST(XFormTest, verifySkew) {
+ // Test a skew along X axis only
Transform A;
- A.SkewX(45.0);
+ A.Skew(45.0, 0.0);
EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A);
EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
- // Verify that skewX() post-multiplies the existing matrix. Row 1, column 2,
+ // Test a skew along Y axis only
+ A.MakeIdentity();
+ A.Skew(0.0, 45.0);
+ EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A);
+ EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
+ EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
+ EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
+
+ // Verify that skew() post-multiplies the existing matrix. Row 1, column 2,
// would incorrectly have value "7" if the matrix is pre-multiplied instead
// of post-multiplied.
A.MakeIdentity();
A.Scale3d(6.0, 7.0, 8.0);
- A.SkewX(45.0);
+ A.Skew(45.0, 0.0);
EXPECT_ROW1_EQ(6.0f, 6.0f, 0.0f, 0.0f, A);
EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A);
EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A);
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
-}
-TEST(XFormTest, verifySkewY) {
- Transform A;
- A.SkewY(45.0);
- EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A);
+ // Test a skew along X and Y axes both
+ A.MakeIdentity();
+ A.Skew(45.0, 45.0);
+ EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
-
- // Verify that skewY() post-multiplies the existing matrix. Row 2, column 1 ,
- // would incorrectly have value "6" if the matrix is pre-multiplied instead
- // of post-multiplied.
- A.MakeIdentity();
- A.Scale3d(6.0, 7.0, 8.0);
- A.SkewY(45.0);
- EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 0.0f, A);
- EXPECT_ROW2_EQ(7.0f, 7.0f, 0.0f, 0.0f, A);
- EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A);
- EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
}
TEST(XFormTest, verifyPerspectiveDepth) {
@@ -2040,7 +2034,7 @@ TEST(XFormTest, verifyIsInvertible) {
EXPECT_TRUE(A.IsInvertible());
A.MakeIdentity();
- A.SkewX(45.0);
+ A.Skew(45.0, 0.0);
EXPECT_TRUE(A.IsInvertible());
// A perspective matrix (projection plane at z=0) is invertible. The
« no previous file with comments | « ui/gfx/transform.cc ('k') | ui/gfx/transform_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698