diff options
author | caryclark <caryclark@google.com> | 2015-04-29 08:28:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-29 08:28:30 -0700 |
commit | aec251012542e971100e218bf463adbfb5d21d20 (patch) | |
tree | 16c2e84c2d59d94b75d7d2bc50fec53c0e38a898 /src/pathops/SkPathOpsCurve.h | |
parent | 97fdea6c4393cf0102d7eee5790782509fb4f57b (diff) |
minor fixes to cubics code and overall alignment of how bounds and tops are computed for all curve types
All but 17 extended tests work.
A helper function is privately added to SkPath.h to permit a test to modify a given point in a path.
BUG=skia:3588
Review URL: https://codereview.chromium.org/1107353004
Diffstat (limited to 'src/pathops/SkPathOpsCurve.h')
-rw-r--r-- | src/pathops/SkPathOpsCurve.h | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/src/pathops/SkPathOpsCurve.h b/src/pathops/SkPathOpsCurve.h index 69af91cf34..bfbc515719 100644 --- a/src/pathops/SkPathOpsCurve.h +++ b/src/pathops/SkPathOpsCurve.h @@ -16,6 +16,8 @@ #include "SkPath.h" #endif +struct SkPathOpsBounds; + struct SkOpCurve { SkPoint fPts[4]; SkScalar fWeight; @@ -43,6 +45,7 @@ struct SkOpCurve { SkDEBUGCODE(fWeight = 1); SkDEBUGCODE(fVerb = SkPath::kCubic_Verb); } + }; struct SkDCurve { @@ -64,9 +67,29 @@ struct SkDCurve { return fCubic[n]; } + SkDPoint conicTop(const SkPoint curve[3], SkScalar curveWeight, + double s, double e, double* topT); + SkDPoint cubicTop(const SkPoint curve[4], SkScalar , double s, double e, double* topT); void dumpID(int ) const; + SkDPoint lineTop(const SkPoint[2], SkScalar , double , double , double* topT); + SkDPoint quadTop(const SkPoint curve[3], SkScalar , double s, double e, double* topT); + + void setConicBounds(const SkPoint curve[3], SkScalar curveWeight, + double s, double e, SkPathOpsBounds* ); + void setCubicBounds(const SkPoint curve[4], SkScalar , + double s, double e, SkPathOpsBounds* ); + void setLineBounds(const SkPoint[2], SkScalar , double , double , SkPathOpsBounds* ); + void setQuadBounds(const SkPoint curve[3], SkScalar , + double s, double e, SkPathOpsBounds*); }; + +extern void (SkDCurve::* const SetBounds[])(const SkPoint curve[], SkScalar cWeight, + double tStart, double tEnd, SkPathOpsBounds* ); + +extern SkDPoint (SkDCurve::* const Top[])(const SkPoint curve[], SkScalar cWeight, + double tStart, double tEnd, double* topT); + static SkDPoint dline_xy_at_t(const SkPoint a[2], SkScalar , double t) { SkDLine line; line.set(a); @@ -179,36 +202,6 @@ static SkVector (* const CurveSlopeAtT[])(const SkPoint[], SkScalar , double ) = fcubic_dxdy_at_t }; -static SkPoint quad_top(const SkPoint a[3], SkScalar , double startT, double endT, double* topT) { - SkDQuad quad; - quad.set(a); - SkDPoint topPt = quad.top(startT, endT, topT); - return topPt.asSkPoint(); -} - -static SkPoint conic_top(const SkPoint a[3], SkScalar weight, double startT, double endT, - double* topT) { - SkDConic conic; - conic.set(a, weight); - SkDPoint topPt = conic.top(startT, endT, topT); - return topPt.asSkPoint(); -} - -static SkPoint cubic_top(const SkPoint a[4], SkScalar , double startT, double endT, double* topT) { - SkDCubic cubic; - cubic.set(a); - SkDPoint topPt = cubic.top(startT, endT, topT); - return topPt.asSkPoint(); -} - -static SkPoint (* const CurveTop[])(const SkPoint[], SkScalar , double , double , double* ) = { - NULL, - NULL, - quad_top, - conic_top, - cubic_top -}; - static bool line_is_vertical(const SkPoint a[2], SkScalar , double startT, double endT) { SkDLine line; line.set(a); |