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 #include "PathOpsCubicIntersectionTestData.h" | 7 #include "PathOpsCubicIntersectionTestData.h" |
8 #include "PathOpsQuadIntersectionTestData.h" | 8 #include "PathOpsQuadIntersectionTestData.h" |
9 #include "PathOpsTestCommon.h" | 9 #include "PathOpsTestCommon.h" |
10 #include "SkIntersections.h" | 10 #include "SkIntersections.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 ? firstTestIndex : SK_MaxS32; | 98 ? firstTestIndex : SK_MaxS32; |
99 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines | 99 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines |
100 ? firstTestIndex : SK_MaxS32; | 100 ? firstTestIndex : SK_MaxS32; |
101 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes | 101 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes |
102 ? firstTestIndex : SK_MaxS32; | 102 ? firstTestIndex : SK_MaxS32; |
103 #if 0 | 103 #if 0 |
104 int firstComputedLinesTest = run == RunAll ? 0 : run == RunComputedLines | 104 int firstComputedLinesTest = run == RunAll ? 0 : run == RunComputedLines |
105 ? firstTestIndex : SK_MaxS32; | 105 ? firstTestIndex : SK_MaxS32; |
106 #endif | 106 #endif |
107 for (index = firstPointDegeneratesTest; index < pointDegenerates_count; ++in
dex) { | 107 for (index = firstPointDegeneratesTest; index < pointDegenerates_count; ++in
dex) { |
108 const SkDCubic& cubic = pointDegenerates[index]; | 108 const CubicPts& c = pointDegenerates[index]; |
| 109 SkDCubic cubic; |
| 110 cubic.debugSet(c.fPts); |
109 SkASSERT(ValidCubic(cubic)); | 111 SkASSERT(ValidCubic(cubic)); |
110 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 112 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
111 if (order != 1) { | 113 if (order != 1) { |
112 SkDebugf("[%d] pointDegenerates order=%d\n", static_cast<int>(index)
, order); | 114 SkDebugf("[%d] pointDegenerates order=%d\n", static_cast<int>(index)
, order); |
113 REPORTER_ASSERT(reporter, 0); | 115 REPORTER_ASSERT(reporter, 0); |
114 } | 116 } |
115 } | 117 } |
116 for (index = firstNotPointDegeneratesTest; index < notPointDegenerates_count
; ++index) { | 118 for (index = firstNotPointDegeneratesTest; index < notPointDegenerates_count
; ++index) { |
117 const SkDCubic& cubic = notPointDegenerates[index]; | 119 const CubicPts& c = notPointDegenerates[index]; |
| 120 SkDCubic cubic; |
| 121 cubic.debugSet(c.fPts); |
118 SkASSERT(ValidCubic(cubic)); | 122 SkASSERT(ValidCubic(cubic)); |
119 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 123 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
120 if (order == 1) { | 124 if (order == 1) { |
121 SkDebugf("[%d] notPointDegenerates order=%d\n", static_cast<int>(ind
ex), order); | 125 SkDebugf("[%d] notPointDegenerates order=%d\n", static_cast<int>(ind
ex), order); |
122 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 126 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
123 REPORTER_ASSERT(reporter, 0); | 127 REPORTER_ASSERT(reporter, 0); |
124 } | 128 } |
125 } | 129 } |
126 for (index = firstLinesTest; index < lines_count; ++index) { | 130 for (index = firstLinesTest; index < lines_count; ++index) { |
127 const SkDCubic& cubic = lines[index]; | 131 const CubicPts& c = lines[index]; |
| 132 SkDCubic cubic; |
| 133 cubic.debugSet(c.fPts); |
128 SkASSERT(ValidCubic(cubic)); | 134 SkASSERT(ValidCubic(cubic)); |
129 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 135 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
130 if (order != 2) { | 136 if (order != 2) { |
131 SkDebugf("[%d] lines order=%d\n", static_cast<int>(index), order); | 137 SkDebugf("[%d] lines order=%d\n", static_cast<int>(index), order); |
132 REPORTER_ASSERT(reporter, 0); | 138 REPORTER_ASSERT(reporter, 0); |
133 } | 139 } |
134 } | 140 } |
135 for (index = firstNotLinesTest; index < notLines_count; ++index) { | 141 for (index = firstNotLinesTest; index < notLines_count; ++index) { |
136 const SkDCubic& cubic = notLines[index]; | 142 const CubicPts& c = notLines[index]; |
| 143 SkDCubic cubic; |
| 144 cubic.debugSet(c.fPts); |
137 SkASSERT(ValidCubic(cubic)); | 145 SkASSERT(ValidCubic(cubic)); |
138 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 146 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
139 if (order == 2) { | 147 if (order == 2) { |
140 SkDebugf("[%d] notLines order=%d\n", static_cast<int>(index), order)
; | 148 SkDebugf("[%d] notLines order=%d\n", static_cast<int>(index), order)
; |
141 REPORTER_ASSERT(reporter, 0); | 149 REPORTER_ASSERT(reporter, 0); |
142 } | 150 } |
143 } | 151 } |
144 for (index = firstModEpsilonTest; index < modEpsilonLines_count; ++index) { | 152 for (index = firstModEpsilonTest; index < modEpsilonLines_count; ++index) { |
145 const SkDCubic& cubic = modEpsilonLines[index]; | 153 const CubicPts& c = modEpsilonLines[index]; |
| 154 SkDCubic cubic; |
| 155 cubic.debugSet(c.fPts); |
146 SkASSERT(ValidCubic(cubic)); | 156 SkASSERT(ValidCubic(cubic)); |
147 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 157 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
148 if (order == 2) { | 158 if (order == 2) { |
149 SkDebugf("[%d] line mod by epsilon order=%d\n", static_cast<int>(ind
ex), order); | 159 SkDebugf("[%d] line mod by epsilon order=%d\n", static_cast<int>(ind
ex), order); |
150 REPORTER_ASSERT(reporter, 0); | 160 REPORTER_ASSERT(reporter, 0); |
151 } | 161 } |
152 } | 162 } |
153 for (index = firstLessEpsilonTest; index < lessEpsilonLines_count; ++index)
{ | 163 for (index = firstLessEpsilonTest; index < lessEpsilonLines_count; ++index)
{ |
154 const SkDCubic& cubic = lessEpsilonLines[index]; | 164 const CubicPts& c = lessEpsilonLines[index]; |
| 165 SkDCubic cubic; |
| 166 cubic.debugSet(c.fPts); |
155 SkASSERT(ValidCubic(cubic)); | 167 SkASSERT(ValidCubic(cubic)); |
156 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 168 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
157 if (order != 2) { | 169 if (order != 2) { |
158 SkDebugf("[%d] line less by epsilon/2 order=%d\n", static_cast<int>(
index), order); | 170 SkDebugf("[%d] line less by epsilon/2 order=%d\n", static_cast<int>(
index), order); |
159 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 171 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
160 REPORTER_ASSERT(reporter, 0); | 172 REPORTER_ASSERT(reporter, 0); |
161 } | 173 } |
162 } | 174 } |
163 for (index = firstNegEpsilonTest; index < negEpsilonLines_count; ++index) { | 175 for (index = firstNegEpsilonTest; index < negEpsilonLines_count; ++index) { |
164 const SkDCubic& cubic = negEpsilonLines[index]; | 176 const CubicPts& c = negEpsilonLines[index]; |
| 177 SkDCubic cubic; |
| 178 cubic.debugSet(c.fPts); |
165 SkASSERT(ValidCubic(cubic)); | 179 SkASSERT(ValidCubic(cubic)); |
166 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 180 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
167 if (order != 2) { | 181 if (order != 2) { |
168 SkDebugf("[%d] line neg by epsilon/2 order=%d\n", static_cast<int>(i
ndex), order); | 182 SkDebugf("[%d] line neg by epsilon/2 order=%d\n", static_cast<int>(i
ndex), order); |
169 REPORTER_ASSERT(reporter, 0); | 183 REPORTER_ASSERT(reporter, 0); |
170 } | 184 } |
171 } | 185 } |
172 for (index = firstQuadraticPointTest; index < quadraticPoints_count; ++index
) { | 186 for (index = firstQuadraticPointTest; index < quadraticPoints_count; ++index
) { |
173 const SkDQuad& quad = quadraticPoints[index]; | 187 const QuadPts& q = quadraticPoints[index]; |
| 188 SkDQuad quad; |
| 189 quad.debugSet(q.fPts); |
174 SkASSERT(ValidQuad(quad)); | 190 SkASSERT(ValidQuad(quad)); |
175 SkDCubic cubic = quad.debugToCubic(); | 191 SkDCubic cubic = quad.debugToCubic(); |
176 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 192 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
177 if (order != 1) { | 193 if (order != 1) { |
178 SkDebugf("[%d] point quad order=%d\n", static_cast<int>(index), orde
r); | 194 SkDebugf("[%d] point quad order=%d\n", static_cast<int>(index), orde
r); |
179 REPORTER_ASSERT(reporter, 0); | 195 REPORTER_ASSERT(reporter, 0); |
180 } | 196 } |
181 } | 197 } |
182 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ | 198 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ |
183 const SkDQuad& quad = quadraticLines[index]; | 199 const QuadPts& q = quadraticLines[index]; |
| 200 SkDQuad quad; |
| 201 quad.debugSet(q.fPts); |
184 SkASSERT(ValidQuad(quad)); | 202 SkASSERT(ValidQuad(quad)); |
185 SkDCubic cubic = quad.debugToCubic(); | 203 SkDCubic cubic = quad.debugToCubic(); |
186 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 204 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
187 if (order != 2) { | 205 if (order != 2) { |
188 SkDebugf("[%d] line quad order=%d\n", static_cast<int>(index), order
); | 206 SkDebugf("[%d] line quad order=%d\n", static_cast<int>(index), order
); |
189 REPORTER_ASSERT(reporter, 0); | 207 REPORTER_ASSERT(reporter, 0); |
190 } | 208 } |
191 } | 209 } |
192 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { | 210 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { |
193 const SkDQuad& quad = quadraticModEpsilonLines[index]; | 211 const QuadPts& q = quadraticModEpsilonLines[index]; |
| 212 SkDQuad quad; |
| 213 quad.debugSet(q.fPts); |
194 SkASSERT(ValidQuad(quad)); | 214 SkASSERT(ValidQuad(quad)); |
195 SkDCubic cubic = quad.debugToCubic(); | 215 SkDCubic cubic = quad.debugToCubic(); |
196 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); | 216 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
197 if (order != 3) { | 217 if (order != 3) { |
198 SkDebugf("[%d] line mod quad order=%d\n", static_cast<int>(index), o
rder); | 218 SkDebugf("[%d] line mod quad order=%d\n", static_cast<int>(index), o
rder); |
199 REPORTER_ASSERT(reporter, 0); | 219 REPORTER_ASSERT(reporter, 0); |
200 } | 220 } |
201 } | 221 } |
202 | 222 |
203 #if 0 // disable test until stroke reduction is supported | 223 #if 0 // disable test until stroke reduction is supported |
(...skipping 29 matching lines...) Expand all Loading... |
233 && !AlmostEqualUlps(reducer.fLine[1].fX, bounds.fRight)) | 253 && !AlmostEqualUlps(reducer.fLine[1].fX, bounds.fRight)) |
234 || (!AlmostEqualUlps(reducer.fLine[1].fY, bounds.fTop) | 254 || (!AlmostEqualUlps(reducer.fLine[1].fY, bounds.fTop) |
235 && !AlmostEqualUlps(reducer.fLine[1].fY, bounds.fBottom))) { | 255 && !AlmostEqualUlps(reducer.fLine[1].fY, bounds.fBottom))) { |
236 SkDebugf("[%d] line computed tight bounds order=%d\n", static_ca
st<int>(index), order); | 256 SkDebugf("[%d] line computed tight bounds order=%d\n", static_ca
st<int>(index), order); |
237 REPORTER_ASSERT(reporter, 0); | 257 REPORTER_ASSERT(reporter, 0); |
238 } | 258 } |
239 } | 259 } |
240 } | 260 } |
241 #endif | 261 #endif |
242 } | 262 } |
OLD | NEW |