aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/pathfill.cpp10
-rw-r--r--src/core/SkPath.cpp3
-rw-r--r--tests/PathTest.cpp6
3 files changed, 18 insertions, 1 deletions
diff --git a/gm/pathfill.cpp b/gm/pathfill.cpp
index db1f3f2557..ebe6d4a340 100644
--- a/gm/pathfill.cpp
+++ b/gm/pathfill.cpp
@@ -433,7 +433,7 @@ DEF_SIMPLE_GM(rotatedcubicpath, canvas, 200, 200) {
DEF_GM( return new PathFillGM; )
DEF_GM( return new PathInverseFillGM; )
-DEF_SIMPLE_GM(bug7792, canvas, 600, 800) {
+DEF_SIMPLE_GM(bug7792, canvas, 800, 800) {
// from skbug.com/7792 bug description
SkPaint p;
SkPath path;
@@ -568,4 +568,12 @@ DEF_SIMPLE_GM(bug7792, canvas, 600, 800) {
path.moveTo(75, 75);
path.lineTo(75, 75);
canvas->drawPath(path, p);
+ // from skbug.com/7792#c39
+ canvas->translate(200, -200 * 3);
+ path.reset();
+ path.moveTo(150, 75);
+ path.lineTo(150, 150);
+ path.lineTo(75, 150);
+ path.lineTo(75, 100);
+ canvas->drawPath(path, p);
}
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index ff4208a346..7110a3086a 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -564,6 +564,9 @@ addMissingClose:
// If autoClose, check if close generates diagonal
bool result = 4 == corners && (closeXY.isZero() || (autoClose && (!closeXY.fX || !closeXY.fY)));
if (!result) {
+ if (closeXY.fX && closeXY.fY) {
+ return false; // we're diagonal, abort
+ }
// check if we are just an incomplete rectangle, in which case we can
// return true, but not claim to be closed.
// e.g.
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index d7b38d87e1..611393becd 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -5018,4 +5018,10 @@ DEF_TEST(Path_isRect, reporter) {
SkPoint points36[] = { {75, 75}, {150, 75}, {150, 150}, {10, 150}, {75, 75}, {75, 75} };
path = makePath2(points36, verbs36, SK_ARRAY_COUNT(verbs36));
REPORTER_ASSERT(reporter, !path.isRect(&rect, nullptr, nullptr));
+ // isolated from skbug.com/7792#c39
+ SkPath::Verb verbs39[] = { SkPath::kMove_Verb, SkPath::kLine_Verb, SkPath::kLine_Verb,
+ SkPath::kLine_Verb };
+ SkPoint points39[] = { {150, 75}, {150, 150}, {75, 150}, {75, 100} };
+ path = makePath2(points39, verbs39, SK_ARRAY_COUNT(verbs39));
+ REPORTER_ASSERT(reporter, !path.isRect(&rect, nullptr, nullptr));
}