Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2012 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SkPathOpsCubic_DEFINED | |
| 9 #define SkPathOpsCubic_DEFINED | |
| 10 | |
| 11 #include "SkPathOpsPoint.h" | |
| 12 #include "SkTDArray.h" | |
| 13 | |
| 14 struct SkDCubicPair { | |
| 15 const SkDCubic& first() const { return (const SkDCubic&) pts[0]; } | |
| 16 const SkDCubic& second() const { return (const SkDCubic&) pts[3]; } | |
| 17 SkDPoint pts[7]; | |
| 18 }; | |
| 19 | |
| 20 struct SkDCubic { | |
| 21 SkDPoint fPts[4]; | |
| 22 | |
| 23 void set(const SkPoint pts[4]) { | |
| 24 fPts[0] = pts[0]; | |
| 25 fPts[1] = pts[1]; | |
| 26 fPts[2] = pts[2]; | |
| 27 fPts[3] = pts[3]; | |
| 28 } | |
| 29 | |
| 30 static const int gPrecisionUnit; | |
| 31 | |
| 32 const SkDPoint& operator[](int n) const { return fPts[n]; } | |
|
whunt
2013/03/22 18:16:06
DCHECK/assert n < 4
reed1
2013/03/22 19:00:37
whunt: good catch. fyi -- in skia we use SkASSERT(
caryclark
2013/03/22 19:38:51
Done.
caryclark
2013/03/22 20:05:00
Done.
| |
| 33 SkDPoint& operator[](int n) { return fPts[n]; } | |
|
whunt
2013/03/22 18:16:06
DCHECK/assert n < 4
caryclark
2013/03/22 19:38:51
Done.
| |
| 34 | |
| 35 double calcPrecision() const; | |
| 36 SkDCubicPair chopAt(double t) const; | |
| 37 bool clockwise() const; | |
| 38 static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D); | |
| 39 bool controlsContainedByEnds() const; | |
| 40 SkDVector dxdyAtT(double t) const; | |
| 41 bool endsAreExtremaInXOrY() const; | |
| 42 static int FindExtrema(double a, double b, double c, double d, double tValue [2]); | |
| 43 int findInflections(double tValues[]) const; | |
| 44 int findMaxCurvature(double tValues[]) const; | |
| 45 bool isLinear(int startIndex, int endIndex) const; | |
| 46 bool monotonicInY() const; | |
| 47 static int RootsReal(double A, double B, double C, double D, double t[3]); | |
| 48 static int RootsValidT(const double A, const double B, const double C, doubl e D, double s[3]); | |
| 49 bool serpentine() const; | |
| 50 SkDCubic subDivide(double t1, double t2) const; | |
| 51 static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) { | |
| 52 SkDCubic cubic; | |
| 53 cubic.set(a); | |
| 54 return cubic.subDivide(t1, t2); | |
| 55 } | |
| 56 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S kDPoint p[2]) const; | |
| 57 | |
| 58 static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoin t& d, double t1, | |
| 59 double t2, SkDPoint p[2]) { | |
| 60 SkDCubic cubic; | |
| 61 cubic.set(pts); | |
| 62 cubic.subDivide(a, d, t1, t2, p); | |
| 63 } | |
| 64 | |
| 65 SkDPoint top(double startT, double endT) const; | |
| 66 void toQuadraticTs(double precision, SkTDArray<double>* ts) const; | |
| 67 SkDQuad toQuad() const; | |
| 68 SkDPoint xyAtT(double t) const; | |
| 69 }; | |
| 70 | |
| 71 #endif | |
| OLD | NEW |