aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkRegion.cpp21
-rw-r--r--tests/RegionTest.cpp7
2 files changed, 20 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;
}
diff --git a/tests/RegionTest.cpp b/tests/RegionTest.cpp
index e629a9eb93..a8ce0e0db0 100644
--- a/tests/RegionTest.cpp
+++ b/tests/RegionTest.cpp
@@ -67,6 +67,13 @@ static void test_fromchrome(skiatest::Reporter* reporter) {
Union(&container, SkIRect::MakeXYWH(30, 20, 10, 20));
TEST_NO_CONTAINS(container, SkIRect::MakeXYWH(0, 0, 10, 39));
TEST_NO_CONTAINS(container, SkIRect::MakeXYWH(29, 0, 10, 39));
+
+ {
+ SkRegion rgn;
+ Union(&rgn, SkIRect::MakeXYWH(0, 0, 10, 10));
+ Union(&rgn, SkIRect::MakeLTRB(5, 10, 20, 20));
+ TEST_INTERSECT(rgn, SkIRect::MakeXYWH(15, 0, 5, 11));
+ }
}
static void test_empties(skiatest::Reporter* reporter) {