| 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 QuadPts 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 QuadPts& q = testSet[index]; |
| 23 SkDQuad quad; |
| 24 quad.debugSet(q.fPts); |
| 23 SkReduceOrder reducer; | 25 SkReduceOrder reducer; |
| 24 SkDEBUGCODE(int result = ) reducer.reduce(quad); | 26 SkDEBUGCODE(int result = ) reducer.reduce(quad); |
| 25 SkASSERT(result == 3); | 27 SkASSERT(result == 3); |
| 26 } | 28 } |
| 27 } | 29 } |
| 28 | 30 |
| 29 static void standardTestCases(skiatest::Reporter* reporter) { | 31 static void standardTestCases(skiatest::Reporter* reporter) { |
| 30 size_t index; | 32 size_t index; |
| 31 SkReduceOrder reducer; | 33 SkReduceOrder reducer; |
| 32 int order; | 34 int order; |
| 33 enum { | 35 enum { |
| 34 RunAll, | 36 RunAll, |
| 35 RunQuadraticLines, | 37 RunQuadraticLines, |
| 36 RunQuadraticModLines, | 38 RunQuadraticModLines, |
| 37 RunNone | 39 RunNone |
| 38 } run = RunAll; | 40 } run = RunAll; |
| 39 int firstTestIndex = 0; | 41 int firstTestIndex = 0; |
| 40 #if 0 | 42 #if 0 |
| 41 run = RunQuadraticLines; | 43 run = RunQuadraticLines; |
| 42 firstTestIndex = 1; | 44 firstTestIndex = 1; |
| 43 #endif | 45 #endif |
| 44 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ?
firstTestIndex | 46 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ?
firstTestIndex |
| 45 : SK_MaxS32; | 47 : SK_MaxS32; |
| 46 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes ? firstTestIndex | 48 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes ? firstTestIndex |
| 47 : SK_MaxS32; | 49 : SK_MaxS32; |
| 48 | 50 |
| 49 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ | 51 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ |
| 50 const SkDQuad& quad = quadraticLines[index]; | 52 const QuadPts& q = quadraticLines[index]; |
| 53 SkDQuad quad; |
| 54 quad.debugSet(q.fPts); |
| 51 order = reducer.reduce(quad); | 55 order = reducer.reduce(quad); |
| 52 if (order != 2) { | 56 if (order != 2) { |
| 53 SkDebugf("[%d] line quad order=%d\n", (int) index, order); | 57 SkDebugf("[%d] line quad order=%d\n", (int) index, order); |
| 54 } | 58 } |
| 55 } | 59 } |
| 56 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { | 60 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { |
| 57 const SkDQuad& quad = quadraticModEpsilonLines[index]; | 61 const QuadPts& q = quadraticModEpsilonLines[index]; |
| 62 SkDQuad quad; |
| 63 quad.debugSet(q.fPts); |
| 58 order = reducer.reduce(quad); | 64 order = reducer.reduce(quad); |
| 59 if (order != 2 && order != 3) { // FIXME: data probably is not good | 65 if (order != 2 && order != 3) { // FIXME: data probably is not good |
| 60 SkDebugf("[%d] line mod quad order=%d\n", (int) index, order); | 66 SkDebugf("[%d] line mod quad order=%d\n", (int) index, order); |
| 61 } | 67 } |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 | 70 |
| 65 DEF_TEST(PathOpsReduceOrderQuad, reporter) { | 71 DEF_TEST(PathOpsReduceOrderQuad, reporter) { |
| 66 oneOffTest(reporter); | 72 oneOffTest(reporter); |
| 67 standardTestCases(reporter); | 73 standardTestCases(reporter); |
| 68 } | 74 } |
| OLD | NEW |