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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/transform.cc ('k') | ui/gfx/transform_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/gfx/transform.h" 8 #include "ui/gfx/transform.h"
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 EXPECT_FLOAT_EQ(t * 4 + 1, to.matrix().get(0, 0)) << "i: " << i; 770 EXPECT_FLOAT_EQ(t * 4 + 1, to.matrix().get(0, 0)) << "i: " << i;
771 EXPECT_FLOAT_EQ(t * 3 + 1, to.matrix().get(1, 1)) << "i: " << i; 771 EXPECT_FLOAT_EQ(t * 3 + 1, to.matrix().get(1, 1)) << "i: " << i;
772 EXPECT_FLOAT_EQ(t * 2 + 1, to.matrix().get(2, 2)) << "i: " << i; 772 EXPECT_FLOAT_EQ(t * 2 + 1, to.matrix().get(2, 2)) << "i: " << i;
773 } 773 }
774 } 774 }
775 775
776 TEST(XFormTest, BlendSkew) { 776 TEST(XFormTest, BlendSkew) {
777 Transform from; 777 Transform from;
778 for (int i = 0; i < 2; ++i) { 778 for (int i = 0; i < 2; ++i) {
779 Transform to; 779 Transform to;
780 to.SkewX(10); 780 to.Skew(10, 5);
781 to.SkewY(5);
782 double t = i; 781 double t = i;
783 Transform expected; 782 Transform expected;
784 expected.SkewX(t * 10); 783 expected.Skew(t * 10, t * 5);
785 expected.SkewY(t * 5);
786 EXPECT_TRUE(to.Blend(from, t)); 784 EXPECT_TRUE(to.Blend(from, t));
787 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); 785 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to));
788 } 786 }
789 } 787 }
790 788
791 TEST(XFormTest, ExtrapolateSkew) { 789 TEST(XFormTest, ExtrapolateSkew) {
792 Transform from; 790 Transform from;
793 for (int i = -1; i < 2; ++i) { 791 for (int i = -1; i < 2; ++i) {
794 Transform to; 792 Transform to;
795 to.SkewX(20); 793 to.Skew(20, 0);
796 double t = i; 794 double t = i;
797 Transform expected; 795 Transform expected;
798 expected.SkewX(t * 20); 796 expected.Skew(t * 20, t * 0);
799 EXPECT_TRUE(to.Blend(from, t)); 797 EXPECT_TRUE(to.Blend(from, t));
800 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); 798 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to));
801 } 799 }
802 } 800 }
803 801
804 #if defined(_WIN64) 802 #if defined(_WIN64)
805 // http://crbug.com/406574 803 // http://crbug.com/406574
806 #define MAYBE_BlendPerspective DISABLED_BlendPerspective 804 #define MAYBE_BlendPerspective DISABLED_BlendPerspective
807 #else 805 #else
808 #define MAYBE_BlendPerspective BlendPerspective 806 #define MAYBE_BlendPerspective BlendPerspective
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 897
900 to = Transform(); 898 to = Transform();
901 to.Scale3d(200.0, 100.0, 300.0); 899 to.Scale3d(200.0, 100.0, 300.0);
902 to.Blend(from, 1.0); 900 to.Blend(from, 1.0);
903 EXPECT_ROW1_EQ(200.0f, 0.0f, 0.0f, 0.0f, to); 901 EXPECT_ROW1_EQ(200.0f, 0.0f, 0.0f, 0.0f, to);
904 EXPECT_ROW2_EQ(0.0f, 100.0f, 0.0f, 0.0f, to); 902 EXPECT_ROW2_EQ(0.0f, 100.0f, 0.0f, 0.0f, to);
905 EXPECT_ROW3_EQ(0.0f, 0.0f, 300.0f, 0.0f, to); 903 EXPECT_ROW3_EQ(0.0f, 0.0f, 300.0f, 0.0f, to);
906 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 904 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
907 } 905 }
908 906
909 TEST(XFormTest, VerifyBlendForSkewX) { 907 TEST(XFormTest, VerifyBlendForSkew) {
908 // Along X axis only
910 Transform from; 909 Transform from;
911 from.SkewX(0.0); 910 from.Skew(0.0, 0.0);
912 911
913 Transform to; 912 Transform to;
914 913
915 to.SkewX(45.0); 914 to.Skew(45.0, 0.0);
916 to.Blend(from, 0.0); 915 to.Blend(from, 0.0);
917 EXPECT_EQ(from, to); 916 EXPECT_EQ(from, to);
918 917
919 to = Transform(); 918 to = Transform();
920 to.SkewX(45.0); 919 to.Skew(45.0, 0.0);
921 to.Blend(from, 0.5); 920 to.Blend(from, 0.5);
922 EXPECT_ROW1_EQ(1.0f, 0.5f, 0.0f, 0.0f, to); 921 EXPECT_ROW1_EQ(1.0f, 0.5f, 0.0f, 0.0f, to);
923 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); 922 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to);
924 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); 923 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
925 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 924 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
926 925
927 to = Transform(); 926 to = Transform();
928 to.SkewX(45.0); 927 to.Skew(45.0, 0.0);
929 to.Blend(from, 0.25); 928 to.Blend(from, 0.25);
930 EXPECT_ROW1_EQ(1.0f, 0.25f, 0.0f, 0.0f, to); 929 EXPECT_ROW1_EQ(1.0f, 0.25f, 0.0f, 0.0f, to);
931 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); 930 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to);
932 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); 931 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
933 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 932 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
934 933
935 to = Transform(); 934 to = Transform();
936 to.SkewX(45.0); 935 to.Skew(45.0, 0.0);
937 to.Blend(from, 1.0); 936 to.Blend(from, 1.0);
938 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, to); 937 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, to);
939 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); 938 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to);
940 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); 939 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
941 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 940 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
942 }
943 941
944 TEST(XFormTest, VerifyBlendForSkewY) {
945 // NOTE CAREFULLY: Decomposition of skew and rotation terms of the matrix 942 // NOTE CAREFULLY: Decomposition of skew and rotation terms of the matrix
946 // is inherently underconstrained, and so it does not always compute the 943 // is inherently underconstrained, and so it does not always compute the
947 // originally intended skew parameters. The current implementation uses QR 944 // originally intended skew parameters. The current implementation uses QR
948 // decomposition, which decomposes the shear into a rotation + non-uniform 945 // decomposition, which decomposes the shear into a rotation + non-uniform
949 // scale. 946 // scale.
950 // 947 //
951 // It is unlikely that the decomposition implementation will need to change 948 // It is unlikely that the decomposition implementation will need to change
952 // very often, so to get any test coverage, the compromise is to verify the 949 // very often, so to get any test coverage, the compromise is to verify the
953 // exact matrix that the.Blend() operation produces. 950 // exact matrix that the.Blend() operation produces.
954 // 951 //
955 // This problem also potentially exists for skewX, but the current QR 952 // This problem also potentially exists for skew along the X axis, but the
956 // decomposition implementation just happens to decompose those test 953 // current QR decomposition implementation just happens to decompose those
957 // matrices intuitively. 954 // test matrices intuitively.
958 // 955 //
959 // Unfortunately, this case suffers from uncomfortably large precision 956 // Unfortunately, this case suffers from uncomfortably large precision
960 // error. 957 // error.
961 958
962 Transform from; 959 from = Transform();
963 from.SkewY(0.0); 960 from.Skew(0.0, 0.0);
964 961
965 Transform to; 962 to = Transform();
966 963
967 to.SkewY(45.0); 964 to.Skew(0.0, 45.0);
968 to.Blend(from, 0.0); 965 to.Blend(from, 0.0);
969 EXPECT_EQ(from, to); 966 EXPECT_EQ(from, to);
970 967
971 to = Transform(); 968 to = Transform();
972 to.SkewY(45.0); 969 to.Skew(0.0, 45.0);
973 to.Blend(from, 0.25); 970 to.Blend(from, 0.25);
974 EXPECT_ROW1_NEAR(1.0823489449280947471976333, 971 EXPECT_ROW1_NEAR(1.0823489449280947471976333,
975 0.0464370719145053845178239, 972 0.0464370719145053845178239,
976 0.0, 973 0.0,
977 0.0, 974 0.0,
978 to, 975 to,
979 LOOSE_ERROR_THRESHOLD); 976 LOOSE_ERROR_THRESHOLD);
980 EXPECT_ROW2_NEAR(0.2152925909665224513123150, 977 EXPECT_ROW2_NEAR(0.2152925909665224513123150,
981 0.9541702441750861130032035, 978 0.9541702441750861130032035,
982 0.0, 979 0.0,
983 0.0, 980 0.0,
984 to, 981 to,
985 LOOSE_ERROR_THRESHOLD); 982 LOOSE_ERROR_THRESHOLD);
986 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); 983 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
987 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 984 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
988 985
989 to = Transform(); 986 to = Transform();
990 to.SkewY(45.0); 987 to.Skew(0.0, 45.0);
991 to.Blend(from, 0.5); 988 to.Blend(from, 0.5);
992 EXPECT_ROW1_NEAR(1.1152212925809066312865525, 989 EXPECT_ROW1_NEAR(1.1152212925809066312865525,
993 0.0676495144007326631996335, 990 0.0676495144007326631996335,
994 0.0, 991 0.0,
995 0.0, 992 0.0,
996 to, 993 to,
997 LOOSE_ERROR_THRESHOLD); 994 LOOSE_ERROR_THRESHOLD);
998 EXPECT_ROW2_NEAR(0.4619397844342648662419037, 995 EXPECT_ROW2_NEAR(0.4619397844342648662419037,
999 0.9519009045724774464858342, 996 0.9519009045724774464858342,
1000 0.0, 997 0.0,
1001 0.0, 998 0.0,
1002 to, 999 to,
1003 LOOSE_ERROR_THRESHOLD); 1000 LOOSE_ERROR_THRESHOLD);
1004 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); 1001 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
1005 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 1002 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
1006 1003
1007 to = Transform(); 1004 to = Transform();
1008 to.SkewY(45.0); 1005 to.Skew(0.0, 45.0);
1009 to.Blend(from, 1.0); 1006 to.Blend(from, 1.0);
1010 EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD); 1007 EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD);
1011 EXPECT_ROW2_NEAR(1.0, 1.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD); 1008 EXPECT_ROW2_NEAR(1.0, 1.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD);
1012 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); 1009 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to);
1013 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); 1010 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to);
1014 } 1011 }
1015 1012
1016 #if defined(_WIN64) 1013 #if defined(_WIN64)
1017 // http://crbug.com/406574 1014 // http://crbug.com/406574
1018 #define MAYBE_VerifyBlendForRotationAboutX DISABLED_VerifyBlendForRotationAboutX 1015 #define MAYBE_VerifyBlendForRotationAboutX DISABLED_VerifyBlendForRotationAboutX
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 // interpolations; order of operations will be tested well enough by the 1214 // interpolations; order of operations will be tested well enough by the
1218 // end cases that are easier to specify. 1215 // end cases that are easier to specify.
1219 1216
1220 Transform from; 1217 Transform from;
1221 Transform to; 1218 Transform to;
1222 1219
1223 Transform expectedEndOfAnimation; 1220 Transform expectedEndOfAnimation;
1224 expectedEndOfAnimation.ApplyPerspectiveDepth(1.0); 1221 expectedEndOfAnimation.ApplyPerspectiveDepth(1.0);
1225 expectedEndOfAnimation.Translate3d(10.0, 20.0, 30.0); 1222 expectedEndOfAnimation.Translate3d(10.0, 20.0, 30.0);
1226 expectedEndOfAnimation.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 25.0); 1223 expectedEndOfAnimation.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 25.0);
1227 expectedEndOfAnimation.SkewY(45.0); 1224 expectedEndOfAnimation.Skew(0.0, 45.0);
1228 expectedEndOfAnimation.Scale3d(6.0, 7.0, 8.0); 1225 expectedEndOfAnimation.Scale3d(6.0, 7.0, 8.0);
1229 1226
1230 to = expectedEndOfAnimation; 1227 to = expectedEndOfAnimation;
1231 to.Blend(from, 0.0); 1228 to.Blend(from, 0.0);
1232 EXPECT_EQ(from, to); 1229 EXPECT_EQ(from, to);
1233 1230
1234 to = expectedEndOfAnimation; 1231 to = expectedEndOfAnimation;
1235 // We short circuit if blend is >= 1, so to check the numerics, we will 1232 // We short circuit if blend is >= 1, so to check the numerics, we will
1236 // check that we get close to what we expect when we're nearly done 1233 // check that we get close to what we expect when we're nearly done
1237 // interpolating. 1234 // interpolating.
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 InitializeTestMatrix(&A); 1919 InitializeTestMatrix(&A);
1923 A.RotateAbout(Vector3dF(0.0, 0.0, 0.0), 35.0); 1920 A.RotateAbout(Vector3dF(0.0, 0.0, 0.0), 35.0);
1924 1921
1925 // Verify that A remains unchanged. 1922 // Verify that A remains unchanged.
1926 EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, A); 1923 EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, A);
1927 EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, A); 1924 EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, A);
1928 EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, A); 1925 EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, A);
1929 EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, A); 1926 EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, A);
1930 } 1927 }
1931 1928
1932 TEST(XFormTest, verifySkewX) { 1929 TEST(XFormTest, verifySkew) {
1930 // Test a skew along X axis only
1933 Transform A; 1931 Transform A;
1934 A.SkewX(45.0); 1932 A.Skew(45.0, 0.0);
1935 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); 1933 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
1936 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); 1934 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A);
1937 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); 1935 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
1938 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); 1936 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
1939 1937
1940 // Verify that skewX() post-multiplies the existing matrix. Row 1, column 2, 1938 // Test a skew along Y axis only
1941 // would incorrectly have value "7" if the matrix is pre-multiplied instead
1942 // of post-multiplied.
1943 A.MakeIdentity(); 1939 A.MakeIdentity();
1944 A.Scale3d(6.0, 7.0, 8.0); 1940 A.Skew(0.0, 45.0);
1945 A.SkewX(45.0);
1946 EXPECT_ROW1_EQ(6.0f, 6.0f, 0.0f, 0.0f, A);
1947 EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A);
1948 EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A);
1949 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
1950 }
1951
1952 TEST(XFormTest, verifySkewY) {
1953 Transform A;
1954 A.SkewY(45.0);
1955 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); 1941 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A);
1956 EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); 1942 EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
1957 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); 1943 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
1958 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); 1944 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
1959 1945
1960 // Verify that skewY() post-multiplies the existing matrix. Row 2, column 1 , 1946 // Verify that skew() post-multiplies the existing matrix. Row 1, column 2,
1961 // would incorrectly have value "6" if the matrix is pre-multiplied instead 1947 // would incorrectly have value "7" if the matrix is pre-multiplied instead
1962 // of post-multiplied. 1948 // of post-multiplied.
1963 A.MakeIdentity(); 1949 A.MakeIdentity();
1964 A.Scale3d(6.0, 7.0, 8.0); 1950 A.Scale3d(6.0, 7.0, 8.0);
1965 A.SkewY(45.0); 1951 A.Skew(45.0, 0.0);
1966 EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 0.0f, A); 1952 EXPECT_ROW1_EQ(6.0f, 6.0f, 0.0f, 0.0f, A);
1967 EXPECT_ROW2_EQ(7.0f, 7.0f, 0.0f, 0.0f, A); 1953 EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A);
1968 EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); 1954 EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A);
1969 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); 1955 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
1956
1957 // Test a skew along X and Y axes both
1958 A.MakeIdentity();
1959 A.Skew(45.0, 45.0);
1960 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
1961 EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A);
1962 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
1963 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A);
1970 } 1964 }
1971 1965
1972 TEST(XFormTest, verifyPerspectiveDepth) { 1966 TEST(XFormTest, verifyPerspectiveDepth) {
1973 Transform A; 1967 Transform A;
1974 A.ApplyPerspectiveDepth(1.0); 1968 A.ApplyPerspectiveDepth(1.0);
1975 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); 1969 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A);
1976 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); 1970 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A);
1977 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); 1971 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A);
1978 EXPECT_ROW4_EQ(0.0f, 0.0f, -1.0f, 1.0f, A); 1972 EXPECT_ROW4_EQ(0.0f, 0.0f, -1.0f, 1.0f, A);
1979 1973
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 A.Scale3d(6.0, 7.0, 8.0); 2027 A.Scale3d(6.0, 7.0, 8.0);
2034 EXPECT_TRUE(A.IsInvertible()); 2028 EXPECT_TRUE(A.IsInvertible());
2035 2029
2036 A.MakeIdentity(); 2030 A.MakeIdentity();
2037 A.RotateAboutXAxis(10.0); 2031 A.RotateAboutXAxis(10.0);
2038 A.RotateAboutYAxis(20.0); 2032 A.RotateAboutYAxis(20.0);
2039 A.RotateAboutZAxis(30.0); 2033 A.RotateAboutZAxis(30.0);
2040 EXPECT_TRUE(A.IsInvertible()); 2034 EXPECT_TRUE(A.IsInvertible());
2041 2035
2042 A.MakeIdentity(); 2036 A.MakeIdentity();
2043 A.SkewX(45.0); 2037 A.Skew(45.0, 0.0);
2044 EXPECT_TRUE(A.IsInvertible()); 2038 EXPECT_TRUE(A.IsInvertible());
2045 2039
2046 // A perspective matrix (projection plane at z=0) is invertible. The 2040 // A perspective matrix (projection plane at z=0) is invertible. The
2047 // intuitive explanation is that perspective is eqivalent to a skew of the 2041 // intuitive explanation is that perspective is eqivalent to a skew of the
2048 // w-axis; skews are invertible. 2042 // w-axis; skews are invertible.
2049 A.MakeIdentity(); 2043 A.MakeIdentity();
2050 A.ApplyPerspectiveDepth(1.0); 2044 A.ApplyPerspectiveDepth(1.0);
2051 EXPECT_TRUE(A.IsInvertible()); 2045 EXPECT_TRUE(A.IsInvertible());
2052 2046
2053 // A "pure" perspective matrix derived by similar triangles, with m44() set 2047 // A "pure" perspective matrix derived by similar triangles, with m44() set
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 // Rounding should only affect 2d translation components. 2687 // Rounding should only affect 2d translation components.
2694 translation.Translate3d(0.f, 0.f, 0.5f); 2688 translation.Translate3d(0.f, 0.f, 0.5f);
2695 expected.Translate3d(0.f, 0.f, 0.5f); 2689 expected.Translate3d(0.f, 0.f, 0.5f);
2696 translation.RoundTranslationComponents(); 2690 translation.RoundTranslationComponents();
2697 EXPECT_EQ(expected.ToString(), translation.ToString()); 2691 EXPECT_EQ(expected.ToString(), translation.ToString());
2698 } 2692 }
2699 2693
2700 } // namespace 2694 } // namespace
2701 2695
2702 } // namespace gfx 2696 } // namespace gfx
OLDNEW
« 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