Home | History | Annotate | Download | only in tests

Lines Matching refs:Reporter

32 static void test_add_rrect(skiatest::Reporter* reporter, const SkRect& bounds,
36 REPORTER_ASSERT(reporter, bounds == rrect.rect());
41 REPORTER_ASSERT(reporter, bounds == path.getBounds());
44 static void test_skbug_3469(skiatest::Reporter* reporter) {
49 REPORTER_ASSERT(reporter, !path.isConvex());
52 static void test_skbug_3239(skiatest::Reporter* reporter) {
65 test_add_rrect(reporter, rectx, radii);
66 test_add_rrect(reporter, recty, radii);
237 static void make_path_crbugskia2820(SkPath* path, skiatest::Reporter* reporter) {
250 static void test_path_crbugskia2820(skiatest::Reporter* reporter) {//GrContext* context) {
252 make_path_crbugskia2820(&path, reporter);
296 static void test_path_to_region(skiatest::Reporter* reporter) {
322 static void test_path_close_issue1474(skiatest::Reporter* reporter) {
335 REPORTER_ASSERT(reporter, 50 == last.fX);
336 REPORTER_ASSERT(reporter, 50 == last.fY);
346 REPORTER_ASSERT(reporter, 75 == last.fX);
347 REPORTER_ASSERT(reporter, 75 == last.fY);
357 REPORTER_ASSERT(reporter, 85 == last.fX);
358 REPORTER_ASSERT(reporter, 85 == last.fY);
368 REPORTER_ASSERT(reporter, 95 == last.fX);
369 REPORTER_ASSERT(reporter, 95 == last.fY);
372 static void test_gen_id(skiatest::Reporter* reporter) {
374 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID());
378 REPORTER_ASSERT(reporter, z != b.getGenerationID());
381 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID());
385 REPORTER_ASSERT(reporter, z != y);
389 REPORTER_ASSERT(reporter, x != y && x != z);
392 REPORTER_ASSERT(reporter, b.getGenerationID() == y && a.getGenerationID() == x);
395 REPORTER_ASSERT(reporter, b.getGenerationID() == x);
398 REPORTER_ASSERT(reporter, c.getGenerationID() == x);
402 REPORTER_ASSERT(reporter, b.getGenerationID() == x);
403 REPORTER_ASSERT(reporter, a.getGenerationID() == x);
404 REPORTER_ASSERT(reporter, w != x);
414 REPORTER_ASSERT(reporter, (v == w) == kExpectGenIDToIgnoreFill);
417 REPORTER_ASSERT(reporter, v != c.getGenerationID());
559 static void test_tiny_path_convexity(skiatest::Reporter* reporter, const char* pathBug,
572 REPORTER_ASSERT(reporter, smallConvex == largeConvex);
575 static void test_crbug_493450(skiatest::Reporter* reporter) {
583 test_tiny_path_convexity(reporter, reducedCase, 100, 100, 100000);
590 test_tiny_path_convexity(reporter, originalFiddleData, 280081.4116670522f, 93268.04618493588f,
594 static void test_crbug_495894(skiatest::Reporter* reporter) {
616 test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7819.72220766405f,
631 static void test_addrect(skiatest::Reporter* reporter) {
635 REPORTER_ASSERT(reporter, path.isRect(nullptr));
640 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
645 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
650 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
655 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
659 static void test_addrect_isfinite(skiatest::Reporter* reporter) {
663 REPORTER_ASSERT(reporter, path.isFinite());
667 REPORTER_ASSERT(reporter, !path.isFinite());
670 REPORTER_ASSERT(reporter, !path.isFinite());
673 REPORTER_ASSERT(reporter, path.isFinite());
676 REPORTER_ASSERT(reporter, path.isFinite());
718 static void dump_if_ne(skiatest::Reporter* reporter, const SkRect& expected, const SkRect& bounds) {
720 ERRORF(reporter, "path.getBounds() returned [%g %g %g %g], but expected [%g %g %g %g]",
726 static void test_bounds_crbug_513799(skiatest::Reporter* reporter) {
731 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(0, 0, 0, 0) == path.getBounds());
734 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, -5, -8) == path.getBounds());
737 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds());
740 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds());
742 dump_if_ne(reporter, SkRect::MakeLTRB(0, 0, 0, 0), path.getBounds());
745 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, -5, -8), path.getBounds());
748 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, 3, 4), path.getBounds());
751 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, 3, 4), path.getBounds());
756 static void test_fuzz_crbug_627414(skiatest::Reporter* reporter) {
792 static void test_isfinite_after_transform(skiatest::Reporter* reporter) {
805 REPORTER_ASSERT(reporter, path.getBounds().isFinite());
806 REPORTER_ASSERT(reporter, !path.getBounds().isEmpty());
809 REPORTER_ASSERT(reporter, path.getBounds().isEmpty());
814 REPORTER_ASSERT(reporter, !path.isFinite());
815 REPORTER_ASSERT(reporter, path.getBounds().isEmpty());
862 static void test_arb_round_rect_is_convex(skiatest::Reporter* reporter) {
881 REPORTER_ASSERT(reporter, temp.isConvex());
889 static void test_arb_zero_rad_round_rect_is_rect(skiatest::Reporter* reporter) {
909 REPORTER_ASSERT(reporter, temp.isRect(&result));
910 REPORTER_ASSERT(reporter, r == result);
914 static void test_rect_isfinite(skiatest::Reporter* reporter) {
921 REPORTER_ASSERT(reporter, r.isFinite());
923 REPORTER_ASSERT(reporter, !r.isFinite());
925 REPORTER_ASSERT(reporter, !r.isFinite());
934 REPORTER_ASSERT(reporter, isFine);
935 REPORTER_ASSERT(reporter, !r.isEmpty());
939 REPORTER_ASSERT(reporter, !isFine);
940 REPORTER_ASSERT(reporter, r.isEmpty());
944 REPORTER_ASSERT(reporter, !isFine);
945 REPORTER_ASSERT(reporter, r.isEmpty());
948 static void test_path_isfinite(skiatest::Reporter* reporter) {
954 REPORTER_ASSERT(reporter, path.isFinite());
957 REPORTER_ASSERT(reporter, path.isFinite());
961 REPORTER_ASSERT(reporter, path.isFinite());
965 REPORTER_ASSERT(reporter, !path.isFinite());
969 REPORTER_ASSERT(reporter, !path.isFinite());
972 static void test_isfinite(skiatest::Reporter* reporter) {
973 test_rect_isfinite(reporter);
974 test_path_isfinite(reporter);
977 static void test_islastcontourclosed(skiatest::Reporter* reporter) {
979 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
981 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
983 REPORTER_ASSERT(reporter, path.isLastContourClosed());
985 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
987 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
989 REPORTER_ASSERT(reporter, path.isLastContourClosed());
991 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
1001 static void test_poly(skiatest::Reporter* reporter, const SkPath& path,
1011 REPORTER_ASSERT(reporter, firstTime);
1012 REPORTER_ASSERT(reporter, pts[0] == srcPts[0]);
1017 REPORTER_ASSERT(reporter, !firstTime);
1018 REPORTER_ASSERT(reporter, pts[1] == srcPts[0]);
1022 REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected quad verb");
1025 REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected conic verb");
1028 REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected cubic verb");
1031 REPORTER_ASSERT(reporter, !firstTime);
1032 REPORTER_ASSERT(reporter, !foundClose);
1033 REPORTER_ASSERT(reporter, expectClose);
1041 REPORTER_ASSERT(reporter, foundClose == expectClose);
1044 static void test_addPoly(skiatest::Reporter* reporter) {
1057 test_poly(reporter, path, pts, SkToBool(doClose));
1062 static void test_strokerec(skiatest::Reporter* reporter) {
1064 REPORTER_ASSERT(reporter, rec.isFillStyle());
1067 REPORTER_ASSERT(reporter, rec.isHairlineStyle());
1070 REPORTER_ASSERT(reporter, SkStrokeRec::kStroke_Style == rec.getStyle());
1073 REPORTER_ASSERT(reporter, SkStrokeRec::kStrokeAndFill_Style == rec.getStyle());
1076 REPORTER_ASSERT(reporter, SkStrokeRec::kHairline_Style == rec.getStyle());
1079 REPORTER_ASSERT(reporter, SkStrokeRec::kFill_Style == rec.getStyle());
1086 static void check_direction(skiatest::Reporter* reporter, const SkPath& path,
1095 REPORTER_ASSERT(reporter, dir == expected);
1097 REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expected);
1101 static void test_direction(skiatest::Reporter* reporter) {
1104 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
1105 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
1106 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
1107 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kUnknown_FirstDirection));
1120 REPORTER_ASSERT(reporter, valid);
1121 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
1136 REPORTER_ASSERT(reporter, valid);
1137 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1152 REPORTER_ASSERT(reporter, valid);
1153 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1161 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1166 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1174 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1179 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1185 REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity());
1186 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1197 static void test_bounds(skiatest::Reporter* reporter) {
1211 REPORTER_ASSERT(reporter, path0.getBounds() == path1.getBounds());
1250 static void check_close(skiatest::Reporter* reporter, const SkPath& path) {
1266 REPORTER_ASSERT(reporter, mv == pts[0]);
1275 REPORTER_ASSERT(reporter, !i || nMT == nCL);
1279 static void test_close(skiatest::Reporter* reporter) {
1283 check_close(reporter, closePt);
1287 check_close(reporter, openPt);
1290 check_close(reporter, empty);
1292 check_close(reporter, empty);
1296 check_close(reporter, rect);
1298 check_close(reporter, rect);
1302 check_close(reporter, quad);
1304 check_close(reporter, quad);
1309 check_close(reporter, cubic);
1311 check_close(reporter, cubic);
1316 check_close(reporter, line);
1318 check_close(reporter, line);
1324 check_close(reporter, rect2);
1326 check_close(reporter, rect2);
1332 check_close(reporter, oval3);
1334 check_close(reporter, oval3);
1341 check_close(reporter, moves);
1346 static void check_convexity(skiatest::Reporter* reporter, const SkPath& path,
1350 REPORTER_ASSERT(reporter, c == expected);
1353 static void test_path_crbug389050(skiatest::Reporter* reporter) {
1361 check_convexity(reporter, tinyConvexPolygon, SkPath::kConvex_Convexity);
1362 check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection);
1370 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1378 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1381 static void test_convexity2(skiatest::Reporter* reporter) {
1385 check_convexity(reporter, pt, SkPath::kConvex_Convexity);
1386 check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection);
1392 check_convexity(reporter, line, SkPath::kConvex_Convexity);
1393 check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection);
1400 check_convexity(reporter, triLeft, SkPath::kConvex_Convexity);
1401 check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection);
1408 check_convexity(reporter, triRight, SkPath::kConvex_Convexity);
1409 check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection);
1417 check_convexity(reporter, square, SkPath::kConvex_Convexity);
1418 check_direction(reporter, square, SkPathPriv::kCW_FirstDirection);
1434 check_convexity(reporter, redundantSquare, SkPath::kConvex_Convexity);
1435 check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection);
1451 check_convexity(reporter, bowTie, SkPath::kConcave_Convexity);
1452 check_direction(reporter, bowTie, kDontCheckDir);
1463 check_convexity(reporter, spiral, SkPath::kConcave_Convexity);
1464 check_direction(reporter, spiral, kDontCheckDir);
1473 check_convexity(reporter, dent, SkPath::kConcave_Convexity);
1474 check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection);
1490 check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity);
1491 check_direction(reporter, strokedSin, kDontCheckDir);
1501 check_convexity(reporter, degenerateConcave, SkPath::kConcave_Convexity);
1502 check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirection);
1516 check_convexity(reporter, badFirstVector, SkPath::kConcave_Convexity);
1519 static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p,
1521 REPORTER_ASSERT(reporter, p.isConvex());
1522 REPORTER_ASSERT(reporter, p.getBounds() == bounds);
1525 REPORTER_ASSERT(reporter, p2.isConvex());
1526 REPORTER_ASSERT(reporter, p2.getBounds() == bounds);
1530 REPORTER_ASSERT(reporter, other.isConvex());
1531 REPORTER_ASSERT(reporter, other.getBounds() == bounds);
1553 static void test_convexity(skiatest::Reporter* reporter) {
1556 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1558 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1560 check_convexity(reporter, path, SkPath::kConcave_Convexity);
1564 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1565 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
1569 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1570 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
1574 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1594 check_convexity(reporter, path, gRec[i].fExpectedConvexity);
1595 check_direction(reporter, path, gRec[i].fExpectedDirection);
1601 REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPathPriv::kUnknown_FirstDirection)
1603 REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir);
1604 check_convexity(reporter, copy, gRec[i].fExpectedConvexity);
1606 REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexity());
1607 check_direction(reporter, path, gRec[i].fExpectedDirection);
1657 check_convexity(reporter, path, SkPath::kUnknown_Convexity);
1678 check_convexity(reporter, path, curveSelect == 0 ? SkPath::kConvex_Convexity
1684 static void test_isLine(skiatest::Reporter* reporter) {
1689 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1694 REPORTER_ASSERT(reporter, !path.isLine(pts));
1696 REPORTER_ASSERT(reporter, pts[0].equals(value, value));
1697 REPORTER_ASSERT(reporter, pts[1].equals(value, value));
1701 REPORTER_ASSERT(reporter, value != moveX && value != moveY);
1704 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1705 REPORTER_ASSERT(reporter, !path.isLine(pts));
1707 REPORTER_ASSERT(reporter, pts[0].equals(value, value));
1708 REPORTER_ASSERT(reporter, pts[1].equals(value, value));
1712 REPORTER_ASSERT(reporter, value != lineX && value != lineY);
1715 REPORTER_ASSERT(reporter, path.isLine(nullptr));
1717 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY));
1718 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY));
1719 REPORTER_ASSERT(reporter, path.isLine(pts));
1720 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY));
1721 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY));
1724 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1725 REPORTER_ASSERT(reporter, !path.isLine(pts));
1726 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY));
1727 REPORTER_ASSERT(reporter
1731 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1734 static void test_conservativelyContains(skiatest::Reporter* reporter) {
1837 REPORTER_ASSERT(reporter, kQueries[q].fInRect ==
1842 REPORTER_ASSERT(reporter, kQueries[q].fInCircle ==
1847 REPORTER_ASSERT(reporter, kQueries[q].fInRR ==
1859 REPORTER_ASSERT(reporter, kQueries[q].fInCubicRR ==
1871 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect));
1882 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1886 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1892 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(-10),
1898 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(10),
1910 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1922 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1934 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1948 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1955 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(0, 0, 1, 1)));
1958 static void test_isRect_open_close(skiatest::Reporter* reporter) {
1965 REPORTER_ASSERT(reporter, path.isRect(nullptr, &isClosed, nullptr));
1966 REPORTER_ASSERT(reporter, isClosed);
1971 static void test_isRect(skiatest::Reporter* reporter) {
1972 test_isRect_open_close(reporter);
2069 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(nullptr));
2077 REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(path, &cheapDirection));
2078 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &direction));
2079 REPORTER_ASSERT(reporter, expected == computed);
2080 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose);
2081 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(direction) == cheapDirection);
2087 REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direction));
2088 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
2089 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
2090 REPORTER_ASSERT(reporter, isClosed == (bool) -1);
2091 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
2103 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2115 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2124 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2136 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2148 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2151 static void check_simple_closed_rect(skiatest::Reporter* reporter, const SkPath& path,
2157 REPORTER_ASSERT(reporter, SkPathPriv::IsSimpleClosedRect(path, &r, &d, &s));
2158 REPORTER_ASSERT(reporter, r == rect);
2159 REPORTER_ASSERT(reporter, d == dir);
2160 REPORTER_ASSERT(reporter, s == start);
2163 static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
2175 check_simple_closed_rect(reporter, path, testRect, dir, start);
2177 check_simple_closed_rect(reporter, path, testRect, dir, start);
2180 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2183 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2186 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2207 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2210 check_simple_closed_rect(reporter, path2, testRect, dir, start);
2213 check_simple_closed_rect(reporter, path2, testRect, dir, start);
2217 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2222 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2227 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2238 check_simple_closed_rect(reporter, path2, testRect, swapDir, kXSwapStarts[start]);
2243 check_simple_closed_rect(reporter, path2, testRect, swapDir, kYSwapStarts[start]);
2256 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2264 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2272 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2280 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2284 static void test_isNestedFillRects(skiatest::Reporter* reporter) {
2368 REPORTER_ASSERT(reporter,
2384 REPORTER_ASSERT(reporter, path.isNestedFillRects(computed, computedDirs));
2385 REPORTER_ASSERT(reporter, expected[0] == computed[0]);
2386 REPORTER_ASSERT(reporter, expected[1] == computed[1]);
2387 REPORTER_ASSERT(reporter, expectedDirs[0] == SkPathPriv::AsFirstDirection(computedDirs[0]));
2388 REPORTER_ASSERT(reporter, expectedDirs[1] == SkPathPriv::AsFirstDirection(computedDirs[1]));
2406 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2424 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2439 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2457 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2475 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2481 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2496 REPORTER_ASSERT(reporter, path.isNestedFillRects(nullptr));
2505 REPORTER_ASSERT(reporter, dst.isNestedFillRects(nullptr));
2508 static void write_and_read_back(skiatest::Reporter* reporter,
2518 REPORTER_ASSERT(reporter, readBack != p);
2520 REPORTER_ASSERT(reporter, readBack == p);
2522 REPORTER_ASSERT(reporter, readBack.getConvexityOrUnknown() ==
2528 REPORTER_ASSERT(reporter, readBack.isOval(nullptr) == p.isOval(nullptr));
2530 REPORTER_ASSERT(reporter, oval0 == oval1);
2531 REPORTER_ASSERT(reporter, dir0 == dir1);
2532 REPORTER_ASSERT(reporter, start0 == start1);
2534 REPORTER_ASSERT(reporter, readBack.isRRect(nullptr) == p.isRRect(nullptr));
2537 REPORTER_ASSERT(reporter, rrect0 == rrect1);
2538 REPORTER_ASSERT(reporter, dir0 == dir1);
2539 REPORTER_ASSERT(reporter, start0 == start1);
2544 REPORTER_ASSERT(reporter, origBounds == readBackBounds);
2547 static void test_corrupt_flattening(skiatest::Reporter* reporter) {
2567 REPORTER_ASSERT(reporter, path.readFromMemory(buffer, sizeof(buffer)));
2572 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2576 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2578 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2582 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2584 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2592 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2598 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2600 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2606 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2610 static void test_flattening(skiatest::Reporter* reporter) {
2624 write_and_read_back(reporter, p);
2631 REPORTER_ASSERT(reporter, size1 == size2);
2635 REPORTER_ASSERT(reporter, size1 == size3);
2636 REPORTER_ASSERT(reporter, p == p2);
2639 REPORTER_ASSERT(reporter, !size3);
2643 REPORTER_ASSERT(reporter, tooShort.isEmpty());
2647 REPORTER_ASSERT(reporter, size1 == size3);
2648 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
2656 write_and_read_back(reporter, oval);
2659 test_corrupt_flattening(reporter);
2662 static void test_transform(skiatest::Reporter* reporter) {
2691 REPORTER_ASSERT(reporter, p == p1);
2704 REPORTER_ASSERT(reporter, kPtCount == count);
2707 REPORTER_ASSERT(reporter, newPt == pts1[i]);
2720 REPORTER_ASSERT(reporter, matrix.invert(&matrix));
2724 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fLeft, p1Bounds.fLeft));
2725 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fTop, p1Bounds.fTop));
2726 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fRight, p1Bounds.fRight));
2727 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fBottom, p1Bounds.fBottom));
2740 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCW_FirstDirection));
2752 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCCW_FirstDirection));
2762 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kUnknown_FirstDirection));
2766 static void test_zero_length_paths(skiatest::Reporter* reporter) {
2826 REPORTER_ASSERT(reporter, valid);
2827 REPORTER_ASSERT(reporter, !p.isEmpty());
2828 REPORTER_ASSERT(reporter, gZeroLengthTests[i].numResultPts == (size_t)p.countPoints());
2829 REPORTER_ASSERT(reporter, gZeroLengthTests[i].resultBound == p.getBounds());
2830 REPORTER_ASSERT(reporter, gZeroLengthTests[i].numResultVerbs == (size_t)p.getVerbs(verbs, SK_ARRAY_COUNT(verbs)));
2832 REPORTER_ASSERT(reporter, gZeroLengthTests[i].resultVerbs[j] == verbs[j]);
2844 static void test_segment_masks(skiatest::Reporter* reporter) {
2849 REPORTER_ASSERT(reporter
2850 REPORTER_ASSERT(reporter, !p.isEmpty());
2852 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2854 REPORTER_ASSERT(reporter, kCurveSegmentMask == p.getSegmentMasks());
2855 REPORTER_ASSERT(reporter, !p.isEmpty());
2857 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2862 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == p.getSegmentMasks());
2864 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2866 REPORTER_ASSERT(reporter, !p.isEmpty());
2869 static void test_iter(skiatest::Reporter* reporter) {
2875 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2879 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2883 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2887 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2891 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2955 REPORTER_ASSERT(reporter, valid);
2959 REPORTER_ASSERT(reporter, iter.next(pts, gIterTests[i].consumeDegenerates) == gIterTests[i].resultVerbs[j]);
2961 REPORTER_ASSERT(reporter, pts[k] == gIterTests[i].resultPts[l++]);
2964 REPORTER_ASSERT(reporter, j == (int)gIterTests[i].numResultVerbs);
2969 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2973 REPORTER_ASSERT(reporter, iter.isClosedContour());
2976 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2979 REPORTER_ASSERT(reporter, iter.isClosedContour());
2983 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2994 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == iter.next(pts, false));
3001 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == iter.next(pts, false));
3004 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3010 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts, false));
3013 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3019 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false));
3022 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3027 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false));
3030 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3042 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == iter.next(pts));
3043 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
3044 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
3045 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts));
3046 REPORTER_ASSERT(reporter, SK_ScalarRoot2Over2 == iter.conicWeight());
3049 static void test_raw_iter(skiatest::Reporter* reporter) {
3055 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
3058 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
3062 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3067 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3068 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3069 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3070 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3076 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3077 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3078 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3079 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3080 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*2);
3081 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1);
3082 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3083 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*3);
3084 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*2);
3085 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3091 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3105 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3106 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3107 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3108 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3109 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3110 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*2);
3111 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1);
3112 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3113 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3114 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*3);
3115 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*2);
3116 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3117 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*4);
3118 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*3);
3119 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3120 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3227 REPORTER_ASSERT(reporter, nextVerb == expectedVerbs[numIterVerbs]);
3231 REPORTER_ASSERT(reporter, numIterPts < numPoints);
3232 REPORTER_ASSERT(reporter, pts[0] == expectedPts[numIterPts]);
3237 REPORTER_ASSERT(reporter, numIterPts < numPoints + 1);
3238 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3239 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3245 REPORTER_ASSERT(reporter, numIterPts < numPoints + 2);
3246 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3247 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3248 REPORTER_ASSERT(reporter, pts[2] == expectedPts[numIterPts + 1]);
3253 REPORTER_ASSERT(reporter, numIterPts < numPoints + 3);
3254 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3255 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3256 REPORTER_ASSERT(reporter, pts[2] == expectedPts[numIterPts + 1]);
3257 REPORTER_ASSERT(reporter, pts[3] == expectedPts[numIterPts + 2]);
3268 REPORTER_ASSERT(reporter, numIterPts == numPoints);
3269 REPORTER_ASSERT(reporter, numIterVerbs == numVerbs);
3273 static void check_for_circle(skiatest::Reporter* reporter,
3278 REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle);
3282 REPORTER_ASSERT(reporter, rect.height() == rect.width());
3283 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(isOvalDir) == expectedDir);
3286 REPORTER_ASSERT(reporter, path == tmpPath);
3288 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, expectedDir));
3291 static void test_circle_skew(skiatest::Reporter* reporter,
3303 REPORTER_ASSERT(reporter, SkPathPriv::kCW_FirstDirection == dir);
3306 check_for_circle(reporter, tmp, false, dir);
3309 static void test_circle_translate(skiatest::Reporter* reporter,
3318 check_for_circle(reporter, tmp, true, dir);
3326 check_for_circle(reporter, tmp, true, dir);
3329 static void test_circle_rotate(skiatest::Reporter* reporter,
3342 check_for_circle(reporter, tmp, true, dir);
3344 check_for_circle(reporter, tmp, false, dir);
3349 static void test_circle_mirror_x(skiatest::Reporter* reporter,
3360 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
3363 check_for_circle(reporter, tmp, true, dir);
3366 static void test_circle_mirror_y(skiatest::Reporter* reporter,
3378 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
3382 check_for_circle(reporter, tmp, true, dir);
3385 static void test_circle_mirror_xy(skiatest::Reporter* reporter,
3395 check_for_circle(reporter, tmp, true, dir);
3398 static void test_circle_with_direction(skiatest::Reporter* reporter,
3406 check_for_circle(reporter, path, true, dir);
3407 test_circle_rotate(reporter, path, dir);
3408 test_circle_translate(reporter, path, dir);
3409 test_circle_skew(reporter, path, dir);
3410 test_circle_mirror_x(reporter, path, dir);
3411 test_circle_mirror_y(reporter, path, dir);
3412 test_circle_mirror_xy(reporter, path, dir);
3419 check_for_circle(reporter, path, true, dir);
3420 test_circle_rotate(reporter, path, dir);
3421 test_circle_translate(reporter, path, dir);
3422 test_circle_skew(reporter, path, dir);
3423 test_circle_mirror_x(reporter, path, dir);
3424 test_circle_mirror_y(reporter, path, dir);
3425 test_circle_mirror_xy(reporter, path, dir);
3431 test_circle_rotate(reporter, path, dir);
3432 test_circle_translate(reporter, path, dir);
3433 test_circle_skew(reporter, path, dir);
3434 test_circle_mirror_x(reporter, path, dir);
3435 test_circle_mirror_y(reporter, path, dir);
3436 test_circle_mirror_xy(reporter, path, dir);
3440 static void test_circle_with_add_paths(skiatest::Reporter* reporter) {
3462 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircleDir));
3468 check_for_circle(reporter, path, true, SkPathPriv::AsFirstDirection(kCircleDir));
3473 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircleDirOpposite));
3476 static void test_circle(skiatest::Reporter* reporter) {
3477 test_circle_with_direction(reporter, SkPath::kCW_Direction);
3478 test_circle_with_direction(reporter, SkPath::kCCW_Direction);
3484 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3490 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3496 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3498 test_circle_with_add_paths(reporter);
3503 REPORTER_ASSERT(reporter, path.isEmpty());
3506 static void test_oval(skiatest::Reporter* reporter) {
3517 REPORTER_ASSERT(reporter, path.isOval(nullptr));
3524 REPORTER_ASSERT(reporter, tmp.isOval(nullptr, &dir, &start));
3525 REPORTER_ASSERT(reporter, 2 == start);
3526 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3533 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3540 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3544 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3550 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3557 REPORTER_ASSERT(reporter, path.isOval(nullptr));
3564 REPORTER_ASSERT(reporter, path.isOval(nullptr, &dir, &start));
3565 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3566 REPORTER_ASSERT(reporter, 1 == start);
3569 static void test_empty(skiatest::Reporter* reporter, const SkPath& p) {
3572 REPORTER_ASSERT(reporter, p.isEmpty());
3573 REPORTER_ASSERT(reporter, 0 == p.countPoints());
3574 REPORTER_ASSERT(reporter, 0 == p.countVerbs());
3575 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks());
3576 REPORTER_ASSERT(reporter, p.isConvex());
3577 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType);
3578 REPORTER_ASSERT(reporter, !p.isInverseFillType());
3579 REPORTER_ASSERT(reporter, p == empty);
3580 REPORTER_ASSERT(reporter, !(p != empty));
3583 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path,
3585 REPORTER_ASSERT(reporter, path->isConvex());
3586 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
3588 REPORTER_ASSERT(reporter, path->isConvex());
3592 static void test_rrect_convexity_is_unknown(skiatest::Reporter* reporter, SkPath* path,
3594 REPORTER_ASSERT(reporter, path->isConvex());
3595 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
3597 REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kUnknown_Convexity);
3601 static void test_rrect(skiatest::Reporter* reporter) {
3608 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3610 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3612 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3614 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3616 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3618 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3624 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3629 REPORTER_ASSERT(reporter, p.isRect(&returnedRect));
3630 REPORTER_ASSERT(reporter, returnedRect == r);
3631 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3637 REPORTER_ASSERT(reporter, p.isRect(nullptr, &closed, &dir));
3638 REPORTER_ASSERT(reporter, closed);
3639 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3640 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3643 REPORTER_ASSERT(reporter, !p.isConvex());
3647 REPORTER_ASSERT(reporter, !p.isConvex());
3652 REPORTER_ASSERT(reporter, p.isEmpty());
3656 test_rrect_convexity_is_unknown(reporter, &p, SkPath::kCW_Direction);
3661 REPORTER_ASSERT(reporter, rr.isEmpty());
3665 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3668 static void test_arc(skiatest::Reporter* reporter) {
3671 REPORTER_ASSERT(reporter, emptyOval.isEmpty());
3673 REPORTER_ASSERT(reporter, p.isEmpty());
3677 REPORTER_ASSERT(reporter, p.isEmpty());
3682 REPORTER_ASSERT(reporter, p == cwOval);
3687 REPORTER_ASSERT(reporter, p == ccwOval);
3690 REPORTER_ASSERT(reporter, p.isConvex());
3691 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::kCW_FirstDirection));
3693 REPORTER_ASSERT(reporter, p.isConvex());
3721 static void check_oval_arc(skiatest::Reporter* reporter, SkScalar start, SkScalar sweep,
3727 REPORTER_ASSERT(reporter, isOval);
3730 REPORTER_ASSERT(reporter, path == recreatedPath);
3731 REPORTER_ASSERT(reporter, oval_start_index_to_angle(s) == canonical_start_angle(start));
3732 REPORTER_ASSERT(reporter, (SkPath::kCW_Direction == d) == (sweep > 0.f));
3735 static void test_arc_ovals(skiatest::Reporter* reporter) {
3744 check_oval_arc(reporter, start, sweep, path);
3746 REPORTER_ASSERT(reporter, !path.isOval(nullptr));
3754 check_oval_arc(reporter, start, sweep, path);
3760 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3764 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb);
3765 REPORTER_ASSERT(reporter, pts[0].fX == x0);
3766 REPORTER_ASSERT(reporter, pts[0].fY == y0);
3769 static void check_line(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3773 REPORTER_ASSERT(reporter, v == SkPath::kLine_Verb);
3774 REPORTER_ASSERT(reporter, pts[1].fX == x1);
3775 REPORTER_ASSERT(reporter, pts[1].fY == y1);
3778 static void check_quad(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3782 REPORTER_ASSERT(reporter, v == SkPath::kQuad_Verb);
3783 REPORTER_ASSERT(reporter, pts[1].fX == x1);
3784 REPORTER_ASSERT(reporter, pts[1].fY == y1);
3785 REPORTER_ASSERT(reporter, pts[2].fX == x2);
3786 REPORTER_ASSERT(reporter, pts[2].fY == y2);
3789 static void check_done(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) {
3792 REPORTER_ASSERT(reporter, v == SkPath::kDone_Verb);
3795 static void check_done_and_reset(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) {
3796 check_done(reporter, p, iter);
3800 static void check_path_is_move_and_reset(skiatest::Reporter* reporter, SkPath* p,
3803 check_move(reporter, &iter, x0, y0);
3804 check_done_and_reset(reporter, p, &iter);
3807 static void check_path_is_line_and_reset(skiatest::Reporter* reporter, SkPath* p,
3810 check_move(reporter, &iter, 0, 0);
3811 check_line(reporter, &iter, x1, y1);
3812 check_done_and_reset(reporter, p, &iter);
3815 static void check_path_is_line(skiatest::Reporter* reporter, SkPath* p,
3818 check_move(reporter, &iter, 0, 0);
3819 check_line(reporter, &iter, x1, y1);
3820 check_done(reporter, p, &iter);
3823 static void check_path_is_line_pair_and_reset(skiatest::Reporter* reporter, SkPath* p,
3826 check_move(reporter, &iter, 0, 0);
3827 check_line(reporter, &iter, x1, y1);
3828 check_line(reporter, &iter, x2, y2);
3829 check_done_and_reset(reporter, p, &iter);
3832 static void check_path_is_quad_and_reset(skiatest::Reporter* reporter, SkPath* p,
3835 check_move(reporter, &iter, 0, 0);
3836 check_quad(reporter, &iter, x1, y1, x2, y2);
3837 check_done_and_reset(reporter, p, &iter);
3847 static void test_arcTo(skiatest::Reporter* reporter) {
3850 check_path_is_line_and_reset(reporter, &p, 0, 0);
3852 check_path_is_line_and_reset(reporter, &p, 1, 2);
3854 check_path_is_line_and_reset(reporter, &p, 1, 2);
3856 check_path_is_line_and_reset(reporter, &p, 1, 2);
3859 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == 1);
3862 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == -1);
3866 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3868 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3870 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3872 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3876 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval));
3882 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval));
3889 REPORTER_ASSERT(reporter, p.isEmpty());
3894 REPORTER_ASSERT(reporter, p.isEmpty());
3897 static void test_addPath(skiatest::Reporter* reporter) {
3908 REPORTER_ASSERT(reporter, p.getBounds() == expected);
3912 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
3915 static void test_addPathMode(skiatest::Reporter* reporter, bool explicitMoveTo, bool extend) {
3928 REPORTER_ASSERT(reporter, verbcount == 4);
3929 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3930 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3931 REPORTER_ASSERT(reporter, verbs[2] == (extend ? SkPath::kLine_Verb : SkPath::kMove_Verb));
3932 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kLine_Verb);
3935 static void test_extendClosedPath(skiatest::Reporter* reporter) {
3946 REPORTER_ASSERT(reporter, verbcount == 7);
3947 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3948 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3949 REPORTER_ASSERT(reporter, verbs[2] == SkPath::kLine_Verb);
3950 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kClose_Verb);
3951 REPORTER_ASSERT(reporter, verbs[4] == SkPath::kMove_Verb);
3952 REPORTER_ASSERT(reporter, verbs[5] == SkPath::kLine_Verb);
3953 REPORTER_ASSERT(reporter, verbs[6] == SkPath::kLine_Verb);
3956 REPORTER_ASSERT(reporter, p.getLastPt(&pt));
3957 REPORTER_ASSERT(reporter, pt == SkPoint::Make(2, 3));
3958 REPORTER_ASSERT(reporter, p.getPoint(3) == SkPoint::Make(1, 1));
3961 static void test_addEmptyPath(skiatest::Reporter* reporter, SkPath::AddPathMode mode) {
3967 REPORTER_ASSERT(reporter, q == p);
3970 REPORTER_ASSERT(reporter, q == p);
3974 REPORTER_ASSERT(reporter, q.isEmpty());
3977 static void test_conicTo_special_case(skiatest::Reporter* reporter) {
3980 check_path_is_line_and_reset(reporter, &p, 3, 4);
3982 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4);
3984 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4);
3987 static void test_get_point(skiatest::Reporter* reporter) {
3990 REPORTER_ASSERT(reporter, pt == SkPoint::Make(0, 0));
3991 REPORTER_ASSERT(reporter, !p.getLastPt(nullptr));
3992 REPORTER_ASSERT(reporter, !p.getLastPt(&pt) && pt == SkPoint::Make(0, 0));
3995 REPORTER_ASSERT(reporter, pt == SkPoint::Make(10, 10));
3996 REPORTER_ASSERT(reporter, p.getLastPt(nullptr));
3998 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt == SkPoint::Make(20, 20));
4001 static void test_contains(skiatest::Reporter* reporter) {
4014 REPORTER_ASSERT(reporter, p.contains(0, 0));
4016 REPORTER_ASSERT(reporter, !p.contains(0, 0));
4021 REPORTER_ASSERT(reporter, p.contains(6, 4));
4022 REPORTER_ASSERT(reporter, p.contains(5, 6));
4023 REPORTER_ASSERT(reporter, p.contains(7, 6));
4025 REPORTER_ASSERT(reporter, !p.contains(4, 0));
4026 REPORTER_ASSERT(reporter, !p.contains(0, 4));
4027 REPORTER_ASSERT(reporter, !p.contains(4, 10));
4028 REPORTER_ASSERT(reporter, !p.contains(10, 4));
4030 REPORTER_ASSERT(reporter, !p.contains(5, 7));
4031 REPORTER_ASSERT(reporter, p.contains(6, 7));
4032 REPORTER_ASSERT(reporter, !p.contains(7, 7));
4038 REPORTER_ASSERT(reporter, p.contains(4, 6));
4039 REPORTER_ASSERT(reporter, p.contains(6, 5));
4040 REPORTER_ASSERT(reporter, p.contains(6, 7));
4042 REPORTER_ASSERT(reporter, !p.contains(7, 5));
4043 REPORTER_ASSERT(reporter, p.contains(7, 6));
4044 REPORTER_ASSERT(reporter, !p.contains(7, 7));
4051 REPORTER_ASSERT(reporter, p.contains(4, 4));
4052 REPORTER_ASSERT(reporter, p.contains(8, 4));
4053 REPORTER_ASSERT(reporter, p.contains(8, 8));
4054 REPORTER_ASSERT(reporter, p.contains(4, 8));
4060 REPORTER_ASSERT(reporter, p.contains(5, 6));
4061 REPORTER_ASSERT(reporter, p.contains(4, 8));
4062 REPORTER_ASSERT(reporter, p.contains(3, 6));
4068 REPORTER_ASSERT(reporter, p.contains(2, 5));
4069 REPORTER_ASSERT(reporter, p.contains(2, 7));
4070 REPORTER_ASSERT(reporter, p.contains(4, 6));
4079 REPORTER_ASSERT(reporter, !p.contains(1, 2));
4080 REPORTER_ASSERT(reporter, !p.contains(3, 2));
4081 REPORTER_ASSERT(reporter
4082 REPORTER_ASSERT(reporter, p.contains(4, 4));
4090 REPORTER_ASSERT(reporter, p.contains(5, 6));
4091 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4093 REPORTER_ASSERT(reporter, p.contains(5, 5));
4094 REPORTER_ASSERT(reporter, p.contains(5, 8));
4095 REPORTER_ASSERT(reporter, p.contains(4, 5));
4097 REPORTER_ASSERT(reporter, p.contains(4, 4));
4098 REPORTER_ASSERT(reporter, p.contains(8, 8));
4099 REPORTER_ASSERT(reporter, p.contains(4, 8));
4107 REPORTER_ASSERT(reporter, p.contains(5, 6));
4108 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4113 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4123 REPORTER_ASSERT(reporter, p.contains(5, 6));
4124 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4129 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4132 REPORTER_ASSERT(reporter, p.contains(4, 4));
4133 REPORTER_ASSERT(reporter, p.contains(8, 8));
4134 REPORTER_ASSERT(reporter, p.contains(4, 8));
4145 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f));
4146 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f));
4149 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4151 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4153 REPORTER_ASSERT(reporter, p.contains(pts[i].fX, pts[i].fY));
4154 REPORTER_ASSERT(reporter, p.contains(pts[i + 3].fX, pts[i + 3].fY));
4155 REPORTER_ASSERT(reporter, p.contains(pts[i + 6].fX, pts[i + 6].fY));
4161 static void TestPathRef(skiatest::Reporter* reporter) {
4170 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4171 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
4172 REPORTER_ASSERT(reporter, 0 == pathRef->getSegmentMasks());
4174 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef->atVerb(i));
4181 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4182 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
4183 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == pathRef->getSegmentMasks());
4185 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == pathRef->atVerb(i));
4192 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4193 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
4194 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef->getSegmentMasks());
4196 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef->atVerb(i));
4204 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4205 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
4206 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countWeights());
4207 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef->getSegmentMasks());
4208 REPORTER_ASSERT(reporter, weights);
4210 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef->atVerb(i));
4217 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4218 REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef->countPoints());
4219 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef->getSegmentMasks());
4221 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef->atVerb(i));
4228 static void test_operatorEqual(skiatest::Reporter* reporter) {
4231 REPORTER_ASSERT(reporter, a == a);
4232 REPORTER_ASSERT(reporter, a == b);
4234 REPORTER_ASSERT(reporter, a != b);
4236 REPORTER_ASSERT(reporter, a == b);
4238 REPORTER_ASSERT(reporter, a != b);
4240 REPORTER_ASSERT(reporter, a == b);
4243 REPORTER_ASSERT(reporter, a != b);
4246 REPORTER_ASSERT(reporter, a == b);
4249 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool force,
4254 REPORTER_ASSERT(reporter, data->size() == strlen(str));
4256 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
4258 REPORTER_ASSERT(reporter, data->data() == nullptr || !memcmp(data->data(), str, strlen(str)));
4262 static void test_dump(skiatest::Reporter* reporter) {
4264 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n");
4265 compare_dump(reporter, p, true, false, "path.setFillType(SkPath::kWinding_FillType);\n");
4268 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4271 compare_dump(reporter, p, true, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4280 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kEvenOdd_FillType);\n"
4287 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kInverseWinding_FillType);\n"
4294 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kInverseEvenOdd_FillType);\n"
4301 compare_dump(reporter, p, false, true,
4308 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4330 static void TestPathTo(skiatest::Reporter* reporter) {
4334 check_path_is_line(reporter, &p, 4, 4);
4337 check_path_is_line(reporter, &p, 4, 4);
4345 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
4348 static void TestPathrefListeners(skiatest::Reporter* reporter) {
4357 REPORTER_ASSERT(reporter, !changed);
4359 REPORTER_ASSERT(reporter, changed);
4363 REPORTER_ASSERT(reporter, !changed);
4365 REPORTER_ASSERT(reporter, changed);
4369 REPORTER_ASSERT(reporter, !changed);
4371 REPORTER_ASSERT(reporter, changed);
4377 REPORTER_ASSERT(reporter, !changed);
4379 REPORTER_ASSERT(reporter, changed);
4386 REPORTER_ASSERT(reporter, !changed);
4389 REPORTER_ASSERT(reporter, changed);
4393 static void test_crbug_629455(skiatest::Reporter* reporter) {
4408 static void test_fuzz_crbug_662952(skiatest::Reporter* reporter) {
4447 static void test_fuzz_crbug_662730(skiatest::Reporter* reporter) {
4461 static void test_interp(skiatest::Reporter* reporter) {
4463 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4464 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
4465 REPORTER_ASSERT(reporter, p1 == out);
4466 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
4467 REPORTER_ASSERT(reporter, p1 == out);
4470 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4471 REPORTER_ASSERT(reporter, !p1.interpolate(p2, 1, &out));
4474 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4475 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
4476 REPORTER_ASSERT(reporter, p2 == out);
4477 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
4478 REPORTER_ASSERT(reporter, p1 == out);
4479 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
4480 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(3, 1, 4, 2));
4487 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4488 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
4489 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(4, 3, 6, 5));
4493 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4497 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4500 DEF_TEST(PathInterp, reporter) {
4501 test_interp(reporter);
4505 DEF_TEST(PathBigCubic, reporter) {
4516 DEF_TEST(PathContains, reporter) {
4517 test_contains(reporter);
4520 DEF_TEST(Paths, reporter) {
4524 test_crbug_629455(reporter);
4525 test_fuzz_crbug_627414(reporter);
4527 test_fuzz_crbug_662952(reporter);
4528 test_fuzz_crbug_662730(reporter);
4538 test_empty(reporter, p);
4540 REPORTER_ASSERT(reporter, p.getBounds().isEmpty());
4552 check_convex_bounds(reporter, p, bounds);
4554 REPORTER_ASSERT(reporter,
4556 REPORTER_ASSERT(reporter, !p.isEmpty());
4559 test_empty(reporter, p);
4562 check_convex_bounds(reporter, p, bounds);
4563 REPORTER_ASSERT(reporter, !p.isEmpty());
4566 test_empty(reporter, p);
4569 check_convex_bounds(reporter, p, bounds);
4571 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks());
4572 REPORTER_ASSERT(reporter, !p.isEmpty());
4574 REPORTER_ASSERT(reporter, p != empty);
4575 REPORTER_ASSERT(reporter, !(p == empty));
4578 REPORTER_ASSERT(reporter, p.getPoints(nullptr, 0) == 4);
4579 REPORTER_ASSERT(reporter, p.getVerbs(nullptr, 0) == 5);
4582 REPORTER_ASSERT(reporter, count == 4);
4586 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == verbs[0]);
4587 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[1]);
4588 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[2]);
4589 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[3]);
4590 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == verbs[4]);
4591 REPORTER_ASSERT(reporter, 0xff == verbs[5]);
4593 REPORTER_ASSERT(reporter, bounds == bounds2);
4597 REPORTER_ASSERT(reporter, bounds == p.getBounds());
4599 REPORTER_ASSERT(reporter, p.isRect(nullptr));
4601 REPORTER_ASSERT(reporter, p.isRect(&bounds2));
4602 REPORTER_ASSERT(reporter, bounds == bounds2);
4607 REPORTER_ASSERT(reporter, !p.isRect(nullptr));
4615 REPORTER_ASSERT(reporter, p.isRect(&r));
4616 REPORTER_ASSERT(reporter, r == bounds);
4619 REPORTER_ASSERT(reporter, p.isRect(&r));
4620 REPORTER_ASSERT(reporter, r == bounds);
4623 test_operatorEqual(reporter);
4624 test_isLine(reporter);
4625 test_isRect(reporter);
4626 test_is_simple_closed_rect(reporter);
4627 test_isNestedFillRects(reporter);
4628 test_zero_length_paths(reporter);
4629 test_direction(reporter);
4630 test_convexity(reporter);
4631 test_convexity2(reporter);
4632 test_conservativelyContains(reporter);
4633 test_close(reporter);
4634 test_segment_masks(reporter);
4635 test_flattening(reporter);
4636 test_transform(reporter);
4637 test_bounds(reporter);
4638 test_iter(reporter);
4639 test_raw_iter(reporter);
4640 test_circle(reporter);
4641 test_oval(reporter);
4642 test_strokerec(reporter);
4643 test_addPoly(reporter);
4644 test_isfinite(reporter);
4645 test_isfinite_after_transform(reporter);
4646 test_islastcontourclosed(reporter);
4647 test_arb_round_rect_is_convex(reporter);
4648 test_arb_zero_rad_round_rect_is_rect(reporter);
4649 test_addrect(reporter);
4650 test_addrect_isfinite(reporter);
4654 test_crbug_493450(reporter);
4655 test_crbug_495894(reporter);
4659 test_gen_id(reporter);
4660 test_path_close_issue1474(reporter);
4661 test_path_to_region(reporter);
4662 test_rrect(reporter);
4663 test_arc(reporter);
4664 test_arc_ovals(reporter);
4665 test_arcTo(reporter);
4666 test_addPath(reporter);
4667 test_addPathMode(reporter, false, false);
4668 test_addPathMode(reporter, true, false);
4669 test_addPathMode(reporter, false, true);
4670 test_addPathMode(reporter, true, true);
4671 test_extendClosedPath(reporter);
4672 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
4673 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
4674 test_conicTo_special_case(reporter);
4675 test_get_point(reporter);
4676 test_contains(reporter);
4677 PathTest_Private::TestPathTo(reporter);
4678 PathRefTest_Private::TestPathRef(reporter);
4679 PathTest_Private::TestPathrefListeners(reporter);
4680 test_dump(reporter);
4681 test_path_crbug389050(reporter);
4682 test_path_crbugskia2820(reporter);
4684 test_skbug_3469(reporter);
4685 test_skbug_3239(reporter);
4686 test_bounds_crbug_513799(reporter);
4690 DEF_TEST(conservatively_contains_rect, reporter) {
4732 DEF_TEST(path_tight_bounds, reporter) {
4745 REPORTER_ASSERT(reporter, bounds.contains(tight));
4749 REPORTER_ASSERT(reporter, nearly_equal(tight, tight2));