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 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 #endif | 39 #endif |
40 } | 40 } |
41 SkASSERT(count == count2); | 41 SkASSERT(count == count2); |
42 return count; | 42 return count; |
43 } | 43 } |
44 | 44 |
45 int SkIntersections::cubicRay(const SkPoint pts[4], const SkDLine& line) { | 45 int SkIntersections::cubicRay(const SkPoint pts[4], const SkDLine& line) { |
46 SkDCubic cubic; | 46 SkDCubic cubic; |
47 cubic.set(pts); | 47 cubic.set(pts); |
| 48 fMax = 3; |
48 return intersectRay(cubic, line); | 49 return intersectRay(cubic, line); |
49 } | 50 } |
50 | 51 |
51 void SkIntersections::flip() { | 52 void SkIntersections::flip() { |
52 for (int index = 0; index < fUsed; ++index) { | 53 for (int index = 0; index < fUsed; ++index) { |
53 fT[1][index] = 1 - fT[1][index]; | 54 fT[1][index] = 1 - fT[1][index]; |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 int SkIntersections::insert(double one, double two, const SkDPoint& pt) { | 58 int SkIntersections::insert(double one, double two, const SkDPoint& pt) { |
(...skipping 22 matching lines...) Expand all Loading... |
80 } | 81 } |
81 #if ONE_OFF_DEBUG | 82 #if ONE_OFF_DEBUG |
82 if (pt.roughlyEqual(fPt[index])) { | 83 if (pt.roughlyEqual(fPt[index])) { |
83 SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one); | 84 SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one); |
84 } | 85 } |
85 #endif | 86 #endif |
86 if (fT[0][index] > one) { | 87 if (fT[0][index] > one) { |
87 break; | 88 break; |
88 } | 89 } |
89 } | 90 } |
90 SkASSERT(fUsed < 9); | 91 if (fUsed >= fMax) { |
| 92 SkASSERT(0); // FIXME : this error, if it is to be handled at runtime i
n release, must |
| 93 // be propagated all the way back down to the caller, and
return failure. |
| 94 fUsed = 0; |
| 95 return 0; |
| 96 } |
91 int remaining = fUsed - index; | 97 int remaining = fUsed - index; |
92 if (remaining > 0) { | 98 if (remaining > 0) { |
93 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); | 99 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); |
94 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); | 100 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); | 101 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); |
96 int clearMask = ~((1 << index) - 1); | 102 int clearMask = ~((1 << index) - 1); |
97 fIsCoincident[0] += fIsCoincident[0] & clearMask; | 103 fIsCoincident[0] += fIsCoincident[0] & clearMask; |
98 fIsCoincident[1] += fIsCoincident[1] & clearMask; | 104 fIsCoincident[1] += fIsCoincident[1] & clearMask; |
99 fIsNear += fIsNear & clearMask; | 105 fIsNear += fIsNear & clearMask; |
100 } | 106 } |
(...skipping 24 matching lines...) Expand all Loading... |
125 double val = fT[fSwap][index]; | 131 double val = fT[fSwap][index]; |
126 val *= end - start; | 132 val *= end - start; |
127 val += start; | 133 val += start; |
128 fT[fSwap][index] = val; | 134 fT[fSwap][index] = val; |
129 } | 135 } |
130 } | 136 } |
131 | 137 |
132 int SkIntersections::quadRay(const SkPoint pts[3], const SkDLine& line) { | 138 int SkIntersections::quadRay(const SkPoint pts[3], const SkDLine& line) { |
133 SkDQuad quad; | 139 SkDQuad quad; |
134 quad.set(pts); | 140 quad.set(pts); |
| 141 fMax = 2; |
135 return intersectRay(quad, line); | 142 return intersectRay(quad, line); |
136 } | 143 } |
137 | 144 |
138 void SkIntersections::quickRemoveOne(int index, int replace) { | 145 void SkIntersections::quickRemoveOne(int index, int replace) { |
139 if (index < replace) { | 146 if (index < replace) { |
140 fT[0][index] = fT[0][replace]; | 147 fT[0][index] = fT[0][replace]; |
141 } | 148 } |
142 } | 149 } |
143 | 150 |
144 #if 0 | 151 #if 0 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 quad.set(a); | 198 quad.set(a); |
192 return vertical(quad, top, bottom, x, flipped); | 199 return vertical(quad, top, bottom, x, flipped); |
193 } | 200 } |
194 | 201 |
195 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, | 202 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo
ttom, |
196 SkScalar x, bool flipped) { | 203 SkScalar x, bool flipped) { |
197 SkDCubic cubic; | 204 SkDCubic cubic; |
198 cubic.set(a); | 205 cubic.set(a); |
199 return vertical(cubic, top, bottom, x, flipped); | 206 return vertical(cubic, top, bottom, x, flipped); |
200 } | 207 } |
OLD | NEW |