| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 86         if (fT[0][index] > one) { | 86         if (fT[0][index] > one) { | 
| 87             break; | 87             break; | 
| 88         } | 88         } | 
| 89     } | 89     } | 
| 90     SkASSERT(fUsed < 9); | 90     SkASSERT(fUsed < 9); | 
| 91     int remaining = fUsed - index; | 91     int remaining = fUsed - index; | 
| 92     if (remaining > 0) { | 92     if (remaining > 0) { | 
| 93         memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 93         memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 
| 94         memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 94         memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 
| 95         memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); | 95         memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); | 
| 96         fIsCoincident[0] += fIsCoincident[0] & ~((1 << index) - 1); | 96         int clearMask = ~((1 << index) - 1); | 
| 97         fIsCoincident[1] += fIsCoincident[1] & ~((1 << index) - 1); | 97         fIsCoincident[0] += fIsCoincident[0] & clearMask; | 
|  | 98         fIsCoincident[1] += fIsCoincident[1] & clearMask; | 
|  | 99         fIsNear += fIsNear & clearMask; | 
| 98     } | 100     } | 
| 99     fPt[index] = pt; | 101     fPt[index] = pt; | 
| 100     fT[0][index] = one; | 102     fT[0][index] = one; | 
| 101     fT[1][index] = two; | 103     fT[1][index] = two; | 
| 102     ++fUsed; | 104     ++fUsed; | 
| 103     return index; | 105     return index; | 
| 104 } | 106 } | 
| 105 | 107 | 
|  | 108 void SkIntersections::insertNear(double one, double two, const SkDPoint& pt) { | 
|  | 109     int index = insert(one, two, pt); | 
|  | 110     if (index < 0) { | 
|  | 111         return; | 
|  | 112     } | 
|  | 113     fIsNear |= 1 << index; | 
|  | 114 } | 
|  | 115 | 
| 106 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p
     t) { | 116 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p
     t) { | 
| 107     int index = insertSwap(one, two, pt); | 117     int index = insertSwap(one, two, pt); | 
| 108     int bit = 1 << index; | 118     int bit = 1 << index; | 
| 109     fIsCoincident[0] |= bit; | 119     fIsCoincident[0] |= bit; | 
| 110     fIsCoincident[1] |= bit; | 120     fIsCoincident[1] |= bit; | 
| 111 } | 121 } | 
| 112 | 122 | 
| 113 void SkIntersections::offset(int base, double start, double end) { | 123 void SkIntersections::offset(int base, double start, double end) { | 
| 114     for (int index = base; index < fUsed; ++index) { | 124     for (int index = base; index < fUsed; ++index) { | 
| 115         double val = fT[fSwap][index]; | 125         double val = fT[fSwap][index]; | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 151         return; | 161         return; | 
| 152     } | 162     } | 
| 153     memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); | 163     memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); | 
| 154     memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); | 164     memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); | 
| 155     memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); | 165     memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); | 
| 156     SkASSERT(fIsCoincident[0] == 0); | 166     SkASSERT(fIsCoincident[0] == 0); | 
| 157     int coBit = fIsCoincident[0] & (1 << index); | 167     int coBit = fIsCoincident[0] & (1 << index); | 
| 158     fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; | 168     fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; | 
| 159     SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); | 169     SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); | 
| 160     fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; | 170     fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; | 
|  | 171     fIsNear -= ((fIsNear >> 1) & ~((1 << index) - 1)) + (fIsNear & (1 << index))
     ; | 
| 161 } | 172 } | 
| 162 | 173 | 
| 163 void SkIntersections::swapPts() { | 174 void SkIntersections::swapPts() { | 
| 164     int index; | 175     int index; | 
| 165     for (index = 0; index < fUsed; ++index) { | 176     for (index = 0; index < fUsed; ++index) { | 
| 166         SkTSwap(fT[0][index], fT[1][index]); | 177         SkTSwap(fT[0][index], fT[1][index]); | 
| 167     } | 178     } | 
| 168 } | 179 } | 
| 169 | 180 | 
| 170 int SkIntersections::verticalLine(const SkPoint a[2], SkScalar top, SkScalar bot
     tom, | 181 int SkIntersections::verticalLine(const SkPoint a[2], SkScalar top, SkScalar bot
     tom, | 
| 171         SkScalar x, bool flipped) { | 182         SkScalar x, bool flipped) { | 
| 172     SkDLine line; | 183     SkDLine line; | 
| 173     line.set(a); | 184     line.set(a); | 
| 174     return vertical(line, top, bottom, x, flipped); | 185     return vertical(line, top, bottom, x, flipped); | 
| 175 } | 186 } | 
| 176 | 187 | 
| 177 int SkIntersections::verticalQuad(const SkPoint a[3], SkScalar top, SkScalar bot
     tom, | 188 int SkIntersections::verticalQuad(const SkPoint a[3], SkScalar top, SkScalar bot
     tom, | 
| 178         SkScalar x, bool flipped) { | 189         SkScalar x, bool flipped) { | 
| 179     SkDQuad quad; | 190     SkDQuad quad; | 
| 180     quad.set(a); | 191     quad.set(a); | 
| 181     return vertical(quad, top, bottom, x, flipped); | 192     return vertical(quad, top, bottom, x, flipped); | 
| 182 } | 193 } | 
| 183 | 194 | 
| 184 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
     ttom, | 195 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
     ttom, | 
| 185         SkScalar x, bool flipped) { | 196         SkScalar x, bool flipped) { | 
| 186     SkDCubic cubic; | 197     SkDCubic cubic; | 
| 187     cubic.set(a); | 198     cubic.set(a); | 
| 188     return vertical(cubic, top, bottom, x, flipped); | 199     return vertical(cubic, top, bottom, x, flipped); | 
| 189 } | 200 } | 
| OLD | NEW | 
|---|