| 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 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(
0, 0, 1, 1))); | 1680 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(SkRect::MakeXYWH(
0, 0, 1, 1))); |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 static void test_isRect_open_close(skiatest::Reporter* reporter) { | 1683 static void test_isRect_open_close(skiatest::Reporter* reporter) { |
| 1684 SkPath path; | 1684 SkPath path; |
| 1685 bool isClosed; | 1685 bool isClosed; |
| 1686 | 1686 |
| 1687 path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(1, 1); path.lineTo(0, 1); | 1687 path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(1, 1); path.lineTo(0, 1); |
| 1688 path.close(); | 1688 path.close(); |
| 1689 | 1689 |
| 1690 REPORTER_ASSERT(reporter, path.isRect(NULL, NULL)); | 1690 REPORTER_ASSERT(reporter, path.isRect(NULL, &isClosed, NULL)); |
| 1691 REPORTER_ASSERT(reporter, path.isRect(&isClosed, NULL)); | |
| 1692 REPORTER_ASSERT(reporter, isClosed); | 1691 REPORTER_ASSERT(reporter, isClosed); |
| 1693 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asRect(NULL)); | 1692 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asRect(NULL)); |
| 1694 } | 1693 } |
| 1695 | 1694 |
| 1696 // Simple isRect test is inline TestPath, below. | 1695 // Simple isRect test is inline TestPath, below. |
| 1697 // test_isRect provides more extensive testing. | 1696 // test_isRect provides more extensive testing. |
| 1698 static void test_isRect(skiatest::Reporter* reporter) { | 1697 static void test_isRect(skiatest::Reporter* reporter) { |
| 1699 test_isRect_open_close(reporter); | 1698 test_isRect_open_close(reporter); |
| 1700 | 1699 |
| 1701 // passing tests (all moveTo / lineTo... | 1700 // passing tests (all moveTo / lineTo... |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { | 1786 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { |
| 1788 SkPath path; | 1787 SkPath path; |
| 1789 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints[0].
fY); | 1788 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints[0].
fY); |
| 1790 for (index = 1; index < tests[testIndex].fPointCount; ++index) { | 1789 for (index = 1; index < tests[testIndex].fPointCount; ++index) { |
| 1791 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex].fPo
ints[index].fY); | 1790 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex].fPo
ints[index].fY); |
| 1792 } | 1791 } |
| 1793 if (tests[testIndex].fClose) { | 1792 if (tests[testIndex].fClose) { |
| 1794 path.close(); | 1793 path.close(); |
| 1795 } | 1794 } |
| 1796 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(NULL))
; | 1795 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(NULL))
; |
| 1797 REPORTER_ASSERT(reporter, tests[testIndex].fIsRect == path.isRect(NULL,
NULL)); | |
| 1798 | 1796 |
| 1799 if (tests[testIndex].fIsRect) { | 1797 if (tests[testIndex].fIsRect) { |
| 1800 SkRect computed, expected; | 1798 SkRect computed, expected; |
| 1801 expected.set(tests[testIndex].fPoints, tests[testIndex].fPointCount)
; | |
| 1802 REPORTER_ASSERT(reporter, path.isRect(&computed)); | |
| 1803 REPORTER_ASSERT(reporter, expected == computed); | |
| 1804 | |
| 1805 bool isClosed; | 1799 bool isClosed; |
| 1806 SkPath::Direction direction, cheapDirection; | 1800 SkPath::Direction direction, cheapDirection; |
| 1801 expected.set(tests[testIndex].fPoints, tests[testIndex].fPointCount)
; |
| 1807 REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection
)); | 1802 REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection
)); |
| 1808 REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction)); | 1803 REPORTER_ASSERT(reporter, path.isRect(&computed, &isClosed, &directi
on)); |
| 1804 REPORTER_ASSERT(reporter, expected == computed); |
| 1809 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose); | 1805 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose); |
| 1810 REPORTER_ASSERT(reporter, direction == cheapDirection); | 1806 REPORTER_ASSERT(reporter, direction == cheapDirection); |
| 1811 direction = (SkPath::Direction) -1; | 1807 direction = (SkPath::Direction) -1; |
| 1812 if (!tests[testIndex].fClose) { | 1808 if (!tests[testIndex].fClose) { |
| 1813 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec
t()); | 1809 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec
t()); |
| 1814 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec
t(&direction)); | 1810 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec
t(&direction)); |
| 1815 } else { | 1811 } else { |
| 1816 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR
ect()); | 1812 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR
ect()); |
| 1817 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR
ect(&direction)); | 1813 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR
ect(&direction)); |
| 1818 } | 1814 } |
| 1819 REPORTER_ASSERT(reporter, direction == cheapDirection); | 1815 REPORTER_ASSERT(reporter, direction == cheapDirection); |
| 1820 } else { | 1816 } else { |
| 1821 SkRect computed; | 1817 SkRect computed; |
| 1822 computed.set(123, 456, 789, 1011); | 1818 computed.set(123, 456, 789, 1011); |
| 1823 REPORTER_ASSERT(reporter, !path.isRect(&computed)); | 1819 bool isClosed = (bool)-1; |
| 1820 SkPath::Direction direction = (SkPath::Direction) - 1; |
| 1821 REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direct
ion)); |
| 1824 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop ==
456); | 1822 REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop ==
456); |
| 1825 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom
== 1011); | 1823 REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom
== 1011); |
| 1826 | |
| 1827 bool isClosed = (bool) -1; | |
| 1828 SkPath::Direction direction = (SkPath::Direction) -1; | |
| 1829 REPORTER_ASSERT(reporter, !path.isRect(&isClosed, &direction)); | |
| 1830 REPORTER_ASSERT(reporter, isClosed == (bool) -1); | 1824 REPORTER_ASSERT(reporter, isClosed == (bool) -1); |
| 1831 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1); | 1825 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1); |
| 1832 REPORTER_ASSERT(reporter, SkPath::kNone_PathAsRect == path.asRect())
; | 1826 REPORTER_ASSERT(reporter, SkPath::kNone_PathAsRect == path.asRect())
; |
| 1833 REPORTER_ASSERT(reporter, SkPath::kNone_PathAsRect == path.asRect(&d
irection)); | 1827 REPORTER_ASSERT(reporter, SkPath::kNone_PathAsRect == path.asRect(&d
irection)); |
| 1834 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1); | 1828 REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1); |
| 1835 } | 1829 } |
| 1836 } | 1830 } |
| 1837 | 1831 |
| 1838 // fail, close then line | 1832 // fail, close then line |
| 1839 SkPath path1; | 1833 SkPath path1; |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3105 p.addRoundRect(r, 0, 0); | 3099 p.addRoundRect(r, 0, 0); |
| 3106 SkRect returnedRect; | 3100 SkRect returnedRect; |
| 3107 REPORTER_ASSERT(reporter, p.isRect(&returnedRect)); | 3101 REPORTER_ASSERT(reporter, p.isRect(&returnedRect)); |
| 3108 REPORTER_ASSERT(reporter, returnedRect == r); | 3102 REPORTER_ASSERT(reporter, returnedRect == r); |
| 3109 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | 3103 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 3110 SkVector zeroRadii[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; | 3104 SkVector zeroRadii[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; |
| 3111 rr.setRectRadii(r, zeroRadii); | 3105 rr.setRectRadii(r, zeroRadii); |
| 3112 p.addRRect(rr); | 3106 p.addRRect(rr); |
| 3113 bool closed; | 3107 bool closed; |
| 3114 SkPath::Direction dir; | 3108 SkPath::Direction dir; |
| 3115 REPORTER_ASSERT(reporter, p.isRect(&closed, &dir)); | 3109 REPORTER_ASSERT(reporter, p.isRect(NULL, &closed, &dir)); |
| 3116 REPORTER_ASSERT(reporter, closed); | 3110 REPORTER_ASSERT(reporter, closed); |
| 3117 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); | 3111 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); |
| 3118 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | 3112 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 3119 p.addRRect(rr, SkPath::kCW_Direction); | 3113 p.addRRect(rr, SkPath::kCW_Direction); |
| 3120 p.addRRect(rr, SkPath::kCW_Direction); | 3114 p.addRRect(rr, SkPath::kCW_Direction); |
| 3121 REPORTER_ASSERT(reporter, !p.isConvex()); | 3115 REPORTER_ASSERT(reporter, !p.isConvex()); |
| 3122 p.reset(); | 3116 p.reset(); |
| 3123 p.addRRect(rr, SkPath::kCCW_Direction); | 3117 p.addRRect(rr, SkPath::kCCW_Direction); |
| 3124 p.addRRect(rr, SkPath::kCCW_Direction); | 3118 p.addRRect(rr, SkPath::kCCW_Direction); |
| 3125 REPORTER_ASSERT(reporter, !p.isConvex()); | 3119 REPORTER_ASSERT(reporter, !p.isConvex()); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3774 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); | 3768 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); |
| 3775 test_conicTo_special_case(reporter); | 3769 test_conicTo_special_case(reporter); |
| 3776 test_get_point(reporter); | 3770 test_get_point(reporter); |
| 3777 test_contains(reporter); | 3771 test_contains(reporter); |
| 3778 PathTest_Private::TestPathTo(reporter); | 3772 PathTest_Private::TestPathTo(reporter); |
| 3779 PathRefTest_Private::TestPathRef(reporter); | 3773 PathRefTest_Private::TestPathRef(reporter); |
| 3780 test_dump(reporter); | 3774 test_dump(reporter); |
| 3781 test_path_crbugskia2820(reporter); | 3775 test_path_crbugskia2820(reporter); |
| 3782 test_skbug_3239(reporter); | 3776 test_skbug_3239(reporter); |
| 3783 } | 3777 } |
| OLD | NEW |