| 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 | 7 |
| 8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
| 9 | 9 |
| 10 void SkIntersections::append(const SkIntersections& i) { | 10 void SkIntersections::append(const SkIntersections& i) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 return 0; | 101 return 0; |
| 102 } | 102 } |
| 103 int remaining = fUsed - index; | 103 int remaining = fUsed - index; |
| 104 if (remaining > 0) { | 104 if (remaining > 0) { |
| 105 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 105 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); |
| 106 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 106 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); |
| 107 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); | 107 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); |
| 108 int clearMask = ~((1 << index) - 1); | 108 int clearMask = ~((1 << index) - 1); |
| 109 fIsCoincident[0] += fIsCoincident[0] & clearMask; | 109 fIsCoincident[0] += fIsCoincident[0] & clearMask; |
| 110 fIsCoincident[1] += fIsCoincident[1] & clearMask; | 110 fIsCoincident[1] += fIsCoincident[1] & clearMask; |
| 111 fIsNear += fIsNear & clearMask; | |
| 112 } | 111 } |
| 113 fPt[index] = pt; | 112 fPt[index] = pt; |
| 114 fT[0][index] = one; | 113 fT[0][index] = one; |
| 115 fT[1][index] = two; | 114 fT[1][index] = two; |
| 116 ++fUsed; | 115 ++fUsed; |
| 117 return index; | 116 return index; |
| 118 } | 117 } |
| 119 | 118 |
| 120 void SkIntersections::insertNear(double one, double two, const SkDPoint& pt) { | |
| 121 int index = insert(one, two, pt); | |
| 122 if (index < 0) { | |
| 123 return; | |
| 124 } | |
| 125 fIsNear |= 1 << index; | |
| 126 } | |
| 127 | |
| 128 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p
t) { | 119 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p
t) { |
| 129 int index = insertSwap(one, two, pt); | 120 int index = insertSwap(one, two, pt); |
| 130 int bit = 1 << index; | 121 int bit = 1 << index; |
| 131 fIsCoincident[0] |= bit; | 122 fIsCoincident[0] |= bit; |
| 132 fIsCoincident[1] |= bit; | 123 fIsCoincident[1] |= bit; |
| 133 } | 124 } |
| 134 | 125 |
| 135 int SkIntersections::lineRay(const SkPoint pts[2], const SkDLine& line) { | 126 int SkIntersections::lineRay(const SkPoint pts[2], const SkDLine& line) { |
| 136 SkDLine l; | 127 SkDLine l; |
| 137 l.set(pts); | 128 l.set(pts); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 return; | 172 return; |
| 182 } | 173 } |
| 183 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); | 174 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); |
| 184 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); | 175 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); |
| 185 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); | 176 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); |
| 186 SkASSERT(fIsCoincident[0] == 0); | 177 SkASSERT(fIsCoincident[0] == 0); |
| 187 int coBit = fIsCoincident[0] & (1 << index); | 178 int coBit = fIsCoincident[0] & (1 << index); |
| 188 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; | 179 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; |
| 189 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); | 180 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); |
| 190 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; | 181 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; |
| 191 fIsNear -= ((fIsNear >> 1) & ~((1 << index) - 1)) + (fIsNear & (1 << index))
; | |
| 192 } | 182 } |
| 193 | 183 |
| 194 void SkIntersections::swapPts() { | 184 void SkIntersections::swapPts() { |
| 195 int index; | 185 int index; |
| 196 for (index = 0; index < fUsed; ++index) { | 186 for (index = 0; index < fUsed; ++index) { |
| 197 SkTSwap(fT[0][index], fT[1][index]); | 187 SkTSwap(fT[0][index], fT[1][index]); |
| 198 } | 188 } |
| 199 } | 189 } |
| 200 | 190 |
| 201 int SkIntersections::verticalLine(const SkPoint a[2], SkScalar top, SkScalar bot
tom, | 191 int SkIntersections::verticalLine(const SkPoint a[2], SkScalar top, SkScalar bot
tom, |
| 202 SkScalar x, bool flipped) { | 192 SkScalar x, bool flipped) { |
| 203 SkDLine line; | 193 SkDLine line; |
| 204 line.set(a); | 194 line.set(a); |
| 205 return vertical(line, top, bottom, x, flipped); | 195 return vertical(line, top, bottom, x, flipped); |
| 206 } | 196 } |
| 207 | 197 |
| 208 int SkIntersections::verticalQuad(const SkPoint a[3], SkScalar top, SkScalar bot
tom, | 198 int SkIntersections::verticalQuad(const SkPoint a[3], SkScalar top, SkScalar bot
tom, |
| 209 SkScalar x, bool flipped) { | 199 SkScalar x, bool flipped) { |
| 210 SkDQuad quad; | 200 SkDQuad quad; |
| 211 quad.set(a); | 201 quad.set(a); |
| 212 return vertical(quad, top, bottom, x, flipped); | 202 return vertical(quad, top, bottom, x, flipped); |
| 213 } | 203 } |
| 214 | 204 |
| 215 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, | 205 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, |
| 216 SkScalar x, bool flipped) { | 206 SkScalar x, bool flipped) { |
| 217 SkDCubic cubic; | 207 SkDCubic cubic; |
| 218 cubic.set(a); | 208 cubic.set(a); |
| 219 return vertical(cubic, top, bottom, x, flipped); | 209 return vertical(cubic, top, bottom, x, flipped); |
| 220 } | 210 } |
| OLD | NEW |