| 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::*CurveVertical[])(const SkPoint[], SkScalar, SkScalar, SkS
     calar, bool) = { | 10 int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar, SkScalar, SkS
     calar, bool) = { | 
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 149                 fT[fSwap ^ 1][iEnd2] = e2; | 149                 fT[fSwap ^ 1][iEnd2] = e2; | 
| 150             } | 150             } | 
| 151             return; | 151             return; | 
| 152         } | 152         } | 
| 153     } while (true); | 153     } while (true); | 
| 154     SkASSERT(fUsed < 9); | 154     SkASSERT(fUsed < 9); | 
| 155     insertCoincident(s1, s2, startPt); | 155     insertCoincident(s1, s2, startPt); | 
| 156     insertCoincident(e1, e2, endPt); | 156     insertCoincident(e1, e2, endPt); | 
| 157 } | 157 } | 
| 158 | 158 | 
| 159 int SkIntersections::insert(double one, double two, double x, double y) { | 159 int SkIntersections::insert(double one, double two, const SkDPoint& pt) { | 
| 160     if (fIsCoincident[0] == 3 && between(fT[0][0], one, fT[0][1])) { | 160     if (fIsCoincident[0] == 3 && between(fT[0][0], one, fT[0][1])) { | 
| 161         // For now, don't allow a mix of coincident and non-coincident intersect
     ions | 161         // For now, don't allow a mix of coincident and non-coincident intersect
     ions | 
| 162         return -1; | 162         return -1; | 
| 163     } | 163     } | 
| 164     SkASSERT(fUsed <= 1 || fT[0][0] <= fT[0][1]); | 164     SkASSERT(fUsed <= 1 || fT[0][0] <= fT[0][1]); | 
| 165     int index; | 165     int index; | 
| 166     for (index = 0; index < fUsed; ++index) { | 166     for (index = 0; index < fUsed; ++index) { | 
| 167         double oldOne = fT[0][index]; | 167         double oldOne = fT[0][index]; | 
| 168         double oldTwo = fT[1][index]; | 168         double oldTwo = fT[1][index]; | 
| 169         if (roughly_equal(oldOne, one) && roughly_equal(oldTwo, two)) { | 169         if (one == oldOne && two == oldTwo) { | 
|  | 170             return -1; | 
|  | 171         } | 
|  | 172         if (more_roughly_equal(oldOne, one) && more_roughly_equal(oldTwo, two)) 
     { | 
| 170             if ((precisely_zero(one) && !precisely_zero(oldOne)) | 173             if ((precisely_zero(one) && !precisely_zero(oldOne)) | 
| 171                     || (precisely_equal(one, 1) && !precisely_equal(oldOne, 1)) | 174                     || (precisely_equal(one, 1) && !precisely_equal(oldOne, 1)) | 
| 172                     || (precisely_zero(two) && !precisely_zero(oldTwo)) | 175                     || (precisely_zero(two) && !precisely_zero(oldTwo)) | 
| 173                     || (precisely_equal(two, 1) && !precisely_equal(oldTwo, 1)))
      { | 176                     || (precisely_equal(two, 1) && !precisely_equal(oldTwo, 1)))
      { | 
| 174                 fT[0][index] = one; | 177                 fT[0][index] = one; | 
| 175                 fT[1][index] = two; | 178                 fT[1][index] = two; | 
| 176                 fPt[index].fX = x; | 179                 fPt[index] = pt; | 
| 177                 fPt[index].fY = y; |  | 
| 178             } | 180             } | 
| 179             return -1; | 181             return -1; | 
| 180         } | 182         } | 
| 181     #if ONE_OFF_DEBUG | 183     #if ONE_OFF_DEBUG | 
| 182         if (pt.roughlyEqual(fPt[index])) { | 184         if (pt.roughlyEqual(fPt[index])) { | 
| 183             SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one); | 185             SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one); | 
| 184         } | 186         } | 
| 185     #endif | 187     #endif | 
| 186         if (fT[0][index] > one) { | 188         if (fT[0][index] > one) { | 
| 187             break; | 189             break; | 
| 188         } | 190         } | 
| 189     } | 191     } | 
| 190     SkASSERT(fUsed < 9); | 192     SkASSERT(fUsed < 9); | 
| 191     int remaining = fUsed - index; | 193     int remaining = fUsed - index; | 
| 192     if (remaining > 0) { | 194     if (remaining > 0) { | 
| 193         memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 195         memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 
| 194         memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 196         memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 
| 195         memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); | 197         memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); | 
| 196         fIsCoincident[0] += fIsCoincident[0] & ~((1 << index) - 1); | 198         fIsCoincident[0] += fIsCoincident[0] & ~((1 << index) - 1); | 
| 197         fIsCoincident[1] += fIsCoincident[1] & ~((1 << index) - 1); | 199         fIsCoincident[1] += fIsCoincident[1] & ~((1 << index) - 1); | 
| 198     } | 200     } | 
| 199     fPt[index].fX = x; | 201     fPt[index] = pt; | 
| 200     fPt[index].fY = y; |  | 
| 201     fT[0][index] = one; | 202     fT[0][index] = one; | 
| 202     fT[1][index] = two; | 203     fT[1][index] = two; | 
| 203     ++fUsed; | 204     ++fUsed; | 
| 204     return index; | 205     return index; | 
| 205 } | 206 } | 
| 206 | 207 | 
| 207 int SkIntersections::insert(double one, double two, const SkDPoint& pt) { |  | 
| 208     return insert(one, two, pt.fX, pt.fY); |  | 
| 209 } |  | 
| 210 |  | 
| 211 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p
     t) { | 208 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p
     t) { | 
| 212     int index = insertSwap(one, two, pt); | 209     int index = insertSwap(one, two, pt); | 
| 213     int bit = 1 << index; | 210     int bit = 1 << index; | 
| 214     fIsCoincident[0] |= bit; | 211     fIsCoincident[0] |= bit; | 
| 215     fIsCoincident[1] |= bit; | 212     fIsCoincident[1] |= bit; | 
| 216 } | 213 } | 
| 217 | 214 | 
| 218 void SkIntersections::offset(int base, double start, double end) { | 215 void SkIntersections::offset(int base, double start, double end) { | 
| 219     for (int index = base; index < fUsed; ++index) { | 216     for (int index = base; index < fUsed; ++index) { | 
| 220         double val = fT[fSwap][index]; | 217         double val = fT[fSwap][index]; | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 285     quad.set(a); | 282     quad.set(a); | 
| 286     return vertical(quad, top, bottom, x, flipped); | 283     return vertical(quad, top, bottom, x, flipped); | 
| 287 } | 284 } | 
| 288 | 285 | 
| 289 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
     ttom, | 286 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
     ttom, | 
| 290         SkScalar x, bool flipped) { | 287         SkScalar x, bool flipped) { | 
| 291     SkDCubic cubic; | 288     SkDCubic cubic; | 
| 292     cubic.set(a); | 289     cubic.set(a); | 
| 293     return vertical(cubic, top, bottom, x, flipped); | 290     return vertical(cubic, top, bottom, x, flipped); | 
| 294 } | 291 } | 
| OLD | NEW | 
|---|