diff options
author | caryclark <caryclark@google.com> | 2015-10-22 07:23:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-22 07:23:52 -0700 |
commit | ed0935a28a29af7d3b16ac8d9365f291a335c6bd (patch) | |
tree | f16bcde492ecfdbf19fcfcec9713c42e52326cb1 /src/pathops/SkPathOpsConic.cpp | |
parent | 7f53819ea9f8317b4bae1d54239b5b4c18240ef0 (diff) |
Reland of path ops: fix conic weight and partial coincidence (patchset #1 id:1 of https://codereview.chromium.org/1408923003/ )
Reason for revert:
suppressions have landed in chrome
Original issue's description:
> Revert of path ops: fix conic weight and partial coincidence (patchset #5 id:80001 of https://codereview.chromium.org/1413763002/ )
>
> Reason for revert:
> path ops change breaks svg clipping layout tests -- conic is now more accurate, changing edge of circle in clip
>
> These need to be rebaselined
>
> svg/clip-path/clip-path-child-clipped.svg
> svg/clip-path/clip-path-nonzero.svg
> svg/clip-path/clip-path-evenodd-nonzero.svg
> svg/clip-path/clip-path-nonzero-evenodd.svg
>
> Original issue's description:
> > The remaining 1m skp bugs are asserts that can be harmlessly
> > suppressed and bugs around conics.
> >
> > The conic calculation for a subdivided w was just wrong.
> >
> > Also added debugging to template intersection to initialize
> > reused structures and dump additional data.
> >
> > TBR=reed@google.com
> >
> > Committed: https://skia.googlesource.com/skia/+/ef33b1e739b23a1201100ff17a572da85b03d9af
>
> TBR=
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/f428df1be3e96d3f8970d0f7f415b862f7da5404
TBR=
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1407003016
Diffstat (limited to 'src/pathops/SkPathOpsConic.cpp')
-rw-r--r-- | src/pathops/SkPathOpsConic.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/pathops/SkPathOpsConic.cpp b/src/pathops/SkPathOpsConic.cpp index 013136bd82..f80af036ee 100644 --- a/src/pathops/SkPathOpsConic.cpp +++ b/src/pathops/SkPathOpsConic.cpp @@ -96,7 +96,27 @@ SkDPoint SkDConic::ptAtT(double t) const { return result; } -/* see quad subdivide for rationale */ +/* see quad subdivide for point rationale */ +/* w rationale : the mid point between t1 and t2 could be determined from the computed a/b/c + values if the computed w was known. Since we know the mid point at (t1+t2)/2, we'll assume + that it is the same as the point on the new curve t==(0+1)/2. + + d / dz == conic_poly(dst, unknownW, .5) / conic_weight(unknownW, .5); + + conic_poly(dst, unknownW, .5) + = a / 4 + (b * unknownW) / 2 + c / 4 + = (a + c) / 4 + (bx * unknownW) / 2 + + conic_weight(unknownW, .5) + = unknownW / 2 + 1 / 2 + + d / dz == ((a + c) / 2 + b * unknownW) / (unknownW + 1) + d / dz * (unknownW + 1) == (a + c) / 2 + b * unknownW + unknownW = ((a + c) / 2 - d / dz) / (d / dz - b) + + Thus, w is the ratio of the distance from the mid of end points to the on-curve point, and the + distance of the on-curve point to the control point. + */ SkDConic SkDConic::subDivide(double t1, double t2) const { double ax, ay, az; if (t1 == 0) { @@ -133,11 +153,13 @@ SkDConic SkDConic::subDivide(double t1, double t2) const { double bx = 2 * dx - (ax + cx) / 2; double by = 2 * dy - (ay + cy) / 2; double bz = 2 * dz - (az + cz) / 2; - double dt = t2 - t1; - double dt_1 = 1 - dt; - SkScalar w = SkDoubleToScalar((1 + dt * (fWeight - 1)) - / sqrt(dt * dt + 2 * dt * dt_1 * fWeight + dt_1 * dt_1)); - SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz}}}, w }; + SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz}}}, 0 }; + SkDPoint dMidAC = { (dst.fPts[0].fX + dst.fPts[2].fX) / 2, + (dst.fPts[0].fY + dst.fPts[2].fY) / 2 }; + SkDPoint dMid = { dx / dz, dy / dz }; + SkDVector dWNumer = dMidAC - dMid; + SkDVector dWDenom = dMid - dst.fPts[1]; + dst.fWeight = dWNumer.length() / dWDenom.length(); return dst; } |