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/SkPathOpsConic.h | |
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/SkPathOpsConic.h')
-rw-r--r-- | src/pathops/SkPathOpsConic.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/src/pathops/SkPathOpsConic.h b/src/pathops/SkPathOpsConic.h new file mode 100644 index 0000000000..dce7032ddc --- /dev/null +++ b/src/pathops/SkPathOpsConic.h @@ -0,0 +1,121 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkPathOpsConic_DEFINED +#define SkPathOpsConic_DEFINED + +#include "SkPathOpsPoint.h" +#include "SkPathOpsQuad.h" + +struct SkDConic { + static const int kPointCount = 3; + static const int kPointLast = kPointCount - 1; + static const int kMaxIntersections = 4; + + SkDQuad fPts; + SkScalar fWeight; + + bool collapsed() const { + return fPts.collapsed(); + } + + bool controlsInside() const { + return fPts.controlsInside(); + } + + void debugInit() { + fPts.debugInit(); + } + + SkDConic flip() const { + SkDConic result = {{{fPts[2], fPts[1], fPts[0]}}, fWeight}; + return result; + } + + static bool IsCubic() { return false; } + + const SkDConic& set(const SkPoint pts[kPointCount], SkScalar weight) { + fPts.set(pts); + fWeight = weight; + return *this; + } + + const SkDPoint& operator[](int n) const { return fPts[n]; } + SkDPoint& operator[](int n) { return fPts[n]; } + + static int AddValidTs(double s[], int realRoots, double* t) { + return SkDQuad::AddValidTs(s, realRoots, t); + } + + void align(int endIndex, SkDPoint* dstPt) const { + fPts.align(endIndex, dstPt); + } + + SkDVector dxdyAtT(double t) const; + static int FindExtrema(const double src[], SkScalar weight, double tValue[1]); + + bool hullIntersects(const SkDQuad& quad, bool* isLinear) const { + return fPts.hullIntersects(quad, isLinear); + } + + bool hullIntersects(const SkDConic& conic, bool* isLinear) const { + return fPts.hullIntersects(conic.fPts, isLinear); + } + + bool hullIntersects(const SkDCubic& cubic, bool* isLinear) const; + + bool isLinear(int startIndex, int endIndex) const { + return fPts.isLinear(startIndex, endIndex); + } + + bool monotonicInY() const { + return fPts.monotonicInY(); + } + + void otherPts(int oddMan, const SkDPoint* endPt[2]) const { + fPts.otherPts(oddMan, endPt); + } + + SkDPoint ptAtT(double t) const; + + static int RootsReal(double A, double B, double C, double t[2]) { + return SkDQuad::RootsReal(A, B, C, t); + } + + static int RootsValidT(const double A, const double B, const double C, double s[2]) { + return SkDQuad::RootsValidT(A, B, C, s); + } + + SkDConic subDivide(double t1, double t2) const; + + static SkDConic SubDivide(const SkPoint a[kPointCount], SkScalar weight, double t1, double t2) { + SkDConic conic; + conic.set(a, weight); + return conic.subDivide(t1, t2); + } + + SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t2, + SkScalar* weight) const; + + static SkDPoint SubDivide(const SkPoint pts[kPointCount], SkScalar weight, + const SkDPoint& a, const SkDPoint& c, + double t1, double t2, SkScalar* newWeight) { + SkDConic conic; + conic.set(pts, weight); + return conic.subDivide(a, c, t1, t2, newWeight); + } + + SkDPoint top(double startT, double endT) const; + + // utilities callable by the user from the debugger when the implementation code is linked in + void dump() const; + void dumpID(int id) const; + void dumpInner() const; +}; + + +#endif |