aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkPath.cpp4
-rw-r--r--tests/PathTest.cpp12
2 files changed, 14 insertions, 2 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 53678de40e..4c7ebe5879 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -263,14 +263,14 @@ bool SkPath::conservativelyContainsRect(const SkRect& rect) const {
SkPoint firstPt;
SkPoint prevPt;
- RawIter iter(*this);
+ SkPath::Iter iter(*this, true);
SkPath::Verb verb;
SkPoint pts[4];
SkDEBUGCODE(int moveCnt = 0;)
SkDEBUGCODE(int segmentCount = 0;)
SkDEBUGCODE(int closeCount = 0;)
- while ((verb = iter.next(pts)) != kDone_Verb) {
+ while ((verb = iter.next(pts, true, true)) != kDone_Verb) {
int nextPt = -1;
switch (verb) {
case kMove_Verb:
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 0ace812ef1..42771d0ff7 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1923,6 +1923,18 @@ static void test_conservativelyContains(skiatest::Reporter* reporter) {
SkIntToScalar(10),
SkIntToScalar(10))));
+ // Same as above path and first test but with the extra moveTo making a degenerate sub-path
+ // following the non-empty sub-path. Verifies that this does not trigger assertions.
+ path.reset();
+ path.moveTo(0, 0);
+ path.lineTo(SkIntToScalar(100), 0);
+ path.lineTo(0, SkIntToScalar(100));
+ path.moveTo(100, 100);
+
+ REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
+ 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();