| 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 Intersections_DEFINE | 7 #ifndef Intersections_DEFINE |
| 8 #define Intersections_DEFINE | 8 #define Intersections_DEFINE |
| 9 | 9 |
| 10 class Intersections { | 10 class Intersections { |
| 11 public: | 11 public: |
| 12 Intersections() | 12 Intersections() |
| 13 : fFlip(0) | 13 : fFlip(0) |
| 14 #if SK_DEBUG | 14 #ifdef SK_DEBUG |
| 15 , fDepth(0) | 15 , fDepth(0) |
| 16 #endif | 16 #endif |
| 17 , fSwap(0) | 17 , fSwap(0) |
| 18 { | 18 { |
| 19 #if SK_DEBUG | 19 #ifdef SK_DEBUG |
| 20 bzero(fPt, sizeof(fPt)); | 20 bzero(fPt, sizeof(fPt)); |
| 21 bzero(fT, sizeof(fT)); | 21 bzero(fT, sizeof(fT)); |
| 22 bzero(fIsCoincident, sizeof(fIsCoincident)); | 22 bzero(fIsCoincident, sizeof(fIsCoincident)); |
| 23 #endif | 23 #endif |
| 24 reset(); | 24 reset(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 int coincidentUsed() const { | 27 int coincidentUsed() const { |
| 28 if (!fIsCoincident[0]) { | 28 if (!fIsCoincident[0]) { |
| 29 SkASSERT(!fIsCoincident[0]); | 29 SkASSERT(!fIsCoincident[0]); |
| 30 return 0; | 30 return 0; |
| 31 } | 31 } |
| 32 int count = 0; | 32 int count = 0; |
| 33 SkDEBUGCODE(int count2 = 0;) | 33 SkDEBUGCODE(int count2 = 0;) |
| 34 for (int index = 0; index < fUsed; ++index) { | 34 for (int index = 0; index < fUsed; ++index) { |
| 35 if (fIsCoincident[0] & (1 << index)) { | 35 if (fIsCoincident[0] & (1 << index)) { |
| 36 ++count; | 36 ++count; |
| 37 } | 37 } |
| 38 #if SK_DEBUG | 38 #ifdef SK_DEBUG |
| 39 if (fIsCoincident[1] & (1 << index)) { | 39 if (fIsCoincident[1] & (1 << index)) { |
| 40 ++count2; | 40 ++count2; |
| 41 } | 41 } |
| 42 #endif | 42 #endif |
| 43 } | 43 } |
| 44 SkASSERT(count == count2); | 44 SkASSERT(count == count2); |
| 45 return count; | 45 return count; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void offset(int base, double start, double end) { | 48 void offset(int base, double start, double end) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 void downDepth() { | 114 void downDepth() { |
| 115 SkASSERT(--fDepth >= 0); | 115 SkASSERT(--fDepth >= 0); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void upDepth() { | 118 void upDepth() { |
| 119 SkASSERT(++fDepth < 16); | 119 SkASSERT(++fDepth < 16); |
| 120 } | 120 } |
| 121 | 121 |
| 122 #if SK_DEBUG | 122 #ifdef SK_DEBUG |
| 123 int depth() const { | 123 int depth() const { |
| 124 return fDepth; | 124 return fDepth; |
| 125 } | 125 } |
| 126 #endif | 126 #endif |
| 127 | 127 |
| 128 _Point fPt[9]; | 128 _Point fPt[9]; |
| 129 double fT[2][9]; | 129 double fT[2][9]; |
| 130 unsigned short fIsCoincident[2]; // bit arrays, one bit set for each coincid
ent T | 130 unsigned short fIsCoincident[2]; // bit arrays, one bit set for each coincid
ent T |
| 131 unsigned char fUsed; | 131 unsigned char fUsed; |
| 132 bool fFlip; | 132 bool fFlip; |
| 133 bool fUnsortable; | 133 bool fUnsortable; |
| 134 #if SK_DEBUG | 134 #ifdef SK_DEBUG |
| 135 int fDepth; | 135 int fDepth; |
| 136 #endif | 136 #endif |
| 137 protected: | 137 protected: |
| 138 // used by addCoincident to remove ordinary intersections in range | 138 // used by addCoincident to remove ordinary intersections in range |
| 139 void remove(double one, double two, const _Point& startPt, const _Point& end
Pt); | 139 void remove(double one, double two, const _Point& startPt, const _Point& end
Pt); |
| 140 private: | 140 private: |
| 141 bool fSwap; | 141 bool fSwap; |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 #endif | 144 #endif |
| OLD | NEW |