| 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" |
| 11 #include "SkPathOpsRect.h" | 11 #include "SkPathOpsRect.h" |
| 12 #include "SkReduceOrder.h" | 12 #include "SkReduceOrder.h" |
| 13 #include "Test.h" | 13 #include "Test.h" |
| 14 #include "TestClassDef.h" |
| 14 | 15 |
| 15 #if 0 // disable test until stroke reduction is supported | 16 #if 0 // disable test until stroke reduction is supported |
| 16 static bool controls_inside(const SkDCubic& cubic) { | 17 static bool controls_inside(const SkDCubic& cubic) { |
| 17 return between(cubic[0].fX, cubic[1].fX, cubic[3].fX) | 18 return between(cubic[0].fX, cubic[1].fX, cubic[3].fX) |
| 18 && between(cubic[0].fX, cubic[2].fX, cubic[3].fX) | 19 && between(cubic[0].fX, cubic[2].fX, cubic[3].fX) |
| 19 && between(cubic[0].fY, cubic[1].fY, cubic[3].fY) | 20 && between(cubic[0].fY, cubic[1].fY, cubic[3].fY) |
| 20 && between(cubic[0].fY, cubic[2].fY, cubic[3].fY); | 21 && between(cubic[0].fY, cubic[2].fY, cubic[3].fY); |
| 21 } | 22 } |
| 22 | 23 |
| 23 static bool tiny(const SkDCubic& cubic) { | 24 static bool tiny(const SkDCubic& cubic) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 51 } | 52 } |
| 52 if (!tiny(cubicPair.second()) && !controls_inside(cubicPair.second())) { | 53 if (!tiny(cubicPair.second()) && !controls_inside(cubicPair.second())) { |
| 53 find_tight_bounds(cubicPair.second(), bounds); | 54 find_tight_bounds(cubicPair.second(), bounds); |
| 54 } else { | 55 } else { |
| 55 bounds.add(cubicPair.second()[0]); | 56 bounds.add(cubicPair.second()[0]); |
| 56 bounds.add(cubicPair.second()[3]); | 57 bounds.add(cubicPair.second()[3]); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 static void PathOpsReduceOrderCubicTest(skiatest::Reporter* reporter) { | 62 DEF_TEST(PathOpsReduceOrderCubic, reporter) { |
| 62 size_t index; | 63 size_t index; |
| 63 SkReduceOrder reducer; | 64 SkReduceOrder reducer; |
| 64 int order; | 65 int order; |
| 65 enum { | 66 enum { |
| 66 RunAll, | 67 RunAll, |
| 67 RunPointDegenerates, | 68 RunPointDegenerates, |
| 68 RunNotPointDegenerates, | 69 RunNotPointDegenerates, |
| 69 RunLines, | 70 RunLines, |
| 70 RunNotLines, | 71 RunNotLines, |
| 71 RunModEpsilonLines, | 72 RunModEpsilonLines, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 && !AlmostEqualUlps(reducer.fLine[1].fX, bounds.fRight)) | 234 && !AlmostEqualUlps(reducer.fLine[1].fX, bounds.fRight)) |
| 234 || (!AlmostEqualUlps(reducer.fLine[1].fY, bounds.fTop) | 235 || (!AlmostEqualUlps(reducer.fLine[1].fY, bounds.fTop) |
| 235 && !AlmostEqualUlps(reducer.fLine[1].fY, bounds.fBottom))) { | 236 && !AlmostEqualUlps(reducer.fLine[1].fY, bounds.fBottom))) { |
| 236 SkDebugf("[%d] line computed tight bounds order=%d\n", static_ca
st<int>(index), order); | 237 SkDebugf("[%d] line computed tight bounds order=%d\n", static_ca
st<int>(index), order); |
| 237 REPORTER_ASSERT(reporter, 0); | 238 REPORTER_ASSERT(reporter, 0); |
| 238 } | 239 } |
| 239 } | 240 } |
| 240 } | 241 } |
| 241 #endif | 242 #endif |
| 242 } | 243 } |
| 243 | |
| 244 #include "TestClassDef.h" | |
| 245 | |
| 246 DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderCubicTest) | |
| OLD | NEW |