2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkPathOpsCubic_DEFINED
9 #define SkPathOpsCubic_DEFINED
12 #include "SkPathOpsPoint.h"
16 const SkDCubic& first() const { return (const SkDCubic&) pts[0]; }
17 const SkDCubic& second() const { return (const SkDCubic&) pts[3]; }
24 void set(const SkPoint pts[4]) {
31 static const int gPrecisionUnit;
33 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 4); return fPts[n]; }
34 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 4); return fPts[n]; }
36 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const;
37 double calcPrecision() const;
38 SkDCubicPair chopAt(double t) const;
39 bool clockwise() const;
40 static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D);
41 bool controlsContainedByEnds() const;
42 SkDVector dxdyAtT(double t) const;
43 bool endsAreExtremaInXOrY() const;
44 static int FindExtrema(double a, double b, double c, double d, double tValue[2]);
45 int findInflections(double tValues[]) const;
47 static int FindInflections(const SkPoint a[4], double tValues[]) {
50 return cubic.findInflections(tValues);
53 int findMaxCurvature(double tValues[]) const;
54 bool isLinear(int startIndex, int endIndex) const;
55 bool monotonicInY() const;
56 SkDPoint ptAtT(double t) const;
57 static int RootsReal(double A, double B, double C, double D, double t[3]);
58 static int RootsValidT(const double A, const double B, const double C, double D, double s[3]);
59 bool serpentine() const;
60 SkDCubic subDivide(double t1, double t2) const;
62 static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) {
65 return cubic.subDivide(t1, t2);
68 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, SkDPoint p[2]) const;
70 static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoint& d, double t1,
71 double t2, SkDPoint p[2]) {
74 cubic.subDivide(a, d, t1, t2, p);
77 SkDPoint top(double startT, double endT) const;
78 void toQuadraticTs(double precision, SkTArray<double, true>* ts) const;
79 SkDQuad toQuad() const;
81 // utilities callable by the user from the debugger when the implementation code is linked in
83 void dumpNumber() const;