diff options
author | Mike Reed <reed@google.com> | 2009-06-29 14:54:46 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2009-06-29 14:54:46 -0400 |
commit | a8c52de60de1d2471206b3c81e9243e2c76f2edb (patch) | |
tree | ca5960eb8aea3bc8cfee1bf774ddf93afc691506 /tests | |
parent | 7d7b3cfdc1683207ff600eb39dbf81be53289a94 (diff) | |
download | external_skia-a8c52de60de1d2471206b3c81e9243e2c76f2edb.zip external_skia-a8c52de60de1d2471206b3c81e9243e2c76f2edb.tar.gz external_skia-a8c52de60de1d2471206b3c81e9243e2c76f2edb.tar.bz2 |
refresh from trunk: shape flattening, bzero
Diffstat (limited to 'tests')
-rw-r--r-- | tests/MatrixTest.cpp | 23 | ||||
-rw-r--r-- | tests/Test.cpp | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index 68e587b..052687d 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -27,6 +27,25 @@ static bool is_identity(const SkMatrix& m) { return nearly_equal(m, identity); } +static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { + // add 100 in case we have a bug, I don't want to kill my stack in the test + char buffer[SkMatrix::kMaxFlattenSize + 100]; + uint32_t size1 = m.flatten(NULL); + uint32_t size2 = m.flatten(buffer); + REPORTER_ASSERT(reporter, size1 == size2); + REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); + + SkMatrix m2; + uint32_t size3 = m2.unflatten(buffer); + REPORTER_ASSERT(reporter, size1 == size2); + REPORTER_ASSERT(reporter, m == m2); + + char buffer2[SkMatrix::kMaxFlattenSize + 100]; + size3 = m2.flatten(buffer2); + REPORTER_ASSERT(reporter, size1 == size2); + REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); +} + void TestMatrix(skiatest::Reporter* reporter) { SkMatrix mat, inverse, iden1, iden2; @@ -40,11 +59,13 @@ void TestMatrix(skiatest::Reporter* reporter) { mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); + test_flatten(reporter, mat); mat.setScale(SK_Scalar1/2, SK_Scalar1/2); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); + test_flatten(reporter, mat); mat.setScale(SkIntToScalar(3), SkIntToScalar(5), SkIntToScalar(20), 0); mat.postRotate(SkIntToScalar(25)); @@ -54,6 +75,8 @@ void TestMatrix(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, is_identity(iden1)); iden2.setConcat(inverse, mat); REPORTER_ASSERT(reporter, is_identity(iden2)); + test_flatten(reporter, mat); + test_flatten(reporter, iden2); // rectStaysRect test { diff --git a/tests/Test.cpp b/tests/Test.cpp index 2de0183..4bbe83a 100644 --- a/tests/Test.cpp +++ b/tests/Test.cpp @@ -9,7 +9,7 @@ Reporter::Reporter() { void Reporter::resetReporting() { fCurrTest = NULL; fTestCount = 0; - bzero(fResultCount, sizeof(fResultCount)); + sk_bzero(fResultCount, sizeof(fResultCount)); } void Reporter::startTest(Test* test) { |