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 SkWriteMatrix(SkWriter32* writer, const SkMatrix& matrix) { size_t size = matrix.flatten(NULL); SkASSERT(SkAlign4(size) == size); matrix.flatten(writer->reserve(size)); }