diff options
author | 2012-11-07 14:23:42 +0000 | |
---|---|---|
committer | 2012-11-07 14:23:42 +0000 | |
commit | bb094b947bb53374f5ad3df1b0cc71f41d43d9bf (patch) | |
tree | 7dfabffd5159e7026e45993bbfa2f72794e012fc /src/core/SkRegion.cpp | |
parent | 3302783ea7edf667794b088e5fc0656946b99816 (diff) |
fix SkRegion::intersects(rect) where the part of the rgn that we intersect is
the last run. The old bug was that we did an early exit from the loop because
we were comparing against the next rgn.bottom, instead of the current one.
inspired and fixed by danakj http://code.google.com/p/skia/issues/detail?id=958
Review URL: https://codereview.appspot.com/6812099
git-svn-id: http://skia.googlecode.com/svn/trunk@6327 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkRegion.cpp')
-rw-r--r-- | src/core/SkRegion.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp index f6fc2dc6c5..776f3e8d33 100644 --- a/src/core/SkRegion.cpp +++ b/src/core/SkRegion.cpp @@ -313,8 +313,8 @@ bool SkRegion::contains(int32_t x, int32_t y) const { if (this->isRect()) { return true; } - SkASSERT(this->isComplex()); + const RunType* runs = fRunHead->findScanline(y); // Skip the Bottom and IntervalCount @@ -371,17 +371,18 @@ bool SkRegion::contains(const SkIRect& r) const { if (this->isRect()) { return true; } - SkASSERT(this->isComplex()); + const RunType* scanline = fRunHead->findScanline(r.fTop); - RunType bottom; - do { + for (;;) { if (!scanline_contains(scanline, r.fLeft, r.fRight)) { return false; } - bottom = scanline_bottom(scanline); + if (r.fBottom <= scanline_bottom(scanline)) { + break; + } scanline = scanline_next(scanline); - } while (r.fBottom > bottom); + } return true; } @@ -455,14 +456,18 @@ bool SkRegion::intersects(const SkIRect& r) const { if (this->isRect()) { return true; } + SkASSERT(this->isComplex()); const RunType* scanline = fRunHead->findScanline(sect.fTop); - do { + for (;;) { if (scanline_intersects(scanline, sect.fLeft, sect.fRight)) { return true; } + if (sect.fBottom <= scanline_bottom(scanline)) { + break; + } scanline = scanline_next(scanline); - } while (sect.fBottom >= scanline[0]); + } return false; } |