| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 int firstLessEpsilonTest = run == RunAll ? 0 : run == RunLessEpsilonLines | 91 int firstLessEpsilonTest = run == RunAll ? 0 : run == RunLessEpsilonLines |
| 92 ? firstTestIndex : SK_MaxS32; | 92 ? firstTestIndex : SK_MaxS32; |
| 93 int firstNegEpsilonTest = run == RunAll ? 0 : run == RunNegEpsilonLines | 93 int firstNegEpsilonTest = run == RunAll ? 0 : run == RunNegEpsilonLines |
| 94 ? firstTestIndex : SK_MaxS32; | 94 ? firstTestIndex : SK_MaxS32; |
| 95 int firstQuadraticPointTest = run == RunAll ? 0 : run == RunQuadraticPoints | 95 int firstQuadraticPointTest = run == RunAll ? 0 : run == RunQuadraticPoints |
| 96 ? firstTestIndex : SK_MaxS32; | 96 ? firstTestIndex : SK_MaxS32; |
| 97 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines | 97 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines |
| 98 ? firstTestIndex : SK_MaxS32; | 98 ? firstTestIndex : SK_MaxS32; |
| 99 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes | 99 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes |
| 100 ? firstTestIndex : SK_MaxS32; | 100 ? firstTestIndex : SK_MaxS32; |
| 101 #if 0 |
| 101 int firstComputedLinesTest = run == RunAll ? 0 : run == RunComputedLines | 102 int firstComputedLinesTest = run == RunAll ? 0 : run == RunComputedLines |
| 102 ? firstTestIndex : SK_MaxS32; | 103 ? firstTestIndex : SK_MaxS32; |
| 103 | 104 #endif |
| 104 for (index = firstPointDegeneratesTest; index < pointDegenerates_count; ++in
dex) { | 105 for (index = firstPointDegeneratesTest; index < pointDegenerates_count; ++in
dex) { |
| 105 const SkDCubic& cubic = pointDegenerates[index]; | 106 const SkDCubic& cubic = pointDegenerates[index]; |
| 106 SkASSERT(ValidCubic(cubic)); | 107 SkASSERT(ValidCubic(cubic)); |
| 107 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 108 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 108 if (order != 1) { | 109 if (order != 1) { |
| 109 SkDebugf("[%d] pointDegenerates order=%d\n", static_cast<int>(index)
, order); | 110 SkDebugf("[%d] pointDegenerates order=%d\n", static_cast<int>(index)
, order); |
| 110 REPORTER_ASSERT(reporter, 0); | 111 REPORTER_ASSERT(reporter, 0); |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 for (index = firstNotPointDegeneratesTest; index < notPointDegenerates_count
; ++index) { | 114 for (index = firstNotPointDegeneratesTest; index < notPointDegenerates_count
; ++index) { |
| 114 const SkDCubic& cubic = notPointDegenerates[index]; | 115 const SkDCubic& cubic = notPointDegenerates[index]; |
| 115 SkASSERT(ValidCubic(cubic)); | 116 SkASSERT(ValidCubic(cubic)); |
| 116 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 117 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 117 if (order == 1) { | 118 if (order == 1) { |
| 118 SkDebugf("[%d] notPointDegenerates order=%d\n", static_cast<int>(ind
ex), order); | 119 SkDebugf("[%d] notPointDegenerates order=%d\n", static_cast<int>(ind
ex), order); |
| 119 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, | 120 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 120 SkReduceOrder::kFill_Style); | |
| 121 REPORTER_ASSERT(reporter, 0); | 121 REPORTER_ASSERT(reporter, 0); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 for (index = firstLinesTest; index < lines_count; ++index) { | 124 for (index = firstLinesTest; index < lines_count; ++index) { |
| 125 const SkDCubic& cubic = lines[index]; | 125 const SkDCubic& cubic = lines[index]; |
| 126 SkASSERT(ValidCubic(cubic)); | 126 SkASSERT(ValidCubic(cubic)); |
| 127 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 127 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 128 if (order != 2) { | 128 if (order != 2) { |
| 129 SkDebugf("[%d] lines order=%d\n", static_cast<int>(index), order); | 129 SkDebugf("[%d] lines order=%d\n", static_cast<int>(index), order); |
| 130 REPORTER_ASSERT(reporter, 0); | 130 REPORTER_ASSERT(reporter, 0); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 for (index = firstNotLinesTest; index < notLines_count; ++index) { | 133 for (index = firstNotLinesTest; index < notLines_count; ++index) { |
| 134 const SkDCubic& cubic = notLines[index]; | 134 const SkDCubic& cubic = notLines[index]; |
| 135 SkASSERT(ValidCubic(cubic)); | 135 SkASSERT(ValidCubic(cubic)); |
| 136 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 136 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 137 if (order == 2) { | 137 if (order == 2) { |
| 138 SkDebugf("[%d] notLines order=%d\n", static_cast<int>(index), order)
; | 138 SkDebugf("[%d] notLines order=%d\n", static_cast<int>(index), order)
; |
| 139 REPORTER_ASSERT(reporter, 0); | 139 REPORTER_ASSERT(reporter, 0); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 for (index = firstModEpsilonTest; index < modEpsilonLines_count; ++index) { | 142 for (index = firstModEpsilonTest; index < modEpsilonLines_count; ++index) { |
| 143 const SkDCubic& cubic = modEpsilonLines[index]; | 143 const SkDCubic& cubic = modEpsilonLines[index]; |
| 144 SkASSERT(ValidCubic(cubic)); | 144 SkASSERT(ValidCubic(cubic)); |
| 145 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 145 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 146 if (order == 2) { | 146 if (order == 2) { |
| 147 SkDebugf("[%d] line mod by epsilon order=%d\n", static_cast<int>(ind
ex), order); | 147 SkDebugf("[%d] line mod by epsilon order=%d\n", static_cast<int>(ind
ex), order); |
| 148 REPORTER_ASSERT(reporter, 0); | 148 REPORTER_ASSERT(reporter, 0); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 for (index = firstLessEpsilonTest; index < lessEpsilonLines_count; ++index)
{ | 151 for (index = firstLessEpsilonTest; index < lessEpsilonLines_count; ++index)
{ |
| 152 const SkDCubic& cubic = lessEpsilonLines[index]; | 152 const SkDCubic& cubic = lessEpsilonLines[index]; |
| 153 SkASSERT(ValidCubic(cubic)); | 153 SkASSERT(ValidCubic(cubic)); |
| 154 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 154 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 155 if (order != 2) { | 155 if (order != 2) { |
| 156 SkDebugf("[%d] line less by epsilon/2 order=%d\n", static_cast<int>(
index), order); | 156 SkDebugf("[%d] line less by epsilon/2 order=%d\n", static_cast<int>(
index), order); |
| 157 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, | 157 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 158 SkReduceOrder::kFill_Style); | |
| 159 REPORTER_ASSERT(reporter, 0); | 158 REPORTER_ASSERT(reporter, 0); |
| 160 } | 159 } |
| 161 } | 160 } |
| 162 for (index = firstNegEpsilonTest; index < negEpsilonLines_count; ++index) { | 161 for (index = firstNegEpsilonTest; index < negEpsilonLines_count; ++index) { |
| 163 const SkDCubic& cubic = negEpsilonLines[index]; | 162 const SkDCubic& cubic = negEpsilonLines[index]; |
| 164 SkASSERT(ValidCubic(cubic)); | 163 SkASSERT(ValidCubic(cubic)); |
| 165 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 164 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 166 if (order != 2) { | 165 if (order != 2) { |
| 167 SkDebugf("[%d] line neg by epsilon/2 order=%d\n", static_cast<int>(i
ndex), order); | 166 SkDebugf("[%d] line neg by epsilon/2 order=%d\n", static_cast<int>(i
ndex), order); |
| 168 REPORTER_ASSERT(reporter, 0); | 167 REPORTER_ASSERT(reporter, 0); |
| 169 } | 168 } |
| 170 } | 169 } |
| 171 for (index = firstQuadraticPointTest; index < quadraticPoints_count; ++index
) { | 170 for (index = firstQuadraticPointTest; index < quadraticPoints_count; ++index
) { |
| 172 const SkDQuad& quad = quadraticPoints[index]; | 171 const SkDQuad& quad = quadraticPoints[index]; |
| 173 SkASSERT(ValidQuad(quad)); | 172 SkASSERT(ValidQuad(quad)); |
| 174 SkDCubic cubic = quad.toCubic(); | 173 SkDCubic cubic = quad.toCubic(); |
| 175 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 174 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 176 if (order != 1) { | 175 if (order != 1) { |
| 177 SkDebugf("[%d] point quad order=%d\n", static_cast<int>(index), orde
r); | 176 SkDebugf("[%d] point quad order=%d\n", static_cast<int>(index), orde
r); |
| 178 REPORTER_ASSERT(reporter, 0); | 177 REPORTER_ASSERT(reporter, 0); |
| 179 } | 178 } |
| 180 } | 179 } |
| 181 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ | 180 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ |
| 182 const SkDQuad& quad = quadraticLines[index]; | 181 const SkDQuad& quad = quadraticLines[index]; |
| 183 SkASSERT(ValidQuad(quad)); | 182 SkASSERT(ValidQuad(quad)); |
| 184 SkDCubic cubic = quad.toCubic(); | 183 SkDCubic cubic = quad.toCubic(); |
| 185 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 184 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 186 if (order != 2) { | 185 if (order != 2) { |
| 187 SkDebugf("[%d] line quad order=%d\n", static_cast<int>(index), order
); | 186 SkDebugf("[%d] line quad order=%d\n", static_cast<int>(index), order
); |
| 188 REPORTER_ASSERT(reporter, 0); | 187 REPORTER_ASSERT(reporter, 0); |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { | 190 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { |
| 192 const SkDQuad& quad = quadraticModEpsilonLines[index]; | 191 const SkDQuad& quad = quadraticModEpsilonLines[index]; |
| 193 SkASSERT(ValidQuad(quad)); | 192 SkASSERT(ValidQuad(quad)); |
| 194 SkDCubic cubic = quad.toCubic(); | 193 SkDCubic cubic = quad.toCubic(); |
| 195 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, SkReduce
Order::kFill_Style); | 194 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics); |
| 196 if (order != 3) { | 195 if (order != 3) { |
| 197 SkDebugf("[%d] line mod quad order=%d\n", static_cast<int>(index), o
rder); | 196 SkDebugf("[%d] line mod quad order=%d\n", static_cast<int>(index), o
rder); |
| 198 REPORTER_ASSERT(reporter, 0); | 197 REPORTER_ASSERT(reporter, 0); |
| 199 } | 198 } |
| 200 } | 199 } |
| 201 | 200 |
| 202 // test if computed line end points are valid | 201 #if 0 // disable test until stroke reduction is supported |
| 202 // test if computed line end points are valid |
| 203 for (index = firstComputedLinesTest; index < lines_count; ++index) { | 203 for (index = firstComputedLinesTest; index < lines_count; ++index) { |
| 204 const SkDCubic& cubic = lines[index]; | 204 const SkDCubic& cubic = lines[index]; |
| 205 SkASSERT(ValidCubic(cubic)); | 205 SkASSERT(ValidCubic(cubic)); |
| 206 bool controlsInside = controls_inside(cubic); | 206 bool controlsInside = controls_inside(cubic); |
| 207 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, | 207 order = reducer.reduce(cubic, SkReduceOrder::kAllow_Quadratics, |
| 208 SkReduceOrder::kStroke_Style); | 208 SkReduceOrder::kStroke_Style); |
| 209 if (order == 2 && reducer.fLine[0] == reducer.fLine[1]) { | 209 if (order == 2 && reducer.fLine[0] == reducer.fLine[1]) { |
| 210 SkDebugf("[%d] line computed ends match order=%d\n", static_cast<int
>(index), order); | 210 SkDebugf("[%d] line computed ends match order=%d\n", static_cast<int
>(index), order); |
| 211 REPORTER_ASSERT(reporter, 0); | 211 REPORTER_ASSERT(reporter, 0); |
| 212 } | 212 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 229 && !AlmostEqualUlps(reducer.fLine[0].fY, bounds.fBottom)) | 229 && !AlmostEqualUlps(reducer.fLine[0].fY, bounds.fBottom)) |
| 230 || (!AlmostEqualUlps(reducer.fLine[1].fX, bounds.fLeft) | 230 || (!AlmostEqualUlps(reducer.fLine[1].fX, bounds.fLeft) |
| 231 && !AlmostEqualUlps(reducer.fLine[1].fX, bounds.fRight)) | 231 && !AlmostEqualUlps(reducer.fLine[1].fX, bounds.fRight)) |
| 232 || (!AlmostEqualUlps(reducer.fLine[1].fY, bounds.fTop) | 232 || (!AlmostEqualUlps(reducer.fLine[1].fY, bounds.fTop) |
| 233 && !AlmostEqualUlps(reducer.fLine[1].fY, bounds.fBottom))) { | 233 && !AlmostEqualUlps(reducer.fLine[1].fY, bounds.fBottom))) { |
| 234 SkDebugf("[%d] line computed tight bounds order=%d\n", static_ca
st<int>(index), order); | 234 SkDebugf("[%d] line computed tight bounds order=%d\n", static_ca
st<int>(index), order); |
| 235 REPORTER_ASSERT(reporter, 0); | 235 REPORTER_ASSERT(reporter, 0); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 #endif |
| 239 } | 240 } |
| 240 | 241 |
| 241 #include "TestClassDef.h" | 242 #include "TestClassDef.h" |
| 242 | 243 |
| 243 DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderCubicTest) | 244 DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderCubicTest) |
| OLD | NEW |