| OLD | NEW |
| 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 #ifndef SkIntersections_DEFINE | 7 #ifndef SkIntersections_DEFINE |
| 8 #define SkIntersections_DEFINE | 8 #define SkIntersections_DEFINE |
| 9 | 9 |
| 10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 void set(const SkIntersections& i) { | 39 void set(const SkIntersections& i) { |
| 40 memcpy(fPt, i.fPt, sizeof(fPt)); | 40 memcpy(fPt, i.fPt, sizeof(fPt)); |
| 41 memcpy(fT, i.fT, sizeof(fT)); | 41 memcpy(fT, i.fT, sizeof(fT)); |
| 42 memcpy(fIsCoincident, i.fIsCoincident, sizeof(fIsCoincident)); | 42 memcpy(fIsCoincident, i.fIsCoincident, sizeof(fIsCoincident)); |
| 43 fUsed = i.fUsed; | 43 fUsed = i.fUsed; |
| 44 fSwap = i.fSwap; | 44 fSwap = i.fSwap; |
| 45 SkDEBUGCODE(fDepth = i.fDepth); | 45 SkDEBUGCODE(fDepth = i.fDepth); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void allowNear(bool nearAllowed) { |
| 49 fAllowNear = nearAllowed; |
| 50 } |
| 51 |
| 48 int cubic(const SkPoint a[4]) { | 52 int cubic(const SkPoint a[4]) { |
| 49 SkDCubic cubic; | 53 SkDCubic cubic; |
| 50 cubic.set(a); | 54 cubic.set(a); |
| 51 return intersect(cubic); | 55 return intersect(cubic); |
| 52 } | 56 } |
| 53 | 57 |
| 54 int cubicCubic(const SkPoint a[4], const SkPoint b[4]) { | 58 int cubicCubic(const SkPoint a[4], const SkPoint b[4]) { |
| 55 SkDCubic aCubic; | 59 SkDCubic aCubic; |
| 56 aCubic.set(a); | 60 aCubic.set(a); |
| 57 SkDCubic bCubic; | 61 SkDCubic bCubic; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 81 } | 85 } |
| 82 | 86 |
| 83 int cubicQuad(const SkPoint a[4], const SkPoint b[3]) { | 87 int cubicQuad(const SkPoint a[4], const SkPoint b[3]) { |
| 84 SkDCubic cubic; | 88 SkDCubic cubic; |
| 85 cubic.set(a); | 89 cubic.set(a); |
| 86 SkDQuad quad; | 90 SkDQuad quad; |
| 87 quad.set(b); | 91 quad.set(b); |
| 88 return intersect(cubic, quad); | 92 return intersect(cubic, quad); |
| 89 } | 93 } |
| 90 | 94 |
| 95 bool hasT(double t) const { |
| 96 SkASSERT(t == 0 || t == 1); |
| 97 return fUsed > 0 && (t == 0 ? fT[0][0] == 0 : fT[0][fUsed - 1] == 1); |
| 98 } |
| 99 |
| 91 int insertSwap(double one, double two, const SkDPoint& pt) { | 100 int insertSwap(double one, double two, const SkDPoint& pt) { |
| 92 if (fSwap) { | 101 if (fSwap) { |
| 93 return insert(two, one, pt); | 102 return insert(two, one, pt); |
| 94 } else { | 103 } else { |
| 95 return insert(one, two, pt); | 104 return insert(one, two, pt); |
| 96 } | 105 } |
| 97 } | 106 } |
| 98 | 107 |
| 99 int insertSwap(double one, double two, double x, double y) { | |
| 100 if (fSwap) { | |
| 101 return insert(two, one, x, y); | |
| 102 } else { | |
| 103 return insert(one, two, x, y); | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 bool isCoincident(int index) { | 108 bool isCoincident(int index) { |
| 108 return (fIsCoincident[0] & 1 << index) != 0; | 109 return (fIsCoincident[0] & 1 << index) != 0; |
| 109 } | 110 } |
| 110 | 111 |
| 111 int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
ar y, | 112 int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
ar y, |
| 112 bool flipped) { | 113 bool flipped) { |
| 113 SkDLine line; | 114 SkDLine line; |
| 114 line.set(a); | 115 line.set(a); |
| 115 return horizontal(line, left, right, y, flipped); | 116 return horizontal(line, left, right, y, flipped); |
| 116 } | 117 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 SkDQuad bQuad; | 160 SkDQuad bQuad; |
| 160 bQuad.set(b); | 161 bQuad.set(b); |
| 161 return intersect(aQuad, bQuad); | 162 return intersect(aQuad, bQuad); |
| 162 } | 163 } |
| 163 | 164 |
| 164 int quadRay(const SkPoint pts[3], const SkDLine& line); | 165 int quadRay(const SkPoint pts[3], const SkDLine& line); |
| 165 void removeOne(int index); | 166 void removeOne(int index); |
| 166 | 167 |
| 167 // leaves flip, swap alone | 168 // leaves flip, swap alone |
| 168 void reset() { | 169 void reset() { |
| 170 fAllowNear = true; |
| 169 fUsed = 0; | 171 fUsed = 0; |
| 170 } | 172 } |
| 171 | 173 |
| 172 void swap() { | 174 void swap() { |
| 173 fSwap ^= true; | 175 fSwap ^= true; |
| 174 } | 176 } |
| 175 | 177 |
| 176 void swapPts(); | 178 void swapPts(); |
| 177 | 179 |
| 178 bool swapped() const { | 180 bool swapped() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 197 void flip(); | 199 void flip(); |
| 198 int horizontal(const SkDLine&, double y); | 200 int horizontal(const SkDLine&, double y); |
| 199 int horizontal(const SkDLine&, double left, double right, double y, bool fli
pped); | 201 int horizontal(const SkDLine&, double left, double right, double y, bool fli
pped); |
| 200 int horizontal(const SkDQuad&, double left, double right, double y, bool fli
pped); | 202 int horizontal(const SkDQuad&, double left, double right, double y, bool fli
pped); |
| 201 int horizontal(const SkDQuad&, double left, double right, double y, double t
Range[2]); | 203 int horizontal(const SkDQuad&, double left, double right, double y, double t
Range[2]); |
| 202 int horizontal(const SkDCubic&, double y, double tRange[3]); | 204 int horizontal(const SkDCubic&, double y, double tRange[3]); |
| 203 int horizontal(const SkDCubic&, double left, double right, double y, bool fl
ipped); | 205 int horizontal(const SkDCubic&, double left, double right, double y, bool fl
ipped); |
| 204 int horizontal(const SkDCubic&, double left, double right, double y, double
tRange[3]); | 206 int horizontal(const SkDCubic&, double left, double right, double y, double
tRange[3]); |
| 205 // FIXME : does not respect swap | 207 // FIXME : does not respect swap |
| 206 int insert(double one, double two, const SkDPoint& pt); | 208 int insert(double one, double two, const SkDPoint& pt); |
| 207 int insert(double one, double two, double x, double y); | |
| 208 // start if index == 0 : end if index == 1 | 209 // start if index == 0 : end if index == 1 |
| 209 void insertCoincident(double one, double two, const SkDPoint& pt); | 210 void insertCoincident(double one, double two, const SkDPoint& pt); |
| 210 void insertCoincidentPair(double s1, double e1, double s2, double e2, | 211 void insertCoincidentPair(double s1, double e1, double s2, double e2, |
| 211 const SkDPoint& startPt, const SkDPoint& endPt); | 212 const SkDPoint& startPt, const SkDPoint& endPt); |
| 212 int intersect(const SkDLine&, const SkDLine&); | 213 int intersect(const SkDLine&, const SkDLine&); |
| 213 int intersect(const SkDQuad&, const SkDLine&); | 214 int intersect(const SkDQuad&, const SkDLine&); |
| 214 int intersect(const SkDQuad&, const SkDQuad&); | 215 int intersect(const SkDQuad&, const SkDQuad&); |
| 215 int intersect(const SkDCubic&); // return true if cubic self-intersects | 216 int intersect(const SkDCubic&); // return true if cubic self-intersects |
| 216 int intersect(const SkDCubic&, const SkDLine&); | 217 int intersect(const SkDCubic&, const SkDLine&); |
| 217 int intersect(const SkDCubic&, const SkDQuad&); | 218 int intersect(const SkDCubic&, const SkDQuad&); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 241 | 242 |
| 242 private: | 243 private: |
| 243 int computePoints(const SkDLine& line, int used); | 244 int computePoints(const SkDLine& line, int used); |
| 244 // used by addCoincident to remove ordinary intersections in range | 245 // used by addCoincident to remove ordinary intersections in range |
| 245 // void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
t& endPt); | 246 // void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
t& endPt); |
| 246 | 247 |
| 247 SkDPoint fPt[9]; | 248 SkDPoint fPt[9]; |
| 248 double fT[2][9]; | 249 double fT[2][9]; |
| 249 uint16_t fIsCoincident[2]; // bit arrays, one bit set for each coincident T | 250 uint16_t fIsCoincident[2]; // bit arrays, one bit set for each coincident T |
| 250 unsigned char fUsed; | 251 unsigned char fUsed; |
| 252 bool fAllowNear; |
| 251 bool fSwap; | 253 bool fSwap; |
| 252 #ifdef SK_DEBUG | 254 #ifdef SK_DEBUG |
| 253 int fDepth; | 255 int fDepth; |
| 254 #endif | 256 #endif |
| 255 }; | 257 }; |
| 256 | 258 |
| 257 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); | 259 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); |
| 258 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
Scalar bottom, | 260 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
Scalar bottom, |
| 259 SkScalar x, bool flipped); | 261 SkScalar x, bool flipped); |
| 260 | 262 |
| 261 #endif | 263 #endif |
| OLD | NEW |