diff options
author | Mike Reed <reed@google.com> | 2018-01-30 10:12:22 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-30 15:56:35 +0000 |
commit | 63227ca63b09ad534b52b1b1957202ab18aa53f7 (patch) | |
tree | d806fb6ce3fc95d4c08595943239455279f1ff57 /src/core/SkScan_Path.cpp | |
parent | ab2621d3e2d2055096b9fbebf16ee443e4ea90fb (diff) |
handle clipping large triangles
originally found by fuzzer.
Bug: skia:
Change-Id: I45007a619f13936153c0db8a60b3631a2c9db20c
Reviewed-on: https://skia-review.googlesource.com/101741
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkScan_Path.cpp')
-rw-r--r-- | src/core/SkScan_Path.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp index f2a18b631e..6234afe873 100644 --- a/src/core/SkScan_Path.cpp +++ b/src/core/SkScan_Path.cpp @@ -759,9 +759,19 @@ void SkScan::FillTriangle(const SkPoint pts[], const SkRasterClip& clip, } SkRect r; - SkIRect ir; r.set(pts, 3); - r.round(&ir); + // If r is too large (larger than can easily fit in SkFixed) then we need perform geometric + // clipping. This is a bit of work, so we just call the general FillPath() to handle it. + // Use FixedMax/2 as the limit so we can subtract two edges and still store that in Fixed. + const SkScalar limit = SK_MaxS16 >> 1; + if (!SkRect::MakeLTRB(-limit, -limit, limit, limit).contains(r)) { + SkPath path; + path.addPoly(pts, 3, false); + FillPath(path, clip, blitter); + return; + } + + SkIRect ir = r.round(); if (ir.isEmpty() || !SkIRect::Intersects(ir, clip.getBounds())) { return; } |