diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-09 21:25:06 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-09 21:25:06 +0000 |
commit | 80b577eba6bd8ad2065e3bd9113b9bb86c4a5288 (patch) | |
tree | cef7ebdd9be3bc2e5f48b0c26d75c2c25af66a08 /tests | |
parent | caa3a3beb6fecc37f24a84db0aff765480e6327b (diff) |
add quick-n-dirty test for concat on matrix44
Review URL: https://codereview.appspot.com/6827069
git-svn-id: http://skia.googlecode.com/svn/trunk@6371 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Matrix44Test.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index 703787701d..6e70c5f42c 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -76,6 +76,44 @@ static void test_common_angles(skiatest::Reporter* reporter) { } } +static void test_concat(skiatest::Reporter* reporter) { + int i; + SkMatrix44 a, b, c, d; + + a.setTranslate(10, 10, 10); + b.setScale(2, 2, 2); + + SkScalar src[8] = { + 0, 0, 0, 1, + 1, 1, 1, 1 + }; + SkScalar dst[8]; + + c.setConcat(a, b); + + d = a; + d.preConcat(b); + REPORTER_ASSERT(reporter, d == c); + + c.map(src, dst); c.map(src + 4, dst + 4); + for (i = 0; i < 3; ++i) { + REPORTER_ASSERT(reporter, 10 == dst[i]); + REPORTER_ASSERT(reporter, 12 == dst[i + 4]); + } + + c.setConcat(b, a); + + d = a; + d.postConcat(b); + REPORTER_ASSERT(reporter, d == c); + + c.map(src, dst); c.map(src + 4, dst + 4); + for (i = 0; i < 3; ++i) { + REPORTER_ASSERT(reporter, 20 == dst[i]); + REPORTER_ASSERT(reporter, 22 == dst[i + 4]); + } +} + static void TestMatrix44(skiatest::Reporter* reporter) { #ifdef SK_SCALAR_IS_FLOAT SkMatrix44 mat, inverse, iden1, iden2, rot; @@ -139,6 +177,8 @@ static void TestMatrix44(skiatest::Reporter* reporter) { 0, 0, 0, 1); } + test_concat(reporter); + if (false) { // avoid bit rot, suppress warning (working on making this pass) test_common_angles(reporter); } |