aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGeometry.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-08-23 09:41:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-23 09:41:00 -0700
commit3cebe24682ea8bea3bcab400ff1c79b8e0b12ff0 (patch)
tree35ba0cdb4abdd244c82f3006bcca22944fd14bac /src/core/SkGeometry.cpp
parentc966ef9f07eed89bd571e3f89f8eb86f73b9328f (diff)
fix conic path fuzz
The test conic has a very large weight, so it reduces to a pair of lines. Detect this case rather than subdividing the conic so much that the answers are meaningless. R=herb@google.com, reed@google.com BUG=638223 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2268073004 Review-Url: https://codereview.chromium.org/2268073004
Diffstat (limited to 'src/core/SkGeometry.cpp')
-rw-r--r--src/core/SkGeometry.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 7dd5359b7d..03a63b2bda 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -1170,10 +1170,24 @@ static SkPoint* subdivide(const SkConic& src, SkPoint pts[], int level) {
int SkConic::chopIntoQuadsPOW2(SkPoint pts[], int pow2) const {
SkASSERT(pow2 >= 0);
+ *pts = fPts[0];
+ SkDEBUGCODE(SkPoint* endPts);
+ if (pow2 == kMaxConicToQuadPOW2) { // If an extreme weight generates many quads ...
+ SkConic dst[2];
+ this->chop(dst);
+ // check to see if the first chop generates a pair of lines
+ if (dst[0].fPts[1] == dst[0].fPts[2] && dst[1].fPts[0] == dst[1].fPts[1]) {
+ pts[1] = pts[2] = pts[3] = dst[0].fPts[1]; // set ctrl == end to make lines
+ pts[4] = dst[1].fPts[2];
+ pow2 = 1;
+ SkDEBUGCODE(endPts = &pts[5]);
+ goto commonFinitePtCheck;
+ }
+ }
+ SkDEBUGCODE(endPts = ) subdivide(*this, pts + 1, pow2);
+commonFinitePtCheck:
const int quadCount = 1 << pow2;
const int ptCount = 2 * quadCount + 1;
- *pts = fPts[0];
- SkDEBUGCODE(SkPoint* endPts =) subdivide(*this, pts + 1, pow2);
SkASSERT(endPts - pts == ptCount);
if (!SkPointsAreFinite(pts, ptCount)) {
// if we generated a non-finite, pin ourselves to the middle of the hull,