Lines Matching refs:Reporter
34 static void test_add_rrect(skiatest::Reporter* reporter, const SkRect& bounds,
38 REPORTER_ASSERT(reporter, bounds == rrect.rect());
43 REPORTER_ASSERT(reporter, bounds == path.getBounds());
46 static void test_skbug_3469(skiatest::Reporter* reporter) {
51 REPORTER_ASSERT(reporter, !path.isConvex());
54 static void test_skbug_3239(skiatest::Reporter* reporter) {
67 test_add_rrect(reporter, rectx, radii);
68 test_add_rrect(reporter, recty, radii);
227 static void make_path_crbugskia2820(SkPath* path, skiatest::Reporter* reporter) {
240 static void test_path_crbugskia2820(skiatest::Reporter* reporter) {//GrContext* context) {
242 make_path_crbugskia2820(&path, reporter);
282 static void test_path_to_region(skiatest::Reporter* reporter) {
308 static void test_path_close_issue1474(skiatest::Reporter* reporter) {
321 REPORTER_ASSERT(reporter, 50 == last.fX);
322 REPORTER_ASSERT(reporter, 50 == last.fY);
332 REPORTER_ASSERT(reporter, 75 == last.fX);
333 REPORTER_ASSERT(reporter, 75 == last.fY);
343 REPORTER_ASSERT(reporter, 85 == last.fX);
344 REPORTER_ASSERT(reporter, 85 == last.fY);
354 REPORTER_ASSERT(reporter, 95 == last.fX);
355 REPORTER_ASSERT(reporter, 95 == last.fY);
358 static void test_gen_id(skiatest::Reporter* reporter) {
360 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID());
364 REPORTER_ASSERT(reporter, z != b.getGenerationID());
367 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID());
371 REPORTER_ASSERT(reporter, z != y);
375 REPORTER_ASSERT(reporter, x != y && x != z);
378 REPORTER_ASSERT(reporter, b.getGenerationID() == y && a.getGenerationID() == x);
381 REPORTER_ASSERT(reporter, b.getGenerationID() == x);
384 REPORTER_ASSERT(reporter, c.getGenerationID() == x);
388 REPORTER_ASSERT(reporter, b.getGenerationID() == x);
389 REPORTER_ASSERT(reporter, a.getGenerationID() == x);
390 REPORTER_ASSERT(reporter, w != x);
400 REPORTER_ASSERT(reporter, (v == w) == kExpectGenIDToIgnoreFill);
403 REPORTER_ASSERT(reporter, v != c.getGenerationID());
536 static void test_tiny_path_convexity(skiatest::Reporter* reporter, const char* pathBug,
549 REPORTER_ASSERT(reporter, smallConvex == largeConvex);
552 static void test_crbug_493450(skiatest::Reporter* reporter) {
560 test_tiny_path_convexity(reporter, reducedCase, 100, 100, 100000);
567 test_tiny_path_convexity(reporter, originalFiddleData, 280081.4116670522f, 93268.04618493588f,
571 static void test_crbug_495894(skiatest::Reporter* reporter) {
593 test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7819.72220766405f,
608 static void test_addrect(skiatest::Reporter* reporter) {
612 REPORTER_ASSERT(reporter, path.isRect(nullptr));
617 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
622 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
627 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
632 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
636 static void test_addrect_isfinite(skiatest::Reporter* reporter) {
640 REPORTER_ASSERT(reporter, path.isFinite());
644 REPORTER_ASSERT(reporter, !path.isFinite());
647 REPORTER_ASSERT(reporter, !path.isFinite());
650 REPORTER_ASSERT(reporter, path.isFinite());
653 REPORTER_ASSERT(reporter, path.isFinite());
695 static void dump_if_ne(skiatest::Reporter* reporter, const SkRect& expected, const SkRect& bounds) {
697 ERRORF(reporter, "path.getBounds() returned [%g %g %g %g], but expected [%g %g %g %g]",
703 static void test_bounds_crbug_513799(skiatest::Reporter* reporter) {
708 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(0, 0, 0, 0) == path.getBounds());
711 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, -5, -8) == path.getBounds());
714 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds());
717 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds());
719 dump_if_ne(reporter, SkRect::MakeLTRB(0, 0, 0, 0), path.getBounds());
722 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, -5, -8), path.getBounds());
725 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, 3, 4), path.getBounds());
728 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, 3, 4), path.getBounds());
733 static void test_fuzz_crbug_627414(skiatest::Reporter* reporter) {
760 static void test_isfinite_after_transform(skiatest::Reporter* reporter) {
773 REPORTER_ASSERT(reporter, path.getBounds().isFinite());
774 REPORTER_ASSERT(reporter, !path.getBounds().isEmpty());
777 REPORTER_ASSERT(reporter, path.getBounds().isEmpty());
782 REPORTER_ASSERT(reporter, !path.isFinite());
783 REPORTER_ASSERT(reporter, path.getBounds().isEmpty());
830 static void test_arb_round_rect_is_convex(skiatest::Reporter* reporter) {
849 REPORTER_ASSERT(reporter, temp.isConvex());
857 static void test_arb_zero_rad_round_rect_is_rect(skiatest::Reporter* reporter) {
877 REPORTER_ASSERT(reporter, temp.isRect(&result));
878 REPORTER_ASSERT(reporter, r == result);
882 static void test_rect_isfinite(skiatest::Reporter* reporter) {
889 REPORTER_ASSERT(reporter, r.isFinite());
891 REPORTER_ASSERT(reporter, !r.isFinite());
893 REPORTER_ASSERT(reporter, !r.isFinite());
902 REPORTER_ASSERT(reporter, isFine);
903 REPORTER_ASSERT(reporter, !r.isEmpty());
907 REPORTER_ASSERT(reporter, !isFine);
908 REPORTER_ASSERT(reporter, r.isEmpty());
912 REPORTER_ASSERT(reporter, !isFine);
913 REPORTER_ASSERT(reporter, r.isEmpty());
916 static void test_path_isfinite(skiatest::Reporter* reporter) {
922 REPORTER_ASSERT(reporter, path.isFinite());
925 REPORTER_ASSERT(reporter, path.isFinite());
929 REPORTER_ASSERT(reporter, path.isFinite());
933 REPORTER_ASSERT(reporter, !path.isFinite());
937 REPORTER_ASSERT(reporter, !path.isFinite());
940 static void test_isfinite(skiatest::Reporter* reporter) {
941 test_rect_isfinite(reporter);
942 test_path_isfinite(reporter);
945 static void test_islastcontourclosed(skiatest::Reporter* reporter) {
947 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
949 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
951 REPORTER_ASSERT(reporter, path.isLastContourClosed());
953 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
955 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
957 REPORTER_ASSERT(reporter, path.isLastContourClosed());
959 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
969 static void test_poly(skiatest::Reporter* reporter, const SkPath& path,
979 REPORTER_ASSERT(reporter, firstTime);
980 REPORTER_ASSERT(reporter, pts[0] == srcPts[0]);
985 REPORTER_ASSERT(reporter, !firstTime);
986 REPORTER_ASSERT(reporter, pts[1] == srcPts[0]);
990 REPORTER_ASSERT(reporter, false, "unexpected quad verb");
993 REPORTER_ASSERT(reporter, false, "unexpected conic verb");
996 REPORTER_ASSERT(reporter, false, "unexpected cubic verb");
999 REPORTER_ASSERT(reporter, !firstTime);
1000 REPORTER_ASSERT(reporter, !foundClose);
1001 REPORTER_ASSERT(reporter, expectClose);
1009 REPORTER_ASSERT(reporter, foundClose == expectClose);
1012 static void test_addPoly(skiatest::Reporter* reporter) {
1025 test_poly(reporter, path, pts, SkToBool(doClose));
1030 static void test_strokerec(skiatest::Reporter* reporter) {
1032 REPORTER_ASSERT(reporter, rec.isFillStyle());
1035 REPORTER_ASSERT(reporter, rec.isHairlineStyle());
1038 REPORTER_ASSERT(reporter, SkStrokeRec::kStroke_Style == rec.getStyle());
1041 REPORTER_ASSERT(reporter, SkStrokeRec::kStrokeAndFill_Style == rec.getStyle());
1044 REPORTER_ASSERT(reporter, SkStrokeRec::kHairline_Style == rec.getStyle());
1047 REPORTER_ASSERT(reporter, SkStrokeRec::kFill_Style == rec.getStyle());
1054 static void check_direction(skiatest::Reporter* reporter, const SkPath& path,
1063 REPORTER_ASSERT(reporter, dir == expected);
1065 REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expected);
1069 static void test_direction(skiatest::Reporter* reporter) {
1072 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
1073 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
1074 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
1075 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kUnknown_FirstDirection));
1088 REPORTER_ASSERT(reporter, valid);
1089 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
1104 REPORTER_ASSERT(reporter, valid);
1105 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1120 REPORTER_ASSERT(reporter, valid);
1121 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1129 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1134 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1142 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1147 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1153 REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity());
1154 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1165 static void test_bounds(skiatest::Reporter* reporter) {
1179 REPORTER_ASSERT(reporter, path0.getBounds() == path1.getBounds());
1218 static void check_close(skiatest::Reporter* reporter, const SkPath& path) {
1234 REPORTER_ASSERT(reporter, mv == pts[0]);
1243 REPORTER_ASSERT(reporter, !i || nMT == nCL);
1247 static void test_close(skiatest::Reporter* reporter) {
1251 check_close(reporter, closePt);
1255 check_close(reporter, openPt);
1258 check_close(reporter, empty);
1260 check_close(reporter, empty);
1264 check_close(reporter, rect);
1266 check_close(reporter, rect);
1270 check_close(reporter, quad);
1272 check_close(reporter, quad);
1277 check_close(reporter, cubic);
1279 check_close(reporter, cubic);
1284 check_close(reporter, line);
1286 check_close(reporter, line);
1292 check_close(reporter, rect2);
1294 check_close(reporter, rect2);
1300 check_close(reporter, oval3);
1302 check_close(reporter, oval3);
1309 check_close(reporter, moves);
1314 static void check_convexity(skiatest::Reporter* reporter, const SkPath& path,
1318 REPORTER_ASSERT(reporter, c == expected);
1321 static void test_path_crbug389050(skiatest::Reporter* reporter) {
1329 check_convexity(reporter, tinyConvexPolygon, SkPath::kConvex_Convexity);
1330 check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection);
1338 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1346 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1349 static void test_convexity2(skiatest::Reporter* reporter) {
1353 check_convexity(reporter, pt, SkPath::kConvex_Convexity);
1354 check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection);
1360 check_convexity(reporter, line, SkPath::kConvex_Convexity);
1361 check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection);
1368 check_convexity(reporter, triLeft, SkPath::kConvex_Convexity);
1369 check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection);
1376 check_convexity(reporter, triRight, SkPath::kConvex_Convexity);
1377 check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection);
1385 check_convexity(reporter, square, SkPath::kConvex_Convexity);
1386 check_direction(reporter, square, SkPathPriv::kCW_FirstDirection);
1402 check_convexity(reporter, redundantSquare, SkPath::kConvex_Convexity);
1403 check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection);
1419 check_convexity(reporter, bowTie, SkPath::kConcave_Convexity);
1420 check_direction(reporter, bowTie, kDontCheckDir);
1431 check_convexity(reporter, spiral, SkPath::kConcave_Convexity);
1432 check_direction(reporter, spiral, kDontCheckDir);
1441 check_convexity(reporter, dent, SkPath::kConcave_Convexity);
1442 check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection);
1458 check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity);
1459 check_direction(reporter, strokedSin, kDontCheckDir);
1469 check_convexity(reporter, degenerateConcave, SkPath::kConcave_Convexity);
1470 check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirection);
1484 check_convexity(reporter, badFirstVector, SkPath::kConcave_Convexity);
1487 static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p,
1489 REPORTER_ASSERT(reporter, p.isConvex());
1490 REPORTER_ASSERT(reporter, p.getBounds() == bounds);
1493 REPORTER_ASSERT(reporter, p2.isConvex());
1494 REPORTER_ASSERT(reporter, p2.getBounds() == bounds);
1498 REPORTER_ASSERT(reporter, other.isConvex());
1499 REPORTER_ASSERT(reporter, other.getBounds() == bounds);
1521 static void test_convexity(skiatest::Reporter* reporter) {
1524 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1526 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1528 check_convexity(reporter, path, SkPath::kConcave_Convexity);
1532 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1533 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
1537 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1538 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
1542 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1562 check_convexity(reporter, path, gRec[i].fExpectedConvexity);
1563 check_direction(reporter, path, gRec[i].fExpectedDirection);
1569 REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPathPriv::kUnknown_FirstDirection)
1571 REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir);
1572 check_convexity(reporter, copy, gRec[i].fExpectedConvexity);
1574 REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexity());
1575 check_direction(reporter, path, gRec[i].fExpectedDirection);
1625 check_convexity(reporter, path, SkPath::kUnknown_Convexity);
1646 check_convexity(reporter, path, curveSelect == 0 ? SkPath::kConvex_Convexity
1658 check_convexity(reporter, path, SkPath::kConcave_Convexity);
1662 static void test_isLine(skiatest::Reporter* reporter) {
1667 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1672 REPORTER_ASSERT(reporter, !path.isLine(pts));
1674 REPORTER_ASSERT(reporter, pts[0].equals(value, value));
1675 REPORTER_ASSERT(reporter, pts[1].equals(value, value));
1679 REPORTER_ASSERT(reporter, value != moveX && value != moveY);
1682 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1683 REPORTER_ASSERT(reporter, !path.isLine(pts));
1685 REPORTER_ASSERT(reporter, pts[0].equals(value, value));
1686 REPORTER_ASSERT(reporter, pts[1].equals(value, value));
1690 REPORTER_ASSERT(reporter, value != lineX && value != lineY);
1693 REPORTER_ASSERT(reporter, path.isLine(nullptr));
1695 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY));
1696 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY));
1697 REPORTER_ASSERT(reporter, path.isLine(pts));
1698 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY));
1699 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY));
1702 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1703 REPORTER_ASSERT(reporter, !path.isLine(pts));
1704 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY));
1705 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY));
1709 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1712 static void test_conservativelyContains(skiatest::Reporter* reporter) {
1815 REPORTER_ASSERT(reporter, kQueries[q].fInRect ==
1820 REPORTER_ASSERT(reporter, kQueries[q].fInCircle ==
1825 REPORTER_ASSERT(reporter, kQueries[q].fInRR ==
1837 REPORTER_ASSERT(reporter, kQueries[q].fInCubicRR ==
1849 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect));
1860 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1864 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1870 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(-10),
1876 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(10),
1884 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1896 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1909 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1923 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1930 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(0, 0, 1, 1)));
1936 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeWH(1,1)));
1937 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeWH(0,0)));
1940 static void test_isRect_open_close(skiatest::Reporter* reporter) {
1947 REPORTER_ASSERT(reporter, path.isRect(nullptr, &isClosed, nullptr));
1948 REPORTER_ASSERT(reporter, isClosed);
1953 static void test_isRect(skiatest::Reporter* reporter) {
1954 test_isRect_open_close(reporter);
2051 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(nullptr));
2059 REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(path, &cheapDirection));
2060 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &direction));
2061 REPORTER_ASSERT(reporter, expected == computed);
2062 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose);
2063 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(direction) == cheapDirection);
2069 REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direction));
2070 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
2071 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
2072 REPORTER_ASSERT(reporter, isClosed == (bool) -1);
2073 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
2085 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2097 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2106 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2118 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2130 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2133 static void check_simple_closed_rect(skiatest::Reporter* reporter, const SkPath& path,
2139 REPORTER_ASSERT(reporter, SkPathPriv::IsSimpleClosedRect(path, &r, &d, &s));
2140 REPORTER_ASSERT(reporter, r == rect);
2141 REPORTER_ASSERT(reporter, d == dir);
2142 REPORTER_ASSERT(reporter, s == start);
2145 static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
2157 check_simple_closed_rect(reporter, path, testRect, dir, start);
2159 check_simple_closed_rect(reporter, path, testRect, dir, start);
2162 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2165 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2168 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2189 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2192 check_simple_closed_rect(reporter, path2, testRect, dir, start);
2195 check_simple_closed_rect(reporter, path2, testRect, dir, start);
2199 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2204 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2209 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2220 check_simple_closed_rect(reporter, path2, testRect, swapDir, kXSwapStarts[start]);
2225 check_simple_closed_rect(reporter, path2, testRect, swapDir, kYSwapStarts[start]);
2238 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2246 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2254 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2262 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2266 static void test_isNestedFillRects(skiatest::Reporter* reporter) {
2350 REPORTER_ASSERT(reporter,
2366 REPORTER_ASSERT(reporter, path.isNestedFillRects(computed, computedDirs));
2367 REPORTER_ASSERT(reporter, expected[0] == computed[0]);
2368 REPORTER_ASSERT(reporter, expected[1] == computed[1]);
2369 REPORTER_ASSERT(reporter, expectedDirs[0] == SkPathPriv::AsFirstDirection(computedDirs[0]));
2370 REPORTER_ASSERT(reporter, expectedDirs[1] == SkPathPriv::AsFirstDirection(computedDirs[1]));
2388 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2406 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2421 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2439 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2457 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2463 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2478 REPORTER_ASSERT(reporter, path.isNestedFillRects(nullptr));
2487 REPORTER_ASSERT(reporter, dst.isNestedFillRects(nullptr));
2490 static void write_and_read_back(skiatest::Reporter* reporter,
2500 REPORTER_ASSERT(reporter, readBack != p);
2502 REPORTER_ASSERT(reporter, readBack == p);
2504 REPORTER_ASSERT(reporter, readBack.getConvexityOrUnknown() ==
2510 REPORTER_ASSERT(reporter, readBack.isOval(nullptr) == p.isOval(nullptr));
2513 REPORTER_ASSERT(reporter, oval0 == oval1);
2514 REPORTER_ASSERT(reporter, dir0 == dir1);
2515 REPORTER_ASSERT(reporter, start0 == start1);
2517 REPORTER_ASSERT(reporter, readBack.isRRect(nullptr) == p.isRRect(nullptr));
2521 REPORTER_ASSERT(reporter, rrect0 == rrect1);
2522 REPORTER_ASSERT(reporter, dir0 == dir1);
2523 REPORTER_ASSERT(reporter, start0 == start1);
2528 REPORTER_ASSERT(reporter, origBounds == readBackBounds);
2531 static void test_flattening(skiatest::Reporter* reporter) {
2545 write_and_read_back(reporter, p);
2552 REPORTER_ASSERT(reporter, size1 == size2);
2556 REPORTER_ASSERT(reporter, size1 == size3);
2557 REPORTER_ASSERT(reporter, p == p2);
2560 REPORTER_ASSERT(reporter, !size3);
2564 REPORTER_ASSERT(reporter, tooShort.isEmpty());
2568 REPORTER_ASSERT(reporter, size1 == size3);
2569 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
2577 write_and_read_back(reporter, oval);
2581 static void test_transform(skiatest::Reporter* reporter) {
2610 REPORTER_ASSERT(reporter, p == p1);
2623 REPORTER_ASSERT(reporter, kPtCount == count);
2626 REPORTER_ASSERT(reporter, newPt == pts1[i]);
2639 REPORTER_ASSERT(reporter, matrix.invert(&matrix));
2643 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fLeft, p1Bounds.fLeft));
2644 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fTop, p1Bounds.fTop));
2645 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fRight, p1Bounds.fRight));
2646 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fBottom, p1Bounds.fBottom));
2659 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCW_FirstDirection));
2671 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCCW_FirstDirection));
2681 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kUnknown_FirstDirection));
2685 static void test_zero_length_paths(skiatest::Reporter* reporter) {
2745 REPORTER_ASSERT(reporter, valid);
2746 REPORTER_ASSERT(reporter, !p.isEmpty());
2747 REPORTER_ASSERT(reporter, gZeroLengthTests[i].numResultPts == (size_t)p.countPoints());
2748 REPORTER_ASSERT(reporter, gZeroLengthTests[i].resultBound == p.getBounds());
2749 REPORTER_ASSERT(reporter, gZeroLengthTests[i].numResultVerbs == (size_t)p.getVerbs(verbs, SK_ARRAY_COUNT(verbs)));
2751 REPORTER_ASSERT(reporter, gZeroLengthTests[i].resultVerbs[j] == verbs[j]);
2763 static void test_segment_masks(skiatest::Reporter* reporter) {
2768 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == p.getSegmentMasks());
2769 REPORTER_ASSERT(reporter, !p.isEmpty());
2771 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2773 REPORTER_ASSERT(reporter, kCurveSegmentMask == p.getSegmentMasks());
2774 REPORTER_ASSERT(reporter, !p.isEmpty());
2776 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2781 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == p.getSegmentMasks());
2783 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2785 REPORTER_ASSERT(reporter, !p.isEmpty());
2788 static void test_iter(skiatest::Reporter* reporter) {
2794 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2798 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2802 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2806 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2810 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2874 REPORTER_ASSERT(reporter, valid);
2878 REPORTER_ASSERT(reporter, iter.next(pts, gIterTests[i].consumeDegenerates) == gIterTests[i].resultVerbs[j]);
2880 REPORTER_ASSERT(reporter, pts[k] == gIterTests[i].resultPts[l++]);
2883 REPORTER_ASSERT(reporter, j == (int)gIterTests[i].numResultVerbs);
2888 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2892 REPORTER_ASSERT(reporter, iter.isClosedContour());
2895 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2898 REPORTER_ASSERT(reporter, iter.isClosedContour());
2902 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2913 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == iter.next(pts, false));
2920 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == iter.next(pts, false));
2923 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
2929 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts, false));
2932 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
2938 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false));
2941 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
2946 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false));
2949 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
2961 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == iter.next(pts));
2962 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
2963 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
2964 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts));
2965 REPORTER_ASSERT(reporter, SK_ScalarRoot2Over2 == iter.conicWeight());
2968 static void test_raw_iter(skiatest::Reporter* reporter) {
2974 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2977 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2981 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2986 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
2987 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
2988 REPORTER_ASSERT(reporter, pts[0].fY == 0);
2989 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2995 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
2996 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
2997 REPORTER_ASSERT(reporter, pts[0].fY == 0);
2998 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
2999 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*2);
3000 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1);
3001 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3002 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*3);
3003 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*2);
3004 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3010 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3024 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3025 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3026 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3027 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3028 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3029 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*2);
3030 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1);
3031 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3032 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3033 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*3);
3034 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*2);
3035 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3036 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*4);
3037 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*3);
3038 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3039 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3146 REPORTER_ASSERT(reporter, nextVerb == expectedVerbs[numIterVerbs]);
3150 REPORTER_ASSERT(reporter, numIterPts < numPoints);
3151 REPORTER_ASSERT(reporter, pts[0] == expectedPts[numIterPts]);
3156 REPORTER_ASSERT(reporter, numIterPts < numPoints + 1);
3157 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3158 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3164 REPORTER_ASSERT(reporter, numIterPts < numPoints + 2);
3165 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3166 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3167 REPORTER_ASSERT(reporter, pts[2] == expectedPts[numIterPts + 1]);
3172 REPORTER_ASSERT(reporter, numIterPts < numPoints + 3);
3173 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3174 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3175 REPORTER_ASSERT(reporter, pts[2] == expectedPts[numIterPts + 1]);
3176 REPORTER_ASSERT(reporter, pts[3] == expectedPts[numIterPts + 2]);
3187 REPORTER_ASSERT(reporter, numIterPts == numPoints);
3188 REPORTER_ASSERT(reporter, numIterVerbs == numVerbs);
3192 static void check_for_circle(skiatest::Reporter* reporter,
3197 REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle);
3201 REPORTER_ASSERT(reporter, rect.height() == rect.width());
3202 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(isOvalDir) == expectedDir);
3205 REPORTER_ASSERT(reporter, path == tmpPath);
3207 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, expectedDir));
3210 static void test_circle_skew(skiatest::Reporter* reporter,
3222 REPORTER_ASSERT(reporter, SkPathPriv::kCW_FirstDirection == dir);
3225 check_for_circle(reporter, tmp, false, dir);
3228 static void test_circle_translate(skiatest::Reporter* reporter,
3237 check_for_circle(reporter, tmp, true, dir);
3245 check_for_circle(reporter, tmp, true, dir);
3248 static void test_circle_rotate(skiatest::Reporter* reporter,
3261 check_for_circle(reporter, tmp, true, dir);
3263 check_for_circle(reporter, tmp, false, dir);
3268 static void test_circle_mirror_x(skiatest::Reporter* reporter,
3279 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
3282 check_for_circle(reporter, tmp, true, dir);
3285 static void test_circle_mirror_y(skiatest::Reporter* reporter,
3297 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
3301 check_for_circle(reporter, tmp, true, dir);
3304 static void test_circle_mirror_xy(skiatest::Reporter* reporter,
3314 check_for_circle(reporter, tmp, true, dir);
3317 static void test_circle_with_direction(skiatest::Reporter* reporter,
3325 check_for_circle(reporter, path, true, dir);
3326 test_circle_rotate(reporter, path, dir);
3327 test_circle_translate(reporter, path, dir);
3328 test_circle_skew(reporter, path, dir);
3329 test_circle_mirror_x(reporter, path, dir);
3330 test_circle_mirror_y(reporter, path, dir);
3331 test_circle_mirror_xy(reporter, path, dir);
3338 check_for_circle(reporter, path, true, dir);
3339 test_circle_rotate(reporter, path, dir);
3340 test_circle_translate(reporter, path, dir);
3341 test_circle_skew(reporter, path, dir);
3342 test_circle_mirror_x(reporter, path, dir);
3343 test_circle_mirror_y(reporter, path, dir);
3344 test_circle_mirror_xy(reporter, path, dir);
3350 test_circle_rotate(reporter, path, dir);
3351 test_circle_translate(reporter, path, dir);
3352 test_circle_skew(reporter, path, dir);
3353 test_circle_mirror_x(reporter, path, dir);
3354 test_circle_mirror_y(reporter, path, dir);
3355 test_circle_mirror_xy(reporter, path, dir);
3359 static void test_circle_with_add_paths(skiatest::Reporter* reporter) {
3381 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircleDir));
3387 check_for_circle(reporter, path, true, SkPathPriv::AsFirstDirection(kCircleDir));
3392 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircleDirOpposite));
3395 static void test_circle(skiatest::Reporter* reporter) {
3396 test_circle_with_direction(reporter, SkPath::kCW_Direction);
3397 test_circle_with_direction(reporter, SkPath::kCCW_Direction);
3403 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3409 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3415 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3417 test_circle_with_add_paths(reporter);
3422 REPORTER_ASSERT(reporter, path.isEmpty());
3425 static void test_oval(skiatest::Reporter* reporter) {
3436 REPORTER_ASSERT(reporter, path.isOval(nullptr));
3443 REPORTER_ASSERT(reporter, SkPathPriv::IsOval(tmp, nullptr, &dir, &start));
3444 REPORTER_ASSERT(reporter, 2 == start);
3445 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3452 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3459 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3463 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3469 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3476 REPORTER_ASSERT(reporter, path.isOval(nullptr));
3483 REPORTER_ASSERT(reporter, SkPathPriv::IsOval(path, nullptr, &dir, &start));
3484 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3485 REPORTER_ASSERT(reporter, 1 == start);
3488 static void test_empty(skiatest::Reporter* reporter, const SkPath& p) {
3491 REPORTER_ASSERT(reporter, p.isEmpty());
3492 REPORTER_ASSERT(reporter, 0 == p.countPoints());
3493 REPORTER_ASSERT(reporter, 0 == p.countVerbs());
3494 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks());
3495 REPORTER_ASSERT(reporter, p.isConvex());
3496 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType);
3497 REPORTER_ASSERT(reporter, !p.isInverseFillType());
3498 REPORTER_ASSERT(reporter, p == empty);
3499 REPORTER_ASSERT(reporter, !(p != empty));
3502 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path,
3504 REPORTER_ASSERT(reporter, path->isConvex());
3505 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
3507 REPORTER_ASSERT(reporter, path->isConvex());
3511 static void test_rrect_convexity_is_unknown(skiatest::Reporter* reporter, SkPath* path,
3513 REPORTER_ASSERT(reporter, path->isConvex());
3514 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
3516 REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kUnknown_Convexity);
3520 static void test_rrect(skiatest::Reporter* reporter) {
3527 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3529 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3531 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3533 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3535 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3537 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3543 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3548 REPORTER_ASSERT(reporter, p.isRect(&returnedRect));
3549 REPORTER_ASSERT(reporter, returnedRect == r);
3550 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3556 REPORTER_ASSERT(reporter, p.isRect(nullptr, &closed, &dir));
3557 REPORTER_ASSERT(reporter, closed);
3558 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3559 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3562 REPORTER_ASSERT(reporter, !p.isConvex());
3566 REPORTER_ASSERT(reporter, !p.isConvex());
3573 REPORTER_ASSERT(reporter, !p.isEmpty());
3578 test_rrect_convexity_is_unknown(reporter, &p, SkPath::kCW_Direction);
3583 REPORTER_ASSERT(reporter, rr.isEmpty());
3587 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3590 static void test_arc(skiatest::Reporter* reporter) {
3593 REPORTER_ASSERT(reporter, emptyOval.isEmpty());
3595 REPORTER_ASSERT(reporter, p.isEmpty());
3599 REPORTER_ASSERT(reporter, p.isEmpty());
3604 REPORTER_ASSERT(reporter, p == cwOval);
3609 REPORTER_ASSERT(reporter, p == ccwOval);
3612 REPORTER_ASSERT(reporter, p.isConvex());
3613 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::kCW_FirstDirection));
3615 REPORTER_ASSERT(reporter, p.isConvex());
3643 static void check_oval_arc(skiatest::Reporter* reporter
3649 REPORTER_ASSERT(reporter, isOval);
3652 REPORTER_ASSERT(reporter, path == recreatedPath);
3653 REPORTER_ASSERT(reporter, oval_start_index_to_angle(s) == canonical_start_angle(start));
3654 REPORTER_ASSERT(reporter, (SkPath::kCW_Direction == d) == (sweep > 0.f));
3657 static void test_arc_ovals(skiatest::Reporter* reporter) {
3666 check_oval_arc(reporter, start, sweep, path);
3668 REPORTER_ASSERT(reporter, !path.isOval(nullptr));
3676 check_oval_arc(reporter, start, sweep, path);
3682 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3686 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb);
3687 REPORTER_ASSERT(reporter, pts[0].fX == x0);
3688 REPORTER_ASSERT(reporter, pts[0].fY == y0);
3691 static void check_line(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3695 REPORTER_ASSERT(reporter, v == SkPath::kLine_Verb);
3696 REPORTER_ASSERT(reporter, pts[1].fX == x1);
3697 REPORTER_ASSERT(reporter, pts[1].fY == y1);
3700 static void check_quad(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3704 REPORTER_ASSERT(reporter, v == SkPath::kQuad_Verb);
3705 REPORTER_ASSERT(reporter, pts[1].fX == x1);
3706 REPORTER_ASSERT(reporter, pts[1].fY == y1);
3707 REPORTER_ASSERT(reporter, pts[2].fX == x2);
3708 REPORTER_ASSERT(reporter, pts[2].fY == y2);
3711 static void check_done(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) {
3714 REPORTER_ASSERT(reporter, v == SkPath::kDone_Verb);
3717 static void check_done_and_reset(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) {
3718 check_done(reporter, p, iter);
3722 static void check_path_is_move_and_reset(skiatest::Reporter* reporter, SkPath* p,
3725 check_move(reporter, &iter, x0, y0);
3726 check_done_and_reset(reporter, p, &iter);
3729 static void check_path_is_line_and_reset(skiatest::Reporter* reporter, SkPath* p,
3732 check_move(reporter, &iter, 0, 0);
3733 check_line(reporter, &iter, x1, y1);
3734 check_done_and_reset(reporter, p, &iter);
3737 static void check_path_is_line(skiatest::Reporter* reporter, SkPath* p,
3740 check_move(reporter, &iter, 0, 0);
3741 check_line(reporter, &iter, x1, y1);
3742 check_done(reporter, p, &iter);
3745 static void check_path_is_line_pair_and_reset(skiatest::Reporter* reporter, SkPath* p,
3748 check_move(reporter, &iter, 0, 0);
3749 check_line(reporter, &iter, x1, y1);
3750 check_line(reporter, &iter, x2, y2);
3751 check_done_and_reset(reporter, p, &iter);
3754 static void check_path_is_quad_and_reset(skiatest::Reporter* reporter, SkPath* p,
3757 check_move(reporter, &iter, 0, 0);
3758 check_quad(reporter, &iter, x1, y1, x2, y2);
3759 check_done_and_reset(reporter, p, &iter);
3769 static void test_arcTo(skiatest::Reporter* reporter) {
3772 check_path_is_line_and_reset(reporter, &p, 0, 0);
3774 check_path_is_line_and_reset(reporter, &p, 1, 2);
3776 check_path_is_line_and_reset(reporter, &p, 1, 2);
3778 check_path_is_line_and_reset(reporter, &p, 1, 2);
3781 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == 1);
3784 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == -1);
3788 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3790 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3792 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3794 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3798 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval));
3804 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval));
3811 REPORTER_ASSERT(reporter, p.isEmpty());
3816 REPORTER_ASSERT(reporter, p.isEmpty());
3819 static void test_addPath(skiatest::Reporter* reporter) {
3830 REPORTER_ASSERT(reporter, p.getBounds() == expected);
3834 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
3837 static void test_addPathMode(skiatest::Reporter* reporter, bool explicitMoveTo, bool extend) {
3850 REPORTER_ASSERT(reporter, verbcount == 4);
3851 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3852 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3853 REPORTER_ASSERT(reporter, verbs[2] == (extend ? SkPath::kLine_Verb : SkPath::kMove_Verb));
3854 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kLine_Verb);
3857 static void test_extendClosedPath(skiatest::Reporter* reporter) {
3868 REPORTER_ASSERT(reporter, verbcount == 7);
3869 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3870 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3871 REPORTER_ASSERT(reporter, verbs[2] == SkPath::kLine_Verb);
3872 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kClose_Verb);
3873 REPORTER_ASSERT(reporter, verbs[4] == SkPath::kMove_Verb);
3874 REPORTER_ASSERT(reporter, verbs[5] == SkPath::kLine_Verb);
3875 REPORTER_ASSERT(reporter, verbs[6] == SkPath::kLine_Verb);
3878 REPORTER_ASSERT(reporter, p.getLastPt(&pt));
3879 REPORTER_ASSERT(reporter, pt == SkPoint::Make(2, 3));
3880 REPORTER_ASSERT(reporter, p.getPoint(3) == SkPoint::Make(1, 1));
3883 static void test_addEmptyPath(skiatest::Reporter* reporter, SkPath::AddPathMode mode) {
3889 REPORTER_ASSERT(reporter, q == p);
3892 REPORTER_ASSERT(reporter, q == p);
3896 REPORTER_ASSERT(reporter, q.isEmpty());
3899 static void test_conicTo_special_case(skiatest::Reporter* reporter) {
3902 check_path_is_line_and_reset(reporter, &p, 3, 4);
3904 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4);
3906 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4);
3909 static void test_get_point(skiatest::Reporter* reporter) {
3912 REPORTER_ASSERT(reporter, pt == SkPoint::Make(0, 0));
3913 REPORTER_ASSERT(reporter, !p.getLastPt(nullptr));
3914 REPORTER_ASSERT(reporter, !p.getLastPt(&pt) && pt == SkPoint::Make(0, 0));
3917 REPORTER_ASSERT(reporter, pt == SkPoint::Make(10, 10));
3918 REPORTER_ASSERT(reporter, p.getLastPt(nullptr));
3920 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt == SkPoint::Make(20, 20));
3923 static void test_contains(skiatest::Reporter* reporter) {
3936 REPORTER_ASSERT(reporter, p.contains(0, 0));
3938 REPORTER_ASSERT(reporter, !p.contains(0, 0));
3943 REPORTER_ASSERT(reporter, p.contains(6, 4));
3944 REPORTER_ASSERT(reporter, p.contains(5, 6));
3945 REPORTER_ASSERT(reporter, p.contains(7, 6));
3947 REPORTER_ASSERT(reporter, !p.contains(4, 0));
3948 REPORTER_ASSERT(reporter, !p.contains(0, 4));
3949 REPORTER_ASSERT(reporter, !p.contains(4, 10));
3950 REPORTER_ASSERT(reporter, !p.contains(10, 4));
3952 REPORTER_ASSERT(reporter, !p.contains(5, 7));
3953 REPORTER_ASSERT(reporter, p.contains(6, 7));
3954 REPORTER_ASSERT(reporter, !p.contains(7, 7));
3960 REPORTER_ASSERT(reporter, p.contains(4, 6));
3961 REPORTER_ASSERT(reporter, p.contains(6, 5));
3962 REPORTER_ASSERT(reporter, p.contains(6, 7));
3964 REPORTER_ASSERT(reporter, !p.contains(7, 5));
3965 REPORTER_ASSERT(reporter, p.contains(7, 6));
3966 REPORTER_ASSERT(reporter, !p.contains(7, 7));
3973 REPORTER_ASSERT(reporter, p.contains(4, 4));
3974 REPORTER_ASSERT(reporter, p.contains(8, 4));
3975 REPORTER_ASSERT(reporter, p.contains(8, 8));
3976 REPORTER_ASSERT(reporter, p.contains(4, 8));
3982 REPORTER_ASSERT(reporter, p.contains(5, 6));
3983 REPORTER_ASSERT(reporter, p.contains(4, 8));
3984 REPORTER_ASSERT(reporter, p.contains(3, 6));
3990 REPORTER_ASSERT(reporter, p.contains(2, 5));
3991 REPORTER_ASSERT(reporter, p.contains(2, 7));
3992 REPORTER_ASSERT(reporter, p.contains(4, 6));
4001 REPORTER_ASSERT(reporter, !p.contains(1, 2));
4002 REPORTER_ASSERT(reporter, !p.contains(3, 2));
4003 REPORTER_ASSERT(reporter, !p.contains(4, 0));
4004 REPORTER_ASSERT(reporter, p.contains(4, 4));
4012 REPORTER_ASSERT(reporter, p.contains(5, 6));
4013 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4015 REPORTER_ASSERT(reporter, p.contains(5, 5));
4016 REPORTER_ASSERT(reporter, p.contains(5, 8));
4017 REPORTER_ASSERT(reporter, p.contains(4, 5));
4019 REPORTER_ASSERT(reporter, p.contains(4, 4));
4020 REPORTER_ASSERT(reporter, p.contains(8, 8));
4021 REPORTER_ASSERT(reporter, p.contains(4, 8));
4029 REPORTER_ASSERT(reporter, p.contains(5, 6));
4030 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4035 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4045 REPORTER_ASSERT(reporter, p.contains(5, 6));
4046 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4051 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4054 REPORTER_ASSERT(reporter, p.contains(4, 4));
4055 REPORTER_ASSERT(reporter, p.contains(8, 8));
4056 REPORTER_ASSERT(reporter, p.contains(4, 8));
4067 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f));
4068 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f));
4071 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4073 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4075 REPORTER_ASSERT(reporter, p.contains(pts[i].fX, pts[i].fY));
4076 REPORTER_ASSERT(reporter, p.contains(pts[i + 3].fX, pts[i + 3].fY));
4077 REPORTER_ASSERT(reporter, p.contains(pts[i + 6].fX, pts[i + 6].fY));
4083 static void TestPathRef(skiatest::Reporter* reporter) {
4092 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4093 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
4094 REPORTER_ASSERT(reporter, 0 == pathRef->getSegmentMasks());
4096 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef->atVerb(i));
4103 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4104 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
4105 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == pathRef->getSegmentMasks());
4107 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == pathRef->atVerb(i));
4114 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4115 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
4116 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef->getSegmentMasks());
4118 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef->atVerb(i));
4126 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4127 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
4128 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countWeights());
4129 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef->getSegmentMasks());
4130 REPORTER_ASSERT(reporter, weights);
4132 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef->atVerb(i));
4139 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4140 REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef->countPoints());
4141 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef->getSegmentMasks());
4143 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef->atVerb(i));
4150 static void test_operatorEqual(skiatest::Reporter* reporter) {
4153 REPORTER_ASSERT(reporter, a == a);
4154 REPORTER_ASSERT(reporter, a == b);
4156 REPORTER_ASSERT(reporter, a != b);
4158 REPORTER_ASSERT(reporter, a == b);
4160 REPORTER_ASSERT(reporter, a != b);
4162 REPORTER_ASSERT(reporter, a == b);
4165 REPORTER_ASSERT(reporter, a != b);
4168 REPORTER_ASSERT(reporter, a == b);
4171 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool force,
4176 REPORTER_ASSERT(reporter, data->size() == strlen(str));
4178 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
4180 REPORTER_ASSERT(reporter, data->data() == nullptr || !memcmp(data->data(), str, strlen(str)));
4184 static void test_dump(skiatest::Reporter* reporter) {
4186 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n");
4187 compare_dump(reporter, p, true, false, "path.setFillType(SkPath::kWinding_FillType);\n");
4190 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4193 compare_dump(reporter, p, true, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4202 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kEvenOdd_FillType);\n"
4209 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kInverseWinding_FillType);\n"
4216 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kInverseEvenOdd_FillType);\n"
4223 compare_dump(reporter, p, false, true,
4230 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4252 static void TestPathTo(skiatest::Reporter* reporter) {
4256 check_path_is_line(reporter, &p, 4, 4);
4259 check_path_is_line(reporter, &p, 4, 4);
4267 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
4270 static void TestPathrefListeners(skiatest::Reporter* reporter) {
4279 REPORTER_ASSERT(reporter, !changed);
4281 REPORTER_ASSERT(reporter, changed);
4285 REPORTER_ASSERT(reporter, !changed);
4287 REPORTER_ASSERT(reporter, changed);
4291 REPORTER_ASSERT(reporter, !changed);
4293 REPORTER_ASSERT(reporter, changed);
4299 REPORTER_ASSERT(reporter, !changed);
4301 REPORTER_ASSERT(reporter, changed);
4308 REPORTER_ASSERT(reporter, !changed);
4311 REPORTER_ASSERT(reporter, changed);
4315 static void test_crbug_629455(skiatest::Reporter* reporter) {
4326 static void test_fuzz_crbug_662952(skiatest::Reporter* reporter) {
4365 static void test_fuzz_crbug_662730(skiatest::Reporter* reporter) {
4437 static void test_interp(skiatest::Reporter* reporter) {
4439 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4440 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
4441 REPORTER_ASSERT(reporter, p1 == out);
4442 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
4443 REPORTER_ASSERT(reporter, p1 == out);
4446 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4447 REPORTER_ASSERT(reporter, !p1.interpolate(p2, 1, &out));
4450 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4451 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
4452 REPORTER_ASSERT(reporter, p2 == out);
4453 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
4454 REPORTER_ASSERT(reporter, p1 == out);
4455 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
4456 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(3, 1, 4, 2));
4463 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4464 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
4465 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(4, 3, 6, 5));
4469 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4473 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4476 DEF_TEST(PathInterp, reporter) {
4477 test_interp(reporter);
4481 DEF_TEST(PathBigCubic, reporter) {
4492 DEF_TEST(PathContains, reporter) {
4493 test_contains(reporter);
4496 DEF_TEST(Paths, reporter) {
4500 test_crbug_629455(reporter);
4501 test_fuzz_crbug_627414(reporter);
4503 test_fuzz_crbug_662952(reporter);
4504 test_fuzz_crbug_662730(reporter);
4519 test_empty(reporter, p);
4521 REPORTER_ASSERT(reporter, p.getBounds().isEmpty());
4533 check_convex_bounds(reporter, p, bounds);
4535 REPORTER_ASSERT(reporter,
4537 REPORTER_ASSERT(reporter, !p.isEmpty());
4540 test_empty(reporter, p);
4543 check_convex_bounds(reporter, p, bounds);
4544 REPORTER_ASSERT(reporter, !p.isEmpty());
4547 test_empty(reporter, p);
4550 check_convex_bounds(reporter, p, bounds);
4552 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks());
4553 REPORTER_ASSERT(reporter, !p.isEmpty());
4555 REPORTER_ASSERT(reporter, p != empty);
4556 REPORTER_ASSERT(reporter, !(p == empty));
4559 REPORTER_ASSERT(reporter, p.getPoints(nullptr, 0) == 4);
4560 REPORTER_ASSERT(reporter, p.getVerbs(nullptr, 0) == 5);
4563 REPORTER_ASSERT(reporter, count == 4);
4567 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == verbs[0]);
4568 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[1]);
4569 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[2]);
4570 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[3]);
4571 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == verbs[4]);
4572 REPORTER_ASSERT(reporter, 0xff == verbs[5]);
4574 REPORTER_ASSERT(reporter, bounds == bounds2);
4578 REPORTER_ASSERT(reporter, bounds == p.getBounds());
4580 REPORTER_ASSERT(reporter, p.isRect(nullptr));
4582 REPORTER_ASSERT(reporter, p.isRect(&bounds2));
4583 REPORTER_ASSERT(reporter, bounds == bounds2);
4588 REPORTER_ASSERT(reporter, !p.isRect(nullptr));
4596 REPORTER_ASSERT(reporter, p.isRect(&r));
4597 REPORTER_ASSERT(reporter, r == bounds);
4600 REPORTER_ASSERT(reporter, p.isRect(&r));
4601 REPORTER_ASSERT(reporter, r == bounds);
4604 test_operatorEqual(reporter);
4605 test_isLine(reporter);
4606 test_isRect(reporter);
4607 test_is_simple_closed_rect(reporter);
4608 test_isNestedFillRects(reporter);
4609 test_zero_length_paths(reporter);
4610 test_direction(reporter);
4611 test_convexity(reporter);
4612 test_convexity2(reporter);
4613 test_conservativelyContains(reporter);
4614 test_close(reporter);
4615 test_segment_masks(reporter);
4616 test_flattening(reporter);
4617 test_transform(reporter);
4618 test_bounds(reporter);
4619 test_iter(reporter);
4620 test_raw_iter(reporter);
4621 test_circle(reporter);
4622 test_oval(reporter);
4623 test_strokerec(reporter);
4624 test_addPoly(reporter);
4625 test_isfinite(reporter);
4626 test_isfinite_after_transform(reporter);
4627 test_islastcontourclosed(reporter);
4628 test_arb_round_rect_is_convex(reporter);
4629 test_arb_zero_rad_round_rect_is_rect(reporter);
4630 test_addrect(reporter);
4631 test_addrect_isfinite(reporter);
4635 test_crbug_493450(reporter);
4636 test_crbug_495894(reporter);
4640 test_gen_id(reporter);
4641 test_path_close_issue1474(reporter);
4642 test_path_to_region(reporter);
4643 test_rrect(reporter);
4644 test_arc(reporter);
4645 test_arc_ovals(reporter);
4646 test_arcTo(reporter);
4647 test_addPath(reporter);
4648 test_addPathMode(reporter, false, false);
4649 test_addPathMode(reporter, true, false);
4650 test_addPathMode(reporter, false, true);
4651 test_addPathMode(reporter, true, true);
4652 test_extendClosedPath(reporter);
4653 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
4654 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
4655 test_conicTo_special_case(reporter);
4656 test_get_point(reporter);
4657 test_contains(reporter);
4658 PathTest_Private::TestPathTo(reporter);
4659 PathRefTest_Private::TestPathRef(reporter);
4660 PathTest_Private::TestPathrefListeners(reporter);
4661 test_dump(reporter);
4662 test_path_crbug389050(reporter);
4663 test_path_crbugskia2820(reporter);
4665 test_skbug_3469(reporter);
4666 test_skbug_3239(reporter);
4667 test_bounds_crbug_513799(reporter);
4671 DEF_TEST(conservatively_contains_rect, reporter) {
4713 DEF_TEST(path_tight_bounds, reporter) {
4726 REPORTER_ASSERT(reporter, bounds.contains(tight));
4730 REPORTER_ASSERT(reporter, nearly_equal(tight, tight2));
4758 DEF_TEST(PathRefSerialization, reporter) {
4766 REPORTER_ASSERT(reporter, path.countPoints() == numPoints);
4767 REPORTER_ASSERT(reporter, path.countVerbs() == numVerbs);
4775 REPORTER_ASSERT(reporter, readBack != path);
4777 REPORTER_ASSERT(reporter, bytesRead == bytesWritten);
4778 REPORTER_ASSERT(reporter, readBack == path);
4786 REPORTER_ASSERT(reporter, !bytesRead);
4790 DEF_TEST(NonFinitePathIteration, reporter) {
4802 REPORTER_ASSERT(reporter, verbs == 0);
4807 DEF_TEST(AndroidArc, reporter) {
4839 DEF_TEST(HugeGeometry, reporter) {
4871 DEF_TEST(ClipPath_nonfinite, reporter) {
4875 REPORTER_ASSERT(reporter, !canvas->isClipEmpty());
4893 REPORTER_ASSERT(reporter, canvas->isClipEmpty() == !path.isInverseFillType());
4899 REPORTER_ASSERT(reporter, !canvas->isClipEmpty());