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 "PathOpsQuadIntersectionTestData.h" | 7 #include "PathOpsQuadIntersectionTestData.h" |
8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
9 #include "SkPathOpsRect.h" | 9 #include "SkPathOpsRect.h" |
10 #include "SkReduceOrder.h" | 10 #include "SkReduceOrder.h" |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 static const SkDQuad testSet[] = { | 13 static const SkDQuad testSet[] = { |
14 {{{1, 1}, {2, 2}, {1, 1.000003}}}, | 14 {{{1, 1}, {2, 2}, {1, 1.000003}}}, |
15 {{{1, 0}, {2, 6}, {3, 0}}} | 15 {{{1, 0}, {2, 6}, {3, 0}}} |
16 }; | 16 }; |
17 | 17 |
18 static const size_t testSetCount = SK_ARRAY_COUNT(testSet); | 18 static const size_t testSetCount = SK_ARRAY_COUNT(testSet); |
19 | 19 |
20 static void oneOffTest(skiatest::Reporter* reporter) { | 20 static void oneOffTest(skiatest::Reporter* reporter) { |
21 for (size_t index = 0; index < testSetCount; ++index) { | 21 for (size_t index = 0; index < testSetCount; ++index) { |
22 const SkDQuad& quad = testSet[index]; | 22 const SkDQuad& quad = testSet[index]; |
23 SkReduceOrder reducer; | 23 SkReduceOrder reducer; |
24 SkDEBUGCODE(int result = ) reducer.reduce(quad, SkReduceOrder::kFill_Sty
le); | 24 SkDEBUGCODE(int result = ) reducer.reduce(quad); |
25 SkASSERT(result == 3); | 25 SkASSERT(result == 3); |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 static void standardTestCases(skiatest::Reporter* reporter) { | 29 static void standardTestCases(skiatest::Reporter* reporter) { |
30 size_t index; | 30 size_t index; |
31 SkReduceOrder reducer; | 31 SkReduceOrder reducer; |
32 int order; | 32 int order; |
33 enum { | 33 enum { |
34 RunAll, | 34 RunAll, |
35 RunQuadraticLines, | 35 RunQuadraticLines, |
36 RunQuadraticModLines, | 36 RunQuadraticModLines, |
37 RunNone | 37 RunNone |
38 } run = RunAll; | 38 } run = RunAll; |
39 int firstTestIndex = 0; | 39 int firstTestIndex = 0; |
40 #if 0 | 40 #if 0 |
41 run = RunQuadraticLines; | 41 run = RunQuadraticLines; |
42 firstTestIndex = 1; | 42 firstTestIndex = 1; |
43 #endif | 43 #endif |
44 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ?
firstTestIndex | 44 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ?
firstTestIndex |
45 : SK_MaxS32; | 45 : SK_MaxS32; |
46 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes ? firstTestIndex | 46 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes ? firstTestIndex |
47 : SK_MaxS32; | 47 : SK_MaxS32; |
48 | 48 |
49 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ | 49 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ |
50 const SkDQuad& quad = quadraticLines[index]; | 50 const SkDQuad& quad = quadraticLines[index]; |
51 order = reducer.reduce(quad, SkReduceOrder::kFill_Style); | 51 order = reducer.reduce(quad); |
52 if (order != 2) { | 52 if (order != 2) { |
53 SkDebugf("[%d] line quad order=%d\n", (int) index, order); | 53 SkDebugf("[%d] line quad order=%d\n", (int) index, order); |
54 } | 54 } |
55 } | 55 } |
56 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { | 56 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { |
57 const SkDQuad& quad = quadraticModEpsilonLines[index]; | 57 const SkDQuad& quad = quadraticModEpsilonLines[index]; |
58 order = reducer.reduce(quad, SkReduceOrder::kFill_Style); | 58 order = reducer.reduce(quad); |
59 if (order != 3) { | 59 if (order != 3) { |
60 SkDebugf("[%d] line mod quad order=%d\n", (int) index, order); | 60 SkDebugf("[%d] line mod quad order=%d\n", (int) index, order); |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 static void PathOpsReduceOrderQuadTest(skiatest::Reporter* reporter) { | 65 static void PathOpsReduceOrderQuadTest(skiatest::Reporter* reporter) { |
66 oneOffTest(reporter); | 66 oneOffTest(reporter); |
67 standardTestCases(reporter); | 67 standardTestCases(reporter); |
68 } | 68 } |
69 | 69 |
70 #include "TestClassDef.h" | 70 #include "TestClassDef.h" |
71 DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderQuadTest) | 71 DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderQuadTest) |
OLD | NEW |