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 "Test.h" |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 9 | #include "TestClassDef.h" |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 10 | #include "SkMatrix44.h" |
| 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 |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 81 | SkMatrix44* placeholderMatrix = new SkMatrix44(SkMatrix44::kUninitialized_Constructor); |
robertphillips@google.com | 35300c4 | 2013-03-21 17:38:49 +0000 | [diff] [blame] | 82 | SkAutoTDelete<SkMatrix44> deleteMe(placeholderMatrix); |
| 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()); |
| 108 | } |
| 109 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 110 | static void test_translate(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 111 | SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
| 112 | SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 113 | |
| 114 | mat.setTranslate(0, 0, 0); |
| 115 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kIdentity_Mask)); |
| 116 | mat.setTranslate(1, 2, 3); |
| 117 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kTranslate_Mask)); |
| 118 | REPORTER_ASSERT(reporter, mat.invert(&inverse)); |
| 119 | REPORTER_ASSERT(reporter, bits_isonly(inverse.getType(), SkMatrix44::kTranslate_Mask)); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 120 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 121 | SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); |
| 122 | SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); |
| 123 | SkMatrix44 c(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 124 | a.set3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 125 | b.setTranslate(10, 11, 12); |
| 126 | |
| 127 | c.setConcat(a, b); |
| 128 | mat = a; |
| 129 | mat.preTranslate(10, 11, 12); |
| 130 | REPORTER_ASSERT(reporter, mat == c); |
| 131 | |
| 132 | c.setConcat(b, a); |
| 133 | mat = a; |
| 134 | mat.postTranslate(10, 11, 12); |
| 135 | REPORTER_ASSERT(reporter, mat == c); |
| 136 | } |
| 137 | |
| 138 | static void test_scale(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 139 | SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
| 140 | SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 141 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 142 | mat.setScale(1, 1, 1); |
| 143 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kIdentity_Mask)); |
| 144 | mat.setScale(1, 2, 3); |
| 145 | REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kScale_Mask)); |
| 146 | REPORTER_ASSERT(reporter, mat.invert(&inverse)); |
| 147 | REPORTER_ASSERT(reporter, bits_isonly(inverse.getType(), SkMatrix44::kScale_Mask)); |
| 148 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 149 | SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); |
| 150 | SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); |
| 151 | SkMatrix44 c(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 152 | a.set3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); |
| 153 | b.setScale(10, 11, 12); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 154 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 155 | c.setConcat(a, b); |
| 156 | mat = a; |
| 157 | mat.preScale(10, 11, 12); |
| 158 | REPORTER_ASSERT(reporter, mat == c); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 159 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 160 | c.setConcat(b, a); |
| 161 | mat = a; |
| 162 | mat.postScale(10, 11, 12); |
| 163 | REPORTER_ASSERT(reporter, mat == c); |
| 164 | } |
| 165 | |
| 166 | static void make_i(SkMatrix44* mat) { mat->setIdentity(); } |
| 167 | static void make_t(SkMatrix44* mat) { mat->setTranslate(1, 2, 3); } |
| 168 | static void make_s(SkMatrix44* mat) { mat->setScale(1, 2, 3); } |
| 169 | static void make_st(SkMatrix44* mat) { |
| 170 | mat->setScale(1, 2, 3); |
| 171 | mat->postTranslate(1, 2, 3); |
| 172 | } |
| 173 | static void make_a(SkMatrix44* mat) { |
| 174 | mat->setRotateDegreesAbout(1, 2, 3, 45); |
| 175 | } |
| 176 | static void make_p(SkMatrix44* mat) { |
| 177 | SkMScalar data[] = { |
| 178 | 1, 2, 3, 4, 5, 6, 7, 8, |
| 179 | 1, 2, 3, 4, 5, 6, 7, 8, |
| 180 | }; |
| 181 | mat->setRowMajor(data); |
| 182 | } |
| 183 | |
| 184 | typedef void (*Make44Proc)(SkMatrix44*); |
| 185 | |
| 186 | static const Make44Proc gMakeProcs[] = { |
| 187 | make_i, make_t, make_s, make_st, make_a, make_p |
| 188 | }; |
| 189 | |
| 190 | static void test_map2(skiatest::Reporter* reporter, const SkMatrix44& mat) { |
| 191 | SkMScalar src2[] = { 1, 2 }; |
| 192 | SkMScalar src4[] = { src2[0], src2[1], 0, 1 }; |
| 193 | SkMScalar dstA[4], dstB[4]; |
| 194 | |
| 195 | for (int i = 0; i < 4; ++i) { |
| 196 | dstA[i] = 123456789; |
| 197 | dstB[i] = 987654321; |
| 198 | } |
| 199 | |
| 200 | mat.map2(src2, 1, dstA); |
| 201 | mat.mapMScalars(src4, dstB); |
skia.committer@gmail.com | 0264fb4 | 2012-12-06 02:01:25 +0000 | [diff] [blame] | 202 | |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 203 | for (int i = 0; i < 4; ++i) { |
| 204 | REPORTER_ASSERT(reporter, dstA[i] == dstB[i]); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | static void test_map2(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 209 | SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 210 | |
| 211 | for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProcs); ++i) { |
| 212 | gMakeProcs[i](&mat); |
| 213 | test_map2(reporter, mat); |
| 214 | } |
| 215 | } |
| 216 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 217 | static void test_gettype(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 218 | SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor); |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 219 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 220 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
| 221 | REPORTER_ASSERT(reporter, SkMatrix44::kIdentity_Mask == matrix.getType()); |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 222 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 223 | int expectedMask; |
| 224 | |
| 225 | matrix.set(1, 1, 0); |
| 226 | expectedMask = SkMatrix44::kScale_Mask; |
| 227 | REPORTER_ASSERT(reporter, matrix.getType() == expectedMask); |
| 228 | |
| 229 | matrix.set(0, 3, 1); // translate-x |
| 230 | expectedMask |= SkMatrix44::kTranslate_Mask; |
| 231 | REPORTER_ASSERT(reporter, matrix.getType() == expectedMask); |
| 232 | |
| 233 | matrix.set(2, 0, 1); |
| 234 | expectedMask |= SkMatrix44::kAffine_Mask; |
| 235 | REPORTER_ASSERT(reporter, matrix.getType() == expectedMask); |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 236 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 237 | matrix.set(3, 2, 1); |
| 238 | REPORTER_ASSERT(reporter, matrix.getType() & SkMatrix44::kPerspective_Mask); |
reed@google.com | 87f99cb | 2013-04-19 12:25:00 +0000 | [diff] [blame] | 239 | |
| 240 | // ensure that negative zero is treated as zero |
| 241 | SkMScalar dx = 0; |
| 242 | SkMScalar dy = 0; |
| 243 | SkMScalar dz = 0; |
| 244 | matrix.setTranslate(-dx, -dy, -dz); |
| 245 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
| 246 | matrix.preTranslate(-dx, -dy, -dz); |
| 247 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
| 248 | matrix.postTranslate(-dx, -dy, -dz); |
| 249 | REPORTER_ASSERT(reporter, matrix.isIdentity()); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 250 | } |
| 251 | |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 252 | static void test_common_angles(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 253 | SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 254 | // Test precision of rotation in common cases |
| 255 | int common_angles[] = { 0, 90, -90, 180, -180, 270, -270, 360, -360 }; |
| 256 | for (int i = 0; i < 9; ++i) { |
robertphillips@google.com | 09042b8 | 2012-04-06 20:01:46 +0000 | [diff] [blame] | 257 | rot.setRotateDegreesAbout(0, 0, -1, SkIntToScalar(common_angles[i])); |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 258 | |
| 259 | SkMatrix rot3x3 = rot; |
| 260 | REPORTER_ASSERT(reporter, rot3x3.rectStaysRect()); |
| 261 | } |
| 262 | } |
| 263 | |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 264 | static void test_concat(skiatest::Reporter* reporter) { |
| 265 | int i; |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 266 | SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); |
| 267 | SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); |
| 268 | SkMatrix44 c(SkMatrix44::kUninitialized_Constructor); |
| 269 | SkMatrix44 d(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 270 | |
| 271 | a.setTranslate(10, 10, 10); |
| 272 | b.setScale(2, 2, 2); |
| 273 | |
| 274 | SkScalar src[8] = { |
| 275 | 0, 0, 0, 1, |
| 276 | 1, 1, 1, 1 |
| 277 | }; |
| 278 | SkScalar dst[8]; |
| 279 | |
| 280 | c.setConcat(a, b); |
| 281 | |
| 282 | d = a; |
| 283 | d.preConcat(b); |
| 284 | REPORTER_ASSERT(reporter, d == c); |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 285 | |
reed@google.com | 1ea95be | 2012-11-09 21:39:48 +0000 | [diff] [blame] | 286 | c.mapScalars(src, dst); c.mapScalars(src + 4, dst + 4); |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 287 | for (i = 0; i < 3; ++i) { |
| 288 | REPORTER_ASSERT(reporter, 10 == dst[i]); |
| 289 | REPORTER_ASSERT(reporter, 12 == dst[i + 4]); |
| 290 | } |
skia.committer@gmail.com | 453995e | 2012-11-10 02:01:26 +0000 | [diff] [blame] | 291 | |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 292 | c.setConcat(b, a); |
| 293 | |
| 294 | d = a; |
| 295 | d.postConcat(b); |
| 296 | REPORTER_ASSERT(reporter, d == c); |
| 297 | |
reed@google.com | 1ea95be | 2012-11-09 21:39:48 +0000 | [diff] [blame] | 298 | c.mapScalars(src, dst); c.mapScalars(src + 4, dst + 4); |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 299 | for (i = 0; i < 3; ++i) { |
| 300 | REPORTER_ASSERT(reporter, 20 == dst[i]); |
| 301 | REPORTER_ASSERT(reporter, 22 == dst[i + 4]); |
| 302 | } |
| 303 | } |
| 304 | |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 305 | static void test_determinant(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 306 | SkMatrix44 a(SkMatrix44::kIdentity_Constructor); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 307 | REPORTER_ASSERT(reporter, nearly_equal_double(1, a.determinant())); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 308 | a.set(1, 1, 2); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 309 | REPORTER_ASSERT(reporter, nearly_equal_double(2, a.determinant())); |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 310 | SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 311 | REPORTER_ASSERT(reporter, a.invert(&b)); |
| 312 | REPORTER_ASSERT(reporter, nearly_equal_double(0.5, b.determinant())); |
| 313 | SkMatrix44 c = b = a; |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 314 | c.set(0, 1, 4); |
| 315 | b.set(1, 0, 4); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 316 | REPORTER_ASSERT(reporter, |
| 317 | nearly_equal_double(a.determinant(), |
| 318 | b.determinant())); |
| 319 | SkMatrix44 d = a; |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 320 | d.set(0, 0, 8); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 321 | REPORTER_ASSERT(reporter, nearly_equal_double(16, d.determinant())); |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 322 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 323 | SkMatrix44 e = a; |
| 324 | e.postConcat(d); |
| 325 | REPORTER_ASSERT(reporter, nearly_equal_double(32, e.determinant())); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 326 | e.set(0, 0, 0); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 327 | REPORTER_ASSERT(reporter, nearly_equal_double(0, e.determinant())); |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 328 | } |
| 329 | |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 330 | static void test_invert(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 331 | SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 332 | double inverseData[16]; |
| 333 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 334 | SkMatrix44 identity(SkMatrix44::kIdentity_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 335 | identity.invert(&inverse); |
| 336 | inverse.asRowMajord(inverseData); |
| 337 | assert16<double>(reporter, inverseData, |
| 338 | 1, 0, 0, 0, |
| 339 | 0, 1, 0, 0, |
| 340 | 0, 0, 1, 0, |
| 341 | 0, 0, 0, 1); |
| 342 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 343 | SkMatrix44 translation(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 344 | translation.setTranslate(2, 3, 4); |
| 345 | translation.invert(&inverse); |
| 346 | inverse.asRowMajord(inverseData); |
| 347 | assert16<double>(reporter, inverseData, |
| 348 | 1, 0, 0, -2, |
| 349 | 0, 1, 0, -3, |
| 350 | 0, 0, 1, -4, |
| 351 | 0, 0, 0, 1); |
| 352 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 353 | SkMatrix44 scale(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 354 | scale.setScale(2, 4, 8); |
| 355 | scale.invert(&inverse); |
| 356 | inverse.asRowMajord(inverseData); |
| 357 | assert16<double>(reporter, inverseData, |
| 358 | 0.5, 0, 0, 0, |
| 359 | 0, 0.25, 0, 0, |
| 360 | 0, 0, 0.125, 0, |
| 361 | 0, 0, 0, 1); |
| 362 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 363 | SkMatrix44 scaleTranslation(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 364 | scaleTranslation.setScale(10, 100, 1000); |
| 365 | scaleTranslation.preTranslate(2, 3, 4); |
| 366 | scaleTranslation.invert(&inverse); |
| 367 | inverse.asRowMajord(inverseData); |
| 368 | assert16<double>(reporter, inverseData, |
| 369 | 0.1, 0, 0, -2, |
| 370 | 0, 0.01, 0, -3, |
| 371 | 0, 0, 0.001, -4, |
| 372 | 0, 0, 0, 1); |
| 373 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 374 | SkMatrix44 rotation(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 375 | rotation.setRotateDegreesAbout(0, 0, 1, 90); |
| 376 | rotation.invert(&inverse); |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 377 | SkMatrix44 expected(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 378 | double expectedInverseRotation[16] = |
| 379 | {0, 1, 0, 0, |
| 380 | -1, 0, 0, 0, |
| 381 | 0, 0, 1, 0, |
| 382 | 0, 0, 0, 1}; |
| 383 | expected.setRowMajord(expectedInverseRotation); |
| 384 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 385 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 386 | SkMatrix44 affine(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 387 | affine.setRotateDegreesAbout(0, 0, 1, 90); |
| 388 | affine.preScale(10, 20, 100); |
| 389 | affine.preTranslate(2, 3, 4); |
| 390 | affine.invert(&inverse); |
| 391 | double expectedInverseAffine[16] = |
| 392 | {0, 0.1, 0, -2, |
| 393 | -0.05, 0, 0, -3, |
| 394 | 0, 0, 0.01, -4, |
| 395 | 0, 0, 0, 1}; |
| 396 | expected.setRowMajord(expectedInverseAffine); |
| 397 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
| 398 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 399 | SkMatrix44 perspective(SkMatrix44::kIdentity_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 400 | perspective.setDouble(3, 2, 1.0); |
| 401 | perspective.invert(&inverse); |
| 402 | double expectedInversePerspective[16] = |
| 403 | {1, 0, 0, 0, |
| 404 | 0, 1, 0, 0, |
| 405 | 0, 0, 1, 0, |
| 406 | 0, 0, -1, 1}; |
| 407 | expected.setRowMajord(expectedInversePerspective); |
| 408 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
| 409 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 410 | SkMatrix44 affineAndPerspective(SkMatrix44::kIdentity_Constructor); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 411 | affineAndPerspective.setDouble(3, 2, 1.0); |
| 412 | affineAndPerspective.preScale(10, 20, 100); |
| 413 | affineAndPerspective.preTranslate(2, 3, 4); |
| 414 | affineAndPerspective.invert(&inverse); |
| 415 | double expectedInverseAffineAndPerspective[16] = |
| 416 | {0.1, 0, 2, -2, |
| 417 | 0, 0.05, 3, -3, |
| 418 | 0, 0, 4.01, -4, |
| 419 | 0, 0, -1, 1}; |
| 420 | expected.setRowMajord(expectedInverseAffineAndPerspective); |
| 421 | REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); |
| 422 | } |
| 423 | |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 424 | static void test_transpose(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 425 | SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); |
| 426 | SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 427 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 428 | int i = 0; |
| 429 | for (int row = 0; row < 4; ++row) { |
| 430 | for (int col = 0; col < 4; ++col) { |
| 431 | a.setDouble(row, col, i); |
| 432 | b.setDouble(col, row, i++); |
| 433 | } |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 434 | } |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 435 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 436 | a.transpose(); |
| 437 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | static void test_get_set_double(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 441 | SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 442 | for (int row = 0; row < 4; ++row) { |
| 443 | for (int col = 0; col < 4; ++col) { |
| 444 | a.setDouble(row, col, 3.141592653589793); |
| 445 | REPORTER_ASSERT(reporter, |
| 446 | nearly_equal_double(3.141592653589793, |
| 447 | a.getDouble(row, col))); |
| 448 | a.setDouble(row, col, 0); |
| 449 | REPORTER_ASSERT(reporter, |
| 450 | nearly_equal_double(0, a.getDouble(row, col))); |
| 451 | } |
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 | } |
| 454 | |
| 455 | static void test_set_row_col_major(skiatest::Reporter* reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 456 | SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); |
| 457 | SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); |
| 458 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 459 | for (int row = 0; row < 4; ++row) { |
| 460 | for (int col = 0; col < 4; ++col) { |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 461 | a.setDouble(row, col, row * 4 + col); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 462 | } |
| 463 | } |
skia.committer@gmail.com | e659c2e | 2012-12-04 02:01:25 +0000 | [diff] [blame] | 464 | |
vollick@chromium.org | f11cf9f | 2012-11-19 21:02:06 +0000 | [diff] [blame] | 465 | double bufferd[16]; |
| 466 | float bufferf[16]; |
| 467 | a.asColMajord(bufferd); |
| 468 | b.setColMajord(bufferd); |
| 469 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
| 470 | b.setRowMajord(bufferd); |
| 471 | b.transpose(); |
| 472 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
| 473 | a.asColMajorf(bufferf); |
| 474 | b.setColMajorf(bufferf); |
| 475 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
| 476 | b.setRowMajorf(bufferf); |
| 477 | b.transpose(); |
| 478 | REPORTER_ASSERT(reporter, nearly_equal(a, b)); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 479 | } |
| 480 | |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 481 | static void test_3x3_conversion(skiatest::Reporter* reporter) { |
| 482 | SkMScalar values4x4[16] = { 1, 2, 3, 4, |
| 483 | 5, 6, 7, 8, |
| 484 | 9, 10, 11, 12, |
| 485 | 13, 14, 15, 16 }; |
| 486 | SkScalar values3x3[9] = { 1, 2, 4, |
| 487 | 5, 6, 8, |
| 488 | 13, 14, 16 }; |
| 489 | SkMScalar values4x4flattened[16] = { 1, 2, 0, 4, |
| 490 | 5, 6, 0, 8, |
| 491 | 0, 0, 1, 0, |
| 492 | 13, 14, 0, 16 }; |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 493 | SkMatrix44 a44(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 494 | a44.setRowMajor(values4x4); |
| 495 | |
| 496 | SkMatrix a33 = a44; |
| 497 | SkMatrix expected33; |
| 498 | for (int i = 0; i < 9; i++) expected33[i] = values3x3[i]; |
| 499 | REPORTER_ASSERT(reporter, expected33 == a33); |
| 500 | |
| 501 | SkMatrix44 a44flattened = a33; |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 502 | SkMatrix44 expected44flattened(SkMatrix44::kUninitialized_Constructor); |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 503 | expected44flattened.setRowMajor(values4x4flattened); |
| 504 | REPORTER_ASSERT(reporter, nearly_equal(a44flattened, expected44flattened)); |
| 505 | |
| 506 | // Test that a point with a Z value of 0 is transformed the same way. |
| 507 | SkScalar vec4[4] = { 2, 4, 0, 8 }; |
| 508 | SkScalar vec3[3] = { 2, 4, 8 }; |
| 509 | |
| 510 | SkScalar vec4transformed[4]; |
| 511 | SkScalar vec3transformed[3]; |
| 512 | SkScalar vec4transformed2[4]; |
| 513 | a44.mapScalars(vec4, vec4transformed); |
| 514 | a33.mapHomogeneousPoints(vec3transformed, vec3, 1); |
| 515 | a44flattened.mapScalars(vec4, vec4transformed2); |
| 516 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[0], vec3transformed[0])); |
| 517 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[1], vec3transformed[1])); |
| 518 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[3], vec3transformed[2])); |
| 519 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[0], vec4transformed2[0])); |
| 520 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[1], vec4transformed2[1])); |
| 521 | REPORTER_ASSERT(reporter, !nearly_equal_scalar(vec4transformed[2], vec4transformed2[2])); |
| 522 | REPORTER_ASSERT(reporter, nearly_equal_scalar(vec4transformed[3], vec4transformed2[3])); |
| 523 | } |
| 524 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 525 | DEF_TEST(Matrix44, reporter) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 526 | SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
| 527 | SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); |
| 528 | SkMatrix44 iden1(SkMatrix44::kUninitialized_Constructor); |
| 529 | SkMatrix44 iden2(SkMatrix44::kUninitialized_Constructor); |
| 530 | SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 531 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 532 | mat.setTranslate(1, 1, 1); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 533 | mat.invert(&inverse); |
| 534 | iden1.setConcat(mat, inverse); |
| 535 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 536 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 537 | mat.setScale(2, 2, 2); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 538 | mat.invert(&inverse); |
| 539 | iden1.setConcat(mat, inverse); |
| 540 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 541 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 542 | mat.setScale(SK_MScalar1/2, SK_MScalar1/2, SK_MScalar1/2); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 543 | mat.invert(&inverse); |
| 544 | iden1.setConcat(mat, inverse); |
| 545 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 546 | |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 547 | mat.setScale(3, 3, 3); |
| 548 | rot.setRotateDegreesAbout(0, 0, -1, 90); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 549 | mat.postConcat(rot); |
| 550 | REPORTER_ASSERT(reporter, mat.invert(NULL)); |
| 551 | mat.invert(&inverse); |
| 552 | iden1.setConcat(mat, inverse); |
| 553 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
| 554 | iden2.setConcat(inverse, mat); |
| 555 | REPORTER_ASSERT(reporter, is_identity(iden2)); |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 556 | |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 557 | // test tiny-valued matrix inverse |
| 558 | mat.reset(); |
| 559 | mat.setScale(1.0e-12, 1.0e-12, 1.0e-12); |
| 560 | rot.setRotateDegreesAbout(0, 0, -1, 90); |
| 561 | mat.postConcat(rot); |
| 562 | mat.postTranslate(1.0e-12, 1.0e-12, 1.0e-12); |
| 563 | REPORTER_ASSERT(reporter, mat.invert(NULL)); |
| 564 | mat.invert(&inverse); |
| 565 | iden1.setConcat(mat, inverse); |
| 566 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 567 | |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 568 | // test mixed-valued matrix inverse |
| 569 | mat.reset(); |
jvanverth@google.com | 25f72ed | 2013-09-03 19:46:16 +0000 | [diff] [blame] | 570 | mat.setScale(1.0e-10, 3.0, 1.0e+10); |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 571 | rot.setRotateDegreesAbout(0, 0, -1, 90); |
| 572 | mat.postConcat(rot); |
jvanverth@google.com | 25f72ed | 2013-09-03 19:46:16 +0000 | [diff] [blame] | 573 | mat.postTranslate(1.0e+10, 3.0, 1.0e-10); |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 574 | REPORTER_ASSERT(reporter, mat.invert(NULL)); |
| 575 | mat.invert(&inverse); |
| 576 | iden1.setConcat(mat, inverse); |
| 577 | REPORTER_ASSERT(reporter, is_identity(iden1)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 578 | |
commit-bot@chromium.org | f02f078 | 2013-08-20 15:25:04 +0000 | [diff] [blame] | 579 | // test degenerate matrix |
| 580 | mat.reset(); |
| 581 | mat.set3x3(1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0); |
| 582 | REPORTER_ASSERT(reporter, !mat.invert(NULL)); |
skia.committer@gmail.com | b74bdf0 | 2013-08-21 07:01:29 +0000 | [diff] [blame] | 583 | |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 584 | // test rol/col Major getters |
| 585 | { |
| 586 | mat.setTranslate(2, 3, 4); |
| 587 | float dataf[16]; |
| 588 | double datad[16]; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 589 | |
reed@google.com | da9fac0 | 2011-06-13 14:46:52 +0000 | [diff] [blame] | 590 | mat.asColMajorf(dataf); |
| 591 | assert16<float>(reporter, dataf, |
| 592 | 1, 0, 0, 0, |
| 593 | 0, 1, 0, 0, |
| 594 | 0, 0, 1, 0, |
| 595 | 2, 3, 4, 1); |
| 596 | mat.asColMajord(datad); |
| 597 | assert16<double>(reporter, datad, 1, 0, 0, 0, |
| 598 | 0, 1, 0, 0, |
| 599 | 0, 0, 1, 0, |
| 600 | 2, 3, 4, 1); |
| 601 | mat.asRowMajorf(dataf); |
| 602 | assert16<float>(reporter, dataf, 1, 0, 0, 2, |
| 603 | 0, 1, 0, 3, |
| 604 | 0, 0, 1, 4, |
| 605 | 0, 0, 0, 1); |
| 606 | mat.asRowMajord(datad); |
| 607 | assert16<double>(reporter, datad, 1, 0, 0, 2, |
| 608 | 0, 1, 0, 3, |
| 609 | 0, 0, 1, 4, |
| 610 | 0, 0, 0, 1); |
| 611 | } |
reed@google.com | 6f2b44d | 2011-06-24 18:13:39 +0000 | [diff] [blame] | 612 | |
reed@google.com | 80b577e | 2012-11-09 21:25:06 +0000 | [diff] [blame] | 613 | test_concat(reporter); |
| 614 | |
caryclark@google.com | 42639cd | 2012-06-06 12:03:39 +0000 | [diff] [blame] | 615 | if (false) { // avoid bit rot, suppress warning (working on making this pass) |
| 616 | test_common_angles(reporter); |
| 617 | } |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 618 | |
vollick@chromium.org | 57a54e3 | 2012-12-10 20:16:10 +0000 | [diff] [blame] | 619 | test_constructor(reporter); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 620 | test_gettype(reporter); |
vollick@chromium.org | 3959a76 | 2012-11-13 15:08:22 +0000 | [diff] [blame] | 621 | test_determinant(reporter); |
commit-bot@chromium.org | 9504575 | 2013-08-20 20:15:24 +0000 | [diff] [blame] | 622 | test_invert(reporter); |
vollick@chromium.org | 9b21c25 | 2012-11-14 21:33:55 +0000 | [diff] [blame] | 623 | test_transpose(reporter); |
| 624 | test_get_set_double(reporter); |
reed@google.com | 7d68335 | 2012-12-03 21:19:52 +0000 | [diff] [blame] | 625 | test_set_row_col_major(reporter); |
reed@google.com | 99b5c7f | 2012-12-05 22:13:59 +0000 | [diff] [blame] | 626 | test_translate(reporter); |
| 627 | test_scale(reporter); |
| 628 | test_map2(reporter); |
commit-bot@chromium.org | 722555b | 2013-10-05 01:16:30 +0000 | [diff] [blame] | 629 | test_3x3_conversion(reporter); |
reed@google.com | 125002a | 2011-06-09 19:13:41 +0000 | [diff] [blame] | 630 | } |