Home | History | Annotate | Download | only in tests

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);
239 static void make_path_crbugskia2820(SkPath* path, skiatest::Reporter* reporter) {
252 static void test_path_crbugskia2820(skiatest::Reporter* reporter) {//GrContext* context) {
254 make_path_crbugskia2820(&path, reporter);
298 static void test_path_to_region(skiatest::Reporter* reporter) {
324 static void test_path_close_issue1474(skiatest::Reporter* reporter) {
337 REPORTER_ASSERT(reporter, 50 == last.fX);
338 REPORTER_ASSERT(reporter, 50 == last.fY);
348 REPORTER_ASSERT(reporter, 75 == last.fX);
349 REPORTER_ASSERT(reporter, 75 == last.fY);
359 REPORTER_ASSERT(reporter, 85 == last.fX);
360 REPORTER_ASSERT(reporter, 85 == last.fY);
370 REPORTER_ASSERT(reporter, 95 == last.fX);
371 REPORTER_ASSERT(reporter, 95 == last.fY);
374 static void test_gen_id(skiatest::Reporter* reporter) {
376 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID());
380 REPORTER_ASSERT(reporter, z != b.getGenerationID());
383 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID());
387 REPORTER_ASSERT(reporter, z != y);
391 REPORTER_ASSERT(reporter, x != y && x != z);
394 REPORTER_ASSERT(reporter, b.getGenerationID() == y && a.getGenerationID() == x);
397 REPORTER_ASSERT(reporter, b.getGenerationID() == x);
400 REPORTER_ASSERT(reporter, c.getGenerationID() == x);
404 REPORTER_ASSERT(reporter, b.getGenerationID() == x);
405 REPORTER_ASSERT(reporter, a.getGenerationID() == x);
406 REPORTER_ASSERT(reporter, w != x);
416 REPORTER_ASSERT(reporter, (v == w) == kExpectGenIDToIgnoreFill);
419 REPORTER_ASSERT(reporter, v != c.getGenerationID());
561 static void test_tiny_path_convexity(skiatest::Reporter* reporter, const char* pathBug,
574 REPORTER_ASSERT(reporter, smallConvex == largeConvex);
577 static void test_crbug_493450(skiatest::Reporter* reporter) {
585 test_tiny_path_convexity(reporter, reducedCase, 100, 100, 100000);
592 test_tiny_path_convexity(reporter, originalFiddleData, 280081.4116670522f, 93268.04618493588f,
596 static void test_crbug_495894(skiatest::Reporter* reporter) {
618 test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7819.72220766405f,
633 static void test_addrect(skiatest::Reporter* reporter) {
637 REPORTER_ASSERT(reporter, path.isRect(nullptr));
642 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
647 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
652 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
657 REPORTER_ASSERT(reporter, !path.isRect(nullptr));
661 static void test_addrect_isfinite(skiatest::Reporter* reporter) {
665 REPORTER_ASSERT(reporter, path.isFinite());
669 REPORTER_ASSERT(reporter, !path.isFinite());
672 REPORTER_ASSERT(reporter, !path.isFinite());
675 REPORTER_ASSERT(reporter, path.isFinite());
678 REPORTER_ASSERT(reporter, path.isFinite());
720 static void dump_if_ne(skiatest::Reporter* reporter, const SkRect& expected, const SkRect& bounds) {
722 ERRORF(reporter, "path.getBounds() returned [%g %g %g %g], but expected [%g %g %g %g]",
728 static void test_bounds_crbug_513799(skiatest::Reporter* reporter) {
733 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(0, 0, 0, 0) == path.getBounds());
736 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, -5, -8) == path.getBounds());
739 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds());
742 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds());
744 dump_if_ne(reporter, SkRect::MakeLTRB(0, 0, 0, 0), path.getBounds());
747 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, -5, -8), path.getBounds());
750 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, 3, 4), path.getBounds());
753 dump_if_ne(reporter, SkRect::MakeLTRB(-5, -8, 3, 4), path.getBounds());
758 static void test_fuzz_crbug_627414(skiatest::Reporter* reporter) {
794 static void test_isfinite_after_transform(skiatest::Reporter* reporter) {
807 REPORTER_ASSERT(reporter, path.getBounds().isFinite());
808 REPORTER_ASSERT(reporter, !path.getBounds().isEmpty());
811 REPORTER_ASSERT(reporter, path.getBounds().isEmpty());
816 REPORTER_ASSERT(reporter, !path.isFinite());
817 REPORTER_ASSERT(reporter, path.getBounds().isEmpty());
864 static void test_arb_round_rect_is_convex(skiatest::Reporter* reporter) {
883 REPORTER_ASSERT(reporter, temp.isConvex());
891 static void test_arb_zero_rad_round_rect_is_rect(skiatest::Reporter* reporter) {
911 REPORTER_ASSERT(reporter, temp.isRect(&result));
912 REPORTER_ASSERT(reporter, r == result);
916 static void test_rect_isfinite(skiatest::Reporter* reporter) {
923 REPORTER_ASSERT(reporter, r.isFinite());
925 REPORTER_ASSERT(reporter, !r.isFinite());
927 REPORTER_ASSERT(reporter, !r.isFinite());
936 REPORTER_ASSERT(reporter, isFine);
937 REPORTER_ASSERT(reporter, !r.isEmpty());
941 REPORTER_ASSERT(reporter, !isFine);
942 REPORTER_ASSERT(reporter, r.isEmpty());
946 REPORTER_ASSERT(reporter, !isFine);
947 REPORTER_ASSERT(reporter, r.isEmpty());
950 static void test_path_isfinite(skiatest::Reporter* reporter) {
956 REPORTER_ASSERT(reporter, path.isFinite());
959 REPORTER_ASSERT(reporter, path.isFinite());
963 REPORTER_ASSERT(reporter, path.isFinite());
967 REPORTER_ASSERT(reporter, !path.isFinite());
971 REPORTER_ASSERT(reporter, !path.isFinite());
974 static void test_isfinite(skiatest::Reporter* reporter) {
975 test_rect_isfinite(reporter);
976 test_path_isfinite(reporter);
979 static void test_islastcontourclosed(skiatest::Reporter* reporter) {
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());
993 REPORTER_ASSERT(reporter, !path.isLastContourClosed());
1003 static void test_poly(skiatest::Reporter* reporter, const SkPath& path,
1013 REPORTER_ASSERT(reporter, firstTime);
1014 REPORTER_ASSERT(reporter, pts[0] == srcPts[0]);
1019 REPORTER_ASSERT(reporter, !firstTime);
1020 REPORTER_ASSERT(reporter, pts[1] == srcPts[0]);
1024 REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected quad verb");
1027 REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected conic verb");
1030 REPORTER_ASSERT_MESSAGE(reporter, false, "unexpected cubic verb");
1033 REPORTER_ASSERT(reporter, !firstTime);
1034 REPORTER_ASSERT(reporter, !foundClose);
1035 REPORTER_ASSERT(reporter, expectClose);
1043 REPORTER_ASSERT(reporter, foundClose == expectClose);
1046 static void test_addPoly(skiatest::Reporter* reporter) {
1059 test_poly(reporter, path, pts, SkToBool(doClose));
1064 static void test_strokerec(skiatest::Reporter* reporter) {
1066 REPORTER_ASSERT(reporter, rec.isFillStyle());
1069 REPORTER_ASSERT(reporter, rec.isHairlineStyle());
1072 REPORTER_ASSERT(reporter, SkStrokeRec::kStroke_Style == rec.getStyle());
1075 REPORTER_ASSERT(reporter, SkStrokeRec::kStrokeAndFill_Style == rec.getStyle());
1078 REPORTER_ASSERT(reporter, SkStrokeRec::kHairline_Style == rec.getStyle());
1081 REPORTER_ASSERT(reporter, SkStrokeRec::kFill_Style == rec.getStyle());
1088 static void check_direction(skiatest::Reporter* reporter, const SkPath& path,
1097 REPORTER_ASSERT(reporter, dir == expected);
1099 REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expected);
1103 static void test_direction(skiatest::Reporter* reporter) {
1106 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
1107 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
1108 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
1109 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kUnknown_FirstDirection));
1122 REPORTER_ASSERT(reporter, valid);
1123 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
1138 REPORTER_ASSERT(reporter, valid);
1139 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1154 REPORTER_ASSERT(reporter, valid);
1155 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1163 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1168 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1176 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1181 check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
1187 REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity());
1188 check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
1199 static void test_bounds(skiatest::Reporter* reporter) {
1213 REPORTER_ASSERT(reporter, path0.getBounds() == path1.getBounds());
1252 static void check_close(skiatest::Reporter* reporter, const SkPath& path) {
1268 REPORTER_ASSERT(reporter, mv == pts[0]);
1277 REPORTER_ASSERT(reporter, !i || nMT == nCL);
1281 static void test_close(skiatest::Reporter* reporter) {
1285 check_close(reporter, closePt);
1289 check_close(reporter, openPt);
1292 check_close(reporter, empty);
1294 check_close(reporter, empty);
1298 check_close(reporter, rect);
1300 check_close(reporter, rect);
1304 check_close(reporter, quad);
1306 check_close(reporter, quad);
1311 check_close(reporter, cubic);
1313 check_close(reporter, cubic);
1318 check_close(reporter, line);
1320 check_close(reporter, line);
1326 check_close(reporter, rect2);
1328 check_close(reporter, rect2);
1334 check_close(reporter, oval3);
1336 check_close(reporter, oval3);
1343 check_close(reporter, moves);
1348 static void check_convexity(skiatest::Reporter* reporter, const SkPath& path,
1352 REPORTER_ASSERT(reporter, c == expected);
1355 static void test_path_crbug389050(skiatest::Reporter* reporter) {
1363 check_convexity(reporter, tinyConvexPolygon, SkPath::kConvex_Convexity);
1364 check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection);
1372 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1380 check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
1383 static void test_convexity2(skiatest::Reporter* reporter) {
1387 check_convexity(reporter, pt, SkPath::kConvex_Convexity);
1388 check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection);
1394 check_convexity(reporter, line, SkPath::kConvex_Convexity);
1395 check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection);
1402 check_convexity(reporter, triLeft, SkPath::kConvex_Convexity);
1403 check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection);
1410 check_convexity(reporter, triRight, SkPath::kConvex_Convexity);
1411 check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection);
1419 check_convexity(reporter, square, SkPath::kConvex_Convexity);
1420 check_direction(reporter, square, SkPathPriv::kCW_FirstDirection);
1436 check_convexity(reporter, redundantSquare, SkPath::kConvex_Convexity);
1437 check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection);
1453 check_convexity(reporter, bowTie, SkPath::kConcave_Convexity);
1454 check_direction(reporter, bowTie, kDontCheckDir);
1465 check_convexity(reporter, spiral, SkPath::kConcave_Convexity);
1466 check_direction(reporter, spiral, kDontCheckDir);
1475 check_convexity(reporter, dent, SkPath::kConcave_Convexity);
1476 check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection);
1492 check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity);
1493 check_direction(reporter, strokedSin, kDontCheckDir);
1503 check_convexity(reporter, degenerateConcave, SkPath::kConcave_Convexity);
1504 check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirection);
1518 check_convexity(reporter, badFirstVector, SkPath::kConcave_Convexity);
1521 static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p,
1523 REPORTER_ASSERT(reporter, p.isConvex());
1524 REPORTER_ASSERT(reporter, p.getBounds() == bounds);
1527 REPORTER_ASSERT(reporter, p2.isConvex());
1528 REPORTER_ASSERT(reporter, p2.getBounds() == bounds);
1532 REPORTER_ASSERT(reporter, other.isConvex());
1533 REPORTER_ASSERT(reporter, other.getBounds() == bounds);
1555 static void test_convexity(skiatest::Reporter* reporter) {
1558 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1560 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1562 check_convexity(reporter, path, SkPath::kConcave_Convexity);
1566 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1567 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
1571 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1572 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
1576 check_convexity(reporter, path, SkPath::kConvex_Convexity);
1596 check_convexity(reporter, path, gRec[i].fExpectedConvexity);
1597 check_direction(reporter, path, gRec[i].fExpectedDirection);
1603 REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPathPriv::kUnknown_FirstDirection)
1605 REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir);
1606 check_convexity(reporter, copy, gRec[i].fExpectedConvexity);
1608 REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexity());
1609 check_direction(reporter, path, gRec[i].fExpectedDirection);
1659 check_convexity(reporter, path, SkPath::kUnknown_Convexity);
1680 check_convexity(reporter, path, curveSelect == 0 ? SkPath::kConvex_Convexity
1686 static void test_isLine(skiatest::Reporter* reporter) {
1691 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1696 REPORTER_ASSERT(reporter, !path.isLine(pts));
1698 REPORTER_ASSERT(reporter, pts[0].equals(value, value));
1699 REPORTER_ASSERT(reporter, pts[1].equals(value, value));
1703 REPORTER_ASSERT(reporter, value != moveX && value != moveY);
1706 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1707 REPORTER_ASSERT(reporter, !path.isLine(pts));
1709 REPORTER_ASSERT(reporter, pts[0].equals(value, value));
1710 REPORTER_ASSERT(reporter, pts[1].equals(value, value));
1714 REPORTER_ASSERT(reporter, value != lineX && value != lineY);
1717 REPORTER_ASSERT(reporter, path.isLine(nullptr));
1719 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY));
1720 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY));
1721 REPORTER_ASSERT(reporter, path.isLine(pts));
1722 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY));
1723 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY));
1726 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1727 REPORTER_ASSERT(reporter, !path.isLine(pts));
1728 REPORTER_ASSERT(reporter
1729 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY));
1733 REPORTER_ASSERT(reporter, !path.isLine(nullptr));
1736 static void test_conservativelyContains(skiatest::Reporter* reporter) {
1839 REPORTER_ASSERT(reporter, kQueries[q].fInRect ==
1844 REPORTER_ASSERT(reporter, kQueries[q].fInCircle ==
1849 REPORTER_ASSERT(reporter, kQueries[q].fInRR ==
1861 REPORTER_ASSERT(reporter, kQueries[q].fInCubicRR ==
1873 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect));
1884 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1888 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1894 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(-10),
1900 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(10),
1912 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1924 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1936 REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
1950 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(
1957 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(0, 0, 1, 1)));
1960 static void test_isRect_open_close(skiatest::Reporter* reporter) {
1967 REPORTER_ASSERT(reporter, path.isRect(nullptr, &isClosed, nullptr));
1968 REPORTER_ASSERT(reporter, isClosed);
1973 static void test_isRect(skiatest::Reporter* reporter) {
1974 test_isRect_open_close(reporter);
2071 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(nullptr));
2079 REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(path, &cheapDirection));
2080 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &direction));
2081 REPORTER_ASSERT(reporter, expected == computed);
2082 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose);
2083 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(direction) == cheapDirection);
2089 REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direction));
2090 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
2091 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
2092 REPORTER_ASSERT(reporter, isClosed == (bool) -1);
2093 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
2105 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2117 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2126 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2138 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2150 REPORTER_ASSERT(reporter, !path1.isRect(nullptr));
2153 static void check_simple_closed_rect(skiatest::Reporter* reporter, const SkPath& path,
2159 REPORTER_ASSERT(reporter, SkPathPriv::IsSimpleClosedRect(path, &r, &d, &s));
2160 REPORTER_ASSERT(reporter, r == rect);
2161 REPORTER_ASSERT(reporter, d == dir);
2162 REPORTER_ASSERT(reporter, s == start);
2165 static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
2177 check_simple_closed_rect(reporter, path, testRect, dir, start);
2179 check_simple_closed_rect(reporter, path, testRect, dir, start);
2182 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2185 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2188 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2209 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2212 check_simple_closed_rect(reporter, path2, testRect, dir, start);
2215 check_simple_closed_rect(reporter, path2, testRect, dir, start);
2219 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2224 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2229 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
2240 check_simple_closed_rect(reporter, path2, testRect, swapDir, kXSwapStarts[start]);
2245 check_simple_closed_rect(reporter, path2, testRect, swapDir, kYSwapStarts[start]);
2258 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2266 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2274 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2282 REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
2286 static void test_isNestedFillRects(skiatest::Reporter* reporter) {
2370 REPORTER_ASSERT(reporter,
2386 REPORTER_ASSERT(reporter, path.isNestedFillRects(computed, computedDirs));
2387 REPORTER_ASSERT(reporter, expected[0] == computed[0]);
2388 REPORTER_ASSERT(reporter, expected[1] == computed[1]);
2389 REPORTER_ASSERT(reporter, expectedDirs[0] == SkPathPriv::AsFirstDirection(computedDirs[0]));
2390 REPORTER_ASSERT(reporter, expectedDirs[1] == SkPathPriv::AsFirstDirection(computedDirs[1]));
2408 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2426 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2441 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2459 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2477 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2483 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr));
2498 REPORTER_ASSERT(reporter, path.isNestedFillRects(nullptr));
2507 REPORTER_ASSERT(reporter, dst.isNestedFillRects(nullptr));
2510 static void write_and_read_back(skiatest::Reporter* reporter,
2520 REPORTER_ASSERT(reporter, readBack != p);
2522 REPORTER_ASSERT(reporter, readBack == p);
2524 REPORTER_ASSERT(reporter, readBack.getConvexityOrUnknown() ==
2530 REPORTER_ASSERT(reporter, readBack.isOval(nullptr) == p.isOval(nullptr));
2532 REPORTER_ASSERT(reporter, oval0 == oval1);
2533 REPORTER_ASSERT(reporter, dir0 == dir1);
2534 REPORTER_ASSERT(reporter, start0 == start1);
2536 REPORTER_ASSERT(reporter, readBack.isRRect(nullptr) == p.isRRect(nullptr));
2539 REPORTER_ASSERT(reporter, rrect0 == rrect1);
2540 REPORTER_ASSERT(reporter, dir0 == dir1);
2541 REPORTER_ASSERT(reporter, start0 == start1);
2546 REPORTER_ASSERT(reporter, origBounds == readBackBounds);
2549 static void test_corrupt_flattening(skiatest::Reporter* reporter) {
2569 REPORTER_ASSERT(reporter, path.readFromMemory(buffer, sizeof(buffer)));
2574 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2578 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2580 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2584 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2586 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2594 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2600 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2602 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2608 REPORTER_ASSERT(reporter, !path.readFromMemory(buffer, sizeof(buffer)));
2612 static void test_flattening(skiatest::Reporter* reporter) {
2626 write_and_read_back(reporter, p);
2633 REPORTER_ASSERT(reporter, size1 == size2);
2637 REPORTER_ASSERT(reporter, size1 == size3);
2638 REPORTER_ASSERT(reporter, p == p2);
2641 REPORTER_ASSERT(reporter, !size3);
2645 REPORTER_ASSERT(reporter, tooShort.isEmpty());
2649 REPORTER_ASSERT(reporter, size1 == size3);
2650 REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
2658 write_and_read_back(reporter, oval);
2661 test_corrupt_flattening(reporter);
2664 static void test_transform(skiatest::Reporter* reporter) {
2693 REPORTER_ASSERT(reporter, p == p1);
2706 REPORTER_ASSERT(reporter, kPtCount == count);
2709 REPORTER_ASSERT(reporter, newPt == pts1[i]);
2722 REPORTER_ASSERT(reporter, matrix.invert(&matrix));
2726 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fLeft, p1Bounds.fLeft));
2727 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fTop, p1Bounds.fTop));
2728 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fRight, p1Bounds.fRight));
2729 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fBottom, p1Bounds.fBottom));
2742 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCW_FirstDirection));
2754 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCCW_FirstDirection));
2764 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kUnknown_FirstDirection));
2768 static void test_zero_length_paths(skiatest::Reporter* reporter) {
2828 REPORTER_ASSERT(reporter, valid);
2829 REPORTER_ASSERT(reporter, !p.isEmpty());
2830 REPORTER_ASSERT(reporter, gZeroLengthTests[i].numResultPts == (size_t)p.countPoints());
2831 REPORTER_ASSERT(reporter, gZeroLengthTests[i].resultBound == p.getBounds());
2832 REPORTER_ASSERT(reporter, gZeroLengthTests[i].numResultVerbs == (size_t)p.getVerbs(verbs, SK_ARRAY_COUNT(verbs)));
2834 REPORTER_ASSERT(reporter, gZeroLengthTests[i].resultVerbs[j] == verbs[j]);
2846 static void test_segment_masks(skiatest::Reporter* reporter) {
2851 REPORTER_ASSERT(reporter
2852 REPORTER_ASSERT(reporter, !p.isEmpty());
2854 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2856 REPORTER_ASSERT(reporter, kCurveSegmentMask == p.getSegmentMasks());
2857 REPORTER_ASSERT(reporter, !p.isEmpty());
2859 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2864 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == p.getSegmentMasks());
2866 REPORTER_ASSERT(reporter, p2.getSegmentMasks() == p.getSegmentMasks());
2868 REPORTER_ASSERT(reporter, !p.isEmpty());
2871 static void test_iter(skiatest::Reporter* reporter) {
2877 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2881 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2885 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
2889 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2893 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
2957 REPORTER_ASSERT(reporter, valid);
2961 REPORTER_ASSERT(reporter, iter.next(pts, gIterTests[i].consumeDegenerates) == gIterTests[i].resultVerbs[j]);
2963 REPORTER_ASSERT(reporter, pts[k] == gIterTests[i].resultPts[l++]);
2966 REPORTER_ASSERT(reporter, j == (int)gIterTests[i].numResultVerbs);
2971 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2975 REPORTER_ASSERT(reporter, iter.isClosedContour());
2978 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2981 REPORTER_ASSERT(reporter, iter.isClosedContour());
2985 REPORTER_ASSERT(reporter, !iter.isClosedContour());
2996 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == iter.next(pts, false));
3003 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == iter.next(pts, false));
3006 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3012 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts, false));
3015 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3021 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false));
3024 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3029 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false));
3032 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
3044 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == iter.next(pts));
3045 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
3046 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
3047 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts));
3048 REPORTER_ASSERT(reporter, SK_ScalarRoot2Over2 == iter.conicWeight());
3051 static void test_raw_iter(skiatest::Reporter* reporter) {
3057 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
3060 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb);
3064 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3069 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3070 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3071 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3072 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3078 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3079 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3080 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3081 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3082 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*2);
3083 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1);
3084 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3085 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*3);
3086 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*2);
3087 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3093 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3107 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3108 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1);
3109 REPORTER_ASSERT(reporter, pts[0].fY == 0);
3110 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3111 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3112 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*2);
3113 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1);
3114 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3115 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3116 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*3);
3117 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*2);
3118 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kMove_Verb);
3119 REPORTER_ASSERT(reporter, pts[0].fX == SK_Scalar1*4);
3120 REPORTER_ASSERT(reporter, pts[0].fY == SK_Scalar1*3);
3121 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kClose_Verb);
3122 REPORTER_ASSERT(reporter, iter.next(pts) == SkPath::kDone_Verb);
3229 REPORTER_ASSERT(reporter, nextVerb == expectedVerbs[numIterVerbs]);
3233 REPORTER_ASSERT(reporter, numIterPts < numPoints);
3234 REPORTER_ASSERT(reporter, pts[0] == expectedPts[numIterPts]);
3239 REPORTER_ASSERT(reporter, numIterPts < numPoints + 1);
3240 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3241 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3247 REPORTER_ASSERT(reporter, numIterPts < numPoints + 2);
3248 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3249 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3250 REPORTER_ASSERT(reporter, pts[2] == expectedPts[numIterPts + 1]);
3255 REPORTER_ASSERT(reporter, numIterPts < numPoints + 3);
3256 REPORTER_ASSERT(reporter, pts[0] == lastPt);
3257 REPORTER_ASSERT(reporter, pts[1] == expectedPts[numIterPts]);
3258 REPORTER_ASSERT(reporter, pts[2] == expectedPts[numIterPts + 1]);
3259 REPORTER_ASSERT(reporter, pts[3] == expectedPts[numIterPts + 2]);
3270 REPORTER_ASSERT(reporter, numIterPts == numPoints);
3271 REPORTER_ASSERT(reporter, numIterVerbs == numVerbs);
3275 static void check_for_circle(skiatest::Reporter* reporter,
3280 REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle);
3284 REPORTER_ASSERT(reporter, rect.height() == rect.width());
3285 REPORTER_ASSERT(reporter, SkPathPriv::AsFirstDirection(isOvalDir) == expectedDir);
3288 REPORTER_ASSERT(reporter, path == tmpPath);
3290 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, expectedDir));
3293 static void test_circle_skew(skiatest::Reporter* reporter,
3305 REPORTER_ASSERT(reporter, SkPathPriv::kCW_FirstDirection == dir);
3308 check_for_circle(reporter, tmp, false, dir);
3311 static void test_circle_translate(skiatest::Reporter* reporter,
3320 check_for_circle(reporter, tmp, true, dir);
3328 check_for_circle(reporter, tmp, true, dir);
3331 static void test_circle_rotate(skiatest::Reporter* reporter,
3344 check_for_circle(reporter, tmp, true, dir);
3346 check_for_circle(reporter, tmp, false, dir);
3351 static void test_circle_mirror_x(skiatest::Reporter* reporter,
3362 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
3365 check_for_circle(reporter, tmp, true, dir);
3368 static void test_circle_mirror_y(skiatest::Reporter* reporter,
3380 REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir);
3384 check_for_circle(reporter, tmp, true, dir);
3387 static void test_circle_mirror_xy(skiatest::Reporter* reporter,
3397 check_for_circle(reporter, tmp, true, dir);
3400 static void test_circle_with_direction(skiatest::Reporter* reporter,
3408 check_for_circle(reporter, path, true, dir);
3409 test_circle_rotate(reporter, path, dir);
3410 test_circle_translate(reporter, path, dir);
3411 test_circle_skew(reporter, path, dir);
3412 test_circle_mirror_x(reporter, path, dir);
3413 test_circle_mirror_y(reporter, path, dir);
3414 test_circle_mirror_xy(reporter, path, dir);
3421 check_for_circle(reporter, path, true, dir);
3422 test_circle_rotate(reporter, path, dir);
3423 test_circle_translate(reporter, path, dir);
3424 test_circle_skew(reporter, path, dir);
3425 test_circle_mirror_x(reporter, path, dir);
3426 test_circle_mirror_y(reporter, path, dir);
3427 test_circle_mirror_xy(reporter, path, dir);
3433 test_circle_rotate(reporter, path, dir);
3434 test_circle_translate(reporter, path, dir);
3435 test_circle_skew(reporter, path, dir);
3436 test_circle_mirror_x(reporter, path, dir);
3437 test_circle_mirror_y(reporter, path, dir);
3438 test_circle_mirror_xy(reporter, path, dir);
3442 static void test_circle_with_add_paths(skiatest::Reporter* reporter) {
3464 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircleDir));
3470 check_for_circle(reporter, path, true, SkPathPriv::AsFirstDirection(kCircleDir));
3475 check_for_circle(reporter, path, false, SkPathPriv::AsFirstDirection(kCircleDirOpposite));
3478 static void test_circle(skiatest::Reporter* reporter) {
3479 test_circle_with_direction(reporter, SkPath::kCW_Direction);
3480 test_circle_with_direction(reporter, SkPath::kCCW_Direction);
3486 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3492 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3498 check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
3500 test_circle_with_add_paths(reporter);
3505 REPORTER_ASSERT(reporter, path.isEmpty());
3508 static void test_oval(skiatest::Reporter* reporter) {
3519 REPORTER_ASSERT(reporter, path.isOval(nullptr));
3526 REPORTER_ASSERT(reporter, tmp.isOval(nullptr, &dir, &start));
3527 REPORTER_ASSERT(reporter, 2 == start);
3528 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3535 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3542 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3546 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3552 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr));
3559 REPORTER_ASSERT(reporter, path.isOval(nullptr));
3566 REPORTER_ASSERT(reporter, path.isOval(nullptr, &dir, &start));
3567 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3568 REPORTER_ASSERT(reporter, 1 == start);
3571 static void test_empty(skiatest::Reporter* reporter, const SkPath& p) {
3574 REPORTER_ASSERT(reporter, p.isEmpty());
3575 REPORTER_ASSERT(reporter, 0 == p.countPoints());
3576 REPORTER_ASSERT(reporter, 0 == p.countVerbs());
3577 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks());
3578 REPORTER_ASSERT(reporter, p.isConvex());
3579 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType);
3580 REPORTER_ASSERT(reporter, !p.isInverseFillType());
3581 REPORTER_ASSERT(reporter, p == empty);
3582 REPORTER_ASSERT(reporter, !(p != empty));
3585 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path,
3587 REPORTER_ASSERT(reporter, path->isConvex());
3588 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
3590 REPORTER_ASSERT(reporter, path->isConvex());
3594 static void test_rrect_convexity_is_unknown(skiatest::Reporter* reporter, SkPath* path,
3596 REPORTER_ASSERT(reporter, path->isConvex());
3597 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
3599 REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kUnknown_Convexity);
3603 static void test_rrect(skiatest::Reporter* reporter) {
3610 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3612 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3614 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3616 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3618 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3620 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
3626 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3631 REPORTER_ASSERT(reporter, p.isRect(&returnedRect));
3632 REPORTER_ASSERT(reporter, returnedRect == r);
3633 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3639 REPORTER_ASSERT(reporter, p.isRect(nullptr, &closed, &dir));
3640 REPORTER_ASSERT(reporter, closed);
3641 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
3642 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3645 REPORTER_ASSERT(reporter, !p.isConvex());
3649 REPORTER_ASSERT(reporter
3654 REPORTER_ASSERT(reporter, p.isEmpty());
3658 test_rrect_convexity_is_unknown(reporter, &p, SkPath::kCW_Direction);
3663 REPORTER_ASSERT(reporter, rr.isEmpty());
3667 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
3670 static void test_arc(skiatest::Reporter* reporter) {
3673 REPORTER_ASSERT(reporter, emptyOval.isEmpty());
3675 REPORTER_ASSERT(reporter, p.isEmpty());
3679 REPORTER_ASSERT(reporter, p.isEmpty());
3684 REPORTER_ASSERT(reporter, p == cwOval);
3689 REPORTER_ASSERT(reporter, p == ccwOval);
3692 REPORTER_ASSERT(reporter, p.isConvex());
3693 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::kCW_FirstDirection));
3695 REPORTER_ASSERT(reporter, p.isConvex());
3723 static void check_oval_arc(skiatest::Reporter* reporter, SkScalar start, SkScalar sweep,
3729 REPORTER_ASSERT(reporter, isOval);
3732 REPORTER_ASSERT(reporter, path == recreatedPath);
3733 REPORTER_ASSERT(reporter, oval_start_index_to_angle(s) == canonical_start_angle(start));
3734 REPORTER_ASSERT(reporter, (SkPath::kCW_Direction == d) == (sweep > 0.f));
3737 static void test_arc_ovals(skiatest::Reporter* reporter) {
3746 check_oval_arc(reporter, start, sweep, path);
3748 REPORTER_ASSERT(reporter, !path.isOval(nullptr));
3756 check_oval_arc(reporter, start, sweep, path);
3762 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3766 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb);
3767 REPORTER_ASSERT(reporter, pts[0].fX == x0);
3768 REPORTER_ASSERT(reporter, pts[0].fY == y0);
3771 static void check_line(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3775 REPORTER_ASSERT(reporter, v == SkPath::kLine_Verb);
3776 REPORTER_ASSERT(reporter, pts[1].fX == x1);
3777 REPORTER_ASSERT(reporter, pts[1].fY == y1);
3780 static void check_quad(skiatest::Reporter* reporter, SkPath::RawIter* iter,
3784 REPORTER_ASSERT(reporter, v == SkPath::kQuad_Verb);
3785 REPORTER_ASSERT(reporter, pts[1].fX == x1);
3786 REPORTER_ASSERT(reporter, pts[1].fY == y1);
3787 REPORTER_ASSERT(reporter, pts[2].fX == x2);
3788 REPORTER_ASSERT(reporter, pts[2].fY == y2);
3791 static void check_done(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) {
3794 REPORTER_ASSERT(reporter, v == SkPath::kDone_Verb);
3797 static void check_done_and_reset(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) {
3798 check_done(reporter, p, iter);
3802 static void check_path_is_move_and_reset(skiatest::Reporter* reporter, SkPath* p,
3805 check_move(reporter, &iter, x0, y0);
3806 check_done_and_reset(reporter, p, &iter);
3809 static void check_path_is_line_and_reset(skiatest::Reporter* reporter, SkPath* p,
3812 check_move(reporter, &iter, 0, 0);
3813 check_line(reporter, &iter, x1, y1);
3814 check_done_and_reset(reporter, p, &iter);
3817 static void check_path_is_line(skiatest::Reporter* reporter, SkPath* p,
3820 check_move(reporter, &iter, 0, 0);
3821 check_line(reporter, &iter, x1, y1);
3822 check_done(reporter, p, &iter);
3825 static void check_path_is_line_pair_and_reset(skiatest::Reporter* reporter, SkPath* p,
3828 check_move(reporter, &iter, 0, 0);
3829 check_line(reporter, &iter, x1, y1);
3830 check_line(reporter, &iter, x2, y2);
3831 check_done_and_reset(reporter, p, &iter);
3834 static void check_path_is_quad_and_reset(skiatest::Reporter* reporter, SkPath* p,
3837 check_move(reporter, &iter, 0, 0);
3838 check_quad(reporter, &iter, x1, y1, x2, y2);
3839 check_done_and_reset(reporter, p, &iter);
3849 static void test_arcTo(skiatest::Reporter* reporter) {
3852 check_path_is_line_and_reset(reporter, &p, 0, 0);
3854 check_path_is_line_and_reset(reporter, &p, 1, 2);
3856 check_path_is_line_and_reset(reporter, &p, 1, 2);
3858 check_path_is_line_and_reset(reporter, &p, 1, 2);
3861 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == 1);
3864 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == -1);
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());
3874 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
3878 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval));
3884 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval));
3891 REPORTER_ASSERT(reporter, p.isEmpty());
3896 REPORTER_ASSERT(reporter, p.isEmpty());
3899 static void test_addPath(skiatest::Reporter* reporter) {
3910 REPORTER_ASSERT(reporter, p.getBounds() == expected);
3914 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
3917 static void test_addPathMode(skiatest::Reporter* reporter, bool explicitMoveTo, bool extend) {
3930 REPORTER_ASSERT(reporter, verbcount == 4);
3931 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3932 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3933 REPORTER_ASSERT(reporter, verbs[2] == (extend ? SkPath::kLine_Verb : SkPath::kMove_Verb));
3934 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kLine_Verb);
3937 static void test_extendClosedPath(skiatest::Reporter* reporter) {
3948 REPORTER_ASSERT(reporter, verbcount == 7);
3949 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3950 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3951 REPORTER_ASSERT(reporter, verbs[2] == SkPath::kLine_Verb);
3952 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kClose_Verb);
3953 REPORTER_ASSERT(reporter, verbs[4] == SkPath::kMove_Verb);
3954 REPORTER_ASSERT(reporter, verbs[5] == SkPath::kLine_Verb);
3955 REPORTER_ASSERT(reporter, verbs[6] == SkPath::kLine_Verb);
3958 REPORTER_ASSERT(reporter, p.getLastPt(&pt));
3959 REPORTER_ASSERT(reporter, pt == SkPoint::Make(2, 3));
3960 REPORTER_ASSERT(reporter, p.getPoint(3) == SkPoint::Make(1, 1));
3963 static void test_addEmptyPath(skiatest::Reporter* reporter, SkPath::AddPathMode mode) {
3969 REPORTER_ASSERT(reporter, q == p);
3972 REPORTER_ASSERT(reporter, q == p);
3976 REPORTER_ASSERT(reporter, q.isEmpty());
3979 static void test_conicTo_special_case(skiatest::Reporter* reporter) {
3982 check_path_is_line_and_reset(reporter, &p, 3, 4);
3984 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4);
3986 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4);
3989 static void test_get_point(skiatest::Reporter* reporter) {
3992 REPORTER_ASSERT(reporter, pt == SkPoint::Make(0, 0));
3993 REPORTER_ASSERT(reporter, !p.getLastPt(nullptr));
3994 REPORTER_ASSERT(reporter, !p.getLastPt(&pt) && pt == SkPoint::Make(0, 0));
3997 REPORTER_ASSERT(reporter, pt == SkPoint::Make(10, 10));
3998 REPORTER_ASSERT(reporter, p.getLastPt(nullptr));
4000 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt == SkPoint::Make(20, 20));
4003 static void test_contains(skiatest::Reporter* reporter) {
4016 REPORTER_ASSERT(reporter, p.contains(0, 0));
4018 REPORTER_ASSERT(reporter, !p.contains(0, 0));
4023 REPORTER_ASSERT(reporter, p.contains(6, 4));
4024 REPORTER_ASSERT(reporter, p.contains(5, 6));
4025 REPORTER_ASSERT(reporter, p.contains(7, 6));
4027 REPORTER_ASSERT(reporter, !p.contains(4, 0));
4028 REPORTER_ASSERT(reporter, !p.contains(0, 4));
4029 REPORTER_ASSERT(reporter, !p.contains(4, 10));
4030 REPORTER_ASSERT(reporter, !p.contains(10, 4));
4032 REPORTER_ASSERT(reporter, !p.contains(5, 7));
4033 REPORTER_ASSERT(reporter, p.contains(6, 7));
4034 REPORTER_ASSERT(reporter, !p.contains(7, 7));
4040 REPORTER_ASSERT(reporter, p.contains(4, 6));
4041 REPORTER_ASSERT(reporter, p.contains(6, 5));
4042 REPORTER_ASSERT(reporter, p.contains(6, 7));
4044 REPORTER_ASSERT(reporter, !p.contains(7, 5));
4045 REPORTER_ASSERT(reporter, p.contains(7, 6));
4046 REPORTER_ASSERT(reporter, !p.contains(7, 7));
4053 REPORTER_ASSERT(reporter, p.contains(4, 4));
4054 REPORTER_ASSERT(reporter, p.contains(8, 4));
4055 REPORTER_ASSERT(reporter, p.contains(8, 8));
4056 REPORTER_ASSERT(reporter, p.contains(4, 8));
4062 REPORTER_ASSERT(reporter, p.contains(5, 6));
4063 REPORTER_ASSERT(reporter, p.contains(4, 8));
4064 REPORTER_ASSERT(reporter, p.contains(3, 6));
4070 REPORTER_ASSERT(reporter, p.contains(2, 5));
4071 REPORTER_ASSERT(reporter, p.contains(2, 7));
4072 REPORTER_ASSERT(reporter, p.contains(4, 6));
4081 REPORTER_ASSERT(reporter, !p.contains(1, 2));
4082 REPORTER_ASSERT(reporter, !p.contains(3, 2));
4083 reporter, !p.contains(4, 0));
4084 REPORTER_ASSERT(reporter, p.contains(4, 4));
4092 REPORTER_ASSERT(reporter, p.contains(5, 6));
4093 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4095 REPORTER_ASSERT(reporter, p.contains(5, 5));
4096 REPORTER_ASSERT(reporter, p.contains(5, 8));
4097 REPORTER_ASSERT(reporter, p.contains(4, 5));
4099 REPORTER_ASSERT(reporter, p.contains(4, 4));
4100 REPORTER_ASSERT(reporter, p.contains(8, 8));
4101 REPORTER_ASSERT(reporter, p.contains(4, 8));
4109 REPORTER_ASSERT(reporter, p.contains(5, 6));
4110 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4115 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4125 REPORTER_ASSERT(reporter, p.contains(5, 6));
4126 REPORTER_ASSERT(reporter, !p.contains(6, 5));
4131 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4134 REPORTER_ASSERT(reporter, p.contains(4, 4));
4135 REPORTER_ASSERT(reporter, p.contains(8, 8));
4136 REPORTER_ASSERT(reporter, p.contains(4, 8));
4147 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f));
4148 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f));
4151 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4153 REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
4155 REPORTER_ASSERT(reporter, p.contains(pts[i].fX, pts[i].fY));
4156 REPORTER_ASSERT(reporter, p.contains(pts[i + 3].fX, pts[i + 3].fY));
4157 REPORTER_ASSERT(reporter, p.contains(pts[i + 6].fX, pts[i + 6].fY));
4163 static void TestPathRef(skiatest::Reporter* reporter) {
4172 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4173 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
4174 REPORTER_ASSERT(reporter, 0 == pathRef->getSegmentMasks());
4176 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef->atVerb(i));
4183 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4184 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints());
4185 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == pathRef->getSegmentMasks());
4187 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == pathRef->atVerb(i));
4194 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4195 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
4196 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef->getSegmentMasks());
4198 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef->atVerb(i));
4206 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4207 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints());
4208 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countWeights());
4209 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef->getSegmentMasks());
4210 REPORTER_ASSERT(reporter, weights);
4212 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef->atVerb(i));
4219 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs());
4220 REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef->countPoints());
4221 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef->getSegmentMasks());
4223 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef->atVerb(i));
4230 static void test_operatorEqual(skiatest::Reporter* reporter) {
4233 REPORTER_ASSERT(reporter, a == a);
4234 REPORTER_ASSERT(reporter, a == b);
4236 REPORTER_ASSERT(reporter, a != b);
4238 REPORTER_ASSERT(reporter, a == b);
4240 REPORTER_ASSERT(reporter, a != b);
4242 REPORTER_ASSERT(reporter, a == b);
4245 REPORTER_ASSERT(reporter, a != b);
4248 REPORTER_ASSERT(reporter, a == b);
4251 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool force,
4256 REPORTER_ASSERT(reporter, data->size() == strlen(str));
4258 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
4260 REPORTER_ASSERT(reporter, data->data() == nullptr || !memcmp(data->data(), str, strlen(str)));
4264 static void test_dump(skiatest::Reporter* reporter) {
4266 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n");
4267 compare_dump(reporter, p, true, false, "path.setFillType(SkPath::kWinding_FillType);\n");
4270 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4273 compare_dump(reporter, p, true, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4282 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kEvenOdd_FillType);\n"
4289 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kInverseWinding_FillType);\n"
4296 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kInverseEvenOdd_FillType);\n"
4303 compare_dump(reporter, p, false, true,
4310 compare_dump(reporter, p, false, false, "path.setFillType(SkPath::kWinding_FillType);\n"
4332 static void TestPathTo(skiatest::Reporter* reporter) {
4336 check_path_is_line(reporter, &p, 4, 4);
4339 check_path_is_line(reporter, &p, 4, 4);
4347 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
4350 static void TestPathrefListeners(skiatest::Reporter* reporter) {
4359 REPORTER_ASSERT(reporter, !changed);
4361 REPORTER_ASSERT(reporter, changed);
4365 REPORTER_ASSERT(reporter, !changed);
4367 REPORTER_ASSERT(reporter, changed);
4371 REPORTER_ASSERT(reporter, !changed);
4373 REPORTER_ASSERT(reporter, changed);
4379 REPORTER_ASSERT(reporter, !changed);
4381 REPORTER_ASSERT(reporter, changed);
4388 REPORTER_ASSERT(reporter, !changed);
4391 REPORTER_ASSERT(reporter, changed);
4395 static void test_crbug_629455(skiatest::Reporter* reporter) {
4410 static void test_fuzz_crbug_662952(skiatest::Reporter* reporter) {
4449 static void test_fuzz_crbug_662730(skiatest::Reporter* reporter) {
4463 static void test_interp(skiatest::Reporter* reporter) {
4465 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4466 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
4467 REPORTER_ASSERT(reporter, p1 == out);
4468 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
4469 REPORTER_ASSERT(reporter, p1 == out);
4472 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4473 REPORTER_ASSERT(reporter
4476 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4477 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0, &out));
4478 REPORTER_ASSERT(reporter, p2 == out);
4479 REPORTER_ASSERT(reporter, p1.interpolate(p2, 1, &out));
4480 REPORTER_ASSERT(reporter, p1 == out);
4481 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
4482 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(3, 1, 4, 2));
4489 REPORTER_ASSERT(reporter, p1.isInterpolatable(p2));
4490 REPORTER_ASSERT(reporter, p1.interpolate(p2, 0.5f, &out));
4491 REPORTER_ASSERT(reporter, out.getBounds() == SkRect::MakeLTRB(4, 3, 6, 5));
4495 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4499 REPORTER_ASSERT(reporter, !p1.isInterpolatable(p2));
4502 DEF_TEST(PathInterp, reporter) {
4503 test_interp(reporter);
4507 DEF_TEST(PathBigCubic, reporter) {
4518 DEF_TEST(PathContains, reporter) {
4519 test_contains(reporter);
4522 DEF_TEST(Paths, reporter) {
4526 test_crbug_629455(reporter);
4527 test_fuzz_crbug_627414(reporter);
4529 test_fuzz_crbug_662952(reporter);
4530 test_fuzz_crbug_662730(reporter);
4540 test_empty(reporter, p);
4542 REPORTER_ASSERT(reporter, p.getBounds().isEmpty());
4554 check_convex_bounds(reporter, p, bounds);
4556 REPORTER_ASSERT(reporter,
4558 REPORTER_ASSERT(reporter, !p.isEmpty());
4561 test_empty(reporter, p);
4564 check_convex_bounds(reporter, p, bounds);
4565 REPORTER_ASSERT(reporter, !p.isEmpty());
4568 test_empty(reporter, p);
4571 check_convex_bounds(reporter, p, bounds);
4573 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks());
4574 REPORTER_ASSERT(reporter, !p.isEmpty());
4576 REPORTER_ASSERT(reporter, p != empty);
4577 REPORTER_ASSERT(reporter, !(p == empty));
4580 REPORTER_ASSERT(reporter, p.getPoints(nullptr, 0) == 4);
4581 REPORTER_ASSERT(reporter, p.getVerbs(nullptr, 0) == 5);
4584 REPORTER_ASSERT(reporter, count == 4);
4588 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == verbs[0]);
4589 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[1]);
4590 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[2]);
4591 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[3]);
4592 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == verbs[4]);
4593 REPORTER_ASSERT(reporter, 0xff == verbs[5]);
4595 REPORTER_ASSERT(reporter, bounds == bounds2);
4599 REPORTER_ASSERT(reporter, bounds == p.getBounds());
4601 REPORTER_ASSERT(reporter, p.isRect(nullptr));
4603 REPORTER_ASSERT(reporter, p.isRect(&bounds2));
4604 REPORTER_ASSERT(reporter, bounds == bounds2);
4609 REPORTER_ASSERT(reporter, !p.isRect(nullptr));
4617 REPORTER_ASSERT(reporter, p.isRect(&r));
4618 REPORTER_ASSERT(reporter, r == bounds);
4621 REPORTER_ASSERT(reporter, p.isRect(&r));
4622 REPORTER_ASSERT(reporter, r == bounds);
4625 test_operatorEqual(reporter);
4626 test_isLine(reporter);
4627 test_isRect(reporter);
4628 test_is_simple_closed_rect(reporter);
4629 test_isNestedFillRects(reporter);
4630 test_zero_length_paths(reporter);
4631 test_direction(reporter);
4632 test_convexity(reporter);
4633 test_convexity2(reporter);
4634 test_conservativelyContains(reporter);
4635 test_close(reporter);
4636 test_segment_masks(reporter);
4637 test_flattening(reporter);
4638 test_transform(reporter);
4639 test_bounds(reporter);
4640 test_iter(reporter);
4641 test_raw_iter(reporter);
4642 test_circle(reporter);
4643 test_oval(reporter);
4644 test_strokerec(reporter);
4645 test_addPoly(reporter);
4646 test_isfinite(reporter);
4647 test_isfinite_after_transform(reporter);
4648 test_islastcontourclosed(reporter);
4649 test_arb_round_rect_is_convex(reporter);
4650 test_arb_zero_rad_round_rect_is_rect(reporter);
4651 test_addrect(reporter);
4652 test_addrect_isfinite(reporter);
4656 test_crbug_493450(reporter);
4657 test_crbug_495894(reporter);
4661 test_gen_id(reporter);
4662 test_path_close_issue1474(reporter);
4663 test_path_to_region(reporter);
4664 test_rrect(reporter);
4665 test_arc(reporter);
4666 test_arc_ovals(reporter);
4667 test_arcTo(reporter);
4668 test_addPath(reporter);
4669 test_addPathMode(reporter, false, false);
4670 test_addPathMode(reporter, true, false);
4671 test_addPathMode(reporter, false, true);
4672 test_addPathMode(reporter, true, true);
4673 test_extendClosedPath(reporter);
4674 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
4675 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
4676 test_conicTo_special_case(reporter);
4677 test_get_point(reporter);
4678 test_contains(reporter);
4679 PathTest_Private::TestPathTo(reporter);
4680 PathRefTest_Private::TestPathRef(reporter);
4681 PathTest_Private::TestPathrefListeners(reporter);
4682 test_dump(reporter);
4683 test_path_crbug389050(reporter);
4684 test_path_crbugskia2820(reporter);
4686 test_skbug_3469(reporter);
4687 test_skbug_3239(reporter);
4688 test_bounds_crbug_513799(reporter);
4692 DEF_TEST(conservatively_contains_rect, reporter) {
4734 DEF_TEST(path_tight_bounds, reporter) {
4747 REPORTER_ASSERT(reporter, bounds.contains(tight));
4751 REPORTER_ASSERT(reporter, nearly_equal(tight, tight2));