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 "PathOpsExtendedTest.h" |
7 #include "SkPath.h" | 8 #include "SkPath.h" |
8 #include "SkPathOps.h" | 9 #include "SkPathOps.h" |
9 #include "SkPoint.h" | 10 #include "SkPoint.h" |
10 #include "Test.h" | 11 #include "Test.h" |
11 | 12 |
12 static const SkPoint nonFinitePts[] = { | 13 static const SkPoint nonFinitePts[] = { |
13 { SK_ScalarInfinity, 0 }, | 14 { SK_ScalarInfinity, 0 }, |
14 { 0, SK_ScalarInfinity }, | 15 { 0, SK_ScalarInfinity }, |
15 { SK_ScalarInfinity, SK_ScalarInfinity }, | 16 { SK_ScalarInfinity, SK_ScalarInfinity }, |
16 { SK_ScalarNegativeInfinity, 0}, | 17 { SK_ScalarNegativeInfinity, 0}, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 SkPath result; | 87 SkPath result; |
87 result.setFillType(SkPath::kWinding_FillType); | 88 result.setFillType(SkPath::kWinding_FillType); |
88 bool success = Simplify(path, &result); | 89 bool success = Simplify(path, &result); |
89 if (index != 17 && index != 31 && index != 38) { // cubic fails to chop in
two without creating NaNs | 90 if (index != 17 && index != 31 && index != 38) { // cubic fails to chop in
two without creating NaNs |
90 REPORTER_ASSERT(reporter, success); | 91 REPORTER_ASSERT(reporter, success); |
91 REPORTER_ASSERT(reporter, result.getFillType() != SkPath::kWinding_FillT
ype); | 92 REPORTER_ASSERT(reporter, result.getFillType() != SkPath::kWinding_FillT
ype); |
92 } | 93 } |
93 reporter->bumpTestCount(); | 94 reporter->bumpTestCount(); |
94 } | 95 } |
95 | 96 |
| 97 static void fuzz_59(skiatest::Reporter* reporter, const char* filename) { |
| 98 SkPath path; |
| 99 path.moveTo(SkBits2Float(0x430c0000), SkBits2Float(0xce58f41c)); // 140, -9
.09969e+08f |
| 100 path.lineTo(SkBits2Float(0x43480000), SkBits2Float(0xce58f419)); // 200, -9
.09969e+08f |
| 101 path.lineTo(SkBits2Float(0x42200000), SkBits2Float(0xce58f41b)); // 40, -9.
09969e+08f |
| 102 path.lineTo(SkBits2Float(0x43700000), SkBits2Float(0xce58f41b)); // 240, -9
.09969e+08f |
| 103 path.lineTo(SkBits2Float(0x428c0000), SkBits2Float(0xce58f419)); // 70, -9.
09969e+08f |
| 104 path.lineTo(SkBits2Float(0x430c0000), SkBits2Float(0xce58f41c)); // 140, -9
.09969e+08f |
| 105 path.close(); |
| 106 testSimplifyCheck(reporter, path, filename, true); |
| 107 } |
| 108 |
| 109 static void fuzz_x1(skiatest::Reporter* reporter, const char* filename) { |
| 110 SkPath path; |
| 111 path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000)); // 0, 0 |
| 112 path.cubicTo(SkBits2Float(0x1931204a), SkBits2Float(0x2ba1a14a), SkBits2Float(0x
4a4a08ff), SkBits2Float(0x4a4a08ff), SkBits2Float(0x4a4a4a34), SkBits2Float(0x4a
4a4a4a)); // 9.15721e-24f, 1.14845e-12f, 3.31014e+06f, 3.31014e+06f, 3.31432e+0
6f, 3.31432e+06f |
| 113 path.moveTo(SkBits2Float(0x000010a1), SkBits2Float(0x19312000)); // 5.96533e-42
f, 9.15715e-24f |
| 114 path.cubicTo(SkBits2Float(0x4a6a4a4a), SkBits2Float(0x4a4a4a4a), SkBits2Float(0x
a14a4a4a), SkBits2Float(0x08ff2ba1), SkBits2Float(0x08ff4a4a), SkBits2Float(0x4a
344a4a)); // 3.83861e+06f, 3.31432e+06f, -6.85386e-19f, 1.53575e-33f, 1.53647e-
33f, 2.95387e+06f |
| 115 path.cubicTo(SkBits2Float(0x4a4a4a4a), SkBits2Float(0x4a4a4a4a), SkBits2Float(0x
2ba1a14a), SkBits2Float(0x4e4a08ff), SkBits2Float(0x4a4a4a4a), SkBits2Float(0xa1
a181ff)); // 3.31432e+06f, 3.31432e+06f, 1.14845e-12f, 8.47397e+08f, 3.31432e+0
6f, -1.09442e-18f |
| 116 testSimplify(reporter, path, filename); |
| 117 } |
| 118 |
| 119 static void fuzz_x2(skiatest::Reporter* reporter, const char* filename) { |
| 120 SkPath path; |
| 121 path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000)); // 0, 0 |
| 122 path.cubicTo(SkBits2Float(0x1931204a), SkBits2Float(0x2ba1a14a), SkBits2Float(0x
4a4a08ff), SkBits2Float(0x4a4a08ff), SkBits2Float(0x4a4a4a34), SkBits2Float(0x4a
4a4a4a)); // 9.15721e-24f, 1.14845e-12f, 3.31014e+06f, 3.31014e+06f, 3.31432e+0
6f, 3.31432e+06f |
| 123 path.moveTo(SkBits2Float(0x000010a1), SkBits2Float(0x19312000)); // 5.96533e-42
f, 9.15715e-24f |
| 124 path.cubicTo(SkBits2Float(0x4a6a4a4a), SkBits2Float(0x4a4a4a4a), SkBits2Float(0x
a14a4a4a), SkBits2Float(0x08ff2ba1), SkBits2Float(0x08ff4a4a), SkBits2Float(0x4a
344a4a)); // 3.83861e+06f, 3.31432e+06f, -6.85386e-19f, 1.53575e-33f, 1.53647e-
33f, 2.95387e+06f |
| 125 path.cubicTo(SkBits2Float(0x4a4a4a4a), SkBits2Float(0x4a4a4a4a), SkBits2Float(0x
2ba1a14a), SkBits2Float(0x4e4a08ff), SkBits2Float(0x4a4a4a4a), SkBits2Float(0xa1
a181ff)); // 3.31432e+06f, 3.31432e+06f, 1.14845e-12f, 8.47397e+08f, 3.31432e+0
6f, -1.09442e-18f |
| 126 testSimplify(reporter, path, filename); |
| 127 } |
| 128 |
| 129 #define TEST(test) test(reporter, #test) |
| 130 |
96 DEF_TEST(PathOpsSimplifyFail, reporter) { | 131 DEF_TEST(PathOpsSimplifyFail, reporter) { |
| 132 TEST(fuzz_x2); |
| 133 TEST(fuzz_x1); |
| 134 TEST(fuzz_59); |
97 for (int index = 0; index < (int) (13 * nonFinitePtsCount * finitePtsCount);
++index) { | 135 for (int index = 0; index < (int) (13 * nonFinitePtsCount * finitePtsCount);
++index) { |
98 failOne(reporter, index); | 136 failOne(reporter, index); |
99 } | 137 } |
100 for (int index = 0; index < (int) (11 * finitePtsCount); ++index) { | 138 for (int index = 0; index < (int) (11 * finitePtsCount); ++index) { |
101 dontFailOne(reporter, index); | 139 dontFailOne(reporter, index); |
102 } | 140 } |
103 } | 141 } |
104 | 142 |
| 143 #undef TEST |
| 144 |
105 DEF_TEST(PathOpsSimplifyFailOne, reporter) { | 145 DEF_TEST(PathOpsSimplifyFailOne, reporter) { |
106 int index = 0; | 146 int index = 0; |
107 failOne(reporter, index); | 147 failOne(reporter, index); |
108 } | 148 } |
109 | 149 |
110 DEF_TEST(PathOpsSimplifyDontFailOne, reporter) { | 150 DEF_TEST(PathOpsSimplifyDontFailOne, reporter) { |
111 int index = 17; | 151 int index = 17; |
112 dontFailOne(reporter, index); | 152 dontFailOne(reporter, index); |
113 } | 153 } |
OLD | NEW |