handle paths with degenerate verbs
Bug: skia:7507
Change-Id: I13cedcf8a13f4ce4417ae5c19f7f74d2652724d2
Reviewed-on: https://skia-review.googlesource.com/101760
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 984ec41..2db7d81 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -4984,3 +4984,35 @@
}
+// Treat nonfinite paths as "empty" or "full", depending on inverse-filltype
+DEF_TEST(ClipPath_nonfinite, reporter) {
+ auto surf = SkSurface::MakeRasterN32Premul(10, 10);
+ SkCanvas* canvas = surf->getCanvas();
+
+ REPORTER_ASSERT(reporter, !canvas->isClipEmpty());
+ for (bool aa : {false, true}) {
+ for (SkPath::FillType ft : {SkPath::kWinding_FillType, SkPath::kInverseWinding_FillType}) {
+ for (SkScalar bad : {SK_ScalarInfinity, SK_ScalarNaN}) {
+ for (int bits = 1; bits <= 15; ++bits) {
+ SkPoint p0 = { 0, 0 };
+ SkPoint p1 = { 0, 0 };
+ if (bits & 1) p0.fX = -bad;
+ if (bits & 2) p0.fY = -bad;
+ if (bits & 4) p1.fX = bad;
+ if (bits & 8) p1.fY = bad;
+
+ SkPath path;
+ path.moveTo(p0);
+ path.lineTo(p1);
+ path.setFillType(ft);
+ canvas->save();
+ canvas->clipPath(path, aa);
+ REPORTER_ASSERT(reporter, canvas->isClipEmpty() == !path.isInverseFillType());
+ canvas->restore();
+ }
+ }
+ }
+ }
+ REPORTER_ASSERT(reporter, !canvas->isClipEmpty());
+}
+