| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
| 8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
| 9 #include "SkPathOpsCubic.h" | 9 #include "SkPathOpsCubic.h" |
| 10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
| 11 #include "SkReduceOrder.h" | 11 #include "SkReduceOrder.h" |
| 12 #include "Test.h" | 12 #include "Test.h" |
| 13 #include "TestClassDef.h" |
| 13 | 14 |
| 14 static struct lineCubic { | 15 static struct lineCubic { |
| 15 SkDCubic cubic; | 16 SkDCubic cubic; |
| 16 SkDQuad quad; | 17 SkDQuad quad; |
| 17 int answerCount; | 18 int answerCount; |
| 18 SkDPoint answers[2]; | 19 SkDPoint answers[2]; |
| 19 } quadCubicTests[] = { | 20 } quadCubicTests[] = { |
| 20 {{{{778, 14089}, {778, 14091.208984375}, {776.20916748046875, 14093}, {774,
14093}}}, | 21 {{{{778, 14089}, {778, 14091.208984375}, {776.20916748046875, 14093}, {774,
14093}}}, |
| 21 {{{778, 14089}, {777.99957275390625, 14090.65625}, {776.82843017578125, 140
91.828125}}}, 2, | 22 {{{778, 14089}, {777.99957275390625, 14090.65625}, {776.82843017578125, 140
91.828125}}}, 2, |
| 22 {{778, 14089}, {776.82855609581270,14091.828250841330}}}, | 23 {{778, 14089}, {776.82855609581270,14091.828250841330}}}, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 {{{18,226}, {14.686291694641113,226}, {12.342399597167969,228.3424072265625
}}}, 1, | 44 {{{18,226}, {14.686291694641113,226}, {12.342399597167969,228.3424072265625
}}}, 1, |
| 44 {{18,226}, {0,0}}}, | 45 {{18,226}, {0,0}}}, |
| 45 | 46 |
| 46 {{{{10,234}, {10,229.58172607421875}, {13.581720352172852,226}, {18,226}}}, | 47 {{{{10,234}, {10,229.58172607421875}, {13.581720352172852,226}, {18,226}}}, |
| 47 {{{12.342399597167969,228.3424072265625}, {10,230.68629455566406}, {10,234}
}}, 1, | 48 {{{12.342399597167969,228.3424072265625}, {10,230.68629455566406}, {10,234}
}}, 1, |
| 48 {{10,234}, {0,0}}}, | 49 {{10,234}, {0,0}}}, |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 static const size_t quadCubicTests_count = SK_ARRAY_COUNT(quadCubicTests); | 52 static const size_t quadCubicTests_count = SK_ARRAY_COUNT(quadCubicTests); |
| 52 | 53 |
| 53 static void PathOpsCubicQuadIntersectionTest(skiatest::Reporter* reporter) { | 54 DEF_TEST(PathOpsCubicQuadIntersection, reporter) { |
| 54 for (size_t index = 0; index < quadCubicTests_count; ++index) { | 55 for (size_t index = 0; index < quadCubicTests_count; ++index) { |
| 55 int iIndex = static_cast<int>(index); | 56 int iIndex = static_cast<int>(index); |
| 56 const SkDCubic& cubic = quadCubicTests[index].cubic; | 57 const SkDCubic& cubic = quadCubicTests[index].cubic; |
| 57 SkASSERT(ValidCubic(cubic)); | 58 SkASSERT(ValidCubic(cubic)); |
| 58 const SkDQuad& quad = quadCubicTests[index].quad; | 59 const SkDQuad& quad = quadCubicTests[index].quad; |
| 59 SkASSERT(ValidQuad(quad)); | 60 SkASSERT(ValidQuad(quad)); |
| 60 SkReduceOrder reduce1; | 61 SkReduceOrder reduce1; |
| 61 SkReduceOrder reduce2; | 62 SkReduceOrder reduce2; |
| 62 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics); | 63 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics); |
| 63 int order2 = reduce2.reduce(quad); | 64 int order2 = reduce2.reduce(quad); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 } | 89 } |
| 89 if (!found) { | 90 if (!found) { |
| 90 SkDebugf("%s [%d,%d] xy1=(%g,%g) != \n", | 91 SkDebugf("%s [%d,%d] xy1=(%g,%g) != \n", |
| 91 __FUNCTION__, iIndex, pt, xy1.fX, xy1.fY); | 92 __FUNCTION__, iIndex, pt, xy1.fX, xy1.fY); |
| 92 } | 93 } |
| 93 REPORTER_ASSERT(reporter, found); | 94 REPORTER_ASSERT(reporter, found); |
| 94 } | 95 } |
| 95 reporter->bumpTestCount(); | 96 reporter->bumpTestCount(); |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | |
| 99 #include "TestClassDef.h" | |
| 100 DEFINE_TESTCLASS_SHORT(PathOpsCubicQuadIntersectionTest) | |
| OLD | NEW |