Add dirty_after_edit to SkPath::moveTo. Add commented out test case that triggers assert.
BUG=skia:1460
R=reed@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/517023003
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index aa7943c..c0049ca 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -671,6 +671,8 @@
fLastMoveToIndex = fPathRef->countPoints();
ed.growForVerb(kMove_Verb)->set(x, y);
+
+ DIRTY_AFTER_EDIT;
}
void SkPath::rMoveTo(SkScalar x, SkScalar y) {
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 0de64b0..57587c4 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1504,7 +1504,19 @@
SkIntToScalar(20),
SkIntToScalar(5))));
- // same as above path and first test but with an extra moveTo.
+
+ // Test that multiple move commands do not cause asserts.
+
+ // At the time of writing, this would not modify cached convexity. This caused an assert while
+ // checking conservative containment again. http://skbug.com/1460
+ path.moveTo(SkIntToScalar(100), SkIntToScalar(100));
+#if 0
+ REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
+ SkIntToScalar(10),
+ SkIntToScalar(10))));
+#endif
+
+ // Same as above path and first test but with an extra moveTo.
path.reset();
path.moveTo(100, 100);
path.moveTo(0, 0);
@@ -1515,6 +1527,21 @@
SkIntToScalar(10),
SkIntToScalar(10))));
+ // Test that multiple move commands do not cause asserts and that the function
+ // is not confused by the multiple moves.
+ path.reset();
+ path.moveTo(0, 0);
+ path.lineTo(SkIntToScalar(100), 0);
+ path.lineTo(0, SkIntToScalar(100));
+ path.moveTo(0, SkIntToScalar(200));
+ path.lineTo(SkIntToScalar(100), SkIntToScalar(200));
+ path.lineTo(0, SkIntToScalar(300));
+
+ REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
+ SkRect::MakeXYWH(SkIntToScalar(50), 0,
+ SkIntToScalar(10),
+ SkIntToScalar(10))));
+
path.reset();
path.lineTo(100, 100);
REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(0, 0, 1, 1)));