Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: src/pathops/SkPathOpsCubic.h

Issue 1107353004: align top and bounds computations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up code Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pathops/SkPathOpsConic.cpp ('k') | src/pathops/SkPathOpsCubic.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkPathOpsCubic_DEFINED 8 #ifndef SkPathOpsCubic_DEFINED
9 #define SkPathOpsCubic_DEFINED 9 #define SkPathOpsCubic_DEFINED
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 static bool IsCubic() { return true; } 51 static bool IsCubic() { return true; }
52 52
53 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount ); return fPts[n]; } 53 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount ); return fPts[n]; }
54 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fP ts[n]; } 54 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fP ts[n]; }
55 55
56 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const; 56 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const;
57 double binarySearch(double min, double max, double axisIntercept, SearchAxis xAxis) const; 57 double binarySearch(double min, double max, double axisIntercept, SearchAxis xAxis) const;
58 double calcPrecision() const; 58 double calcPrecision() const;
59 SkDCubicPair chopAt(double t) const; 59 SkDCubicPair chopAt(double t) const;
60 bool clockwise(bool* swap) const; 60 bool clockwise(const SkDCubic& whole, bool* swap) const;
61 static bool Clockwise(const SkPoint* pts, double startT, double endT, bool* swap); 61 static bool Clockwise(const SkPoint* pts, double startT, double endT, bool* swap);
62 static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D); 62 static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D);
63 static bool ComplexBreak(const SkPoint pts[4], SkScalar* t, CubicType* cubic Type); 63 static bool ComplexBreak(const SkPoint pts[4], SkScalar* t, CubicType* cubic Type);
64 int convexHull(char order[kPointCount]) const; 64 int convexHull(char order[kPointCount]) const;
65 65
66 void debugInit() { 66 void debugInit() {
67 sk_bzero(fPts, sizeof(fPts)); 67 sk_bzero(fPts, sizeof(fPts));
68 } 68 }
69 69
70 void dump() const; // callable from the debugger when the implementation co de is linked in 70 void dump() const; // callable from the debugger when the implementation co de is linked in
71 void dumpID(int id) const; 71 void dumpID(int id) const;
72 void dumpInner() const; 72 void dumpInner() const;
73 SkDVector dxdyAtT(double t) const; 73 SkDVector dxdyAtT(double t) const;
74 bool endsAreExtremaInXOrY() const; 74 bool endsAreExtremaInXOrY() const;
75 static int FindExtrema(double a, double b, double c, double d, double tValue [2]); 75 static int FindExtrema(const double src[], double tValue[2]);
76 int findInflections(double tValues[2]) const; 76 int findInflections(double tValues[2]) const;
77 77
78 static int FindInflections(const SkPoint a[kPointCount], double tValues[2]) { 78 static int FindInflections(const SkPoint a[kPointCount], double tValues[2]) {
79 SkDCubic cubic; 79 SkDCubic cubic;
80 cubic.set(a); 80 cubic.set(a);
81 return cubic.findInflections(tValues); 81 return cubic.findInflections(tValues);
82 } 82 }
83 83
84 int findMaxCurvature(double tValues[]) const; 84 int findMaxCurvature(double tValues[]) const;
85 bool hullIntersects(const SkDCubic& c2, bool* isLinear) const; 85 bool hullIntersects(const SkDCubic& c2, bool* isLinear) const;
86 bool hullIntersects(const SkDConic& c, bool* isLinear) const; 86 bool hullIntersects(const SkDConic& c, bool* isLinear) const;
87 bool hullIntersects(const SkDQuad& c2, bool* isLinear) const; 87 bool hullIntersects(const SkDQuad& c2, bool* isLinear) const;
88 bool hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const; 88 bool hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const;
89 bool isLinear(int startIndex, int endIndex) const; 89 bool isLinear(int startIndex, int endIndex) const;
90 bool monotonicInX() const;
90 bool monotonicInY() const; 91 bool monotonicInY() const;
91 void otherPts(int index, const SkDPoint* o1Pts[kPointCount - 1]) const; 92 void otherPts(int index, const SkDPoint* o1Pts[kPointCount - 1]) const;
92 SkDPoint ptAtT(double t) const; 93 SkDPoint ptAtT(double t) const;
93 static int RootsReal(double A, double B, double C, double D, double t[3]); 94 static int RootsReal(double A, double B, double C, double D, double t[3]);
94 static int RootsValidT(const double A, const double B, const double C, doubl e D, double s[3]); 95 static int RootsValidT(const double A, const double B, const double C, doubl e D, double s[3]);
95 96
96 int searchRoots(double extremes[6], int extrema, double axisIntercept, 97 int searchRoots(double extremes[6], int extrema, double axisIntercept,
97 SearchAxis xAxis, double* validRoots) const; 98 SearchAxis xAxis, double* validRoots) const;
98 99
99 const SkDCubic& set(const SkPoint pts[kPointCount]) { 100 const SkDCubic& set(const SkPoint pts[kPointCount]) {
(...skipping 14 matching lines...) Expand all
114 115
115 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S kDPoint p[2]) const; 116 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S kDPoint p[2]) const;
116 117
117 static void SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a, con st SkDPoint& d, double t1, 118 static void SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a, con st SkDPoint& d, double t1,
118 double t2, SkDPoint p[2]) { 119 double t2, SkDPoint p[2]) {
119 SkDCubic cubic; 120 SkDCubic cubic;
120 cubic.set(pts); 121 cubic.set(pts);
121 cubic.subDivide(a, d, t1, t2, p); 122 cubic.subDivide(a, d, t1, t2, p);
122 } 123 }
123 124
124 SkDPoint top(double startT, double endT, double* topT) const;
125 SkDQuad toQuad() const; 125 SkDQuad toQuad() const;
126 126
127 static const int gPrecisionUnit; 127 static const int gPrecisionUnit;
128 128
129 SkDPoint fPts[kPointCount]; 129 SkDPoint fPts[kPointCount];
130 }; 130 };
131 131
132 /* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask 132 /* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask
133 that computes the other two. Note that: 133 that computes the other two. Note that:
134 134
135 one ^ two == 3 for (0, 3), (1, 2) 135 one ^ two == 3 for (0, 3), (1, 2)
136 one ^ two < 3 for (0, 1), (0, 2), (1, 3), (2, 3) 136 one ^ two < 3 for (0, 1), (0, 2), (1, 3), (2, 3)
137 3 - (one ^ two) is either 0, 1, or 2 137 3 - (one ^ two) is either 0, 1, or 2
138 1 >> (3 - (one ^ two)) is either 0 or 1 138 1 >> (3 - (one ^ two)) is either 0 or 1
139 thus: 139 thus:
140 returned == 2 for (0, 3), (1, 2) 140 returned == 2 for (0, 3), (1, 2)
141 returned == 3 for (0, 1), (0, 2), (1, 3), (2, 3) 141 returned == 3 for (0, 1), (0, 2), (1, 3), (2, 3)
142 given that: 142 given that:
143 (0, 3) ^ 2 -> (2, 1) (1, 2) ^ 2 -> (3, 0) 143 (0, 3) ^ 2 -> (2, 1) (1, 2) ^ 2 -> (3, 0)
144 (0, 1) ^ 3 -> (3, 2) (0, 2) ^ 3 -> (3, 1) (1, 3) ^ 3 -> (2, 0) (2, 3) ^ 3 -> (1, 0) 144 (0, 1) ^ 3 -> (3, 2) (0, 2) ^ 3 -> (3, 1) (1, 3) ^ 3 -> (2, 0) (2, 3) ^ 3 -> (1, 0)
145 */ 145 */
146 inline int other_two(int one, int two) { 146 inline int other_two(int one, int two) {
147 return 1 >> (3 - (one ^ two)) ^ 3; 147 return 1 >> (3 - (one ^ two)) ^ 3;
148 } 148 }
149 149
150 #endif 150 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsConic.cpp ('k') | src/pathops/SkPathOpsCubic.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698