diff options
author | caryclark <caryclark@google.com> | 2015-04-20 08:31:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-20 08:31:59 -0700 |
commit | 1049f1246e7be4ccb68001361efceb8933e6f81c (patch) | |
tree | 9c71ceb245856cbe2173913eaec3b0ebb490dd74 /src/pathops/SkPathOpsCubic.cpp | |
parent | 5c476fb2776639bdbf0e974dd38d1c5d4c4ff1aa (diff) |
Now, path ops natively intersect conics, quads, and cubics in any combination. There are still a class of cubic tests that fail and a handful of undiagnosed failures from skps and fuzz tests, but things are much better overall.
Extended tests (150M+) run to completion in release in about 6 minutes; the standard test suite exceeds 100K and finishes in a few seconds on desktops.
TBR=reed
BUG=skia:3588
Review URL: https://codereview.chromium.org/1037953004
Diffstat (limited to 'src/pathops/SkPathOpsCubic.cpp')
-rw-r--r-- | src/pathops/SkPathOpsCubic.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp index d4a5898a1d..a44d29bb0f 100644 --- a/src/pathops/SkPathOpsCubic.cpp +++ b/src/pathops/SkPathOpsCubic.cpp @@ -6,6 +6,7 @@ */ #include "SkGeometry.h" #include "SkLineParameters.h" +#include "SkPathOpsConic.h" #include "SkPathOpsCubic.h" #include "SkPathOpsLine.h" #include "SkPathOpsQuad.h" @@ -105,7 +106,7 @@ bool SkDCubic::endsAreExtremaInXOrY() const { /* if returning true, check contains true if cubic's hull collapsed, making the cubic linear if returning false, check contains true if the the cubic pair have only the end point in common */ -bool SkDCubic::hullIntersects(const SkDCubic& c2, bool* isLinear) const { +bool SkDCubic::hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const { bool linear = true; char hullOrder[4]; int hullCount = convexHull(hullOrder); @@ -137,8 +138,8 @@ bool SkDCubic::hullIntersects(const SkDCubic& c2, bool* isLinear) const { } linear = false; bool foundOutlier = false; - for (int n = 0; n < kPointCount; ++n) { - double test = (c2[n].fY - origY) * adj - (c2[n].fX - origX) * opp; + for (int n = 0; n < ptCount; ++n) { + double test = (pts[n].fY - origY) * adj - (pts[n].fX - origX) * opp; if (test * sign > 0 && !precisely_zero(test)) { foundOutlier = true; break; @@ -154,6 +155,19 @@ bool SkDCubic::hullIntersects(const SkDCubic& c2, bool* isLinear) const { return true; } +bool SkDCubic::hullIntersects(const SkDCubic& c2, bool* isLinear) const { + return hullIntersects(c2.fPts, c2.kPointCount, isLinear); +} + +bool SkDCubic::hullIntersects(const SkDQuad& quad, bool* isLinear) const { + return hullIntersects(quad.fPts, quad.kPointCount, isLinear); +} + +bool SkDCubic::hullIntersects(const SkDConic& conic, bool* isLinear) const { + + return hullIntersects(conic.fPts, isLinear); +} + bool SkDCubic::isLinear(int startIndex, int endIndex) const { SkLineParameters lineParameters; lineParameters.cubicEndPoints(*this, startIndex, endIndex); @@ -191,7 +205,7 @@ bool SkDCubic::ComplexBreak(const SkPoint pointsPtr[4], SkScalar* t) { *t = (smaller + larger) / 2; return *t > 0 && *t < 1; } - } else if (cubicType == kSerpentine_SkCubicType) { + } else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubicType) { SkDCubic cubic; cubic.set(pointsPtr); double inflectionTs[2]; |