Revert "relax path bounds check so we can draw larger paths"
This reverts commit e2330261a704e2db762e2de0d297bf8b4dc510f1.
Reason for revert: triggered assert
48.3s start tiles_rt-8888 gm bigrect
48.3s start tiles_rt-8888 gm big_rrect_circle_aa_effect
48.3s start tiles_rt-8888 gm big_rrect_ellipse_aa_effect
../../../src/core/SkScan_Path.cpp(229): fatal error: "assert(leftE->fFirstY <= stop_y)"
Original change's description:
> relax path bounds check so we can draw larger paths
>
> Bug:800804
> Change-Id: Ief0679de95887d8e11aa5853228c2bdef27d07a2
> Reviewed-on: https://skia-review.googlesource.com/94100
> Reviewed-by: Yuqian Li <liyuqian@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=egdaniel@google.com,liyuqian@google.com,reed@google.com
Change-Id: I63509625b8afaa2064f0b187c17b73bd7739cdb9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 800804
Reviewed-on: https://skia-review.googlesource.com/94481
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/gm/hugepath.cpp b/gm/hugepath.cpp
index 83dff9e..dbca413 100644
--- a/gm/hugepath.cpp
+++ b/gm/hugepath.cpp
@@ -9,29 +9,20 @@
#include "SkCanvas.h"
#include "SkPath.h"
-DEF_SIMPLE_GM(path_huge_crbug_800804, canvas, 50, 600) {
+DEF_SIMPLE_GM(path_huge_crbug_800804, canvas, 30, 600) {
SkPaint paint;
paint.setAntiAlias(true);
+
paint.setStyle(SkPaint::kStroke_Style);
-
- // exercise various special-cases (e.g. hairlines or not)
- const float widths[] = { 0.9f, 1.0f, 1.1f };
-
+ paint.setStrokeWidth(1);
SkPath path;
- for (float w : widths) {
- paint.setStrokeWidth(w);
+ path.moveTo(-1000,12345678901234567890.f);
+ path.lineTo(10.5f,200);
+ canvas->drawPath(path, paint);
- path.reset();
- path.moveTo(-1000,12345678901234567890.f);
- path.lineTo(10.5f,200);
- canvas->drawPath(path, paint);
-
- path.reset();
- path.moveTo(30.5f,400);
- path.lineTo(1000,-9.8765432109876543210e+19f);
- canvas->drawPath(path, paint);
-
- canvas->translate(3, 0);
- }
+ path.reset();
+ path.moveTo(20.5f,400);
+ path.lineTo(1000,-9.8765432109876543210e+19f);
+ canvas->drawPath(path, paint);
}
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 28a6cfc..f903a4f 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -630,6 +630,12 @@
}
}
+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;
@@ -653,17 +659,14 @@
overflows_short_shift(rect.fBottom, shift);
}
-static SkIRect safeRoundOut(const SkRect& src) {
- // roundOut will pin huge floats to max/min int
- SkIRect dst = src.roundOut();
+static bool safeRoundOut(const SkRect& src, SkIRect* dst, int32_t maxInt) {
+ const SkScalar maxScalar = SkIntToScalar(maxInt);
- // 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;
+ if (fitsInsideLimit(src, maxScalar)) {
+ src.roundOut(dst);
+ return true;
+ }
+ return false;
}
void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
@@ -673,7 +676,12 @@
}
const bool isInverse = path.isInverseFillType();
- SkIRect ir = safeRoundOut(path.getBounds());
+ SkIRect ir;
+
+ if (!safeRoundOut(path.getBounds(), &ir, SK_MaxS32 >> SHIFT)) {
+ // Bounds can't fit in SkIRect; we'll return without drawing
+ return;
+ }
if (ir.isEmpty()) {
if (isInverse) {
blitter->blitRegion(origClip);
@@ -737,6 +745,8 @@
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)) {