Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: tests/PathTest.cpp

Issue 1703943003: add interp path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test to error if conics don't match Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 1048fcd97920242d667ac10df1e4050b87aee478..2ba40005d40ce2cb11df1a9d02f302c71517813d 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -3904,6 +3904,49 @@ public:
}
};
+static void test_interp(skiatest::Reporter* reporter) {
+ SkPath p1, p2, out;
+ REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
+ REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
+ REPORTER_ASSERT(reporter, p1 == out);
+ REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
+ REPORTER_ASSERT(reporter, p1 == out);
+ p1.moveTo(0, 2);
+ p1.lineTo(0, 4);
+ REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
+ REPORTER_ASSERT(reporter, !p1.interpolate(p2, 1, &out));
+ p2.moveTo(6, 0);
+ p2.lineTo(8, 0);
+ REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
+ REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
+ REPORTER_ASSERT(reporter, p2 == out);
+ REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
+ REPORTER_ASSERT(reporter, p1 == out);
+ REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
+ REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(3, 1, 4, 2));
+ p1.reset();
+ p1.moveTo(4, 4);
+ p1.conicTo(5, 4, 5, 5, 1 / SkScalarSqrt(2));
+ p2.reset();
+ p2.moveTo(4, 2);
+ p2.conicTo(7, 2, 7, 5, 1 / SkScalarSqrt(2));
+ REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
+ REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
+ REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(4, 3, 6, 5));
+ p2.reset();
+ p2.moveTo(4, 2);
+ p2.conicTo(6, 3, 6, 5, 1);
+ REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
+ p2.reset();
+ p2.moveTo(4, 4);
+ p2.conicTo(5, 4, 5, 5, 0.5f);
+ REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
+}
+
+DEF_TEST(PathInterp, reporter) {
+ test_interp(reporter);
+}
+
DEF_TEST(PathContains, reporter) {
test_contains(reporter);
}
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698