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 int SkIntersections::closestTo(double rangeStart, double rangeEnd, const SkDPoin
t& testPt, | 10 int SkIntersections::closestTo(double rangeStart, double rangeEnd, const SkDPoin
t& testPt, |
(...skipping 29 matching lines...) Expand all Loading... |
40 #ifdef SK_DEBUG | 40 #ifdef SK_DEBUG |
41 if (fIsCoincident[1] & (1 << index)) { | 41 if (fIsCoincident[1] & (1 << index)) { |
42 ++count2; | 42 ++count2; |
43 } | 43 } |
44 #endif | 44 #endif |
45 } | 45 } |
46 SkASSERT(count == count2); | 46 SkASSERT(count == count2); |
47 return count; | 47 return count; |
48 } | 48 } |
49 | 49 |
50 int (SkIntersections::* const CurveVertical[])(const SkPoint[], SkScalar, SkScal
ar, SkScalar, bool) = { | 50 int (SkIntersections::* const CurveVertical[])(const SkPoint[], SkScalar, |
| 51 SkScalar, SkScalar, SkScalar, boo
l) = { |
51 NULL, | 52 NULL, |
52 &SkIntersections::verticalLine, | 53 &SkIntersections::verticalLine, |
53 &SkIntersections::verticalQuad, | 54 &SkIntersections::verticalQuad, |
| 55 &SkIntersections::verticalConic, |
54 &SkIntersections::verticalCubic | 56 &SkIntersections::verticalCubic |
55 }; | 57 }; |
56 | 58 |
57 void SkIntersections::flip() { | 59 void SkIntersections::flip() { |
58 for (int index = 0; index < fUsed; ++index) { | 60 for (int index = 0; index < fUsed; ++index) { |
59 fT[1][index] = 1 - fT[1][index]; | 61 fT[1][index] = 1 - fT[1][index]; |
60 } | 62 } |
61 } | 63 } |
62 | 64 |
63 int SkIntersections::insert(double one, double two, const SkDPoint& pt) { | 65 int SkIntersections::insert(double one, double two, const SkDPoint& pt) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); | 188 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); |
187 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); | 189 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); |
188 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); | 190 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); |
189 // SkASSERT(fIsCoincident[0] == 0); | 191 // SkASSERT(fIsCoincident[0] == 0); |
190 int coBit = fIsCoincident[0] & (1 << index); | 192 int coBit = fIsCoincident[0] & (1 << index); |
191 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; | 193 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; |
192 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); | 194 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); |
193 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; | 195 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; |
194 } | 196 } |
195 | 197 |
196 int SkIntersections::verticalLine(const SkPoint a[2], SkScalar top, SkScalar bot
tom, | 198 int SkIntersections::verticalConic(const SkPoint a[3], SkScalar weight, |
197 SkScalar x, bool flipped) { | 199 SkScalar top, SkScalar bottom, SkScalar x, bool flipped) { |
| 200 SkDConic conic; |
| 201 conic.set(a, weight); |
| 202 return vertical(conic, top, bottom, x, flipped); |
| 203 } |
| 204 |
| 205 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar weight, |
| 206 SkScalar top, SkScalar bottom, SkScalar x, bool flipped) { |
| 207 SkDCubic cubic; |
| 208 cubic.set(a); |
| 209 return vertical(cubic, top, bottom, x, flipped); |
| 210 } |
| 211 |
| 212 int SkIntersections::verticalLine(const SkPoint a[2], SkScalar weight, |
| 213 SkScalar top, SkScalar bottom, SkScalar x, bool flipped) { |
198 SkDLine line; | 214 SkDLine line; |
199 line.set(a); | 215 line.set(a); |
200 return vertical(line, top, bottom, x, flipped); | 216 return vertical(line, top, bottom, x, flipped); |
201 } | 217 } |
202 | 218 |
203 int SkIntersections::verticalQuad(const SkPoint a[3], SkScalar top, SkScalar bot
tom, | 219 int SkIntersections::verticalQuad(const SkPoint a[3], SkScalar weight, |
204 SkScalar x, bool flipped) { | 220 SkScalar top, SkScalar bottom, SkScalar x, bool flipped) { |
205 SkDQuad quad; | 221 SkDQuad quad; |
206 quad.set(a); | 222 quad.set(a); |
207 return vertical(quad, top, bottom, x, flipped); | 223 return vertical(quad, top, bottom, x, flipped); |
208 } | 224 } |
209 | |
210 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, | |
211 SkScalar x, bool flipped) { | |
212 SkDCubic cubic; | |
213 cubic.set(a); | |
214 return vertical(cubic, top, bottom, x, flipped); | |
215 } | |
OLD | NEW |