epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkPathMeasure.h" |
Mike Reed | f1f1e7d | 2020-10-15 14:52:54 -0400 | [diff] [blame] | 9 | #include "src/core/SkPathPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "tests/Test.h" |
reed@android.com | 5e5adfd | 2009-03-07 03:39:23 +0000 | [diff] [blame] | 11 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 12 | static void test_small_segment3() { |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 13 | SkPath path; |
| 14 | const SkPoint pts[] = { |
| 15 | { 0, 0 }, |
| 16 | { 100000000000.0f, 100000000000.0f }, { 0, 0 }, { 10, 10 }, |
| 17 | { 10, 10 }, { 0, 0 }, { 10, 10 } |
| 18 | }; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 19 | |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 20 | path.moveTo(pts[0]); |
bsalomon@google.com | 2fc2359 | 2012-10-03 19:10:31 +0000 | [diff] [blame] | 21 | for (size_t i = 1; i < SK_ARRAY_COUNT(pts); i += 3) { |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 22 | path.cubicTo(pts[i], pts[i + 1], pts[i + 2]); |
| 23 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 24 | |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 25 | SkPathMeasure meas(path, false); |
| 26 | meas.getLength(); |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 27 | } |
| 28 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 29 | static void test_small_segment2() { |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 30 | SkPath path; |
| 31 | const SkPoint pts[] = { |
| 32 | { 0, 0 }, |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 33 | { 100000000000.0f, 100000000000.0f }, { 0, 0 }, |
| 34 | { 10, 10 }, { 0, 0 }, |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 35 | }; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 36 | |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 37 | path.moveTo(pts[0]); |
| 38 | for (size_t i = 1; i < SK_ARRAY_COUNT(pts); i += 2) { |
| 39 | path.quadTo(pts[i], pts[i + 1]); |
| 40 | } |
| 41 | SkPathMeasure meas(path, false); |
| 42 | meas.getLength(); |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 43 | } |
| 44 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 45 | static void test_small_segment() { |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 46 | SkPath path; |
| 47 | const SkPoint pts[] = { |
| 48 | { 100000, 100000}, |
| 49 | // big jump between these points, makes a big segment |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 50 | { 1.0005f, 0.9999f }, |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 51 | // tiny (non-zero) jump between these points |
robertphillips@google.com | c6ce750 | 2012-05-08 13:15:37 +0000 | [diff] [blame] | 52 | { SK_Scalar1, SK_Scalar1 }, |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 53 | }; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 54 | |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 55 | path.moveTo(pts[0]); |
| 56 | for (size_t i = 1; i < SK_ARRAY_COUNT(pts); ++i) { |
| 57 | path.lineTo(pts[i]); |
| 58 | } |
| 59 | SkPathMeasure meas(path, false); |
| 60 | |
| 61 | /* this would assert (before a fix) because we added a segment with |
| 62 | the same length as the prev segment, due to the follow (bad) pattern |
| 63 | |
| 64 | d = distance(pts[0], pts[1]); |
| 65 | distance += d; |
| 66 | seg->fDistance = distance; |
reed@google.com | ded4414 | 2012-04-27 20:22:07 +0000 | [diff] [blame] | 67 | |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 68 | SkASSERT(d > 0); // TRUE |
| 69 | SkASSERT(seg->fDistance > prevSeg->fDistance); // FALSE |
| 70 | |
| 71 | This 2nd assert failes because (distance += d) didn't affect distance |
| 72 | because distance >>> d. |
| 73 | */ |
| 74 | meas.getLength(); |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 75 | } |
| 76 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 77 | DEF_TEST(PathMeasure, reporter) { |
reed@android.com | 5e5adfd | 2009-03-07 03:39:23 +0000 | [diff] [blame] | 78 | SkPath path; |
| 79 | |
| 80 | path.moveTo(0, 0); |
| 81 | path.lineTo(SK_Scalar1, 0); |
| 82 | path.lineTo(SK_Scalar1, SK_Scalar1); |
| 83 | path.lineTo(0, SK_Scalar1); |
| 84 | |
| 85 | SkPathMeasure meas(path, true); |
| 86 | SkScalar length = meas.getLength(); |
| 87 | SkASSERT(length == SK_Scalar1*4); |
| 88 | |
| 89 | path.reset(); |
| 90 | path.moveTo(0, 0); |
| 91 | path.lineTo(SK_Scalar1*3, SK_Scalar1*4); |
| 92 | meas.setPath(&path, false); |
| 93 | length = meas.getLength(); |
| 94 | REPORTER_ASSERT(reporter, length == SK_Scalar1*5); |
| 95 | |
| 96 | path.reset(); |
| 97 | path.addCircle(0, 0, SK_Scalar1); |
| 98 | meas.setPath(&path, true); |
| 99 | length = meas.getLength(); |
| 100 | // SkDebugf("circle arc-length = %g\n", length); |
| 101 | |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 102 | // Test the behavior following a close not followed by a move. |
| 103 | path.reset(); |
| 104 | path.lineTo(SK_Scalar1, 0); |
| 105 | path.lineTo(SK_Scalar1, SK_Scalar1); |
| 106 | path.lineTo(0, SK_Scalar1); |
| 107 | path.close(); |
| 108 | path.lineTo(-SK_Scalar1, 0); |
| 109 | meas.setPath(&path, false); |
| 110 | length = meas.getLength(); |
| 111 | REPORTER_ASSERT(reporter, length == SK_Scalar1 * 4); |
| 112 | meas.nextContour(); |
| 113 | length = meas.getLength(); |
| 114 | REPORTER_ASSERT(reporter, length == SK_Scalar1); |
| 115 | SkPoint position; |
| 116 | SkVector tangent; |
| 117 | REPORTER_ASSERT(reporter, meas.getPosTan(SK_ScalarHalf, &position, &tangent)); |
| 118 | REPORTER_ASSERT(reporter, |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 119 | SkScalarNearlyEqual(position.fX, |
| 120 | -SK_ScalarHalf, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 121 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 122 | REPORTER_ASSERT(reporter, position.fY == 0); |
| 123 | REPORTER_ASSERT(reporter, tangent.fX == -SK_Scalar1); |
| 124 | REPORTER_ASSERT(reporter, tangent.fY == 0); |
| 125 | |
| 126 | // Test degenerate paths |
| 127 | path.reset(); |
| 128 | path.moveTo(0, 0); |
| 129 | path.lineTo(0, 0); |
| 130 | path.lineTo(SK_Scalar1, 0); |
| 131 | path.quadTo(SK_Scalar1, 0, SK_Scalar1, 0); |
| 132 | path.quadTo(SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1 * 2); |
| 133 | path.cubicTo(SK_Scalar1, SK_Scalar1 * 2, |
| 134 | SK_Scalar1, SK_Scalar1 * 2, |
| 135 | SK_Scalar1, SK_Scalar1 * 2); |
| 136 | path.cubicTo(SK_Scalar1*2, SK_Scalar1 * 2, |
| 137 | SK_Scalar1*3, SK_Scalar1 * 2, |
| 138 | SK_Scalar1*4, SK_Scalar1 * 2); |
| 139 | meas.setPath(&path, false); |
| 140 | length = meas.getLength(); |
| 141 | REPORTER_ASSERT(reporter, length == SK_Scalar1 * 6); |
| 142 | REPORTER_ASSERT(reporter, meas.getPosTan(SK_ScalarHalf, &position, &tangent)); |
| 143 | REPORTER_ASSERT(reporter, |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 144 | SkScalarNearlyEqual(position.fX, |
| 145 | SK_ScalarHalf, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 146 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 147 | REPORTER_ASSERT(reporter, position.fY == 0); |
| 148 | REPORTER_ASSERT(reporter, tangent.fX == SK_Scalar1); |
| 149 | REPORTER_ASSERT(reporter, tangent.fY == 0); |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 150 | REPORTER_ASSERT(reporter, meas.getPosTan(2.5f, &position, &tangent)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 151 | REPORTER_ASSERT(reporter, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 152 | SkScalarNearlyEqual(position.fX, SK_Scalar1, 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 153 | REPORTER_ASSERT(reporter, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 154 | SkScalarNearlyEqual(position.fY, 1.5f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 155 | REPORTER_ASSERT(reporter, tangent.fX == 0); |
| 156 | REPORTER_ASSERT(reporter, tangent.fY == SK_Scalar1); |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 157 | REPORTER_ASSERT(reporter, meas.getPosTan(4.5f, &position, &tangent)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 158 | REPORTER_ASSERT(reporter, |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 159 | SkScalarNearlyEqual(position.fX, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 160 | 2.5f, |
| 161 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 162 | REPORTER_ASSERT(reporter, |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 163 | SkScalarNearlyEqual(position.fY, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 164 | 2.0f, |
| 165 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 166 | REPORTER_ASSERT(reporter, tangent.fX == SK_Scalar1); |
| 167 | REPORTER_ASSERT(reporter, tangent.fY == 0); |
| 168 | |
| 169 | path.reset(); |
| 170 | path.moveTo(0, 0); |
| 171 | path.lineTo(SK_Scalar1, 0); |
| 172 | path.moveTo(SK_Scalar1, SK_Scalar1); |
| 173 | path.moveTo(SK_Scalar1 * 2, SK_Scalar1 * 2); |
| 174 | path.lineTo(SK_Scalar1, SK_Scalar1 * 2); |
| 175 | meas.setPath(&path, false); |
| 176 | length = meas.getLength(); |
| 177 | REPORTER_ASSERT(reporter, length == SK_Scalar1); |
| 178 | REPORTER_ASSERT(reporter, meas.getPosTan(SK_ScalarHalf, &position, &tangent)); |
| 179 | REPORTER_ASSERT(reporter, |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 180 | SkScalarNearlyEqual(position.fX, |
| 181 | SK_ScalarHalf, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 182 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 183 | REPORTER_ASSERT(reporter, position.fY == 0); |
| 184 | REPORTER_ASSERT(reporter, tangent.fX == SK_Scalar1); |
| 185 | REPORTER_ASSERT(reporter, tangent.fY == 0); |
| 186 | meas.nextContour(); |
| 187 | length = meas.getLength(); |
| 188 | REPORTER_ASSERT(reporter, length == SK_Scalar1); |
| 189 | REPORTER_ASSERT(reporter, meas.getPosTan(SK_ScalarHalf, &position, &tangent)); |
| 190 | REPORTER_ASSERT(reporter, |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 191 | SkScalarNearlyEqual(position.fX, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 192 | 1.5f, |
| 193 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 194 | REPORTER_ASSERT(reporter, |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 195 | SkScalarNearlyEqual(position.fY, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 196 | 2.0f, |
| 197 | 0.0001f)); |
schenney@chromium.org | 510c6b1 | 2012-01-12 20:04:06 +0000 | [diff] [blame] | 198 | REPORTER_ASSERT(reporter, tangent.fX == -SK_Scalar1); |
| 199 | REPORTER_ASSERT(reporter, tangent.fY == 0); |
reed@google.com | fab1ddd | 2012-04-20 15:10:32 +0000 | [diff] [blame] | 200 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 201 | test_small_segment(); |
| 202 | test_small_segment2(); |
| 203 | test_small_segment3(); |
reed@android.com | 5e5adfd | 2009-03-07 03:39:23 +0000 | [diff] [blame] | 204 | } |
caryclark | b6474dd | 2016-01-19 08:07:49 -0800 | [diff] [blame] | 205 | |
| 206 | DEF_TEST(PathMeasureConic, reporter) { |
| 207 | SkPoint stdP, hiP, pts[] = {{0,0}, {100,0}, {100,0}}; |
| 208 | SkPath p; |
| 209 | p.moveTo(0, 0); |
| 210 | p.conicTo(pts[1], pts[2], 1); |
| 211 | SkPathMeasure stdm(p, false); |
| 212 | REPORTER_ASSERT(reporter, stdm.getPosTan(20, &stdP, nullptr)); |
| 213 | p.reset(); |
| 214 | p.moveTo(0, 0); |
| 215 | p.conicTo(pts[1], pts[2], 10); |
| 216 | stdm.setPath(&p, false); |
| 217 | REPORTER_ASSERT(reporter, stdm.getPosTan(20, &hiP, nullptr)); |
| 218 | REPORTER_ASSERT(reporter, 19.5f < stdP.fX && stdP.fX < 20.5f); |
| 219 | REPORTER_ASSERT(reporter, 19.5f < hiP.fX && hiP.fX < 20.5f); |
| 220 | } |
Mike Reed | 140ab36 | 2018-03-20 16:47:32 +0000 | [diff] [blame] | 221 | |
| 222 | // Regression test for b/26425223 |
| 223 | DEF_TEST(PathMeasure_nextctr, reporter) { |
| 224 | SkPath path; |
| 225 | path.moveTo(0, 0); path.lineTo(100, 0); |
| 226 | |
| 227 | SkPathMeasure meas(path, false); |
| 228 | // only expect 1 contour, even if we didn't explicitly call getLength() ourselves |
| 229 | REPORTER_ASSERT(reporter, !meas.nextContour()); |
| 230 | } |
Mike Reed | cc88f3a | 2019-02-06 11:40:27 -0500 | [diff] [blame] | 231 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 232 | #include "include/core/SkContourMeasure.h" |
Mike Reed | cc88f3a | 2019-02-06 11:40:27 -0500 | [diff] [blame] | 233 | |
| 234 | static void test_90_degrees(sk_sp<SkContourMeasure> cm, SkScalar radius, |
| 235 | skiatest::Reporter* reporter) { |
| 236 | SkPoint pos; |
| 237 | SkVector tan; |
| 238 | SkScalar distance = cm->length() / 4; |
| 239 | bool success = cm->getPosTan(distance, &pos, &tan); |
| 240 | |
| 241 | REPORTER_ASSERT(reporter, success); |
| 242 | REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pos.fX, 0)); |
| 243 | REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pos.fY, radius)); |
| 244 | REPORTER_ASSERT(reporter, SkScalarNearlyEqual(tan.fX, -1)); |
| 245 | REPORTER_ASSERT(reporter, SkScalarNearlyEqual(tan.fY, 0)); |
| 246 | } |
| 247 | |
| 248 | static void test_empty_contours(skiatest::Reporter* reporter) { |
| 249 | SkPath path; |
| 250 | |
| 251 | path.moveTo(0, 0).lineTo(100, 100).lineTo(200, 100); |
| 252 | path.moveTo(2, 2).moveTo(3, 3); // zero-length(s) |
| 253 | path.moveTo(4, 4).close().close().close(); // zero-length |
| 254 | path.moveTo(5, 5).lineTo(5, 5); // zero-length |
| 255 | path.moveTo(5, 5).lineTo(5, 5).close(); // zero-length |
| 256 | path.moveTo(5, 5).lineTo(5, 5).close().close(); // zero-length |
| 257 | path.moveTo(6, 6).lineTo(7, 7); |
| 258 | path.moveTo(10, 10); // zero-length |
| 259 | |
| 260 | SkContourMeasureIter fact(path, false); |
| 261 | |
| 262 | // given the above construction, we expect only 2 contours (the rest are "empty") |
| 263 | |
| 264 | REPORTER_ASSERT(reporter, fact.next()); |
| 265 | REPORTER_ASSERT(reporter, fact.next()); |
| 266 | REPORTER_ASSERT(reporter, !fact.next()); |
| 267 | } |
| 268 | |
Mike Reed | 62ad46b | 2019-02-13 11:48:35 -0500 | [diff] [blame] | 269 | static void test_MLM_contours(skiatest::Reporter* reporter) { |
| 270 | SkPath path; |
| 271 | |
| 272 | // This odd sequence (with a trailing moveTo) used to return a 2nd contour, which is |
| 273 | // wrong, since the contract for a measure is to only return non-zero length contours. |
| 274 | path.moveTo(10, 10).lineTo(20, 20).moveTo(30, 30); |
| 275 | |
| 276 | for (bool forceClosed : {false, true}) { |
| 277 | SkContourMeasureIter fact(path, forceClosed); |
| 278 | REPORTER_ASSERT(reporter, fact.next()); |
| 279 | REPORTER_ASSERT(reporter, !fact.next()); |
| 280 | } |
| 281 | } |
| 282 | |
Mike Reed | c924a88 | 2020-10-13 21:22:47 -0400 | [diff] [blame] | 283 | static void test_shrink(skiatest::Reporter* reporter) { |
| 284 | SkPath path; |
| 285 | path.addRect({1, 2, 3, 4}); |
| 286 | path.incReserve(100); // give shrinkToFit() something to do |
| 287 | |
| 288 | SkContourMeasureIter iter(path, false); |
| 289 | |
| 290 | // shrinks the allocation, possibly relocating the underlying arrays. |
| 291 | // The contouremasureiter needs to have safely copied path, to be unaffected by this |
| 292 | // change to "path". |
Mike Reed | f1f1e7d | 2020-10-15 14:52:54 -0400 | [diff] [blame] | 293 | SkPathPriv::ShrinkToFit(&path); |
Mike Reed | c924a88 | 2020-10-13 21:22:47 -0400 | [diff] [blame] | 294 | |
| 295 | // Note, this failed (before the fix) on an ASAN build, which notices that we were |
| 296 | // using an internal iterator of the passed-in path, not our copy. |
| 297 | while (iter.next()) |
| 298 | ; |
| 299 | } |
| 300 | |
Mike Reed | cc88f3a | 2019-02-06 11:40:27 -0500 | [diff] [blame] | 301 | DEF_TEST(contour_measure, reporter) { |
| 302 | SkPath path; |
| 303 | path.addCircle(0, 0, 100); |
| 304 | path.addCircle(0, 0, 10); |
| 305 | |
| 306 | SkContourMeasureIter fact(path, false); |
| 307 | path.reset(); // we should not need the path avert we created the factory |
| 308 | |
| 309 | auto cm0 = fact.next(); |
| 310 | auto cm1 = fact.next(); |
| 311 | |
| 312 | REPORTER_ASSERT(reporter, cm0->isClosed()); |
| 313 | REPORTER_ASSERT(reporter, SkScalarNearlyEqual(cm0->length(), 200 * SK_ScalarPI, 1.5f)); |
| 314 | |
| 315 | test_90_degrees(cm0, 100, reporter); |
| 316 | |
| 317 | REPORTER_ASSERT(reporter, cm1->isClosed()); |
| 318 | REPORTER_ASSERT(reporter, SkScalarNearlyEqual(cm1->length(), 20 * SK_ScalarPI, 0.5f)); |
| 319 | |
| 320 | test_90_degrees(cm1, 10, reporter); |
| 321 | |
| 322 | auto cm2 = fact.next(); |
| 323 | REPORTER_ASSERT(reporter, !cm2); |
| 324 | |
| 325 | test_empty_contours(reporter); |
Mike Reed | 62ad46b | 2019-02-13 11:48:35 -0500 | [diff] [blame] | 326 | test_MLM_contours(reporter); |
Mike Reed | c924a88 | 2020-10-13 21:22:47 -0400 | [diff] [blame] | 327 | |
| 328 | test_shrink(reporter); |
Mike Reed | cc88f3a | 2019-02-06 11:40:27 -0500 | [diff] [blame] | 329 | } |