michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkPathOpsQuad_DEFINED michael@0: #define SkPathOpsQuad_DEFINED michael@0: michael@0: #include "SkPathOpsPoint.h" michael@0: michael@0: struct SkDQuadPair { michael@0: const SkDQuad& first() const { return (const SkDQuad&) pts[0]; } michael@0: const SkDQuad& second() const { return (const SkDQuad&) pts[2]; } michael@0: SkDPoint pts[5]; michael@0: }; michael@0: michael@0: struct SkDQuad { michael@0: SkDPoint fPts[3]; michael@0: michael@0: SkDQuad flip() const { michael@0: SkDQuad result = {{fPts[2], fPts[1], fPts[0]}}; michael@0: return result; michael@0: } michael@0: michael@0: void set(const SkPoint pts[3]) { michael@0: fPts[0] = pts[0]; michael@0: fPts[1] = pts[1]; michael@0: fPts[2] = pts[2]; michael@0: } michael@0: michael@0: const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 3); return fPts[n]; } michael@0: SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 3); return fPts[n]; } michael@0: michael@0: static int AddValidTs(double s[], int realRoots, double* t); michael@0: void align(int endIndex, SkDPoint* dstPt) const; michael@0: SkDQuadPair chopAt(double t) const; michael@0: SkDVector dxdyAtT(double t) const; michael@0: static int FindExtrema(double a, double b, double c, double tValue[1]); michael@0: bool isLinear(int startIndex, int endIndex) const; michael@0: bool monotonicInY() const; michael@0: double nearestT(const SkDPoint&) const; michael@0: bool pointInHull(const SkDPoint&) const; michael@0: SkDPoint ptAtT(double t) const; michael@0: static int RootsReal(double A, double B, double C, double t[2]); michael@0: static int RootsValidT(const double A, const double B, const double C, double s[2]); michael@0: static void SetABC(const double* quad, double* a, double* b, double* c); michael@0: SkDQuad subDivide(double t1, double t2) const; michael@0: static SkDQuad SubDivide(const SkPoint a[3], double t1, double t2) { michael@0: SkDQuad quad; michael@0: quad.set(a); michael@0: return quad.subDivide(t1, t2); michael@0: } michael@0: SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t2) const; michael@0: static SkDPoint SubDivide(const SkPoint pts[3], const SkDPoint& a, const SkDPoint& c, michael@0: double t1, double t2) { michael@0: SkDQuad quad; michael@0: quad.set(pts); michael@0: return quad.subDivide(a, c, t1, t2); michael@0: } michael@0: SkDCubic toCubic() const; michael@0: SkDPoint top(double startT, double endT) const; michael@0: michael@0: #ifdef SK_DEBUG michael@0: void dump(); michael@0: #endif michael@0: private: michael@0: // static double Tangent(const double* quadratic, double t); // uncalled michael@0: }; michael@0: michael@0: #endif