Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef SkPathOpsCubic_DEFINED |
michael@0 | 9 | #define SkPathOpsCubic_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkPath.h" |
michael@0 | 12 | #include "SkPathOpsPoint.h" |
michael@0 | 13 | #include "SkTArray.h" |
michael@0 | 14 | |
michael@0 | 15 | struct SkDCubicPair { |
michael@0 | 16 | const SkDCubic& first() const { return (const SkDCubic&) pts[0]; } |
michael@0 | 17 | const SkDCubic& second() const { return (const SkDCubic&) pts[3]; } |
michael@0 | 18 | SkDPoint pts[7]; |
michael@0 | 19 | }; |
michael@0 | 20 | |
michael@0 | 21 | struct SkDCubic { |
michael@0 | 22 | SkDPoint fPts[4]; |
michael@0 | 23 | |
michael@0 | 24 | void set(const SkPoint pts[4]) { |
michael@0 | 25 | fPts[0] = pts[0]; |
michael@0 | 26 | fPts[1] = pts[1]; |
michael@0 | 27 | fPts[2] = pts[2]; |
michael@0 | 28 | fPts[3] = pts[3]; |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | static const int gPrecisionUnit; |
michael@0 | 32 | |
michael@0 | 33 | const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 4); return fPts[n]; } |
michael@0 | 34 | SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 4); return fPts[n]; } |
michael@0 | 35 | |
michael@0 | 36 | void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const; |
michael@0 | 37 | double calcPrecision() const; |
michael@0 | 38 | SkDCubicPair chopAt(double t) const; |
michael@0 | 39 | bool clockwise() const; |
michael@0 | 40 | static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D); |
michael@0 | 41 | bool controlsContainedByEnds() const; |
michael@0 | 42 | SkDVector dxdyAtT(double t) const; |
michael@0 | 43 | bool endsAreExtremaInXOrY() const; |
michael@0 | 44 | static int FindExtrema(double a, double b, double c, double d, double tValue[2]); |
michael@0 | 45 | int findInflections(double tValues[]) const; |
michael@0 | 46 | |
michael@0 | 47 | static int FindInflections(const SkPoint a[4], double tValues[]) { |
michael@0 | 48 | SkDCubic cubic; |
michael@0 | 49 | cubic.set(a); |
michael@0 | 50 | return cubic.findInflections(tValues); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | int findMaxCurvature(double tValues[]) const; |
michael@0 | 54 | bool isLinear(int startIndex, int endIndex) const; |
michael@0 | 55 | bool monotonicInY() const; |
michael@0 | 56 | SkDPoint ptAtT(double t) const; |
michael@0 | 57 | static int RootsReal(double A, double B, double C, double D, double t[3]); |
michael@0 | 58 | static int RootsValidT(const double A, const double B, const double C, double D, double s[3]); |
michael@0 | 59 | bool serpentine() const; |
michael@0 | 60 | SkDCubic subDivide(double t1, double t2) const; |
michael@0 | 61 | |
michael@0 | 62 | static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) { |
michael@0 | 63 | SkDCubic cubic; |
michael@0 | 64 | cubic.set(a); |
michael@0 | 65 | return cubic.subDivide(t1, t2); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, SkDPoint p[2]) const; |
michael@0 | 69 | |
michael@0 | 70 | static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoint& d, double t1, |
michael@0 | 71 | double t2, SkDPoint p[2]) { |
michael@0 | 72 | SkDCubic cubic; |
michael@0 | 73 | cubic.set(pts); |
michael@0 | 74 | cubic.subDivide(a, d, t1, t2, p); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | SkDPoint top(double startT, double endT) const; |
michael@0 | 78 | void toQuadraticTs(double precision, SkTArray<double, true>* ts) const; |
michael@0 | 79 | SkDQuad toQuad() const; |
michael@0 | 80 | |
michael@0 | 81 | #ifdef SK_DEBUG |
michael@0 | 82 | void dump(); |
michael@0 | 83 | #endif |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | #endif |