aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-08 18:30:46 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-08 18:30:46 +0000
commit94e75ee46a569cbcdf61fb7f04ee3a69d3ca0896 (patch)
tree69459ed6333c977be86dd36e503593a44a067e94 /tests
parent97caebc7462c202ab0ec5cce4eb26a616930813e (diff)
Rename the existing flatten(void*) methods.
This change avoids naminc confusion with the SkFlattenable flatten methods and also changes SkPath to use the void* model instead of taking a SkReader32. Review URL: https://codereview.appspot.com/6299062 git-svn-id: http://skia.googlecode.com/svn/trunk@4215 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/MatrixTest.cpp12
-rw-r--r--tests/PathTest.cpp21
2 files changed, 25 insertions, 8 deletions
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index 979f6ce76e..60f4831762 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -84,19 +84,19 @@ static bool is_identity(const SkMatrix& m) {
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);
+ uint32_t size1 = m.writeToMemory(NULL);
+ uint32_t size2 = m.writeToMemory(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);
+ uint32_t size3 = m2.readFromMemory(buffer);
+ REPORTER_ASSERT(reporter, size1 == size3);
REPORTER_ASSERT(reporter, are_equal(reporter, m, m2));
char buffer2[SkMatrix::kMaxFlattenSize + 100];
- size3 = m2.flatten(buffer2);
- REPORTER_ASSERT(reporter, size1 == size2);
+ size3 = m2.writeToMemory(buffer2);
+ REPORTER_ASSERT(reporter, size1 == size3);
REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
}
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 21f78bf2ce..ff12e8eb53 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -700,7 +700,7 @@ static void test_flattening(skiatest::Reporter* reporter) {
p.cubicTo(pts[4], pts[5], pts[6]);
SkWriter32 writer(100);
- p.flatten(writer);
+ writer.writePath(p);
size_t size = writer.size();
SkAutoMalloc storage(size);
writer.flatten(storage.get());
@@ -708,8 +708,25 @@ static void test_flattening(skiatest::Reporter* reporter) {
SkPath p1;
REPORTER_ASSERT(reporter, p1 != p);
- p1.unflatten(reader);
+ reader.readPath(&p1);
REPORTER_ASSERT(reporter, p1 == p);
+
+ // create a buffer that should be much larger than the path so we don't
+ // kill our stack if writer goes too far.
+ char buffer[1024];
+ uint32_t size1 = p.writeToMemory(NULL);
+ uint32_t size2 = p.writeToMemory(buffer);
+ REPORTER_ASSERT(reporter, size1 == size2);
+
+ SkPath p2;
+ uint32_t size3 = p2.readFromMemory(buffer);
+ REPORTER_ASSERT(reporter, size1 == size3);
+ REPORTER_ASSERT(reporter, p == p2);
+
+ char buffer2[1024];
+ size3 = p2.writeToMemory(buffer2);
+ REPORTER_ASSERT(reporter, size1 == size3);
+ REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
}
static void test_transform(skiatest::Reporter* reporter) {