| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkParse.h" | 10 #include "SkParse.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 path.moveTo(pts[0]); | 307 path.moveTo(pts[0]); |
| 308 path.cubicTo(pts[1], pts[2], pts[3]); | 308 path.cubicTo(pts[1], pts[2], pts[3]); |
| 309 | 309 |
| 310 SkPaint paint; | 310 SkPaint paint; |
| 311 paint.setStyle(SkPaint::kStroke_Style); | 311 paint.setStyle(SkPaint::kStroke_Style); |
| 312 paint.setStrokeWidth(20); | 312 paint.setStrokeWidth(20); |
| 313 | 313 |
| 314 SkPath dst; | 314 SkPath dst; |
| 315 // Before the fix, this would infinite-recurse, and run out of stack | 315 // Before the fix, this would infinite-recurse, and run out of stack |
| 316 // because we would keep trying to subdivide a degenerate cubic segment. | 316 // because we would keep trying to subdivide a degenerate cubic segment. |
| 317 paint.getFillPath(path, &dst, NULL); | 317 paint.getFillPath(path, &dst, nullptr); |
| 318 } | 318 } |
| 319 | 319 |
| 320 static void build_path_170666(SkPath& path) { | 320 static void build_path_170666(SkPath& path) { |
| 321 path.moveTo(17.9459f, 21.6344f); | 321 path.moveTo(17.9459f, 21.6344f); |
| 322 path.lineTo(139.545f, -47.8105f); | 322 path.lineTo(139.545f, -47.8105f); |
| 323 path.lineTo(139.545f, -47.8105f); | 323 path.lineTo(139.545f, -47.8105f); |
| 324 path.lineTo(131.07f, -47.3888f); | 324 path.lineTo(131.07f, -47.3888f); |
| 325 path.lineTo(131.07f, -47.3888f); | 325 path.lineTo(131.07f, -47.3888f); |
| 326 path.lineTo(122.586f, -46.9532f); | 326 path.lineTo(122.586f, -46.9532f); |
| 327 path.lineTo(122.586f, -46.9532f); | 327 path.lineTo(122.586f, -46.9532f); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 "L-0.33997991989448945,-0.11301535852306784L-0.33990282433493346,-0.1129
6217481488612" | 478 "L-0.33997991989448945,-0.11301535852306784L-0.33990282433493346,-0.1129
6217481488612" |
| 479 "L-0.33993994441916414,-0.11288906492739594Z"; | 479 "L-0.33993994441916414,-0.11288906492739594Z"; |
| 480 test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7
819.72220766405f, | 480 test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7
819.72220766405f, |
| 481 65536); | 481 65536); |
| 482 } | 482 } |
| 483 | 483 |
| 484 static void test_addrect(skiatest::Reporter* reporter) { | 484 static void test_addrect(skiatest::Reporter* reporter) { |
| 485 SkPath path; | 485 SkPath path; |
| 486 path.lineTo(0, 0); | 486 path.lineTo(0, 0); |
| 487 path.addRect(SkRect::MakeWH(50, 100)); | 487 path.addRect(SkRect::MakeWH(50, 100)); |
| 488 REPORTER_ASSERT(reporter, path.isRect(NULL)); | 488 REPORTER_ASSERT(reporter, path.isRect(nullptr)); |
| 489 | 489 |
| 490 path.reset(); | 490 path.reset(); |
| 491 path.lineTo(FLT_EPSILON, FLT_EPSILON); | 491 path.lineTo(FLT_EPSILON, FLT_EPSILON); |
| 492 path.addRect(SkRect::MakeWH(50, 100)); | 492 path.addRect(SkRect::MakeWH(50, 100)); |
| 493 REPORTER_ASSERT(reporter, !path.isRect(NULL)); | 493 REPORTER_ASSERT(reporter, !path.isRect(nullptr)); |
| 494 | 494 |
| 495 path.reset(); | 495 path.reset(); |
| 496 path.quadTo(0, 0, 0, 0); | 496 path.quadTo(0, 0, 0, 0); |
| 497 path.addRect(SkRect::MakeWH(50, 100)); | 497 path.addRect(SkRect::MakeWH(50, 100)); |
| 498 REPORTER_ASSERT(reporter, !path.isRect(NULL)); | 498 REPORTER_ASSERT(reporter, !path.isRect(nullptr)); |
| 499 | 499 |
| 500 path.reset(); | 500 path.reset(); |
| 501 path.conicTo(0, 0, 0, 0, 0.5f); | 501 path.conicTo(0, 0, 0, 0, 0.5f); |
| 502 path.addRect(SkRect::MakeWH(50, 100)); | 502 path.addRect(SkRect::MakeWH(50, 100)); |
| 503 REPORTER_ASSERT(reporter, !path.isRect(NULL)); | 503 REPORTER_ASSERT(reporter, !path.isRect(nullptr)); |
| 504 | 504 |
| 505 path.reset(); | 505 path.reset(); |
| 506 path.cubicTo(0, 0, 0, 0, 0, 0); | 506 path.cubicTo(0, 0, 0, 0, 0, 0); |
| 507 path.addRect(SkRect::MakeWH(50, 100)); | 507 path.addRect(SkRect::MakeWH(50, 100)); |
| 508 REPORTER_ASSERT(reporter, !path.isRect(NULL)); | 508 REPORTER_ASSERT(reporter, !path.isRect(nullptr)); |
| 509 } | 509 } |
| 510 | 510 |
| 511 // Make sure we stay non-finite once we get there (unless we reset or rewind). | 511 // Make sure we stay non-finite once we get there (unless we reset or rewind). |
| 512 static void test_addrect_isfinite(skiatest::Reporter* reporter) { | 512 static void test_addrect_isfinite(skiatest::Reporter* reporter) { |
| 513 SkPath path; | 513 SkPath path; |
| 514 | 514 |
| 515 path.addRect(SkRect::MakeWH(50, 100)); | 515 path.addRect(SkRect::MakeWH(50, 100)); |
| 516 REPORTER_ASSERT(reporter, path.isFinite()); | 516 REPORTER_ASSERT(reporter, path.isFinite()); |
| 517 | 517 |
| 518 path.moveTo(0, 0); | 518 path.moveTo(0, 0); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 if (SkPathPriv::CheapComputeFirstDirection(copy, &dir)) { | 919 if (SkPathPriv::CheapComputeFirstDirection(copy, &dir)) { |
| 920 REPORTER_ASSERT(reporter, dir == expected); | 920 REPORTER_ASSERT(reporter, dir == expected); |
| 921 } else { | 921 } else { |
| 922 REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expecte
d); | 922 REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expecte
d); |
| 923 } | 923 } |
| 924 } | 924 } |
| 925 | 925 |
| 926 static void test_direction(skiatest::Reporter* reporter) { | 926 static void test_direction(skiatest::Reporter* reporter) { |
| 927 size_t i; | 927 size_t i; |
| 928 SkPath path; | 928 SkPath path; |
| 929 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, NULL
)); | 929 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, null
ptr)); |
| 930 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPri
v::kCW_FirstDirection)); | 930 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPri
v::kCW_FirstDirection)); |
| 931 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPri
v::kCCW_FirstDirection)); | 931 REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPri
v::kCCW_FirstDirection)); |
| 932 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv
::kUnknown_FirstDirection)); | 932 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv
::kUnknown_FirstDirection)); |
| 933 | 933 |
| 934 static const char* gDegen[] = { | 934 static const char* gDegen[] = { |
| 935 "M 10 10", | 935 "M 10 10", |
| 936 "M 10 10 M 20 20", | 936 "M 10 10 M 20 20", |
| 937 "M 10 10 L 20 20", | 937 "M 10 10 L 20 20", |
| 938 "M 10 10 L 10 10 L 10 10", | 938 "M 10 10 L 10 10 L 10 10", |
| 939 "M 10 10 Q 10 10 10 10", | 939 "M 10 10 Q 10 10 10 10", |
| 940 "M 10 10 C 10 10 10 10 10 10", | 940 "M 10 10 C 10 10 10 10 10 10", |
| 941 }; | 941 }; |
| 942 for (i = 0; i < SK_ARRAY_COUNT(gDegen); ++i) { | 942 for (i = 0; i < SK_ARRAY_COUNT(gDegen); ++i) { |
| 943 path.reset(); | 943 path.reset(); |
| 944 bool valid = SkParsePath::FromSVGString(gDegen[i], &path); | 944 bool valid = SkParsePath::FromSVGString(gDegen[i], &path); |
| 945 REPORTER_ASSERT(reporter, valid); | 945 REPORTER_ASSERT(reporter, valid); |
| 946 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path,
NULL)); | 946 REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path,
nullptr)); |
| 947 } | 947 } |
| 948 | 948 |
| 949 static const char* gCW[] = { | 949 static const char* gCW[] = { |
| 950 "M 10 10 L 10 10 Q 20 10 20 20", | 950 "M 10 10 L 10 10 Q 20 10 20 20", |
| 951 "M 10 10 C 20 10 20 20 20 20", | 951 "M 10 10 C 20 10 20 20 20 20", |
| 952 "M 20 10 Q 20 20 30 20 L 10 20", // test double-back at y-max | 952 "M 20 10 Q 20 20 30 20 L 10 20", // test double-back at y-max |
| 953 // rect with top two corners replaced by cubics with identical middle | 953 // rect with top two corners replaced by cubics with identical middle |
| 954 // control points | 954 // control points |
| 955 "M 10 10 C 10 0 10 0 20 0 L 40 0 C 50 0 50 0 50 10", | 955 "M 10 10 C 10 0 10 0 20 0 L 40 0 C 50 0 50 0 50 10", |
| 956 "M 20 10 L 0 10 Q 10 10 20 0", // left, degenerate serif | 956 "M 20 10 L 0 10 Q 10 10 20 0", // left, degenerate serif |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 other.swap(p2); | 1354 other.swap(p2); |
| 1355 REPORTER_ASSERT(reporter, other.isConvex()); | 1355 REPORTER_ASSERT(reporter, other.isConvex()); |
| 1356 REPORTER_ASSERT(reporter, other.getBounds() == bounds); | 1356 REPORTER_ASSERT(reporter, other.getBounds() == bounds); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 static void setFromString(SkPath* path, const char str[]) { | 1359 static void setFromString(SkPath* path, const char str[]) { |
| 1360 bool first = true; | 1360 bool first = true; |
| 1361 while (str) { | 1361 while (str) { |
| 1362 SkScalar x, y; | 1362 SkScalar x, y; |
| 1363 str = SkParse::FindScalar(str, &x); | 1363 str = SkParse::FindScalar(str, &x); |
| 1364 if (NULL == str) { | 1364 if (nullptr == str) { |
| 1365 break; | 1365 break; |
| 1366 } | 1366 } |
| 1367 str = SkParse::FindScalar(str, &y); | 1367 str = SkParse::FindScalar(str, &y); |
| 1368 SkASSERT(str); | 1368 SkASSERT(str); |
| 1369 if (first) { | 1369 if (first) { |
| 1370 path->moveTo(x, y); | 1370 path->moveTo(x, y); |
| 1371 first = false; | 1371 first = false; |
| 1372 } else { | 1372 } else { |
| 1373 path->lineTo(x, y); | 1373 path->lineTo(x, y); |
| 1374 } | 1374 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 : SkPath::kUnknown_Convexity); | 1500 : SkPath::kUnknown_Convexity); |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 static void test_isLine(skiatest::Reporter* reporter) { | 1505 static void test_isLine(skiatest::Reporter* reporter) { |
| 1506 SkPath path; | 1506 SkPath path; |
| 1507 SkPoint pts[2]; | 1507 SkPoint pts[2]; |
| 1508 const SkScalar value = SkIntToScalar(5); | 1508 const SkScalar value = SkIntToScalar(5); |
| 1509 | 1509 |
| 1510 REPORTER_ASSERT(reporter, !path.isLine(NULL)); | 1510 REPORTER_ASSERT(reporter, !path.isLine(nullptr)); |
| 1511 | 1511 |
| 1512 // set some non-zero values | 1512 // set some non-zero values |
| 1513 pts[0].set(value, value); | 1513 pts[0].set(value, value); |
| 1514 pts[1].set(value, value); | 1514 pts[1].set(value, value); |
| 1515 REPORTER_ASSERT(reporter, !path.isLine(pts)); | 1515 REPORTER_ASSERT(reporter, !path.isLine(pts)); |
| 1516 // check that pts was untouched | 1516 // check that pts was untouched |
| 1517 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); | 1517 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); |
| 1518 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); | 1518 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); |
| 1519 | 1519 |
| 1520 const SkScalar moveX = SkIntToScalar(1); | 1520 const SkScalar moveX = SkIntToScalar(1); |
| 1521 const SkScalar moveY = SkIntToScalar(2); | 1521 const SkScalar moveY = SkIntToScalar(2); |
| 1522 REPORTER_ASSERT(reporter, value != moveX && value != moveY); | 1522 REPORTER_ASSERT(reporter, value != moveX && value != moveY); |
| 1523 | 1523 |
| 1524 path.moveTo(moveX, moveY); | 1524 path.moveTo(moveX, moveY); |
| 1525 REPORTER_ASSERT(reporter, !path.isLine(NULL)); | 1525 REPORTER_ASSERT(reporter, !path.isLine(nullptr)); |
| 1526 REPORTER_ASSERT(reporter, !path.isLine(pts)); | 1526 REPORTER_ASSERT(reporter, !path.isLine(pts)); |
| 1527 // check that pts was untouched | 1527 // check that pts was untouched |
| 1528 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); | 1528 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); |
| 1529 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); | 1529 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); |
| 1530 | 1530 |
| 1531 const SkScalar lineX = SkIntToScalar(2); | 1531 const SkScalar lineX = SkIntToScalar(2); |
| 1532 const SkScalar lineY = SkIntToScalar(2); | 1532 const SkScalar lineY = SkIntToScalar(2); |
| 1533 REPORTER_ASSERT(reporter, value != lineX && value != lineY); | 1533 REPORTER_ASSERT(reporter, value != lineX && value != lineY); |
| 1534 | 1534 |
| 1535 path.lineTo(lineX, lineY); | 1535 path.lineTo(lineX, lineY); |
| 1536 REPORTER_ASSERT(reporter, path.isLine(NULL)); | 1536 REPORTER_ASSERT(reporter, path.isLine(nullptr)); |
| 1537 | 1537 |
| 1538 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY)); | 1538 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY)); |
| 1539 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY)); | 1539 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY)); |
| 1540 REPORTER_ASSERT(reporter, path.isLine(pts)); | 1540 REPORTER_ASSERT(reporter, path.isLine(pts)); |
| 1541 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY)); | 1541 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY)); |
| 1542 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY)); | 1542 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY)); |
| 1543 | 1543 |
| 1544 path.lineTo(0, 0); // too many points/verbs | 1544 path.lineTo(0, 0); // too many points/verbs |
| 1545 REPORTER_ASSERT(reporter, !path.isLine(NULL)); | 1545 REPORTER_ASSERT(reporter, !path.isLine(nullptr)); |
| 1546 REPORTER_ASSERT(reporter, !path.isLine(pts)); | 1546 REPORTER_ASSERT(reporter, !path.isLine(pts)); |
| 1547 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY)); | 1547 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY)); |
| 1548 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY)); | 1548 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY)); |
| 1549 | 1549 |
| 1550 path.reset(); | 1550 path.reset(); |
| 1551 path.quadTo(1, 1, 2, 2); | 1551 path.quadTo(1, 1, 2, 2); |
| 1552 REPORTER_ASSERT(reporter, !path.isLine(NULL)); | 1552 REPORTER_ASSERT(reporter, !path.isLine(nullptr)); |
| 1553 } | 1553 } |
| 1554 | 1554 |
| 1555 static void test_conservativelyContains(skiatest::Reporter* reporter) { | 1555 static void test_conservativelyContains(skiatest::Reporter* reporter) { |
| 1556 SkPath path; | 1556 SkPath path; |
| 1557 | 1557 |
| 1558 // kBaseRect is used to construct most our test paths: a rect, a circle, and
a round-rect. | 1558 // kBaseRect is used to construct most our test paths: a rect, a circle, and
a round-rect. |
| 1559 static const SkRect kBaseRect = SkRect::MakeWH(SkIntToScalar(100), SkIntToSc
alar(100)); | 1559 static const SkRect kBaseRect = SkRect::MakeWH(SkIntToScalar(100), SkIntToSc
alar(100)); |
| 1560 | 1560 |
| 1561 // A circle that bounds kBaseRect (with a significant amount of slop) | 1561 // A circle that bounds kBaseRect (with a significant amount of slop) |
| 1562 SkScalar circleR = SkMaxScalar(kBaseRect.width(), kBaseRect.height()); | 1562 SkScalar circleR = SkMaxScalar(kBaseRect.width(), kBaseRect.height()); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(
0, 0, 1, 1))); | 1764 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(
0, 0, 1, 1))); |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 static void test_isRect_open_close(skiatest::Reporter* reporter) { | 1767 static void test_isRect_open_close(skiatest::Reporter* reporter) { |
| 1768 SkPath path; | 1768 SkPath path; |
| 1769 bool isClosed; | 1769 bool isClosed; |
| 1770 | 1770 |
| 1771 path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(1, 1); path.lineTo(0, 1); | 1771 path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(1, 1); path.lineTo(0, 1); |
| 1772 path.close(); | 1772 path.close(); |
| 1773 | 1773 |
| 1774 REPORTER_ASSERT(reporter, path.isRect(NULL, &isClosed, NULL)); | 1774 REPORTER_ASSERT(reporter, path.isRect(nullptr, &isClosed, nullptr)); |
| 1775 REPORTER_ASSERT(reporter, isClosed); | 1775 REPORTER_ASSERT(reporter, isClosed); |
| 1776 } | 1776 } |
| 1777 | 1777 |
| 1778 // Simple isRect test is inline TestPath, below. | 1778 // Simple isRect test is inline TestPath, below. |
| 1779 // test_isRect provides more extensive testing. | 1779 // test_isRect provides more extensive testing. |
| 1780 static void test_isRect(skiatest::Reporter* reporter) { | 1780 static void test_isRect(skiatest::Reporter* reporter) { |
| 1781 test_isRect_open_close(reporter); | 1781 test_isRect_open_close(reporter); |
| 1782 | 1782 |
| 1783 // passing tests (all moveTo / lineTo... | 1783 // passing tests (all moveTo / lineTo... |
| 1784 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; | 1784 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 int index; | 1868 int index; |
| 1869 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { | 1869 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { |
| 1870 SkPath path; | 1870 SkPath path; |
| 1871 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints[0].
fY); | 1871 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints[0].
fY); |
| 1872 for (index = 1; index < tests[testIndex].fPointCount; ++index) { | 1872 for (index = 1; index < tests[testIndex].fPointCount; ++index) { |
| 1873 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex].fPo
ints[index].fY); | 1873 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex].fPo
ints[index].fY); |
| 1874 } | 1874 } |
| 1875 if (tests[testIndex].fClose) { | 1875 if (tests[testIndex].fClose) { |
| 1876 path.close(); | 1876 path.close(); |
| 1877 } | 1877 } |
| 1878 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(NULL))
; | 1878 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(nullpt
r)); |
| 1879 | 1879 |
| 1880 if (tests[testIndex].fIsRect) { | 1880 if (tests[testIndex].fIsRect) { |
| 1881 SkRect computed, expected; | 1881 SkRect computed, expected; |
| 1882 bool isClosed; | 1882 bool isClosed; |
| 1883 SkPath::Direction direction; | 1883 SkPath::Direction direction; |
| 1884 SkPathPriv::FirstDirection cheapDirection; | 1884 SkPathPriv::FirstDirection cheapDirection; |
| 1885 expected.set(tests[testIndex].fPoints, tests[testIndex].fPointCount)
; | 1885 expected.set(tests[testIndex].fPoints, tests[testIndex].fPointCount)
; |
| 1886 REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(pat
h, &cheapDirection)); | 1886 REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(pat
h, &cheapDirection)); |
| 1887 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &directi
on)); | 1887 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &directi
on)); |
| 1888 REPORTER_ASSERT(reporter, expected == computed); | 1888 REPORTER_ASSERT(reporter, expected == computed); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 // fail, close then line | 1904 // fail, close then line |
| 1905 SkPath path1; | 1905 SkPath path1; |
| 1906 path1.moveTo(r1[0].fX, r1[0].fY); | 1906 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1907 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1907 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 1908 path1.lineTo(r1[index].fX, r1[index].fY); | 1908 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1909 } | 1909 } |
| 1910 path1.close(); | 1910 path1.close(); |
| 1911 path1.lineTo(1, 0); | 1911 path1.lineTo(1, 0); |
| 1912 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1912 REPORTER_ASSERT(reporter, !path1.isRect(nullptr)); |
| 1913 | 1913 |
| 1914 // fail, move in the middle | 1914 // fail, move in the middle |
| 1915 path1.reset(); | 1915 path1.reset(); |
| 1916 path1.moveTo(r1[0].fX, r1[0].fY); | 1916 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1917 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1917 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 1918 if (index == 2) { | 1918 if (index == 2) { |
| 1919 path1.moveTo(1, .5f); | 1919 path1.moveTo(1, .5f); |
| 1920 } | 1920 } |
| 1921 path1.lineTo(r1[index].fX, r1[index].fY); | 1921 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1922 } | 1922 } |
| 1923 path1.close(); | 1923 path1.close(); |
| 1924 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1924 REPORTER_ASSERT(reporter, !path1.isRect(nullptr)); |
| 1925 | 1925 |
| 1926 // fail, move on the edge | 1926 // fail, move on the edge |
| 1927 path1.reset(); | 1927 path1.reset(); |
| 1928 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1928 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 1929 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); | 1929 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); |
| 1930 path1.lineTo(r1[index].fX, r1[index].fY); | 1930 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1931 } | 1931 } |
| 1932 path1.close(); | 1932 path1.close(); |
| 1933 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1933 REPORTER_ASSERT(reporter, !path1.isRect(nullptr)); |
| 1934 | 1934 |
| 1935 // fail, quad | 1935 // fail, quad |
| 1936 path1.reset(); | 1936 path1.reset(); |
| 1937 path1.moveTo(r1[0].fX, r1[0].fY); | 1937 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1938 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1938 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 1939 if (index == 2) { | 1939 if (index == 2) { |
| 1940 path1.quadTo(1, .5f, 1, .5f); | 1940 path1.quadTo(1, .5f, 1, .5f); |
| 1941 } | 1941 } |
| 1942 path1.lineTo(r1[index].fX, r1[index].fY); | 1942 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1943 } | 1943 } |
| 1944 path1.close(); | 1944 path1.close(); |
| 1945 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1945 REPORTER_ASSERT(reporter, !path1.isRect(nullptr)); |
| 1946 | 1946 |
| 1947 // fail, cubic | 1947 // fail, cubic |
| 1948 path1.reset(); | 1948 path1.reset(); |
| 1949 path1.moveTo(r1[0].fX, r1[0].fY); | 1949 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1950 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1950 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 1951 if (index == 2) { | 1951 if (index == 2) { |
| 1952 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); | 1952 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); |
| 1953 } | 1953 } |
| 1954 path1.lineTo(r1[index].fX, r1[index].fY); | 1954 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1955 } | 1955 } |
| 1956 path1.close(); | 1956 path1.close(); |
| 1957 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1957 REPORTER_ASSERT(reporter, !path1.isRect(nullptr)); |
| 1958 } | 1958 } |
| 1959 | 1959 |
| 1960 static void test_isNestedFillRects(skiatest::Reporter* reporter) { | 1960 static void test_isNestedFillRects(skiatest::Reporter* reporter) { |
| 1961 // passing tests (all moveTo / lineTo... | 1961 // passing tests (all moveTo / lineTo... |
| 1962 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW | 1962 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW |
| 1963 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; | 1963 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; |
| 1964 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; | 1964 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; |
| 1965 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; | 1965 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; |
| 1966 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW | 1966 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW |
| 1967 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1967 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 for (index = 1; index < tests[testIndex].fPointCount; ++index) { | 2035 for (index = 1; index < tests[testIndex].fPointCount; ++index) { |
| 2036 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex]
.fPoints[index].fY); | 2036 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex]
.fPoints[index].fY); |
| 2037 } | 2037 } |
| 2038 if (tests[testIndex].fClose) { | 2038 if (tests[testIndex].fClose) { |
| 2039 path.close(); | 2039 path.close(); |
| 2040 } | 2040 } |
| 2041 if (!rectFirst) { | 2041 if (!rectFirst) { |
| 2042 path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2042 path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 2043 } | 2043 } |
| 2044 REPORTER_ASSERT(reporter, | 2044 REPORTER_ASSERT(reporter, |
| 2045 tests[testIndex].fIsNestedRect == path.isNestedFillRects(NUL
L)); | 2045 tests[testIndex].fIsNestedRect == path.isNestedFillRects(nul
lptr)); |
| 2046 if (tests[testIndex].fIsNestedRect) { | 2046 if (tests[testIndex].fIsNestedRect) { |
| 2047 SkRect expected[2], computed[2]; | 2047 SkRect expected[2], computed[2]; |
| 2048 SkPathPriv::FirstDirection expectedDirs[2]; | 2048 SkPathPriv::FirstDirection expectedDirs[2]; |
| 2049 SkPath::Direction computedDirs[2]; | 2049 SkPath::Direction computedDirs[2]; |
| 2050 SkRect testBounds; | 2050 SkRect testBounds; |
| 2051 testBounds.set(tests[testIndex].fPoints, tests[testIndex].fPoint
Count); | 2051 testBounds.set(tests[testIndex].fPoints, tests[testIndex].fPoint
Count); |
| 2052 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); | 2052 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); |
| 2053 expected[1] = testBounds; | 2053 expected[1] = testBounds; |
| 2054 if (rectFirst) { | 2054 if (rectFirst) { |
| 2055 expectedDirs[0] = SkPathPriv::kCW_FirstDirection; | 2055 expectedDirs[0] = SkPathPriv::kCW_FirstDirection; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2072 } | 2072 } |
| 2073 path1.moveTo(r1[0].fX, r1[0].fY); | 2073 path1.moveTo(r1[0].fX, r1[0].fY); |
| 2074 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2074 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 2075 path1.lineTo(r1[index].fX, r1[index].fY); | 2075 path1.lineTo(r1[index].fX, r1[index].fY); |
| 2076 } | 2076 } |
| 2077 path1.close(); | 2077 path1.close(); |
| 2078 path1.lineTo(1, 0); | 2078 path1.lineTo(1, 0); |
| 2079 if (!rectFirst) { | 2079 if (!rectFirst) { |
| 2080 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2080 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 2081 } | 2081 } |
| 2082 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); | 2082 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr)); |
| 2083 | 2083 |
| 2084 // fail, move in the middle | 2084 // fail, move in the middle |
| 2085 path1.reset(); | 2085 path1.reset(); |
| 2086 if (rectFirst) { | 2086 if (rectFirst) { |
| 2087 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2087 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 2088 } | 2088 } |
| 2089 path1.moveTo(r1[0].fX, r1[0].fY); | 2089 path1.moveTo(r1[0].fX, r1[0].fY); |
| 2090 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2090 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 2091 if (index == 2) { | 2091 if (index == 2) { |
| 2092 path1.moveTo(1, .5f); | 2092 path1.moveTo(1, .5f); |
| 2093 } | 2093 } |
| 2094 path1.lineTo(r1[index].fX, r1[index].fY); | 2094 path1.lineTo(r1[index].fX, r1[index].fY); |
| 2095 } | 2095 } |
| 2096 path1.close(); | 2096 path1.close(); |
| 2097 if (!rectFirst) { | 2097 if (!rectFirst) { |
| 2098 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2098 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 2099 } | 2099 } |
| 2100 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); | 2100 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr)); |
| 2101 | 2101 |
| 2102 // fail, move on the edge | 2102 // fail, move on the edge |
| 2103 path1.reset(); | 2103 path1.reset(); |
| 2104 if (rectFirst) { | 2104 if (rectFirst) { |
| 2105 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2105 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 2106 } | 2106 } |
| 2107 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2107 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 2108 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); | 2108 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); |
| 2109 path1.lineTo(r1[index].fX, r1[index].fY); | 2109 path1.lineTo(r1[index].fX, r1[index].fY); |
| 2110 } | 2110 } |
| 2111 path1.close(); | 2111 path1.close(); |
| 2112 if (!rectFirst) { | 2112 if (!rectFirst) { |
| 2113 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2113 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 2114 } | 2114 } |
| 2115 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); | 2115 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr)); |
| 2116 | 2116 |
| 2117 // fail, quad | 2117 // fail, quad |
| 2118 path1.reset(); | 2118 path1.reset(); |
| 2119 if (rectFirst) { | 2119 if (rectFirst) { |
| 2120 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2120 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 2121 } | 2121 } |
| 2122 path1.moveTo(r1[0].fX, r1[0].fY); | 2122 path1.moveTo(r1[0].fX, r1[0].fY); |
| 2123 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2123 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 2124 if (index == 2) { | 2124 if (index == 2) { |
| 2125 path1.quadTo(1, .5f, 1, .5f); | 2125 path1.quadTo(1, .5f, 1, .5f); |
| 2126 } | 2126 } |
| 2127 path1.lineTo(r1[index].fX, r1[index].fY); | 2127 path1.lineTo(r1[index].fX, r1[index].fY); |
| 2128 } | 2128 } |
| 2129 path1.close(); | 2129 path1.close(); |
| 2130 if (!rectFirst) { | 2130 if (!rectFirst) { |
| 2131 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2131 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 2132 } | 2132 } |
| 2133 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); | 2133 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr)); |
| 2134 | 2134 |
| 2135 // fail, cubic | 2135 // fail, cubic |
| 2136 path1.reset(); | 2136 path1.reset(); |
| 2137 if (rectFirst) { | 2137 if (rectFirst) { |
| 2138 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2138 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 2139 } | 2139 } |
| 2140 path1.moveTo(r1[0].fX, r1[0].fY); | 2140 path1.moveTo(r1[0].fX, r1[0].fY); |
| 2141 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2141 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
| 2142 if (index == 2) { | 2142 if (index == 2) { |
| 2143 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); | 2143 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); |
| 2144 } | 2144 } |
| 2145 path1.lineTo(r1[index].fX, r1[index].fY); | 2145 path1.lineTo(r1[index].fX, r1[index].fY); |
| 2146 } | 2146 } |
| 2147 path1.close(); | 2147 path1.close(); |
| 2148 if (!rectFirst) { | 2148 if (!rectFirst) { |
| 2149 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2149 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 2150 } | 2150 } |
| 2151 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); | 2151 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr)); |
| 2152 | 2152 |
| 2153 // fail, not nested | 2153 // fail, not nested |
| 2154 path1.reset(); | 2154 path1.reset(); |
| 2155 path1.addRect(1, 1, 3, 3, SkPath::kCW_Direction); | 2155 path1.addRect(1, 1, 3, 3, SkPath::kCW_Direction); |
| 2156 path1.addRect(2, 2, 4, 4, SkPath::kCW_Direction); | 2156 path1.addRect(2, 2, 4, 4, SkPath::kCW_Direction); |
| 2157 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); | 2157 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(nullptr)); |
| 2158 } | 2158 } |
| 2159 | 2159 |
| 2160 // pass, constructed explicitly from manually closed rects specified as mov
es/lines. | 2160 // pass, constructed explicitly from manually closed rects specified as mov
es/lines. |
| 2161 SkPath path; | 2161 SkPath path; |
| 2162 path.moveTo(0, 0); | 2162 path.moveTo(0, 0); |
| 2163 path.lineTo(10, 0); | 2163 path.lineTo(10, 0); |
| 2164 path.lineTo(10, 10); | 2164 path.lineTo(10, 10); |
| 2165 path.lineTo(0, 10); | 2165 path.lineTo(0, 10); |
| 2166 path.lineTo(0, 0); | 2166 path.lineTo(0, 0); |
| 2167 path.moveTo(1, 1); | 2167 path.moveTo(1, 1); |
| 2168 path.lineTo(9, 1); | 2168 path.lineTo(9, 1); |
| 2169 path.lineTo(9, 9); | 2169 path.lineTo(9, 9); |
| 2170 path.lineTo(1, 9); | 2170 path.lineTo(1, 9); |
| 2171 path.lineTo(1, 1); | 2171 path.lineTo(1, 1); |
| 2172 REPORTER_ASSERT(reporter, path.isNestedFillRects(NULL)); | 2172 REPORTER_ASSERT(reporter, path.isNestedFillRects(nullptr)); |
| 2173 | 2173 |
| 2174 // pass, stroke rect | 2174 // pass, stroke rect |
| 2175 SkPath src, dst; | 2175 SkPath src, dst; |
| 2176 src.addRect(1, 1, 7, 7, SkPath::kCW_Direction); | 2176 src.addRect(1, 1, 7, 7, SkPath::kCW_Direction); |
| 2177 SkPaint strokePaint; | 2177 SkPaint strokePaint; |
| 2178 strokePaint.setStyle(SkPaint::kStroke_Style); | 2178 strokePaint.setStyle(SkPaint::kStroke_Style); |
| 2179 strokePaint.setStrokeWidth(2); | 2179 strokePaint.setStrokeWidth(2); |
| 2180 strokePaint.getFillPath(src, &dst); | 2180 strokePaint.getFillPath(src, &dst); |
| 2181 REPORTER_ASSERT(reporter, dst.isNestedFillRects(NULL)); | 2181 REPORTER_ASSERT(reporter, dst.isNestedFillRects(nullptr)); |
| 2182 } | 2182 } |
| 2183 | 2183 |
| 2184 static void write_and_read_back(skiatest::Reporter* reporter, | 2184 static void write_and_read_back(skiatest::Reporter* reporter, |
| 2185 const SkPath& p) { | 2185 const SkPath& p) { |
| 2186 SkWriter32 writer; | 2186 SkWriter32 writer; |
| 2187 writer.writePath(p); | 2187 writer.writePath(p); |
| 2188 size_t size = writer.bytesWritten(); | 2188 size_t size = writer.bytesWritten(); |
| 2189 SkAutoMalloc storage(size); | 2189 SkAutoMalloc storage(size); |
| 2190 writer.flatten(storage.get()); | 2190 writer.flatten(storage.get()); |
| 2191 SkReader32 reader(storage.get(), size); | 2191 SkReader32 reader(storage.get(), size); |
| 2192 | 2192 |
| 2193 SkPath readBack; | 2193 SkPath readBack; |
| 2194 REPORTER_ASSERT(reporter, readBack != p); | 2194 REPORTER_ASSERT(reporter, readBack != p); |
| 2195 reader.readPath(&readBack); | 2195 reader.readPath(&readBack); |
| 2196 REPORTER_ASSERT(reporter, readBack == p); | 2196 REPORTER_ASSERT(reporter, readBack == p); |
| 2197 | 2197 |
| 2198 REPORTER_ASSERT(reporter, readBack.getConvexityOrUnknown() == | 2198 REPORTER_ASSERT(reporter, readBack.getConvexityOrUnknown() == |
| 2199 p.getConvexityOrUnknown()); | 2199 p.getConvexityOrUnknown()); |
| 2200 | 2200 |
| 2201 REPORTER_ASSERT(reporter, readBack.isOval(NULL) == p.isOval(NULL)); | 2201 REPORTER_ASSERT(reporter, readBack.isOval(nullptr) == p.isOval(nullptr)); |
| 2202 | 2202 |
| 2203 const SkRect& origBounds = p.getBounds(); | 2203 const SkRect& origBounds = p.getBounds(); |
| 2204 const SkRect& readBackBounds = readBack.getBounds(); | 2204 const SkRect& readBackBounds = readBack.getBounds(); |
| 2205 | 2205 |
| 2206 REPORTER_ASSERT(reporter, origBounds == readBackBounds); | 2206 REPORTER_ASSERT(reporter, origBounds == readBackBounds); |
| 2207 } | 2207 } |
| 2208 | 2208 |
| 2209 static void test_flattening(skiatest::Reporter* reporter) { | 2209 static void test_flattening(skiatest::Reporter* reporter) { |
| 2210 SkPath p; | 2210 SkPath p; |
| 2211 | 2211 |
| 2212 static const SkPoint pts[] = { | 2212 static const SkPoint pts[] = { |
| 2213 { 0, 0 }, | 2213 { 0, 0 }, |
| 2214 { SkIntToScalar(10), SkIntToScalar(10) }, | 2214 { SkIntToScalar(10), SkIntToScalar(10) }, |
| 2215 { SkIntToScalar(20), SkIntToScalar(10) }, { SkIntToScalar(20), 0 }, | 2215 { SkIntToScalar(20), SkIntToScalar(10) }, { SkIntToScalar(20), 0 }, |
| 2216 { 0, 0 }, { 0, SkIntToScalar(10) }, { SkIntToScalar(1), SkIntToScalar(10
) } | 2216 { 0, 0 }, { 0, SkIntToScalar(10) }, { SkIntToScalar(1), SkIntToScalar(10
) } |
| 2217 }; | 2217 }; |
| 2218 p.moveTo(pts[0]); | 2218 p.moveTo(pts[0]); |
| 2219 p.lineTo(pts[1]); | 2219 p.lineTo(pts[1]); |
| 2220 p.quadTo(pts[2], pts[3]); | 2220 p.quadTo(pts[2], pts[3]); |
| 2221 p.cubicTo(pts[4], pts[5], pts[6]); | 2221 p.cubicTo(pts[4], pts[5], pts[6]); |
| 2222 | 2222 |
| 2223 write_and_read_back(reporter, p); | 2223 write_and_read_back(reporter, p); |
| 2224 | 2224 |
| 2225 // create a buffer that should be much larger than the path so we don't | 2225 // create a buffer that should be much larger than the path so we don't |
| 2226 // kill our stack if writer goes too far. | 2226 // kill our stack if writer goes too far. |
| 2227 char buffer[1024]; | 2227 char buffer[1024]; |
| 2228 size_t size1 = p.writeToMemory(NULL); | 2228 size_t size1 = p.writeToMemory(nullptr); |
| 2229 size_t size2 = p.writeToMemory(buffer); | 2229 size_t size2 = p.writeToMemory(buffer); |
| 2230 REPORTER_ASSERT(reporter, size1 == size2); | 2230 REPORTER_ASSERT(reporter, size1 == size2); |
| 2231 | 2231 |
| 2232 SkPath p2; | 2232 SkPath p2; |
| 2233 size_t size3 = p2.readFromMemory(buffer, 1024); | 2233 size_t size3 = p2.readFromMemory(buffer, 1024); |
| 2234 REPORTER_ASSERT(reporter, size1 == size3); | 2234 REPORTER_ASSERT(reporter, size1 == size3); |
| 2235 REPORTER_ASSERT(reporter, p == p2); | 2235 REPORTER_ASSERT(reporter, p == p2); |
| 2236 | 2236 |
| 2237 size3 = p2.readFromMemory(buffer, 0); | 2237 size3 = p2.readFromMemory(buffer, 0); |
| 2238 REPORTER_ASSERT(reporter, !size3); | 2238 REPORTER_ASSERT(reporter, !size3); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 { | 2308 { |
| 2309 SkMatrix matrix; | 2309 SkMatrix matrix; |
| 2310 matrix.reset(); | 2310 matrix.reset(); |
| 2311 matrix.setPerspX(4); | 2311 matrix.setPerspX(4); |
| 2312 | 2312 |
| 2313 SkPath p1; | 2313 SkPath p1; |
| 2314 p1.moveTo(SkPoint::Make(0, 0)); | 2314 p1.moveTo(SkPoint::Make(0, 0)); |
| 2315 | 2315 |
| 2316 p.transform(matrix, &p1); | 2316 p.transform(matrix, &p1); |
| 2317 REPORTER_ASSERT(reporter, matrix.invert(&matrix)); | 2317 REPORTER_ASSERT(reporter, matrix.invert(&matrix)); |
| 2318 p1.transform(matrix, NULL); | 2318 p1.transform(matrix, nullptr); |
| 2319 SkRect pBounds = p.getBounds(); | 2319 SkRect pBounds = p.getBounds(); |
| 2320 SkRect p1Bounds = p1.getBounds(); | 2320 SkRect p1Bounds = p1.getBounds(); |
| 2321 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fLeft, p1Bounds.fL
eft)); | 2321 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fLeft, p1Bounds.fL
eft)); |
| 2322 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fTop, p1Bounds.fTo
p)); | 2322 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fTop, p1Bounds.fTo
p)); |
| 2323 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fRight, p1Bounds.f
Right)); | 2323 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fRight, p1Bounds.f
Right)); |
| 2324 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fBottom, p1Bounds.
fBottom)); | 2324 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fBottom, p1Bounds.
fBottom)); |
| 2325 } | 2325 } |
| 2326 | 2326 |
| 2327 p.reset(); | 2327 p.reset(); |
| 2328 p.addCircle(0, 0, 1, SkPath::kCW_Direction); | 2328 p.addCircle(0, 0, 1, SkPath::kCW_Direction); |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3082 } | 3082 } |
| 3083 | 3083 |
| 3084 static void test_oval(skiatest::Reporter* reporter) { | 3084 static void test_oval(skiatest::Reporter* reporter) { |
| 3085 SkRect rect; | 3085 SkRect rect; |
| 3086 SkMatrix m; | 3086 SkMatrix m; |
| 3087 SkPath path; | 3087 SkPath path; |
| 3088 | 3088 |
| 3089 rect = SkRect::MakeWH(SkIntToScalar(30), SkIntToScalar(50)); | 3089 rect = SkRect::MakeWH(SkIntToScalar(30), SkIntToScalar(50)); |
| 3090 path.addOval(rect); | 3090 path.addOval(rect); |
| 3091 | 3091 |
| 3092 REPORTER_ASSERT(reporter, path.isOval(NULL)); | 3092 REPORTER_ASSERT(reporter, path.isOval(nullptr)); |
| 3093 | 3093 |
| 3094 m.setRotate(SkIntToScalar(90)); | 3094 m.setRotate(SkIntToScalar(90)); |
| 3095 SkPath tmp; | 3095 SkPath tmp; |
| 3096 path.transform(m, &tmp); | 3096 path.transform(m, &tmp); |
| 3097 // an oval rotated 90 degrees is still an oval. | 3097 // an oval rotated 90 degrees is still an oval. |
| 3098 REPORTER_ASSERT(reporter, tmp.isOval(NULL)); | 3098 REPORTER_ASSERT(reporter, tmp.isOval(nullptr)); |
| 3099 | 3099 |
| 3100 m.reset(); | 3100 m.reset(); |
| 3101 m.setRotate(SkIntToScalar(30)); | 3101 m.setRotate(SkIntToScalar(30)); |
| 3102 tmp.reset(); | 3102 tmp.reset(); |
| 3103 path.transform(m, &tmp); | 3103 path.transform(m, &tmp); |
| 3104 // an oval rotated 30 degrees is not an oval anymore. | 3104 // an oval rotated 30 degrees is not an oval anymore. |
| 3105 REPORTER_ASSERT(reporter, !tmp.isOval(NULL)); | 3105 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr)); |
| 3106 | 3106 |
| 3107 // since empty path being transformed. | 3107 // since empty path being transformed. |
| 3108 path.reset(); | 3108 path.reset(); |
| 3109 tmp.reset(); | 3109 tmp.reset(); |
| 3110 m.reset(); | 3110 m.reset(); |
| 3111 path.transform(m, &tmp); | 3111 path.transform(m, &tmp); |
| 3112 REPORTER_ASSERT(reporter, !tmp.isOval(NULL)); | 3112 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr)); |
| 3113 | 3113 |
| 3114 // empty path is not an oval | 3114 // empty path is not an oval |
| 3115 tmp.reset(); | 3115 tmp.reset(); |
| 3116 REPORTER_ASSERT(reporter, !tmp.isOval(NULL)); | 3116 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr)); |
| 3117 | 3117 |
| 3118 // only has moveTo()s | 3118 // only has moveTo()s |
| 3119 tmp.reset(); | 3119 tmp.reset(); |
| 3120 tmp.moveTo(0, 0); | 3120 tmp.moveTo(0, 0); |
| 3121 tmp.moveTo(SkIntToScalar(10), SkIntToScalar(10)); | 3121 tmp.moveTo(SkIntToScalar(10), SkIntToScalar(10)); |
| 3122 REPORTER_ASSERT(reporter, !tmp.isOval(NULL)); | 3122 REPORTER_ASSERT(reporter, !tmp.isOval(nullptr)); |
| 3123 | 3123 |
| 3124 // mimic WebKit's calling convention, | 3124 // mimic WebKit's calling convention, |
| 3125 // call moveTo() first and then call addOval() | 3125 // call moveTo() first and then call addOval() |
| 3126 path.reset(); | 3126 path.reset(); |
| 3127 path.moveTo(0, 0); | 3127 path.moveTo(0, 0); |
| 3128 path.addOval(rect); | 3128 path.addOval(rect); |
| 3129 REPORTER_ASSERT(reporter, path.isOval(NULL)); | 3129 REPORTER_ASSERT(reporter, path.isOval(nullptr)); |
| 3130 | 3130 |
| 3131 // copy path | 3131 // copy path |
| 3132 path.reset(); | 3132 path.reset(); |
| 3133 tmp.reset(); | 3133 tmp.reset(); |
| 3134 tmp.addOval(rect); | 3134 tmp.addOval(rect); |
| 3135 path = tmp; | 3135 path = tmp; |
| 3136 REPORTER_ASSERT(reporter, path.isOval(NULL)); | 3136 REPORTER_ASSERT(reporter, path.isOval(nullptr)); |
| 3137 } | 3137 } |
| 3138 | 3138 |
| 3139 static void test_empty(skiatest::Reporter* reporter, const SkPath& p) { | 3139 static void test_empty(skiatest::Reporter* reporter, const SkPath& p) { |
| 3140 SkPath empty; | 3140 SkPath empty; |
| 3141 | 3141 |
| 3142 REPORTER_ASSERT(reporter, p.isEmpty()); | 3142 REPORTER_ASSERT(reporter, p.isEmpty()); |
| 3143 REPORTER_ASSERT(reporter, 0 == p.countPoints()); | 3143 REPORTER_ASSERT(reporter, 0 == p.countPoints()); |
| 3144 REPORTER_ASSERT(reporter, 0 == p.countVerbs()); | 3144 REPORTER_ASSERT(reporter, 0 == p.countVerbs()); |
| 3145 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); | 3145 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); |
| 3146 REPORTER_ASSERT(reporter, p.isConvex()); | 3146 REPORTER_ASSERT(reporter, p.isConvex()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 p.addRoundRect(r, 0, 0); | 3197 p.addRoundRect(r, 0, 0); |
| 3198 SkRect returnedRect; | 3198 SkRect returnedRect; |
| 3199 REPORTER_ASSERT(reporter, p.isRect(&returnedRect)); | 3199 REPORTER_ASSERT(reporter, p.isRect(&returnedRect)); |
| 3200 REPORTER_ASSERT(reporter, returnedRect == r); | 3200 REPORTER_ASSERT(reporter, returnedRect == r); |
| 3201 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | 3201 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 3202 SkVector zeroRadii[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; | 3202 SkVector zeroRadii[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; |
| 3203 rr.setRectRadii(r, zeroRadii); | 3203 rr.setRectRadii(r, zeroRadii); |
| 3204 p.addRRect(rr); | 3204 p.addRRect(rr); |
| 3205 bool closed; | 3205 bool closed; |
| 3206 SkPath::Direction dir; | 3206 SkPath::Direction dir; |
| 3207 REPORTER_ASSERT(reporter, p.isRect(NULL, &closed, &dir)); | 3207 REPORTER_ASSERT(reporter, p.isRect(nullptr, &closed, &dir)); |
| 3208 REPORTER_ASSERT(reporter, closed); | 3208 REPORTER_ASSERT(reporter, closed); |
| 3209 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); | 3209 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); |
| 3210 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | 3210 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 3211 p.addRRect(rr, SkPath::kCW_Direction); | 3211 p.addRRect(rr, SkPath::kCW_Direction); |
| 3212 p.addRRect(rr, SkPath::kCW_Direction); | 3212 p.addRRect(rr, SkPath::kCW_Direction); |
| 3213 REPORTER_ASSERT(reporter, !p.isConvex()); | 3213 REPORTER_ASSERT(reporter, !p.isConvex()); |
| 3214 p.reset(); | 3214 p.reset(); |
| 3215 p.addRRect(rr, SkPath::kCCW_Direction); | 3215 p.addRRect(rr, SkPath::kCCW_Direction); |
| 3216 p.addRRect(rr, SkPath::kCCW_Direction); | 3216 p.addRRect(rr, SkPath::kCCW_Direction); |
| 3217 REPORTER_ASSERT(reporter, !p.isConvex()); | 3217 REPORTER_ASSERT(reporter, !p.isConvex()); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity); | 3487 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity); |
| 3488 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4); | 3488 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4); |
| 3489 p.conicTo(1, 2, 3, 4, 1); | 3489 p.conicTo(1, 2, 3, 4, 1); |
| 3490 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4); | 3490 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4); |
| 3491 } | 3491 } |
| 3492 | 3492 |
| 3493 static void test_get_point(skiatest::Reporter* reporter) { | 3493 static void test_get_point(skiatest::Reporter* reporter) { |
| 3494 SkPath p; | 3494 SkPath p; |
| 3495 SkPoint pt = p.getPoint(0); | 3495 SkPoint pt = p.getPoint(0); |
| 3496 REPORTER_ASSERT(reporter, pt == SkPoint::Make(0, 0)); | 3496 REPORTER_ASSERT(reporter, pt == SkPoint::Make(0, 0)); |
| 3497 REPORTER_ASSERT(reporter, !p.getLastPt(NULL)); | 3497 REPORTER_ASSERT(reporter, !p.getLastPt(nullptr)); |
| 3498 REPORTER_ASSERT(reporter, !p.getLastPt(&pt) && pt == SkPoint::Make(0, 0)); | 3498 REPORTER_ASSERT(reporter, !p.getLastPt(&pt) && pt == SkPoint::Make(0, 0)); |
| 3499 p.setLastPt(10, 10); | 3499 p.setLastPt(10, 10); |
| 3500 pt = p.getPoint(0); | 3500 pt = p.getPoint(0); |
| 3501 REPORTER_ASSERT(reporter, pt == SkPoint::Make(10, 10)); | 3501 REPORTER_ASSERT(reporter, pt == SkPoint::Make(10, 10)); |
| 3502 REPORTER_ASSERT(reporter, p.getLastPt(NULL)); | 3502 REPORTER_ASSERT(reporter, p.getLastPt(nullptr)); |
| 3503 p.rMoveTo(10, 10); | 3503 p.rMoveTo(10, 10); |
| 3504 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt == SkPoint::Make(20, 20)); | 3504 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt == SkPoint::Make(20, 20)); |
| 3505 } | 3505 } |
| 3506 | 3506 |
| 3507 static void test_contains(skiatest::Reporter* reporter) { | 3507 static void test_contains(skiatest::Reporter* reporter) { |
| 3508 SkPath p; | 3508 SkPath p; |
| 3509 p.setFillType(SkPath::kInverseWinding_FillType); | 3509 p.setFillType(SkPath::kInverseWinding_FillType); |
| 3510 REPORTER_ASSERT(reporter, p.contains(0, 0)); | 3510 REPORTER_ASSERT(reporter, p.contains(0, 0)); |
| 3511 p.setFillType(SkPath::kWinding_FillType); | 3511 p.setFillType(SkPath::kWinding_FillType); |
| 3512 REPORTER_ASSERT(reporter, !p.contains(0, 0)); | 3512 REPORTER_ASSERT(reporter, !p.contains(0, 0)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3608 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs()); | 3608 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs()); |
| 3609 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints()); | 3609 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints()); |
| 3610 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef->getS
egmentMasks()); | 3610 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef->getS
egmentMasks()); |
| 3611 for (int i = 0; i < kRepeatCnt; ++i) { | 3611 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3612 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef->atVerb(
i)); | 3612 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef->atVerb(
i)); |
| 3613 } | 3613 } |
| 3614 ed.resetToSize(0, 0, 0); | 3614 ed.resetToSize(0, 0, 0); |
| 3615 } | 3615 } |
| 3616 | 3616 |
| 3617 { | 3617 { |
| 3618 SkScalar* weights = NULL; | 3618 SkScalar* weights = nullptr; |
| 3619 ed.growForRepeatedVerb(SkPath::kConic_Verb, kRepeatCnt, &weights); | 3619 ed.growForRepeatedVerb(SkPath::kConic_Verb, kRepeatCnt, &weights); |
| 3620 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs()); | 3620 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs()); |
| 3621 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints()); | 3621 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef->countPoints()); |
| 3622 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countWeights()); | 3622 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countWeights()); |
| 3623 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef->get
SegmentMasks()); | 3623 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef->get
SegmentMasks()); |
| 3624 REPORTER_ASSERT(reporter, weights); | 3624 REPORTER_ASSERT(reporter, weights); |
| 3625 for (int i = 0; i < kRepeatCnt; ++i) { | 3625 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3626 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef->atVerb
(i)); | 3626 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef->atVerb
(i)); |
| 3627 } | 3627 } |
| 3628 ed.resetToSize(0, 0, 0); | 3628 ed.resetToSize(0, 0, 0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3664 | 3664 |
| 3665 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool
force, | 3665 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool
force, |
| 3666 bool dumpAsHex, const char* str) { | 3666 bool dumpAsHex, const char* str) { |
| 3667 SkDynamicMemoryWStream wStream; | 3667 SkDynamicMemoryWStream wStream; |
| 3668 path.dump(&wStream, force, dumpAsHex); | 3668 path.dump(&wStream, force, dumpAsHex); |
| 3669 SkAutoDataUnref data(wStream.copyToData()); | 3669 SkAutoDataUnref data(wStream.copyToData()); |
| 3670 REPORTER_ASSERT(reporter, data->size() == strlen(str)); | 3670 REPORTER_ASSERT(reporter, data->size() == strlen(str)); |
| 3671 if (strlen(str) > 0) { | 3671 if (strlen(str) > 0) { |
| 3672 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str))); | 3672 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str))); |
| 3673 } else { | 3673 } else { |
| 3674 REPORTER_ASSERT(reporter, data->data() == NULL || !memcmp(data->data(),
str, strlen(str))); | 3674 REPORTER_ASSERT(reporter, data->data() == nullptr || !memcmp(data->data(
), str, strlen(str))); |
| 3675 } | 3675 } |
| 3676 } | 3676 } |
| 3677 | 3677 |
| 3678 static void test_dump(skiatest::Reporter* reporter) { | 3678 static void test_dump(skiatest::Reporter* reporter) { |
| 3679 SkPath p; | 3679 SkPath p; |
| 3680 compare_dump(reporter, p, false, false, ""); | 3680 compare_dump(reporter, p, false, false, ""); |
| 3681 compare_dump(reporter, p, true, false, ""); | 3681 compare_dump(reporter, p, true, false, ""); |
| 3682 p.moveTo(1, 2); | 3682 p.moveTo(1, 2); |
| 3683 p.lineTo(3, 4); | 3683 p.lineTo(3, 4); |
| 3684 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" | 3684 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3835 p.addRect(bounds); | 3835 p.addRect(bounds); |
| 3836 check_convex_bounds(reporter, p, bounds); | 3836 check_convex_bounds(reporter, p, bounds); |
| 3837 // we have only lines | 3837 // we have only lines |
| 3838 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks()); | 3838 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == p.getSegmentMasks()); |
| 3839 REPORTER_ASSERT(reporter, !p.isEmpty()); | 3839 REPORTER_ASSERT(reporter, !p.isEmpty()); |
| 3840 | 3840 |
| 3841 REPORTER_ASSERT(reporter, p != empty); | 3841 REPORTER_ASSERT(reporter, p != empty); |
| 3842 REPORTER_ASSERT(reporter, !(p == empty)); | 3842 REPORTER_ASSERT(reporter, !(p == empty)); |
| 3843 | 3843 |
| 3844 // do getPoints and getVerbs return the right result | 3844 // do getPoints and getVerbs return the right result |
| 3845 REPORTER_ASSERT(reporter, p.getPoints(NULL, 0) == 4); | 3845 REPORTER_ASSERT(reporter, p.getPoints(nullptr, 0) == 4); |
| 3846 REPORTER_ASSERT(reporter, p.getVerbs(NULL, 0) == 5); | 3846 REPORTER_ASSERT(reporter, p.getVerbs(nullptr, 0) == 5); |
| 3847 SkPoint pts[4]; | 3847 SkPoint pts[4]; |
| 3848 int count = p.getPoints(pts, 4); | 3848 int count = p.getPoints(pts, 4); |
| 3849 REPORTER_ASSERT(reporter, count == 4); | 3849 REPORTER_ASSERT(reporter, count == 4); |
| 3850 uint8_t verbs[6]; | 3850 uint8_t verbs[6]; |
| 3851 verbs[5] = 0xff; | 3851 verbs[5] = 0xff; |
| 3852 p.getVerbs(verbs, 5); | 3852 p.getVerbs(verbs, 5); |
| 3853 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == verbs[0]); | 3853 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == verbs[0]); |
| 3854 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[1]); | 3854 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[1]); |
| 3855 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[2]); | 3855 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[2]); |
| 3856 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[3]); | 3856 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == verbs[3]); |
| 3857 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == verbs[4]); | 3857 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == verbs[4]); |
| 3858 REPORTER_ASSERT(reporter, 0xff == verbs[5]); | 3858 REPORTER_ASSERT(reporter, 0xff == verbs[5]); |
| 3859 bounds2.set(pts, 4); | 3859 bounds2.set(pts, 4); |
| 3860 REPORTER_ASSERT(reporter, bounds == bounds2); | 3860 REPORTER_ASSERT(reporter, bounds == bounds2); |
| 3861 | 3861 |
| 3862 bounds.offset(SK_Scalar1*3, SK_Scalar1*4); | 3862 bounds.offset(SK_Scalar1*3, SK_Scalar1*4); |
| 3863 p.offset(SK_Scalar1*3, SK_Scalar1*4); | 3863 p.offset(SK_Scalar1*3, SK_Scalar1*4); |
| 3864 REPORTER_ASSERT(reporter, bounds == p.getBounds()); | 3864 REPORTER_ASSERT(reporter, bounds == p.getBounds()); |
| 3865 | 3865 |
| 3866 REPORTER_ASSERT(reporter, p.isRect(NULL)); | 3866 REPORTER_ASSERT(reporter, p.isRect(nullptr)); |
| 3867 bounds2.setEmpty(); | 3867 bounds2.setEmpty(); |
| 3868 REPORTER_ASSERT(reporter, p.isRect(&bounds2)); | 3868 REPORTER_ASSERT(reporter, p.isRect(&bounds2)); |
| 3869 REPORTER_ASSERT(reporter, bounds == bounds2); | 3869 REPORTER_ASSERT(reporter, bounds == bounds2); |
| 3870 | 3870 |
| 3871 // now force p to not be a rect | 3871 // now force p to not be a rect |
| 3872 bounds.set(0, 0, SK_Scalar1/2, SK_Scalar1/2); | 3872 bounds.set(0, 0, SK_Scalar1/2, SK_Scalar1/2); |
| 3873 p.addRect(bounds); | 3873 p.addRect(bounds); |
| 3874 REPORTER_ASSERT(reporter, !p.isRect(NULL)); | 3874 REPORTER_ASSERT(reporter, !p.isRect(nullptr)); |
| 3875 | 3875 |
| 3876 // Test an edge case w.r.t. the bound returned by isRect (i.e., the | 3876 // Test an edge case w.r.t. the bound returned by isRect (i.e., the |
| 3877 // path has a trailing moveTo. Please see crbug.com\445368) | 3877 // path has a trailing moveTo. Please see crbug.com\445368) |
| 3878 { | 3878 { |
| 3879 SkRect r; | 3879 SkRect r; |
| 3880 p.reset(); | 3880 p.reset(); |
| 3881 p.addRect(bounds); | 3881 p.addRect(bounds); |
| 3882 REPORTER_ASSERT(reporter, p.isRect(&r)); | 3882 REPORTER_ASSERT(reporter, p.isRect(&r)); |
| 3883 REPORTER_ASSERT(reporter, r == bounds); | 3883 REPORTER_ASSERT(reporter, r == bounds); |
| 3884 // add a moveTo outside of our bounds | 3884 // add a moveTo outside of our bounds |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3940 PathTest_Private::TestPathTo(reporter); | 3940 PathTest_Private::TestPathTo(reporter); |
| 3941 PathRefTest_Private::TestPathRef(reporter); | 3941 PathRefTest_Private::TestPathRef(reporter); |
| 3942 PathTest_Private::TestPathrefListeners(reporter); | 3942 PathTest_Private::TestPathrefListeners(reporter); |
| 3943 test_dump(reporter); | 3943 test_dump(reporter); |
| 3944 test_path_crbug389050(reporter); | 3944 test_path_crbug389050(reporter); |
| 3945 test_path_crbugskia2820(reporter); | 3945 test_path_crbugskia2820(reporter); |
| 3946 test_skbug_3469(reporter); | 3946 test_skbug_3469(reporter); |
| 3947 test_skbug_3239(reporter); | 3947 test_skbug_3239(reporter); |
| 3948 test_bounds_crbug_513799(reporter); | 3948 test_bounds_crbug_513799(reporter); |
| 3949 } | 3949 } |
| OLD | NEW |