| 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" | 
| 11 #include "SkPathOpsLine.h" | 11 #include "SkPathOpsLine.h" | 
| 12 #include "SkPathOpsPoint.h" | 12 #include "SkPathOpsPoint.h" | 
| 13 #include "SkPathOpsQuad.h" | 13 #include "SkPathOpsQuad.h" | 
| 14 | 14 | 
| 15 class SkIntersections { | 15 class SkIntersections { | 
| 16 public: | 16 public: | 
| 17     SkIntersections() | 17     SkIntersections() | 
| 18         : fSwap(0) | 18         : fSwap(0) | 
| 19 #ifdef SK_DEBUG | 19 #ifdef SK_DEBUG | 
| 20         , fDepth(0) | 20         , fDepth(0) | 
| 21 #endif | 21 #endif | 
| 22     { | 22     { | 
| 23         sk_bzero(fPt, sizeof(fPt)); | 23         sk_bzero(fPt, sizeof(fPt)); | 
| 24         sk_bzero(fT, sizeof(fT)); | 24         sk_bzero(fT, sizeof(fT)); | 
| 25         sk_bzero(fIsCoincident, sizeof(fIsCoincident)); | 25         sk_bzero(fIsCoincident, sizeof(fIsCoincident)); | 
|  | 26         sk_bzero(&fIsNear, sizeof(fIsNear)); | 
| 26         reset(); | 27         reset(); | 
| 27     } | 28     } | 
| 28 | 29 | 
| 29     class TArray { | 30     class TArray { | 
| 30     public: | 31     public: | 
| 31         explicit TArray(const double ts[9]) : fTArray(ts) {} | 32         explicit TArray(const double ts[9]) : fTArray(ts) {} | 
| 32         double operator[](int n) const { | 33         double operator[](int n) const { | 
| 33             return fTArray[n]; | 34             return fTArray[n]; | 
| 34         } | 35         } | 
| 35         const double* fTArray; | 36         const double* fTArray; | 
| 36     }; | 37     }; | 
| 37     TArray operator[](int n) const { return TArray(fT[n]); } | 38     TArray operator[](int n) const { return TArray(fT[n]); } | 
| 38 | 39 | 
| 39     void set(const SkIntersections& i) { | 40     void set(const SkIntersections& i) { | 
| 40         memcpy(fPt, i.fPt, sizeof(fPt)); | 41         memcpy(fPt, i.fPt, sizeof(fPt)); | 
| 41         memcpy(fT, i.fT, sizeof(fT)); | 42         memcpy(fT, i.fT, sizeof(fT)); | 
| 42         memcpy(fIsCoincident, i.fIsCoincident, sizeof(fIsCoincident)); | 43         memcpy(fIsCoincident, i.fIsCoincident, sizeof(fIsCoincident)); | 
|  | 44         memcpy(&fIsNear, &i.fIsNear, sizeof(fIsNear)); | 
| 43         fUsed = i.fUsed; | 45         fUsed = i.fUsed; | 
| 44         fSwap = i.fSwap; | 46         fSwap = i.fSwap; | 
| 45         SkDEBUGCODE(fDepth = i.fDepth); | 47         SkDEBUGCODE(fDepth = i.fDepth); | 
| 46     } | 48     } | 
| 47 | 49 | 
| 48     void allowNear(bool nearAllowed) { | 50     void allowNear(bool nearAllowed) { | 
| 49         fAllowNear = nearAllowed; | 51         fAllowNear = nearAllowed; | 
| 50     } | 52     } | 
| 51 | 53 | 
| 52     int cubic(const SkPoint a[4]) { | 54     int cubic(const SkPoint a[4]) { | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102             return insert(two, one, pt); | 104             return insert(two, one, pt); | 
| 103         } else { | 105         } else { | 
| 104             return insert(one, two, pt); | 106             return insert(one, two, pt); | 
| 105         } | 107         } | 
| 106     } | 108     } | 
| 107 | 109 | 
| 108     bool isCoincident(int index) { | 110     bool isCoincident(int index) { | 
| 109         return (fIsCoincident[0] & 1 << index) != 0; | 111         return (fIsCoincident[0] & 1 << index) != 0; | 
| 110     } | 112     } | 
| 111 | 113 | 
|  | 114     bool isNear(int index) { | 
|  | 115         return (fIsNear & 1 << index) != 0; | 
|  | 116     } | 
|  | 117 | 
| 112     int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
     ar y, | 118     int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
     ar y, | 
