| 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 "SkGeometry.h" | 10 #include "SkGeometry.h" |
| 11 #include "SkIntersections.h" | 11 #include "SkIntersections.h" |
| 12 #include "SkPathOpsRect.h" | 12 #include "SkPathOpsRect.h" |
| 13 #include "SkReduceOrder.h" | 13 #include "SkReduceOrder.h" |
| 14 #include "Test.h" | 14 #include "Test.h" |
| 15 | 15 |
| 16 static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const cha
r* name, | 16 static void test(skiatest::Reporter* reporter, const SkDCubic* cubics, const cha
r* name, |
| 17 int firstTest, size_t testCount) { | 17 int firstTest, size_t testCount) { |
| 18 for (size_t index = firstTest; index < testCount; ++index) { | 18 for (size_t index = firstTest; index < testCount; ++index) { |
| 19 const SkDCubic& cubic = cubics[index]; | 19 const SkDCubic& cubic = cubics[index]; |
| 20 double precision = cubic.calcPrecision(); | 20 double precision = cubic.calcPrecision(); |
| 21 SkTDArray<SkDQuad> quads; | 21 SkTDArray<SkDQuad> quads; |
| 22 CubicToQuads(cubic, precision, quads); | 22 CubicToQuads(cubic, precision, quads); |
| 23 if (quads.count() != 1) { | 23 if (quads.count() != 1 && quads.count() != 2) { |
| 24 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat
ic_cast<int>(index), | 24 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat
ic_cast<int>(index), |
| 25 quads.count()); | 25 quads.count()); |
| 26 } | 26 } |
| 27 REPORTER_ASSERT(reporter, quads.count() == 1); | 27 REPORTER_ASSERT(reporter, quads.count() == 1); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 static void test(skiatest::Reporter* reporter, const SkDQuad* quadTests, const c
har* name, | 31 static void test(skiatest::Reporter* reporter, const SkDQuad* quadTests, const c
har* name, |
| 32 int firstTest, size_t testCount) { | 32 int firstTest, size_t testCount) { |
| 33 for (size_t index = firstTest; index < testCount; ++index) { | 33 for (size_t index = firstTest; index < testCount; ++index) { |
| 34 const SkDQuad& quad = quadTests[index]; | 34 const SkDQuad& quad = quadTests[index]; |
| 35 SkDCubic cubic = quad.toCubic(); | 35 SkDCubic cubic = quad.toCubic(); |
| 36 double precision = cubic.calcPrecision(); | 36 double precision = cubic.calcPrecision(); |
| 37 SkTDArray<SkDQuad> quads; | 37 SkTDArray<SkDQuad> quads; |
| 38 CubicToQuads(cubic, precision, quads); | 38 CubicToQuads(cubic, precision, quads); |
| 39 if (quads.count() != 1) { | 39 if (quads.count() != 1 && quads.count() != 2) { |
| 40 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat
ic_cast<int>(index), | 40 SkDebugf("%s [%d] cubic to quadratics failed count=%d\n", name, stat
ic_cast<int>(index), |
| 41 quads.count()); | 41 quads.count()); |
| 42 } | 42 } |
| 43 REPORTER_ASSERT(reporter, quads.count() == 1); | 43 REPORTER_ASSERT(reporter, quads.count() <= 2); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 static void testC(skiatest::Reporter* reporter, const SkDCubic* cubics, const ch
ar* name, | 47 static void testC(skiatest::Reporter* reporter, const SkDCubic* cubics, const ch
ar* name, |
| 48 int firstTest, size_t testCount) { | 48 int firstTest, size_t testCount) { |
| 49 // test if computed line end points are valid | 49 // test if computed line end points are valid |
| 50 for (size_t index = firstTest; index < testCount; ++index) { | 50 for (size_t index = firstTest; index < testCount; ++index) { |
| 51 const SkDCubic& cubic = cubics[index]; | 51 const SkDCubic& cubic = cubics[index]; |
| 52 double precision = cubic.calcPrecision(); | 52 double precision = cubic.calcPrecision(); |
| 53 SkTDArray<SkDQuad> quads; | 53 SkTDArray<SkDQuad> quads; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 static void PathOpsCubicToQuadsTest(skiatest::Reporter* reporter) { | 195 static void PathOpsCubicToQuadsTest(skiatest::Reporter* reporter) { |
| 196 CubicToQuads_Test(reporter); | 196 CubicToQuads_Test(reporter); |
| 197 CubicsToQuadratics_OneOffTest(reporter); | 197 CubicsToQuadratics_OneOffTest(reporter); |
| 198 CubicsToQuadratics_OneOffTests(reporter); | 198 CubicsToQuadratics_OneOffTests(reporter); |
| 199 } | 199 } |
| 200 | 200 |
| 201 #include "TestClassDef.h" | 201 #include "TestClassDef.h" |
| 202 DEFINE_TESTCLASS_SHORT(PathOpsCubicToQuadsTest) | 202 DEFINE_TESTCLASS_SHORT(PathOpsCubicToQuadsTest) |
| OLD | NEW |