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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 double oldOne = fT[0][index]; | 72 double oldOne = fT[0][index]; |
73 double oldTwo = fT[1][index]; | 73 double oldTwo = fT[1][index]; |
74 if (one == oldOne && two == oldTwo) { | 74 if (one == oldOne && two == oldTwo) { |
75 return -1; | 75 return -1; |
76 } | 76 } |
77 if (more_roughly_equal(oldOne, one) && more_roughly_equal(oldTwo, two))
{ | 77 if (more_roughly_equal(oldOne, one) && more_roughly_equal(oldTwo, two))
{ |
78 if ((precisely_zero(one) && !precisely_zero(oldOne)) | 78 if ((precisely_zero(one) && !precisely_zero(oldOne)) |
79 || (precisely_equal(one, 1) && !precisely_equal(oldOne, 1)) | 79 || (precisely_equal(one, 1) && !precisely_equal(oldOne, 1)) |
80 || (precisely_zero(two) && !precisely_zero(oldTwo)) | 80 || (precisely_zero(two) && !precisely_zero(oldTwo)) |
81 || (precisely_equal(two, 1) && !precisely_equal(oldTwo, 1)))
{ | 81 || (precisely_equal(two, 1) && !precisely_equal(oldTwo, 1)))
{ |
| 82 SkASSERT(one >= 0 && one <= 1); |
| 83 SkASSERT(two >= 0 && two <= 1); |
82 fT[0][index] = one; | 84 fT[0][index] = one; |
83 fT[1][index] = two; | 85 fT[1][index] = two; |
84 fPt[index] = pt; | 86 fPt[index] = pt; |
85 } | 87 } |
86 return -1; | 88 return -1; |
87 } | 89 } |
88 #if ONE_OFF_DEBUG | 90 #if ONE_OFF_DEBUG |
89 if (pt.roughlyEqual(fPt[index])) { | 91 if (pt.roughlyEqual(fPt[index])) { |
90 SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one); | 92 SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one); |
91 } | 93 } |
(...skipping 12 matching lines...) Expand all Loading... |
104 if (remaining > 0) { | 106 if (remaining > 0) { |
105 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 107 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); |
106 memmove(&fPt2[index + 1], &fPt2[index], sizeof(fPt2[0]) * remaining); | 108 memmove(&fPt2[index + 1], &fPt2[index], sizeof(fPt2[0]) * remaining); |
107 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 109 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); |
108 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); | 110 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); |
109 int clearMask = ~((1 << index) - 1); | 111 int clearMask = ~((1 << index) - 1); |
110 fIsCoincident[0] += fIsCoincident[0] & clearMask; | 112 fIsCoincident[0] += fIsCoincident[0] & clearMask; |
111 fIsCoincident[1] += fIsCoincident[1] & clearMask; | 113 fIsCoincident[1] += fIsCoincident[1] & clearMask; |
112 } | 114 } |
113 fPt[index] = pt; | 115 fPt[index] = pt; |
| 116 SkASSERT(one >= 0 && one <= 1); |
| 117 SkASSERT(two >= 0 && two <= 1); |
114 fT[0][index] = one; | 118 fT[0][index] = one; |
115 fT[1][index] = two; | 119 fT[1][index] = two; |
116 ++fUsed; | 120 ++fUsed; |
117 return index; | 121 return index; |
118 } | 122 } |
119 | 123 |
120 void SkIntersections::insertNear(double one, double two, const SkDPoint& pt1, co
nst SkDPoint& pt2) { | 124 void SkIntersections::insertNear(double one, double two, const SkDPoint& pt1, co
nst SkDPoint& pt2) { |
121 SkASSERT(one == 0 || one == 1); | 125 SkASSERT(one == 0 || one == 1); |
122 SkASSERT(two == 0 || two == 1); | 126 SkASSERT(two == 0 || two == 1); |
123 SkASSERT(pt1 != pt2); | 127 SkASSERT(pt1 != pt2); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 168 |
165 void SkIntersections::removeOne(int index) { | 169 void SkIntersections::removeOne(int index) { |
166 int remaining = --fUsed - index; | 170 int remaining = --fUsed - index; |
167 if (remaining <= 0) { | 171 if (remaining <= 0) { |
168 return; | 172 return; |
169 } | 173 } |
170 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); | 174 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); |
171 memmove(&fPt2[index], &fPt2[index + 1], sizeof(fPt2[0]) * remaining); | 175 memmove(&fPt2[index], &fPt2[index + 1], sizeof(fPt2[0]) * remaining); |
172 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); | 176 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); |
173 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); | 177 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); |
174 SkASSERT(fIsCoincident[0] == 0); | 178 // SkASSERT(fIsCoincident[0] == 0); |
175 int coBit = fIsCoincident[0] & (1 << index); | 179 int coBit = fIsCoincident[0] & (1 << index); |
176 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; | 180 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; |
177 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); | 181 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); |
178 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; | 182 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; |
179 } | 183 } |
180 | 184 |
181 void SkIntersections::swapPts() { | 185 void SkIntersections::swapPts() { |
182 int index; | 186 int index; |
183 for (index = 0; index < fUsed; ++index) { | 187 for (index = 0; index < fUsed; ++index) { |
184 SkTSwap(fT[0][index], fT[1][index]); | 188 SkTSwap(fT[0][index], fT[1][index]); |
(...skipping 13 matching lines...) Expand all Loading... |
198 quad.set(a); | 202 quad.set(a); |
199 return vertical(quad, top, bottom, x, flipped); | 203 return vertical(quad, top, bottom, x, flipped); |
200 } | 204 } |
201 | 205 |
202 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, | 206 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, |
203 SkScalar x, bool flipped) { | 207 SkScalar x, bool flipped) { |
204 SkDCubic cubic; | 208 SkDCubic cubic; |
205 cubic.set(a); | 209 cubic.set(a); |
206 return vertical(cubic, top, bottom, x, flipped); | 210 return vertical(cubic, top, bottom, x, flipped); |
207 } | 211 } |
OLD | NEW |