1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/pathops/SkPathOpsQuad.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* 1.5 + * Copyright 2012 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef SkPathOpsQuad_DEFINED 1.12 +#define SkPathOpsQuad_DEFINED 1.13 + 1.14 +#include "SkPathOpsPoint.h" 1.15 + 1.16 +struct SkDQuadPair { 1.17 + const SkDQuad& first() const { return (const SkDQuad&) pts[0]; } 1.18 + const SkDQuad& second() const { return (const SkDQuad&) pts[2]; } 1.19 + SkDPoint pts[5]; 1.20 +}; 1.21 + 1.22 +struct SkDQuad { 1.23 + SkDPoint fPts[3]; 1.24 + 1.25 + SkDQuad flip() const { 1.26 + SkDQuad result = {{fPts[2], fPts[1], fPts[0]}}; 1.27 + return result; 1.28 + } 1.29 + 1.30 + void set(const SkPoint pts[3]) { 1.31 + fPts[0] = pts[0]; 1.32 + fPts[1] = pts[1]; 1.33 + fPts[2] = pts[2]; 1.34 + } 1.35 + 1.36 + const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 3); return fPts[n]; } 1.37 + SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 3); return fPts[n]; } 1.38 + 1.39 + static int AddValidTs(double s[], int realRoots, double* t); 1.40 + void align(int endIndex, SkDPoint* dstPt) const; 1.41 + SkDQuadPair chopAt(double t) const; 1.42 + SkDVector dxdyAtT(double t) const; 1.43 + static int FindExtrema(double a, double b, double c, double tValue[1]); 1.44 + bool isLinear(int startIndex, int endIndex) const; 1.45 + bool monotonicInY() const; 1.46 + double nearestT(const SkDPoint&) const; 1.47 + bool pointInHull(const SkDPoint&) const; 1.48 + SkDPoint ptAtT(double t) const; 1.49 + static int RootsReal(double A, double B, double C, double t[2]); 1.50 + static int RootsValidT(const double A, const double B, const double C, double s[2]); 1.51 + static void SetABC(const double* quad, double* a, double* b, double* c); 1.52 + SkDQuad subDivide(double t1, double t2) const; 1.53 + static SkDQuad SubDivide(const SkPoint a[3], double t1, double t2) { 1.54 + SkDQuad quad; 1.55 + quad.set(a); 1.56 + return quad.subDivide(t1, t2); 1.57 + } 1.58 + SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t2) const; 1.59 + static SkDPoint SubDivide(const SkPoint pts[3], const SkDPoint& a, const SkDPoint& c, 1.60 + double t1, double t2) { 1.61 + SkDQuad quad; 1.62 + quad.set(pts); 1.63 + return quad.subDivide(a, c, t1, t2); 1.64 + } 1.65 + SkDCubic toCubic() const; 1.66 + SkDPoint top(double startT, double endT) const; 1.67 + 1.68 +#ifdef SK_DEBUG 1.69 + void dump(); 1.70 +#endif 1.71 +private: 1.72 +// static double Tangent(const double* quadratic, double t); // uncalled 1.73 +}; 1.74 + 1.75 +#endif