| 113                        bool flipped) { | 119                        bool flipped) { | 
| 114         SkDLine line; | 120         SkDLine line; | 
| 115         line.set(a); | 121         line.set(a); | 
| 116         return horizontal(line, left, right, y, flipped); | 122         return horizontal(line, left, right, y, flipped); | 
| 117     } | 123     } | 
| 118 | 124 | 
| 119     int lineVertical(const SkPoint a[2], SkScalar top, SkScalar bottom, SkScalar
      x, bool flipped) { | 125     int lineVertical(const SkPoint a[2], SkScalar top, SkScalar bottom, SkScalar
      x, bool flipped) { | 
| 120         SkDLine line; | 126         SkDLine line; | 
| 121         line.set(a); | 127         line.set(a); | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 199     void flip(); | 205     void flip(); | 
| 200     int horizontal(const SkDLine&, double y); | 206     int horizontal(const SkDLine&, double y); | 
| 201     int horizontal(const SkDLine&, double left, double right, double y, bool fli
     pped); | 207     int horizontal(const SkDLine&, double left, double right, double y, bool fli
     pped); | 
| 202     int horizontal(const SkDQuad&, double left, double right, double y, bool fli
     pped); | 208     int horizontal(const SkDQuad&, double left, double right, double y, bool fli
     pped); | 
| 203     int horizontal(const SkDQuad&, double left, double right, double y, double t
     Range[2]); | 209     int horizontal(const SkDQuad&, double left, double right, double y, double t
     Range[2]); | 
| 204     int horizontal(const SkDCubic&, double y, double tRange[3]); | 210     int horizontal(const SkDCubic&, double y, double tRange[3]); | 
| 205     int horizontal(const SkDCubic&, double left, double right, double y, bool fl
     ipped); | 211     int horizontal(const SkDCubic&, double left, double right, double y, bool fl
     ipped); | 
| 206     int horizontal(const SkDCubic&, double left, double right, double y, double 
     tRange[3]); | 212     int horizontal(const SkDCubic&, double left, double right, double y, double 
     tRange[3]); | 
| 207     // FIXME : does not respect swap | 213     // FIXME : does not respect swap | 
| 208     int insert(double one, double two, const SkDPoint& pt); | 214     int insert(double one, double two, const SkDPoint& pt); | 
|  | 215     void insertNear(double one, double two, const SkDPoint& pt); | 
| 209     // start if index == 0 : end if index == 1 | 216     // start if index == 0 : end if index == 1 | 
| 210     void insertCoincident(double one, double two, const SkDPoint& pt); | 217     void insertCoincident(double one, double two, const SkDPoint& pt); | 
| 211     int intersect(const SkDLine&, const SkDLine&); | 218     int intersect(const SkDLine&, const SkDLine&); | 
| 212     int intersect(const SkDQuad&, const SkDLine&); | 219     int intersect(const SkDQuad&, const SkDLine&); | 
| 213     int intersect(const SkDQuad&, const SkDQuad&); | 220     int intersect(const SkDQuad&, const SkDQuad&); | 
| 214     int intersect(const SkDCubic&);  // return true if cubic self-intersects | 221     int intersect(const SkDCubic&);  // return true if cubic self-intersects | 
| 215     int intersect(const SkDCubic&, const SkDLine&); | 222     int intersect(const SkDCubic&, const SkDLine&); | 
| 216     int intersect(const SkDCubic&, const SkDQuad&); | 223     int intersect(const SkDCubic&, const SkDQuad&); | 
| 217     int intersect(const SkDCubic&, const SkDCubic&); | 224     int intersect(const SkDCubic&, const SkDCubic&); | 
| 218     int intersectRay(const SkDLine&, const SkDLine&); | 225     int intersectRay(const SkDLine&, const SkDLine&); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 236 #else | 243 #else | 
| 237         return 0; | 244         return 0; | 
| 238 #endif | 245 #endif | 
| 239     } | 246     } | 
| 240 | 247 | 
| 241 private: | 248 private: | 
| 242     int computePoints(const SkDLine& line, int used); | 249     int computePoints(const SkDLine& line, int used); | 
| 243     // used by addCoincident to remove ordinary intersections in range | 250     // used by addCoincident to remove ordinary intersections in range | 
| 244  //   void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
     t& endPt); | 251  //   void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
     t& endPt); | 
| 245 | 252 | 
| 246     SkDPoint fPt[9]; | 253     SkDPoint fPt[9];  // FIXME: since scans store points as SkPoint, this should
      also | 
| 247     double fT[2][9]; | 254     double fT[2][9]; | 
| 248     uint16_t fIsCoincident[2];  // bit arrays, one bit set for each coincident T | 255     uint16_t fIsCoincident[2];  // bit set for each curve's coincident T | 
|  | 256     uint16_t fIsNear;  // bit set for each T if 2nd curve's point is near but no
     t equal to 1st | 
| 249     unsigned char fUsed; | 257     unsigned char fUsed; | 
| 250     bool fAllowNear; | 258     bool fAllowNear; | 
| 251     bool fSwap; | 259     bool fSwap; | 
| 252 #ifdef SK_DEBUG | 260 #ifdef SK_DEBUG | 
| 253     int fDepth; | 261     int fDepth; | 
| 254 #endif | 262 #endif | 
| 255 }; | 263 }; | 
| 256 | 264 | 
| 257 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); | 265 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); | 
| 258 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
     Scalar bottom, | 266 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
     Scalar bottom, | 
| 259             SkScalar x, bool flipped); | 267             SkScalar x, bool flipped); | 
| 260 | 268 | 
| 261 #endif | 269 #endif | 
| OLD | NEW | 
|---|