aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkScan_AntiPath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkScan_AntiPath.cpp')
-rw-r--r--src/core/SkScan_AntiPath.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index f903a4fd5c..28a6cfc5fc 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -630,12 +630,6 @@ void SkScan::SAAFillPath(const SkPath& path, SkBlitter* blitter, const SkIRect&
}
}
-static bool fitsInsideLimit(const SkRect& r, SkScalar max) {
- const SkScalar min = -max;
- return r.fLeft > min && r.fTop > min &&
- r.fRight < max && r.fBottom < max;
-}
-
static int overflows_short_shift(int value, int shift) {
const int s = 16 + shift;
return (SkLeftShift(value, s) >> s) - value;
@@ -659,14 +653,17 @@ static int rect_overflows_short_shift(SkIRect rect, int shift) {
overflows_short_shift(rect.fBottom, shift);
}
-static bool safeRoundOut(const SkRect& src, SkIRect* dst, int32_t maxInt) {
- const SkScalar maxScalar = SkIntToScalar(maxInt);
+static SkIRect safeRoundOut(const SkRect& src) {
+ // roundOut will pin huge floats to max/min int
+ SkIRect dst = src.roundOut();
- if (fitsInsideLimit(src, maxScalar)) {
- src.roundOut(dst);
- return true;
- }
- return false;
+ // intersect with a smaller huge rect, so the rect will not be considered empty for being
+ // too large. e.g. { -SK_MaxS32 ... SK_MaxS32 } is considered empty because its width
+ // exceeds signed 32bit.
+ const int32_t limit = SK_MaxS32 >> 1;
+ (void)dst.intersect({ -limit, -limit, limit, limit});
+
+ return dst;
}
void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
@@ -676,12 +673,7 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
}
const bool isInverse = path.isInverseFillType();
- SkIRect ir;
-
- if (!safeRoundOut(path.getBounds(), &ir, SK_MaxS32 >> SHIFT)) {
- // Bounds can't fit in SkIRect; we'll return without drawing
- return;
- }
+ SkIRect ir = safeRoundOut(path.getBounds());
if (ir.isEmpty()) {
if (isInverse) {
blitter->blitRegion(origClip);
@@ -745,8 +737,6 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
sk_blit_above(blitter, ir, *clipRgn);
}
- SkASSERT(SkIntToScalar(ir.fTop) <= path.getBounds().fTop);
-
if (forceDAA || ShouldUseDAA(path)) {
SkScan::DAAFillPath(path, blitter, ir, clipRgn->getBounds(), forceRLE);
} else if (ShouldUseAAA(path)) {