epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 7 | |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 8 | #include "SkMatrix44.h" |
Cary Clark | e4442cb | 2017-10-18 11:46:18 -0400 | [diff] [blame] | 9 | #include "SkPoint3.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 10 | #include "Test.h" |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 11 | |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 12 | static bool nearly_equal_double(double a, double b) { |
| 13 | const double tolerance = 1e-7; |
| 14 | double diff = a - b; |
| 15 | if (diff < 0) |
| 16 | diff = -diff; |
| 17 | return diff <= tolerance; |
| 18 | } |
| 19 | |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 20 | static bool nearly_equal_mscalar(SkMScalar a, SkMScalar b) { |
| 21 | const SkMScalar tolerance = SK_MScalar1 / 200000; |
| 22 | |
| 23 | return SkTAbs<SkMScalar>(a - b) <= tolerance; |
| 24 | } |
| 25 | |
| 26 | static bool nearly_equal_scalar(SkScalar a, SkScalar b) { |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 27 | const SkScalar tolerance = SK_Scalar1 / 200000; |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 28 | return SkScalarAbs(a - b) <= tolerance; |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 29 | } |
| 30 | |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 31 | template <typename T> void assert16(skiatest::Reporter* reporter, const T data[], |
| 32 | T m0, T m1, T m2, T m3, |
| 33 | T m4, T m5, T m6, T m7, |
| 34 | T m8, T m9, T m10, T m11, |
| 35 | T m12, T m13, T m14, T m15) { |
| 36 | REPORTER_ASSERT(reporter, data[0] == m0); |
| 37 | REPORTER_ASSERT(reporter, data[1] == m1); |
| 38 | REPORTER_ASSERT(reporter, data[2] == m2); |
| 39 | REPORTER_ASSERT(reporter, data[3] == m3); |
| 40 | |
| 41 | REPORTER_ASSERT(reporter, data[4] == m4); |
| 42 | REPORTER_ASSERT(reporter, data[5] == m5); |
| 43 | REPORTER_ASSERT(reporter, data[6] == m6); |
| 44 | REPORTER_ASSERT(reporter, data[7] == m7); |
| 45 | |
| 46 | REPORTER_ASSERT(reporter, data[8] == m8); |
| 47 | REPORTER_ASSERT(reporter, data[9] == m9); |
| 48 | REPORTER_ASSERT(reporter, data[10] == m10); |
| 49 | REPORTER_ASSERT(reporter, data[11] == m11); |
| 50 | |
| 51 | REPORTER_ASSERT(reporter, data[12] == m12); |
| 52 | REPORTER_ASSERT(reporter, data[13] == m13); |
| 53 | REPORTER_ASSERT(reporter, data[14] == m14); |
| 54 | REPORTER_ASSERT(reporter, data[15] == m15); |
| 55 | } |
| 56 | |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 57 | static bool nearly_equal(const SkMatrix44& a, const SkMatrix44& b) { |
| 58 | for (int i = 0; i < 4; ++i) { |
| 59 | for (int j = 0; j < 4; ++j) { |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 60 | if (!nearly_equal_mscalar(a.get(i, j), b.get(i, j))) { |
bungeman@google.com | fab44db | 2013-10-11 18:50:45 +0000 | [diff] [blame] | 61 | SkDebugf("not equal %g %g\n", a.get(i, j), b.get(i, j)); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | static bool is_identity(const SkMatrix44& m) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 70 | SkMatrix44 identity(SkMatrix44::kIdentity_Constructor); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 71 | return nearly_equal(m, identity); |
| 72 | } |
| 73 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 74 | /////////////////////////////////////////////////////////////////////////////// |
| 75 | static bool bits_isonly(int value, int mask) { |
| 76 | return 0 == (value & ~mask); |
| 77 | } |
| 78 | |
vollick@chromium.org | 57a54e3 | 2012-12-10 20:16:10 +0000 | [diff] [blame] | 79 | static void test_constructor(skiatest::Reporter* reporter) { |
| 80 | // Allocate a matrix on the heap |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 81 | SkMatrix44* placeholderMatrix = new SkMatrix44; |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 82 | std::unique_ptr<SkMatrix44> deleteMe(placeholderMatrix); |
robertphillips@google.com | 35300c4 | 2013-03-21 17:38:49 +0000 | [diff] [blame] | 83 | |
vollick@chromium.org | 57a54e3 | 2012-12-10 20:16:10 +0000 | [diff] [blame] | 84 | for (int row = 0; row < 4; ++row) { |
| 85 | for (int col = 0; col < 4; ++col) { |
| 86 | placeholderMatrix->setDouble(row, col, row * col); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // Use placement-new syntax to trigger the constructor on top of the heap |
| 91 | // address we already initialized. This allows us to check that the |
| 92 | // constructor did avoid initializing the matrix contents. |
| 93 | SkMatrix44* testMatrix = new(placeholderMatrix) SkMatrix44(SkMatrix44::kUninitialized_Constructor); |
| 94 | REPORTER_ASSERT(reporter, testMatrix == placeholderMatrix); |
| 95 | REPORTER_ASSERT(reporter, !testMatrix->isIdentity()); |
| 96 | for (int row = 0; row < 4; ++row) { |
| 97 | for (int col = 0; col < 4; ++col) { |
| 98 | REPORTER_ASSERT(reporter, nearly_equal_double(row * col, testMatrix->getDouble(row, col))); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // Verify that kIdentity_Constructor really does initialize to an identity matrix. |
| 103 | testMatrix = 0; |
skia.committer@gmail.com | c7b4be7 | 2012-12-11 02:01:20 +0000 | [diff] [blame] | 104 | testMatrix = new(placeholderMatrix) SkMatrix44(SkMatrix44::kIdentity_Constructor); |
vollick@chromium.org | 57a54e3 | 2012-12-10 20:16:10 +0000 | [diff] [blame] | 105 | REPORTER_ASSERT(reporter, testMatrix == placeholderMatrix); |
| 106 | REPORTER_ASSERT(reporter, testMatrix->isIdentity()); |
| 107 | REPORTER_ASSERT(reporter, *testMatrix == SkMatrix44::I()); |
fs | 88640cf | 2014-12-16 08:36:11 -0800 | [diff] [blame] | 108 | |
| 109 | // Verify that that constructing from an SkMatrix initializes everything. |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 110 | SkMatrix44 scaleMatrix; |
fs | 88640cf | 2014-12-16 08:36:11 -0800 | [diff] [blame] | 111 | scaleMatrix.setScale(3, 4, 5); |
| 112 | REPORTER_ASSERT(reporter, scaleMatrix.isScale()); |
| 113 | testMatrix = new(&scaleMatrix) SkMatrix44(SkMatrix::I()); |
| 114 | REPORTER_ASSERT(reporter, testMatrix->isIdentity()); |
| 115 | REPORTER_ASSERT(reporter, *testMatrix == SkMatrix44::I()); |
vollick@chromium.org | 57a54e3 | 2012-12-10 20:16:10 +0000 | [diff] [blame] | 116 | } |
| 117 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 118 | static void test_translate(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 119 | SkMatrix44 mat; |
| 120 | SkMatrix44 inverse; |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 121 | |
| 122 | mat.setTranslate(0, 0, 0); |
| 123 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kIdentity_Mask)); |
| 124 | mat.setTranslate(1, 2, 3); |
| 125 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kTranslate_Mask)); |
| 126 | REPORTER_ASSERT(reporter, mat.invert(&inverse)); |
| 127 | REPORTER_ASSERT(reporter, bits_isonly(inverse.getType(), SkMatrix44::kTranslate_Mask)); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 128 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 129 | SkMatrix44 a,b,c; |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 130 | a.set3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 131 | b.setTranslate(10, 11, 12); |
| 132 | |
| 133 | c.setConcat(a, b); |
| 134 | mat = a; |
| 135 | mat.preTranslate(10, 11, 12); |
| 136 | REPORTER_ASSERT(reporter, mat == c); |
| 137 | |
| 138 | c.setConcat(b, a); |
| 139 | mat = a; |
| 140 | mat.postTranslate(10, 11, 12); |
| 141 | REPORTER_ASSERT(reporter, mat == c); |
| 142 | } |
| 143 | |
| 144 | static void test_scale(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 145 | SkMatrix44 mat; |
| 146 | SkMatrix44 inverse; |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 147 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 148 | mat.setScale(1, 1, 1); |
| 149 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kIdentity_Mask)); |
| 150 | mat.setScale(1, 2, 3); |
| 151 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kScale_Mask)); |
| 152 | REPORTER_ASSERT(reporter, mat.invert(&inverse)); |
| 153 | REPORTER_ASSERT(reporter, bits_isonly(inverse.getType(), SkMatrix44::kScale_Mask)); |
| 154 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 155 | SkMatrix44 a,b,c; |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 156 | a.set3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 157 | b.setScale(10, 11, 12); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 158 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 159 | c.setConcat(a, b); |
| 160 | mat = a; |
| 161 | mat.preScale(10, 11, 12); |
| 162 | REPORTER_ASSERT(reporter, mat == c); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 163 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 164 | c.setConcat(b, a); |
| 165 | mat = a; |
| 166 | mat.postScale(10, 11, 12); |
| 167 | REPORTER_ASSERT(reporter, mat == c); |
| 168 | } |
| 169 | |
| 170 | static void make_i(SkMatrix44* mat) { mat->setIdentity(); } |
| 171 | static void make_t(SkMatrix44* mat) { mat->setTranslate(1, 2, 3); } |
| 172 | static void make_s(SkMatrix44* mat) { mat->setScale(1, 2, 3); } |
| 173 | static void make_st(SkMatrix44* mat) { |
| 174 | mat->setScale(1, 2, 3); |
| 175 | mat->postTranslate(1, 2, 3); |
| 176 | } |
| 177 | static void make_a(SkMatrix44* mat) { |
| 178 | mat->setRotateDegreesAbout(1, 2, 3, 45); |
| 179 | } |
| 180 | static void make_p(SkMatrix44* mat) { |
| 181 | SkMScalar data[] = { |
| 182 | 1, 2, 3, 4, 5, 6, 7, 8, |
| 183 | 1, 2, 3, 4, 5, 6, 7, 8, |
| 184 | }; |
| 185 | mat->setRowMajor(data); |
| 186 | } |
| 187 | |
| 188 | typedef void (*Make44Proc)(SkMatrix44*); |
| 189 | |
| 190 | static const Make44Proc gMakeProcs[] = { |
| 191 | make_i, make_t, make_s, make_st, make_a, make_p |
| 192 | }; |
| 193 | |
| 194 | static void test_map2(skiatest::Reporter* reporter, const SkMatrix44& mat) { |
| 195 | SkMScalar src2[] = { 1, 2 }; |
| 196 | SkMScalar src4[] = { src2[0], src2[1], 0, 1 }; |
| 197 | SkMScalar dstA[4], dstB[4]; |
| 198 | |
| 199 | for (int i = 0; i < 4; ++i) { |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 200 | dstA[i] = SkDoubleToMScalar(123456789); |
| 201 | dstB[i] = SkDoubleToMScalar(987654321); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | mat.map2(src2, 1, dstA); |
| 205 | mat.mapMScalars(src4, dstB); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 206 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 207 | for (int i = 0; i < 4; ++i) { |
| 208 | REPORTER_ASSERT(reporter, dstA[i] == dstB[i]); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | static void test_map2(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 213 | SkMatrix44 mat; |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 214 | |
| 215 | for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProcs); ++i) { |
| 216 | gMakeProcs[i](&mat); |
| 217 | test_map2(reporter, mat); |
| 218 | } |
| 219 | } |
| 220 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 221 | static void test_gettype(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 222 | SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor); |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 223 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 224 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
| 225 | REPORTER_ASSERT(reporter, SkMatrix44::kIdentity_Mask == matrix.getType()); |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 226 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 227 | int expectedMask; |
| 228 | |
| 229 | matrix.set(1, 1, 0); |
| 230 | expectedMask = SkMatrix44::kScale_Mask; |
| 231 | REPORTER_ASSERT(reporter, matrix.getType() == expectedMask); |
| 232 | |
| 233 | matrix.set(0, 3, 1); // translate-x |
| 234 | expectedMask |= SkMatrix44::kTranslate_Mask; |
| 235 | REPORTER_ASSERT(reporter, matrix.getType() == expectedMask); |
| 236 | |
| 237 | matrix.set(2, 0, 1); |
| 238 | expectedMask |= SkMatrix44::kAffine_Mask; |
| 239 | REPORTER_ASSERT(reporter, matrix.getType() == expectedMask); |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 240 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 241 | matrix.set(3, 2, 1); |
| 242 | REPORTER_ASSERT(reporter, matrix.getType() & SkMatrix44::kPerspective_Mask); |
reed@google.com | 87f99cb | 2013-04-19 12:25:00 +0000 | [diff] [blame] | 243 | |
| 244 | // ensure that negative zero is treated as zero |
| 245 | SkMScalar dx = 0; |
| 246 | SkMScalar dy = 0; |
| 247 | SkMScalar dz = 0; |
| 248 | matrix.setTranslate(-dx, -dy, -dz); |
| 249 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
| 250 | matrix.preTranslate(-dx, -dy, -dz); |
| 251 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
| 252 | matrix.postTranslate(-dx, -dy, -dz); |
| 253 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 254 | } |
| 255 | |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 256 | static void test_common_angles(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 257 | SkMatrix44 rot; |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 258 | // Test precision of rotation in common cases |
| 259 | int common_angles[] = { 0, 90, -90, 180, -180, 270, -270, 360, -360 }; |
| 260 | for (int i = 0; i < 9; ++i) { |
robertphillips@google.com | 09042b8 | 2012-04-06 20:01:46 +0000 | [diff] [blame] | 261 | rot.setRotateDegreesAbout(0, 0, -1, SkIntToScalar(common_angles[i])); |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 262 | |
| 263 | SkMatrix rot3x3 = rot; |
| 264 | REPORTER_ASSERT(reporter, rot3x3.rectStaysRect()); |
| 265 | } |
| 266 | } |
| 267 | |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 268 | static void test_concat(skiatest::Reporter* reporter) { |
| 269 | int i; |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 270 | SkMatrix44 a,b,c,d; |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 271 | |
| 272 | a.setTranslate(10, 10, 10); |
| 273 | b.setScale(2, 2, 2); |
| 274 | |
| 275 | SkScalar src[8] = { |
| 276 | 0, 0, 0, 1, |
| 277 | 1, 1, 1, 1 |
| 278 | }; |
| 279 | SkScalar dst[8]; |
| 280 | |
| 281 | c.setConcat(a, b); |
| 282 | |
| 283 | d = a; |
| 284 | d.preConcat(b); |
| 285 | REPORTER_ASSERT(reporter, d == c); |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 286 | |
reed@google.com | 1ea95be | 2012-11-09 21:39:48 +0000 | [diff] [blame] | 287 | c.mapScalars(src, dst); c.mapScalars(src + 4, dst + 4); |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 288 | for (i = 0; i < 3; ++i) { |
| 289 | REPORTER_ASSERT(reporter, 10 == dst[i]); |
| 290 | REPORTER_ASSERT(reporter, 12 == dst[i + 4]); |
| 291 | } |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 292 | |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 293 | c.setConcat(b, a); |
| 294 | |
| 295 | d = a; |
| 296 | d.postConcat(b); |
| 297 | REPORTER_ASSERT(reporter, d == c); |
| 298 | |
reed@google.com | 1ea95be | 2012-11-09 21:39:48 +0000 | [diff] [blame] | 299 | c.mapScalars(src, dst); c.mapScalars(src + 4, dst + 4); |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 300 | for (i = 0; i < 3; ++i) { |
| 301 | REPORTER_ASSERT(reporter, 20 == dst[i]); |
| 302 | REPORTER_ASSERT(reporter, 22 == dst[i + 4]); |
| 303 | } |
| 304 | } |
| 305 | |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 306 | static void test_determinant(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 307 | SkMatrix44 a(SkMatrix44::kIdentity_Constructor); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 308 | REPORTER_ASSERT(reporter, nearly_equal_double(1, a.determinant())); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 309 | a.set(1, 1, 2); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 310 | REPORTER_ASSERT(reporter, nearly_equal_double(2, a.determinant())); |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 311 | SkMatrix44 b; |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 312 | REPORTER_ASSERT(reporter, a.invert(&b)); |
| 313 | REPORTER_ASSERT(reporter, nearly_equal_double(0.5, b.determinant())); |
| 314 | SkMatrix44 c = b = a; |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 315 | c.set(0, 1, 4); |
| 316 | b.set(1, 0, 4); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 317 | REPORTER_ASSERT(reporter, |
| 318 | nearly_equal_double(a.determinant(), |
| 319 | b.determinant())); |
| 320 | SkMatrix44 d = a; |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 321 | d.set(0, 0, 8); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 322 | REPORTER_ASSERT(reporter, nearly_equal_double(16, d.determinant())); |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 323 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 324 | SkMatrix44 e = a; |
| 325 | e.postConcat(d); |
| 326 | REPORTER_ASSERT(reporter, nearly_equal_double(32, e.determinant())); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 327 | e.set(0, 0, 0); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 328 | REPORTER_ASSERT(reporter, nearly_equal_double(0, e.determinant())); |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 329 | } |
| 330 | |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 331 | static void test_invert(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 332 | SkMatrix44 inverse; |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 333 | double inverseData[16]; |
| 334 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 335 | SkMatrix44 identity(SkMatrix44::kIdentity_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 336 | identity.invert(&inverse); |
| 337 | inverse.asRowMajord(inverseData); |
| 338 | assert16<double>(reporter, inverseData, |
| 339 | 1, 0, 0, 0, |
| 340 | 0, 1, 0, 0, |
| 341 | 0, 0, 1, 0, |
| 342 | 0, 0, 0, 1); |
| 343 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 344 | SkMatrix44 translation; |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 345 | translation.setTranslate(2, 3, 4); |
| 346 | translation.invert(&inverse); |
| 347 | inverse.asRowMajord(inverseData); |
| 348 | assert16<double>(reporter, inverseData, |
| 349 | 1, 0, 0, -2, |
| 350 | 0, 1, 0, -3, |
| 351 | 0, 0, 1, -4, |
| 352 | 0, 0, 0, 1); |
| 353 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 354 | SkMatrix44 scale; |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 355 | scale.setScale(2, 4, 8); |
| 356 | scale.invert(&inverse); |
| 357 | inverse.asRowMajord(inverseData); |
| 358 | assert16<double>(reporter, inverseData, |
| 359 | 0.5, 0, 0, 0, |
| 360 | 0, 0.25, 0, 0, |
| 361 | 0, 0, 0.125, 0, |
| 362 | 0, 0, 0, 1); |
| 363 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 364 | SkMatrix44 scaleTranslation; |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 365 | scaleTranslation.setScale(32, 128, 1024); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 366 | scaleTranslation.preTranslate(2, 3, 4); |
| 367 | scaleTranslation.invert(&inverse); |
| 368 | inverse.asRowMajord(inverseData); |
| 369 | assert16<double>(reporter, inverseData, |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 370 | 0.03125, 0, 0, -2, |
| 371 | 0, 0.0078125, 0, -3, |
| 372 | 0, 0, 0.0009765625, -4, |
| 373 | 0, 0, 0, 1); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 374 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 375 | SkMatrix44 rotation; |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 376 | rotation.setRotateDegreesAbout(0, 0, 1, 90); |
| 377 | rotation.invert(&inverse); |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 378 | SkMatrix44 expected; |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 379 | double expectedInverseRotation[16] = |
| 380 | {0, 1, 0, 0, |
| 381 | -1, 0, 0, 0, |
| 382 | 0, 0, 1, 0, |
| 383 | 0, 0, 0, 1}; |
| 384 | expected.setRowMajord(expectedInverseRotation); |
| 385 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 386 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 387 | SkMatrix44 affine; |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 388 | affine.setRotateDegreesAbout(0, 0, 1, 90); |
| 389 | affine.preScale(10, 20, 100); |
| 390 | affine.preTranslate(2, 3, 4); |
| 391 | affine.invert(&inverse); |
| 392 | double expectedInverseAffine[16] = |
| 393 | {0, 0.1, 0, -2, |
| 394 | -0.05, 0, 0, -3, |
| 395 | 0, 0, 0.01, -4, |
| 396 | 0, 0, 0, 1}; |
| 397 | expected.setRowMajord(expectedInverseAffine); |
| 398 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
| 399 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 400 | SkMatrix44 perspective(SkMatrix44::kIdentity_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 401 | perspective.setDouble(3, 2, 1.0); |
| 402 | perspective.invert(&inverse); |
| 403 | double expectedInversePerspective[16] = |
| 404 | {1, 0, 0, 0, |
| 405 | 0, 1, 0, 0, |
| 406 | 0, 0, 1, 0, |
| 407 | 0, 0, -1, 1}; |
| 408 | expected.setRowMajord(expectedInversePerspective); |
| 409 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
| 410 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 411 | SkMatrix44 affineAndPerspective(SkMatrix44::kIdentity_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 412 | affineAndPerspective.setDouble(3, 2, 1.0); |
| 413 | affineAndPerspective.preScale(10, 20, 100); |
| 414 | affineAndPerspective.preTranslate(2, 3, 4); |
| 415 | affineAndPerspective.invert(&inverse); |
| 416 | double expectedInverseAffineAndPerspective[16] = |
| 417 | {0.1, 0, 2, -2, |
| 418 | 0, 0.05, 3, -3, |
| 419 | 0, 0, 4.01, -4, |
| 420 | 0, 0, -1, 1}; |
| 421 | expected.setRowMajord(expectedInverseAffineAndPerspective); |
| 422 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
vmpstr | a8d4559 | 2015-06-30 13:36:04 -0700 | [diff] [blame] | 423 | |
| 424 | SkMatrix44 tinyScale(SkMatrix44::kIdentity_Constructor); |
| 425 | tinyScale.setDouble(0, 0, 1e-39); |
| 426 | REPORTER_ASSERT(reporter, tinyScale.getType() == SkMatrix44::kScale_Mask); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 427 | REPORTER_ASSERT(reporter, !tinyScale.invert(nullptr)); |
vmpstr | a8d4559 | 2015-06-30 13:36:04 -0700 | [diff] [blame] | 428 | REPORTER_ASSERT(reporter, !tinyScale.invert(&inverse)); |
| 429 | |
| 430 | SkMatrix44 tinyScaleTranslate(SkMatrix44::kIdentity_Constructor); |
| 431 | tinyScaleTranslate.setDouble(0, 0, 1e-38); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 432 | REPORTER_ASSERT(reporter, tinyScaleTranslate.invert(nullptr)); |
vmpstr | a8d4559 | 2015-06-30 13:36:04 -0700 | [diff] [blame] | 433 | tinyScaleTranslate.setDouble(0, 3, 10); |
| 434 | REPORTER_ASSERT( |
| 435 | reporter, tinyScaleTranslate.getType() == |
| 436 | (SkMatrix44::kScale_Mask | SkMatrix44::kTranslate_Mask)); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 437 | REPORTER_ASSERT(reporter, !tinyScaleTranslate.invert(nullptr)); |
vmpstr | a8d4559 | 2015-06-30 13:36:04 -0700 | [diff] [blame] | 438 | REPORTER_ASSERT(reporter, !tinyScaleTranslate.invert(&inverse)); |
| 439 | |
| 440 | SkMatrix44 tinyScalePerspective(SkMatrix44::kIdentity_Constructor); |
| 441 | tinyScalePerspective.setDouble(0, 0, 1e-39); |
| 442 | tinyScalePerspective.setDouble(3, 2, -1); |
| 443 | REPORTER_ASSERT(reporter, (tinyScalePerspective.getType() & |
| 444 | SkMatrix44::kPerspective_Mask) == |
| 445 | SkMatrix44::kPerspective_Mask); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 446 | REPORTER_ASSERT(reporter, !tinyScalePerspective.invert(nullptr)); |
vmpstr | a8d4559 | 2015-06-30 13:36:04 -0700 | [diff] [blame] | 447 | REPORTER_ASSERT(reporter, !tinyScalePerspective.invert(&inverse)); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 448 | } |
| 449 | |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 450 | static void test_transpose(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 451 | SkMatrix44 a,b; |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 452 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 453 | int i = 0; |
| 454 | for (int row = 0; row < 4; ++row) { |
| 455 | for (int col = 0; col < 4; ++col) { |
| 456 | a.setDouble(row, col, i); |
| 457 | b.setDouble(col, row, i++); |
| 458 | } |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 459 | } |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 460 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 461 | a.transpose(); |
| 462 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | static void test_get_set_double(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 466 | SkMatrix44 a; |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 467 | for (int row = 0; row < 4; ++row) { |
| 468 | for (int col = 0; col < 4; ++col) { |
| 469 | a.setDouble(row, col, 3.141592653589793); |
| 470 | REPORTER_ASSERT(reporter, |
| 471 | nearly_equal_double(3.141592653589793, |
| 472 | a.getDouble(row, col))); |
| 473 | a.setDouble(row, col, 0); |
| 474 | REPORTER_ASSERT(reporter, |
| 475 | nearly_equal_double(0, a.getDouble(row, col))); |
| 476 | } |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 477 | } |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 478 | } |
| 479 | |
msarett | c1a3e24 | 2016-06-23 12:42:29 -0700 | [diff] [blame] | 480 | static void test_set_3x3(skiatest::Reporter* r) { |
| 481 | static float vals[9] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, }; |
| 482 | |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 483 | SkMatrix44 mat; |
msarett | c1a3e24 | 2016-06-23 12:42:29 -0700 | [diff] [blame] | 484 | mat.set3x3RowMajorf(vals); |
| 485 | |
| 486 | REPORTER_ASSERT(r, 1.0f == mat.getFloat(0, 0)); |
| 487 | REPORTER_ASSERT(r, 2.0f == mat.getFloat(0, 1)); |
| 488 | REPORTER_ASSERT(r, 3.0f == mat.getFloat(0, 2)); |
| 489 | REPORTER_ASSERT(r, 4.0f == mat.getFloat(1, 0)); |
| 490 | REPORTER_ASSERT(r, 5.0f == mat.getFloat(1, 1)); |
| 491 | REPORTER_ASSERT(r, 6.0f == mat.getFloat(1, 2)); |
| 492 | REPORTER_ASSERT(r, 7.0f == mat.getFloat(2, 0)); |
| 493 | REPORTER_ASSERT(r, 8.0f == mat.getFloat(2, 1)); |
| 494 | REPORTER_ASSERT(r, 9.0f == mat.getFloat(2, 2)); |
| 495 | } |
| 496 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 497 | static void test_set_row_col_major(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 498 | SkMatrix44 a,b; |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 499 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 500 | for (int row = 0; row < 4; ++row) { |
| 501 | for (int col = 0; col < 4; ++col) { |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 502 | a.setDouble(row, col, row * 4 + col); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 503 | } |
| 504 | } |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 505 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 506 | double bufferd[16]; |
| 507 | float bufferf[16]; |
| 508 | a.asColMajord(bufferd); |
| 509 | b.setColMajord(bufferd); |
| 510 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
| 511 | b.setRowMajord(bufferd); |
| 512 | b.transpose(); |
| 513 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
| 514 | a.asColMajorf(bufferf); |
| 515 | b.setColMajorf(bufferf); |
| 516 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
| 517 | b.setRowMajorf(bufferf); |
| 518 | b.transpose(); |
| 519 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 520 | } |
| 521 | |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 522 | static void test_3x3_conversion(skiatest::Reporter* reporter) { |
| 523 | SkMScalar values4x4[16] = { 1, 2, 3, 4, |
| 524 | 5, 6, 7, 8, |
| 525 | 9, 10, 11, 12, |
| 526 | 13, 14, 15, 16 }; |
| 527 | SkScalar values3x3[9] = { 1, 2, 4, |
| 528 | 5, 6, 8, |
| 529 | 13, 14, 16 }; |
| 530 | SkMScalar values4x4flattened[16] = { 1, 2, 0, 4, |
| 531 | 5, 6, 0, 8, |
| 532 | 0, 0, 1, 0, |
| 533 | 13, 14, 0, 16 }; |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 534 | SkMatrix44 a44; |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 535 | a44.setRowMajor(values4x4); |
| 536 | |
| 537 | SkMatrix a33 = a44; |
| 538 | SkMatrix expected33; |
| 539 | for (int i = 0; i < 9; i++) expected33[i] = values3x3[i]; |
| 540 | REPORTER_ASSERT(reporter, expected33 == a33); |
| 541 | |
| 542 | SkMatrix44 a44flattened = a33; |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 543 | SkMatrix44 expected44flattened; |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 544 | expected44flattened.setRowMajor(values4x4flattened); |
| 545 | REPORTER_ASSERT(reporter, nearly_equal(a44flattened, expected44flattened)); |
| 546 | |
| 547 | // Test that a point with a Z value of 0 is transformed the same way. |
| 548 | SkScalar vec4[4] = { 2, 4, 0, 8 }; |
Cary Clark | e4442cb | 2017-10-18 11:46:18 -0400 | [diff] [blame] | 549 | SkPoint3 vec3 = { 2, 4, 8 }; |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 550 | |
| 551 | SkScalar vec4transformed[4]; |
Cary Clark | e4442cb | 2017-10-18 11:46:18 -0400 | [diff] [blame] | 552 | SkPoint3 vec3transformed; |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 553 | SkScalar vec4transformed2[4]; |
| 554 | a44.mapScalars(vec4, vec4transformed); |
Cary Clark | e4442cb | 2017-10-18 11:46:18 -0400 | [diff] [blame] | 555 | a33.mapHomogeneousPoints(&vec3transformed, &vec3, 1); |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 556 | a44flattened.mapScalars(vec4, vec4transformed2); |
Cary Clark | e4442cb | 2017-10-18 11:46:18 -0400 | [diff] [blame] | 557 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[0], vec3transformed.fX)); |
| 558 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[1], vec3transformed.fY)); |
| 559 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[3], vec3transformed.fZ)); |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 560 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[0], vec4transformed2[0])); |
| 561 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[1], vec4transformed2[1])); |
| 562 | REPORTER_ASSERT(reporter, !nearly_equal_scalar(vec4transformed[2], vec4transformed2[2])); |
| 563 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[3], vec4transformed2[3])); |
| 564 | } |
| 565 | |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 566 | static void test_has_perspective(skiatest::Reporter* reporter) { |
| 567 | SkMatrix44 transform(SkMatrix44::kIdentity_Constructor); |
| 568 | |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 569 | transform.setDouble(3, 2, -0.1); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 570 | REPORTER_ASSERT(reporter, transform.hasPerspective()); |
| 571 | |
| 572 | transform.reset(); |
| 573 | REPORTER_ASSERT(reporter, !transform.hasPerspective()); |
| 574 | |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 575 | transform.setDouble(3, 0, -1.0); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 576 | REPORTER_ASSERT(reporter, transform.hasPerspective()); |
| 577 | |
| 578 | transform.reset(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 579 | transform.setDouble(3, 1, -1.0); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 580 | REPORTER_ASSERT(reporter, transform.hasPerspective()); |
| 581 | |
| 582 | transform.reset(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 583 | transform.setDouble(3, 2, -0.3); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 584 | REPORTER_ASSERT(reporter, transform.hasPerspective()); |
| 585 | |
| 586 | transform.reset(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 587 | transform.setDouble(3, 3, 0.5); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 588 | REPORTER_ASSERT(reporter, transform.hasPerspective()); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 589 | |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 590 | transform.reset(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 591 | transform.setDouble(3, 3, 0.0); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 592 | REPORTER_ASSERT(reporter, transform.hasPerspective()); |
| 593 | } |
| 594 | |
tomhudson | faccb8e | 2014-09-26 11:45:48 -0700 | [diff] [blame] | 595 | static bool is_rectilinear (SkVector4& p1, SkVector4& p2, SkVector4& p3, SkVector4& p4) { |
| 596 | return (SkScalarNearlyEqual(p1.fData[0], p2.fData[0]) && |
| 597 | SkScalarNearlyEqual(p2.fData[1], p3.fData[1]) && |
| 598 | SkScalarNearlyEqual(p3.fData[0], p4.fData[0]) && |
| 599 | SkScalarNearlyEqual(p4.fData[1], p1.fData[1])) || |
| 600 | (SkScalarNearlyEqual(p1.fData[1], p2.fData[1]) && |
| 601 | SkScalarNearlyEqual(p2.fData[0], p3.fData[0]) && |
| 602 | SkScalarNearlyEqual(p3.fData[1], p4.fData[1]) && |
| 603 | SkScalarNearlyEqual(p4.fData[0], p1.fData[0])); |
| 604 | } |
| 605 | |
| 606 | static SkVector4 mul_with_persp_divide(const SkMatrix44& transform, const SkVector4& target) { |
| 607 | SkVector4 result = transform * target; |
| 608 | if (result.fData[3] != 0.0f && result.fData[3] != SK_Scalar1) { |
| 609 | float wInverse = SK_Scalar1 / result.fData[3]; |
| 610 | result.set(result.fData[0] * wInverse, |
| 611 | result.fData[1] * wInverse, |
| 612 | result.fData[2] * wInverse, |
| 613 | SK_Scalar1); |
| 614 | } |
| 615 | return result; |
| 616 | } |
| 617 | |
| 618 | static bool empirically_preserves_2d_axis_alignment(skiatest::Reporter* reporter, |
| 619 | const SkMatrix44& transform) { |
| 620 | SkVector4 p1(5.0f, 5.0f, 0.0f); |
| 621 | SkVector4 p2(10.0f, 5.0f, 0.0f); |
| 622 | SkVector4 p3(10.0f, 20.0f, 0.0f); |
| 623 | SkVector4 p4(5.0f, 20.0f, 0.0f); |
| 624 | |
| 625 | REPORTER_ASSERT(reporter, is_rectilinear(p1, p2, p3, p4)); |
| 626 | |
| 627 | p1 = mul_with_persp_divide(transform, p1); |
| 628 | p2 = mul_with_persp_divide(transform, p2); |
| 629 | p3 = mul_with_persp_divide(transform, p3); |
| 630 | p4 = mul_with_persp_divide(transform, p4); |
| 631 | |
| 632 | return is_rectilinear(p1, p2, p3, p4); |
| 633 | } |
| 634 | |
| 635 | static void test(bool expected, skiatest::Reporter* reporter, const SkMatrix44& transform) { |
| 636 | if (expected) { |
| 637 | REPORTER_ASSERT(reporter, empirically_preserves_2d_axis_alignment(reporter, transform)); |
| 638 | REPORTER_ASSERT(reporter, transform.preserves2dAxisAlignment()); |
| 639 | } else { |
| 640 | REPORTER_ASSERT(reporter, !empirically_preserves_2d_axis_alignment(reporter, transform)); |
| 641 | REPORTER_ASSERT(reporter, !transform.preserves2dAxisAlignment()); |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | static void test_preserves_2d_axis_alignment(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 646 | SkMatrix44 transform; |
| 647 | SkMatrix44 transform2; |
tomhudson | faccb8e | 2014-09-26 11:45:48 -0700 | [diff] [blame] | 648 | |
| 649 | static const struct TestCase { |
| 650 | SkMScalar a; // row 1, column 1 |
| 651 | SkMScalar b; // row 1, column 2 |
| 652 | SkMScalar c; // row 2, column 1 |
| 653 | SkMScalar d; // row 2, column 2 |
| 654 | bool expected; |
| 655 | } test_cases[] = { |
| 656 | { 3.f, 0.f, |
| 657 | 0.f, 4.f, true }, // basic case |
| 658 | { 0.f, 4.f, |
| 659 | 3.f, 0.f, true }, // rotate by 90 |
| 660 | { 0.f, 0.f, |
| 661 | 0.f, 4.f, true }, // degenerate x |
| 662 | { 3.f, 0.f, |
| 663 | 0.f, 0.f, true }, // degenerate y |
| 664 | { 0.f, 0.f, |
| 665 | 3.f, 0.f, true }, // degenerate x + rotate by 90 |
| 666 | { 0.f, 4.f, |
| 667 | 0.f, 0.f, true }, // degenerate y + rotate by 90 |
| 668 | { 3.f, 4.f, |
| 669 | 0.f, 0.f, false }, |
| 670 | { 0.f, 0.f, |
| 671 | 3.f, 4.f, false }, |
| 672 | { 0.f, 3.f, |
| 673 | 0.f, 4.f, false }, |
| 674 | { 3.f, 0.f, |
| 675 | 4.f, 0.f, false }, |
| 676 | { 3.f, 4.f, |
| 677 | 5.f, 0.f, false }, |
| 678 | { 3.f, 4.f, |
| 679 | 0.f, 5.f, false }, |
| 680 | { 3.f, 0.f, |
| 681 | 4.f, 5.f, false }, |
| 682 | { 0.f, 3.f, |
| 683 | 4.f, 5.f, false }, |
| 684 | { 2.f, 3.f, |
| 685 | 4.f, 5.f, false }, |
| 686 | }; |
| 687 | |
| 688 | for (size_t i = 0; i < sizeof(test_cases)/sizeof(TestCase); ++i) { |
| 689 | const TestCase& value = test_cases[i]; |
| 690 | transform.setIdentity(); |
| 691 | transform.set(0, 0, value.a); |
| 692 | transform.set(0, 1, value.b); |
| 693 | transform.set(1, 0, value.c); |
| 694 | transform.set(1, 1, value.d); |
| 695 | |
| 696 | test(value.expected, reporter, transform); |
| 697 | } |
| 698 | |
| 699 | // Try the same test cases again, but this time make sure that other matrix |
| 700 | // elements (except perspective) have entries, to test that they are ignored. |
| 701 | for (size_t i = 0; i < sizeof(test_cases)/sizeof(TestCase); ++i) { |
| 702 | const TestCase& value = test_cases[i]; |
| 703 | transform.setIdentity(); |
| 704 | transform.set(0, 0, value.a); |
| 705 | transform.set(0, 1, value.b); |
| 706 | transform.set(1, 0, value.c); |
| 707 | transform.set(1, 1, value.d); |
| 708 | |
| 709 | transform.set(0, 2, 1.f); |
| 710 | transform.set(0, 3, 2.f); |
| 711 | transform.set(1, 2, 3.f); |
| 712 | transform.set(1, 3, 4.f); |
| 713 | transform.set(2, 0, 5.f); |
| 714 | transform.set(2, 1, 6.f); |
| 715 | transform.set(2, 2, 7.f); |
| 716 | transform.set(2, 3, 8.f); |
| 717 | |
| 718 | test(value.expected, reporter, transform); |
| 719 | } |
| 720 | |
| 721 | // Try the same test cases again, but this time add perspective which is |
| 722 | // always assumed to not-preserve axis alignment. |
| 723 | for (size_t i = 0; i < sizeof(test_cases)/sizeof(TestCase); ++i) { |
| 724 | const TestCase& value = test_cases[i]; |
| 725 | transform.setIdentity(); |
| 726 | transform.set(0, 0, value.a); |
| 727 | transform.set(0, 1, value.b); |
| 728 | transform.set(1, 0, value.c); |
| 729 | transform.set(1, 1, value.d); |
| 730 | |
| 731 | transform.set(0, 2, 1.f); |
| 732 | transform.set(0, 3, 2.f); |
| 733 | transform.set(1, 2, 3.f); |
| 734 | transform.set(1, 3, 4.f); |
| 735 | transform.set(2, 0, 5.f); |
| 736 | transform.set(2, 1, 6.f); |
| 737 | transform.set(2, 2, 7.f); |
| 738 | transform.set(2, 3, 8.f); |
| 739 | transform.set(3, 0, 9.f); |
| 740 | transform.set(3, 1, 10.f); |
| 741 | transform.set(3, 2, 11.f); |
| 742 | transform.set(3, 3, 12.f); |
| 743 | |
| 744 | test(false, reporter, transform); |
| 745 | } |
| 746 | |
| 747 | // Try a few more practical situations to check precision |
| 748 | // Reuse TestCase (a, b, c, d) as (x, y, z, degrees) axis to rotate about. |
| 749 | TestCase rotation_tests[] = { |
| 750 | { 0.0, 0.0, 1.0, 90.0, true }, |
| 751 | { 0.0, 0.0, 1.0, 180.0, true }, |
| 752 | { 0.0, 0.0, 1.0, 270.0, true }, |
| 753 | { 0.0, 1.0, 0.0, 90.0, true }, |
| 754 | { 1.0, 0.0, 0.0, 90.0, true }, |
| 755 | { 0.0, 0.0, 1.0, 45.0, false }, |
| 756 | // In 3d these next two are non-preserving, but we're testing in 2d after |
| 757 | // orthographic projection, where they are. |
| 758 | { 0.0, 1.0, 0.0, 45.0, true }, |
| 759 | { 1.0, 0.0, 0.0, 45.0, true }, |
| 760 | }; |
| 761 | |
| 762 | for (size_t i = 0; i < sizeof(rotation_tests)/sizeof(TestCase); ++i) { |
| 763 | const TestCase& value = rotation_tests[i]; |
| 764 | transform.setRotateDegreesAbout(value.a, value.b, value.c, value.d); |
| 765 | test(value.expected, reporter, transform); |
| 766 | } |
| 767 | |
| 768 | static const struct DoubleRotationCase { |
| 769 | SkMScalar x1; |
| 770 | SkMScalar y1; |
| 771 | SkMScalar z1; |
| 772 | SkMScalar degrees1; |
| 773 | SkMScalar x2; |
| 774 | SkMScalar y2; |
| 775 | SkMScalar z2; |
| 776 | SkMScalar degrees2; |
| 777 | bool expected; |
| 778 | } double_rotation_tests[] = { |
| 779 | { 0.0, 0.0, 1.0, 90.0, 0.0, 1.0, 0.0, 90.0, true }, |
| 780 | { 0.0, 0.0, 1.0, 90.0, 1.0, 0.0, 0.0, 90.0, true }, |
| 781 | { 0.0, 1.0, 0.0, 90.0, 0.0, 0.0, 1.0, 90.0, true }, |
| 782 | }; |
| 783 | |
| 784 | for (size_t i = 0; i < sizeof(double_rotation_tests)/sizeof(DoubleRotationCase); ++i) { |
| 785 | const DoubleRotationCase& value = double_rotation_tests[i]; |
| 786 | transform.setRotateDegreesAbout(value.x1, value.y1, value.z1, value.degrees1); |
| 787 | transform2.setRotateDegreesAbout(value.x2, value.y2, value.z2, value.degrees2); |
| 788 | transform.postConcat(transform2); |
| 789 | test(value.expected, reporter, transform); |
| 790 | } |
| 791 | |
| 792 | // Perspective cases. |
| 793 | transform.setIdentity(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 794 | transform.setDouble(3, 2, -0.1); // Perspective depth 10 |
tomhudson | faccb8e | 2014-09-26 11:45:48 -0700 | [diff] [blame] | 795 | transform2.setRotateDegreesAbout(0.0, 1.0, 0.0, 45.0); |
| 796 | transform.preConcat(transform2); |
| 797 | test(false, reporter, transform); |
| 798 | |
| 799 | transform.setIdentity(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 800 | transform.setDouble(3, 2, -0.1); // Perspective depth 10 |
tomhudson | faccb8e | 2014-09-26 11:45:48 -0700 | [diff] [blame] | 801 | transform2.setRotateDegreesAbout(0.0, 0.0, 1.0, 90.0); |
| 802 | transform.preConcat(transform2); |
| 803 | test(true, reporter, transform); |
| 804 | } |
| 805 | |
reed | 39393e3 | 2014-10-21 12:33:21 -0700 | [diff] [blame] | 806 | // just want to exercise the various converters for MScalar |
| 807 | static void test_toint(skiatest::Reporter* reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 808 | SkMatrix44 mat; |
reed | 39393e3 | 2014-10-21 12:33:21 -0700 | [diff] [blame] | 809 | mat.setScale(3, 3, 3); |
| 810 | |
| 811 | SkMScalar sum = SkMScalarFloor(mat.get(0, 0)) + |
| 812 | SkMScalarRound(mat.get(1, 0)) + |
| 813 | SkMScalarCeil(mat.get(2, 0)); |
| 814 | int isum = SkMScalarFloorToInt(mat.get(0, 1)) + |
| 815 | SkMScalarRoundToInt(mat.get(1, 2)) + |
| 816 | SkMScalarCeilToInt(mat.get(2, 3)); |
| 817 | REPORTER_ASSERT(reporter, sum >= 0); |
| 818 | REPORTER_ASSERT(reporter, isum >= 0); |
| 819 | REPORTER_ASSERT(reporter, static_cast<SkMScalar>(isum) == SkIntToMScalar(isum)); |
| 820 | } |
tomhudson | faccb8e | 2014-09-26 11:45:48 -0700 | [diff] [blame] | 821 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 822 | DEF_TEST(Matrix44, reporter) { |
Mike Klein | 4429a4f | 2018-10-04 09:06:00 -0400 | [diff] [blame] | 823 | SkMatrix44 mat; |
| 824 | SkMatrix44 inverse; |
| 825 | SkMatrix44 iden1; |
| 826 | SkMatrix44 iden2; |
| 827 | SkMatrix44 rot; |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 828 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 829 | mat.setTranslate(1, 1, 1); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 830 | mat.invert(&inverse); |
| 831 | iden1.setConcat(mat, inverse); |
| 832 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 833 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 834 | mat.setScale(2, 2, 2); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 835 | mat.invert(&inverse); |
| 836 | iden1.setConcat(mat, inverse); |
| 837 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 838 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 839 | mat.setScale(SK_MScalar1/2, SK_MScalar1/2, SK_MScalar1/2); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 840 | mat.invert(&inverse); |
| 841 | iden1.setConcat(mat, inverse); |
| 842 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 843 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 844 | mat.setScale(3, 3, 3); |
| 845 | rot.setRotateDegreesAbout(0, 0, -1, 90); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 846 | mat.postConcat(rot); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 847 | REPORTER_ASSERT(reporter, mat.invert(nullptr)); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 848 | mat.invert(&inverse); |
| 849 | iden1.setConcat(mat, inverse); |
| 850 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 851 | iden2.setConcat(inverse, mat); |
| 852 | REPORTER_ASSERT(reporter, is_identity(iden2)); |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 853 | |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 854 | // test tiny-valued matrix inverse |
| 855 | mat.reset(); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 856 | auto v = SkDoubleToMScalar(1.0e-12); |
| 857 | mat.setScale(v,v,v); |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 858 | rot.setRotateDegreesAbout(0, 0, -1, 90); |
| 859 | mat.postConcat(rot); |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 860 | mat.postTranslate(v,v,v); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 861 | REPORTER_ASSERT(reporter, mat.invert(nullptr)); |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 862 | mat.invert(&inverse); |
| 863 | iden1.setConcat(mat, inverse); |
| 864 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 865 | |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 866 | // test mixed-valued matrix inverse |
| 867 | mat.reset(); |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 868 | mat.setScale(SkDoubleToMScalar(1.0e-2), |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 869 | SkDoubleToMScalar(3.0), |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 870 | SkDoubleToMScalar(1.0e+2)); |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 871 | rot.setRotateDegreesAbout(0, 0, -1, 90); |
| 872 | mat.postConcat(rot); |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 873 | mat.postTranslate(SkDoubleToMScalar(1.0e+2), |
mtklein | 1831f99 | 2015-06-09 11:47:01 -0700 | [diff] [blame] | 874 | SkDoubleToMScalar(3.0), |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 875 | SkDoubleToMScalar(1.0e-2)); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 876 | REPORTER_ASSERT(reporter, mat.invert(nullptr)); |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 877 | mat.invert(&inverse); |
| 878 | iden1.setConcat(mat, inverse); |
| 879 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 880 | |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 881 | // test degenerate matrix |
| 882 | mat.reset(); |
| 883 | mat.set3x3(1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 884 | REPORTER_ASSERT(reporter, !mat.invert(nullptr)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 885 | |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 886 | // test rol/col Major getters |
| 887 | { |
| 888 | mat.setTranslate(2, 3, 4); |
| 889 | float dataf[16]; |
| 890 | double datad[16]; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 891 | |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 892 | mat.asColMajorf(dataf); |
| 893 | assert16<float>(reporter, dataf, |
| 894 | 1, 0, 0, 0, |
| 895 | 0, 1, 0, 0, |
| 896 | 0, 0, 1, 0, |
| 897 | 2, 3, 4, 1); |
| 898 | mat.asColMajord(datad); |
| 899 | assert16<double>(reporter, datad, 1, 0, 0, 0, |
| 900 | 0, 1, 0, 0, |
| 901 | 0, 0, 1, 0, |
| 902 | 2, 3, 4, 1); |
| 903 | mat.asRowMajorf(dataf); |
| 904 | assert16<float>(reporter, dataf, 1, 0, 0, 2, |
| 905 | 0, 1, 0, 3, |
| 906 | 0, 0, 1, 4, |
| 907 | 0, 0, 0, 1); |
| 908 | mat.asRowMajord(datad); |
| 909 | assert16<double>(reporter, datad, 1, 0, 0, 2, |
| 910 | 0, 1, 0, 3, |
| 911 | 0, 0, 1, 4, |
| 912 | 0, 0, 0, 1); |
| 913 | } |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 914 | |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 915 | test_concat(reporter); |
| 916 | |
caryclark@google.com | 42639cd | 2012-06-06 12:03:39 +0000 | [diff] [blame] | 917 | if (false) { // avoid bit rot, suppress warning (working on making this pass) |
| 918 | test_common_angles(reporter); |
| 919 | } |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 920 | |
vollick@chromium.org | 57a54e3 | 2012-12-10 20:16:10 +0000 | [diff] [blame] | 921 | test_constructor(reporter); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 922 | test_gettype(reporter); |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 923 | test_determinant(reporter); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 924 | test_invert(reporter); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 925 | test_transpose(reporter); |
| 926 | test_get_set_double(reporter); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 927 | test_set_row_col_major(reporter); |
msarett | c1a3e24 | 2016-06-23 12:42:29 -0700 | [diff] [blame] | 928 | test_set_3x3(reporter); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 929 | test_translate(reporter); |
| 930 | test_scale(reporter); |
| 931 | test_map2(reporter); |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 932 | test_3x3_conversion(reporter); |
tomhudson | a32f175 | 2014-09-16 08:29:29 -0700 | [diff] [blame] | 933 | test_has_perspective(reporter); |
tomhudson | faccb8e | 2014-09-26 11:45:48 -0700 | [diff] [blame] | 934 | test_preserves_2d_axis_alignment(reporter); |
reed | 39393e3 | 2014-10-21 12:33:21 -0700 | [diff] [blame] | 935 | test_toint(reporter); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 936 | } |