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 "SkIntersections.h" | 8 #include "SkIntersections.h" |
8 #include "SkPathOpsCubic.h" | 9 #include "SkPathOpsCubic.h" |
9 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
10 #include "SkReduceOrder.h" | 11 #include "SkReduceOrder.h" |
11 #include "Test.h" | 12 #include "Test.h" |
12 | 13 |
13 static struct lineCubic { | 14 static struct lineCubic { |
14 SkDCubic cubic; | 15 SkDCubic cubic; |
15 SkDQuad quad; | 16 SkDQuad quad; |
16 int answerCount; | 17 int answerCount; |
17 SkDPoint answers[2]; | 18 SkDPoint answers[2]; |
18 } quadCubicTests[] = { | 19 } quadCubicTests[] = { |
19 {{{{10,234}, {10,229.58172607421875}, {13.581720352172852,226}, {18,226}}}, | 20 {{{{10,234}, {10,229.58172607421875}, {13.581720352172852,226}, {18,226}}}, |
20 {{{18,226}, {14.686291694641113,226}, {12.342399597167969,228.3424072265
625}}}, 1, | 21 {{{18,226}, {14.686291694641113,226}, {12.342399597167969,228.3424072265
625}}}, 1, |
21 {{18,226}, {0,0}}}, | 22 {{18,226}, {0,0}}}, |
22 {{{{10,234}, {10,229.58172607421875}, {13.581720352172852,226}, {18,226}}}, | 23 {{{{10,234}, {10,229.58172607421875}, {13.581720352172852,226}, {18,226}}}, |
23 {{{12.342399597167969,228.3424072265625}, {10,230.68629455566406}, {10,2
34}}}, 1, | 24 {{{12.342399597167969,228.3424072265625}, {10,230.68629455566406}, {10,2
34}}}, 1, |
24 {{10,234}, {0,0}}}, | 25 {{10,234}, {0,0}}}, |
25 }; | 26 }; |
26 | 27 |
27 static const size_t quadCubicTests_count = SK_ARRAY_COUNT(quadCubicTests); | 28 static const size_t quadCubicTests_count = SK_ARRAY_COUNT(quadCubicTests); |
28 | 29 |
29 static void PathOpsCubicQuadIntersectionTest(skiatest::Reporter* reporter) { | 30 static void PathOpsCubicQuadIntersectionTest(skiatest::Reporter* reporter) { |
30 for (size_t index = 0; index < quadCubicTests_count; ++index) { | 31 for (size_t index = 0; index < quadCubicTests_count; ++index) { |
31 int iIndex = static_cast<int>(index); | 32 int iIndex = static_cast<int>(index); |
32 const SkDCubic& cubic = quadCubicTests[index].cubic; | 33 const SkDCubic& cubic = quadCubicTests[index].cubic; |
| 34 SkASSERT(ValidCubic(cubic)); |
33 const SkDQuad& quad = quadCubicTests[index].quad; | 35 const SkDQuad& quad = quadCubicTests[index].quad; |
| 36 SkASSERT(ValidQuad(quad)); |
34 SkReduceOrder reduce1; | 37 SkReduceOrder reduce1; |
35 SkReduceOrder reduce2; | 38 SkReduceOrder reduce2; |
36 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics, | 39 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics, |
37 SkReduceOrder::kFill_Style); | 40 SkReduceOrder::kFill_Style); |
38 int order2 = reduce2.reduce(quad, SkReduceOrder::kFill_Style); | 41 int order2 = reduce2.reduce(quad, SkReduceOrder::kFill_Style); |
39 if (order1 != 4) { | 42 if (order1 != 4) { |
40 SkDebugf("[%d] cubic order=%d\n", iIndex, order1); | 43 SkDebugf("[%d] cubic order=%d\n", iIndex, order1); |
41 REPORTER_ASSERT(reporter, 0); | 44 REPORTER_ASSERT(reporter, 0); |
42 } | 45 } |
43 if (order2 != 3) { | 46 if (order2 != 3) { |
(...skipping 18 matching lines...) Expand all Loading... |
62 found |= quadCubicTests[index].answers[idx2].approximatelyEqual(
xy1); | 65 found |= quadCubicTests[index].answers[idx2].approximatelyEqual(
xy1); |
63 } | 66 } |
64 REPORTER_ASSERT(reporter, found); | 67 REPORTER_ASSERT(reporter, found); |
65 } | 68 } |
66 reporter->bumpTestCount(); | 69 reporter->bumpTestCount(); |
67 } | 70 } |
68 } | 71 } |
69 | 72 |
70 #include "TestClassDef.h" | 73 #include "TestClassDef.h" |
71 DEFINE_TESTCLASS_SHORT(PathOpsCubicQuadIntersectionTest) | 74 DEFINE_TESTCLASS_SHORT(PathOpsCubicQuadIntersectionTest) |
OLD | NEW |