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 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1850 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
1851 if (index == 2) { | 1851 if (index == 2) { |
1852 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); | 1852 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); |
1853 } | 1853 } |
1854 path1.lineTo(r1[index].fX, r1[index].fY); | 1854 path1.lineTo(r1[index].fX, r1[index].fY); |
1855 } | 1855 } |
1856 path1.close(); | 1856 path1.close(); |
1857 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1857 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); |
1858 } | 1858 } |
1859 | 1859 |
1860 static void test_isNestedRects(skiatest::Reporter* reporter) { | 1860 static void test_isNestedFillRects(skiatest::Reporter* reporter) { |
1861 // passing tests (all moveTo / lineTo... | 1861 // passing tests (all moveTo / lineTo... |
1862 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW | 1862 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW |
1863 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; | 1863 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; |
1864 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; | 1864 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; |
1865 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; | 1865 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; |
1866 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW | 1866 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW |
1867 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1867 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
1868 SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}}; | 1868 SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}}; |
1869 SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}}; | 1869 SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}}; |
1870 SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1870 SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
1871 SkPoint ra[] = {{0, 0}, {0, .5f}, {0, 1}, {.5f, 1}, {1, 1}, {1, .5f}, {1, 0}
, {.5f, 0}}; // CCW | 1871 SkPoint ra[] = {{0, 0}, {0, .5f}, {0, 1}, {.5f, 1}, {1, 1}, {1, .5f}, {1, 0}
, {.5f, 0}}; // CCW |
1872 SkPoint rb[] = {{0, 0}, {.5f, 0}, {1, 0}, {1, .5f}, {1, 1}, {.5f, 1}, {0, 1}
, {0, .5f}}; // CW | 1872 SkPoint rb[] = {{0, 0}, {.5f, 0}, {1, 0}, {1, .5f}, {1, 1}, {.5f, 1}, {0, 1}
, {0, .5f}}; // CW |
1873 SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; // CW | 1873 SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; // CW |
1874 SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; // CCW | 1874 SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; // CCW |
1875 SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW | 1875 SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW |
1876 | 1876 |
1877 // failing tests | 1877 // failing tests |
1878 SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points | 1878 SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points |
1879 SkPoint f2[] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}}; // diagonal | 1879 SkPoint f2[] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}}; // diagonal |
1880 SkPoint f3[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}; // wraps | 1880 SkPoint f3[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}; // wraps |
1881 SkPoint f4[] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {1, 1}, {0, 1}}; // backs up | 1881 SkPoint f4[] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {1, 1}, {0, 1}}; // backs up |
1882 SkPoint f5[] = {{0, 0}, {1, 0}, {1, 1}, {2, 0}}; // end overshoots | 1882 SkPoint f5[] = {{0, 0}, {1, 0}, {1, 1}, {2, 0}}; // end overshoots |
1883 SkPoint f6[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 2}}; // end overshoots | 1883 SkPoint f6[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 2}}; // end overshoots |
1884 SkPoint f7[] = {{0, 0}, {1, 0}, {1, 1}, {0, 2}}; // end overshoots | 1884 SkPoint f7[] = {{0, 0}, {1, 0}, {1, 1}, {0, 2}}; // end overshoots |
1885 SkPoint f8[] = {{0, 0}, {1, 0}, {1, 1}, {1, 0}}; // 'L' | 1885 SkPoint f8[] = {{0, 0}, {1, 0}, {1, 1}, {1, 0}}; // 'L' |
1886 | 1886 |
1887 // failing, no close | 1887 // success, no close is OK |
1888 SkPoint c1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // close doesn't match | 1888 SkPoint c1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // close doesn't match |
1889 SkPoint c2[] = {{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 1}}; // ditto | 1889 SkPoint c2[] = {{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 1}}; // ditto |
1890 | 1890 |
1891 struct IsNestedRectTest { | 1891 struct IsNestedRectTest { |
1892 SkPoint *fPoints; | 1892 SkPoint *fPoints; |
1893 int fPointCount; | 1893 int fPointCount; |
1894 SkPath::Direction fDirection; | 1894 SkPath::Direction fDirection; |
1895 bool fClose; | 1895 bool fClose; |
1896 bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2); | 1896 bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2); |
1897 } tests[] = { | 1897 } tests[] = { |
(...skipping 14 matching lines...) Expand all Loading... |
1912 | 1912 |
1913 { f1, SK_ARRAY_COUNT(f1), SkPath::kUnknown_Direction, true, false }, | 1913 { f1, SK_ARRAY_COUNT(f1), SkPath::kUnknown_Direction, true, false }, |
1914 { f2, SK_ARRAY_COUNT(f2), SkPath::kUnknown_Direction, true, false }, | 1914 { f2, SK_ARRAY_COUNT(f2), SkPath::kUnknown_Direction, true, false }, |
1915 { f3, SK_ARRAY_COUNT(f3), SkPath::kUnknown_Direction, true, false }, | 1915 { f3, SK_ARRAY_COUNT(f3), SkPath::kUnknown_Direction, true, false }, |
1916 { f4, SK_ARRAY_COUNT(f4), SkPath::kUnknown_Direction, true, false }, | 1916 { f4, SK_ARRAY_COUNT(f4), SkPath::kUnknown_Direction, true, false }, |
1917 { f5, SK_ARRAY_COUNT(f5), SkPath::kUnknown_Direction, true, false }, | 1917 { f5, SK_ARRAY_COUNT(f5), SkPath::kUnknown_Direction, true, false }, |
1918 { f6, SK_ARRAY_COUNT(f6), SkPath::kUnknown_Direction, true, false }, | 1918 { f6, SK_ARRAY_COUNT(f6), SkPath::kUnknown_Direction, true, false }, |
1919 { f7, SK_ARRAY_COUNT(f7), SkPath::kUnknown_Direction, true, false }, | 1919 { f7, SK_ARRAY_COUNT(f7), SkPath::kUnknown_Direction, true, false }, |
1920 { f8, SK_ARRAY_COUNT(f8), SkPath::kUnknown_Direction, true, false }, | 1920 { f8, SK_ARRAY_COUNT(f8), SkPath::kUnknown_Direction, true, false }, |
1921 | 1921 |
1922 { c1, SK_ARRAY_COUNT(c1), SkPath::kUnknown_Direction, false, false }, | 1922 { c1, SK_ARRAY_COUNT(c1), SkPath::kCW_Direction, false, true }, |
1923 { c2, SK_ARRAY_COUNT(c2), SkPath::kUnknown_Direction, false, false }, | 1923 { c2, SK_ARRAY_COUNT(c2), SkPath::kCW_Direction, false, true }, |
1924 }; | 1924 }; |
1925 | 1925 |
1926 const size_t testCount = SK_ARRAY_COUNT(tests); | 1926 const size_t testCount = SK_ARRAY_COUNT(tests); |
1927 int index; | 1927 int index; |
1928 for (int rectFirst = 0; rectFirst <= 1; ++rectFirst) { | 1928 for (int rectFirst = 0; rectFirst <= 1; ++rectFirst) { |
1929 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { | 1929 for (size_t testIndex = 0; testIndex < testCount; ++testIndex) { |
1930 SkPath path; | 1930 SkPath path; |
1931 if (rectFirst) { | 1931 if (rectFirst) { |
1932 path.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 1932 path.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
1933 } | 1933 } |
1934 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints
[0].fY); | 1934 path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints
[0].fY); |
1935 for (index = 1; index < tests[testIndex].fPointCount; ++index) { | 1935 for (index = 1; index < tests[testIndex].fPointCount; ++index) { |
1936 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex]
.fPoints[index].fY); | 1936 path.lineTo(tests[testIndex].fPoints[index].fX, tests[testIndex]
.fPoints[index].fY); |
1937 } | 1937 } |
1938 if (tests[testIndex].fClose) { | 1938 if (tests[testIndex].fClose) { |
1939 path.close(); | 1939 path.close(); |
1940 } | 1940 } |
1941 if (!rectFirst) { | 1941 if (!rectFirst) { |
1942 path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 1942 path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
1943 } | 1943 } |
1944 REPORTER_ASSERT(reporter, tests[testIndex].fIsNestedRect == path.isN
estedRects(NULL)); | 1944 REPORTER_ASSERT(reporter, |
| 1945 tests[testIndex].fIsNestedRect == path.isNestedFillRects(NUL
L)); |
1945 if (tests[testIndex].fIsNestedRect) { | 1946 if (tests[testIndex].fIsNestedRect) { |
1946 SkRect expected[2], computed[2]; | 1947 SkRect expected[2], computed[2]; |
1947 SkPath::Direction expectedDirs[2], computedDirs[2]; | 1948 SkPath::Direction expectedDirs[2], computedDirs[2]; |
1948 SkRect testBounds; | 1949 SkRect testBounds; |
1949 testBounds.set(tests[testIndex].fPoints, tests[testIndex].fPoint
Count); | 1950 testBounds.set(tests[testIndex].fPoints, tests[testIndex].fPoint
Count); |
1950 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); | 1951 expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); |
1951 expected[1] = testBounds; | 1952 expected[1] = testBounds; |
1952 if (rectFirst) { | 1953 if (rectFirst) { |
1953 expectedDirs[0] = SkPath::kCW_Direction; | 1954 expectedDirs[0] = SkPath::kCW_Direction; |
1954 } else { | 1955 } else { |
1955 expectedDirs[0] = SkPath::kCCW_Direction; | 1956 expectedDirs[0] = SkPath::kCCW_Direction; |
1956 } | 1957 } |
1957 expectedDirs[1] = tests[testIndex].fDirection; | 1958 expectedDirs[1] = tests[testIndex].fDirection; |
1958 REPORTER_ASSERT(reporter, path.isNestedRects(computed, computedD
irs)); | 1959 REPORTER_ASSERT(reporter, path.isNestedFillRects(computed, compu
tedDirs)); |
1959 REPORTER_ASSERT(reporter, expected[0] == computed[0]); | 1960 REPORTER_ASSERT(reporter, expected[0] == computed[0]); |
1960 REPORTER_ASSERT(reporter, expected[1] == computed[1]); | 1961 REPORTER_ASSERT(reporter, expected[1] == computed[1]); |
1961 REPORTER_ASSERT(reporter, expectedDirs[0] == computedDirs[0]); | 1962 REPORTER_ASSERT(reporter, expectedDirs[0] == computedDirs[0]); |
1962 REPORTER_ASSERT(reporter, expectedDirs[1] == computedDirs[1]); | 1963 REPORTER_ASSERT(reporter, expectedDirs[1] == computedDirs[1]); |
1963 } | 1964 } |
1964 } | 1965 } |
1965 | 1966 |
1966 // fail, close then line | 1967 // fail, close then line |
1967 SkPath path1; | 1968 SkPath path1; |
1968 if (rectFirst) { | 1969 if (rectFirst) { |
1969 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 1970 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
1970 } | 1971 } |
1971 path1.moveTo(r1[0].fX, r1[0].fY); | 1972 path1.moveTo(r1[0].fX, r1[0].fY); |
1972 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1973 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
1973 path1.lineTo(r1[index].fX, r1[index].fY); | 1974 path1.lineTo(r1[index].fX, r1[index].fY); |
1974 } | 1975 } |
1975 path1.close(); | 1976 path1.close(); |
1976 path1.lineTo(1, 0); | 1977 path1.lineTo(1, 0); |
1977 if (!rectFirst) { | 1978 if (!rectFirst) { |
1978 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 1979 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
1979 } | 1980 } |
1980 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1981 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); |
1981 | 1982 |
1982 // fail, move in the middle | 1983 // fail, move in the middle |
1983 path1.reset(); | 1984 path1.reset(); |
1984 if (rectFirst) { | 1985 if (rectFirst) { |
1985 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 1986 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
1986 } | 1987 } |
1987 path1.moveTo(r1[0].fX, r1[0].fY); | 1988 path1.moveTo(r1[0].fX, r1[0].fY); |
1988 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 1989 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
1989 if (index == 2) { | 1990 if (index == 2) { |
1990 path1.moveTo(1, .5f); | 1991 path1.moveTo(1, .5f); |
1991 } | 1992 } |
1992 path1.lineTo(r1[index].fX, r1[index].fY); | 1993 path1.lineTo(r1[index].fX, r1[index].fY); |
1993 } | 1994 } |
1994 path1.close(); | 1995 path1.close(); |
1995 if (!rectFirst) { | 1996 if (!rectFirst) { |
1996 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 1997 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
1997 } | 1998 } |
1998 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1999 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); |
1999 | 2000 |
2000 // fail, move on the edge | 2001 // fail, move on the edge |
2001 path1.reset(); | 2002 path1.reset(); |
2002 if (rectFirst) { | 2003 if (rectFirst) { |
2003 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2004 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
2004 } | 2005 } |
2005 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2006 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
2006 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); | 2007 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); |
2007 path1.lineTo(r1[index].fX, r1[index].fY); | 2008 path1.lineTo(r1[index].fX, r1[index].fY); |
2008 } | 2009 } |
2009 path1.close(); | 2010 path1.close(); |
2010 if (!rectFirst) { | 2011 if (!rectFirst) { |
2011 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2012 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
2012 } | 2013 } |
2013 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 2014 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); |
2014 | 2015 |
2015 // fail, quad | 2016 // fail, quad |
2016 path1.reset(); | 2017 path1.reset(); |
2017 if (rectFirst) { | 2018 if (rectFirst) { |
2018 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2019 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
2019 } | 2020 } |
2020 path1.moveTo(r1[0].fX, r1[0].fY); | 2021 path1.moveTo(r1[0].fX, r1[0].fY); |
2021 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2022 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
2022 if (index == 2) { | 2023 if (index == 2) { |
2023 path1.quadTo(1, .5f, 1, .5f); | 2024 path1.quadTo(1, .5f, 1, .5f); |
2024 } | 2025 } |
2025 path1.lineTo(r1[index].fX, r1[index].fY); | 2026 path1.lineTo(r1[index].fX, r1[index].fY); |
2026 } | 2027 } |
2027 path1.close(); | 2028 path1.close(); |
2028 if (!rectFirst) { | 2029 if (!rectFirst) { |
2029 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2030 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
2030 } | 2031 } |
2031 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 2032 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); |
2032 | 2033 |
2033 // fail, cubic | 2034 // fail, cubic |
2034 path1.reset(); | 2035 path1.reset(); |
2035 if (rectFirst) { | 2036 if (rectFirst) { |
2036 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 2037 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
2037 } | 2038 } |
2038 path1.moveTo(r1[0].fX, r1[0].fY); | 2039 path1.moveTo(r1[0].fX, r1[0].fY); |
2039 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { | 2040 for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) { |
2040 if (index == 2) { | 2041 if (index == 2) { |
2041 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); | 2042 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); |
2042 } | 2043 } |
2043 path1.lineTo(r1[index].fX, r1[index].fY); | 2044 path1.lineTo(r1[index].fX, r1[index].fY); |
2044 } | 2045 } |
2045 path1.close(); | 2046 path1.close(); |
2046 if (!rectFirst) { | 2047 if (!rectFirst) { |
2047 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 2048 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
2048 } | 2049 } |
2049 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 2050 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); |
2050 | 2051 |
2051 // fail, not nested | 2052 // fail, not nested |
2052 path1.reset(); | 2053 path1.reset(); |
2053 path1.addRect(1, 1, 3, 3, SkPath::kCW_Direction); | 2054 path1.addRect(1, 1, 3, 3, SkPath::kCW_Direction); |
2054 path1.addRect(2, 2, 4, 4, SkPath::kCW_Direction); | 2055 path1.addRect(2, 2, 4, 4, SkPath::kCW_Direction); |
2055 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 2056 REPORTER_ASSERT(reporter, !path1.isNestedFillRects(NULL)); |
2056 } | 2057 } |
2057 | 2058 |
| 2059 // pass, constructed explicitly from manually closed rects specified as mov
es/lines. |
| 2060 SkPath path; |
| 2061 path.moveTo(0, 0); |
| 2062 path.lineTo(10, 0); |
| 2063 path.lineTo(10, 10); |
| 2064 path.lineTo(0, 10); |
| 2065 path.lineTo(0, 0); |
| 2066 path.moveTo(1, 1); |
| 2067 path.lineTo(9, 1); |
| 2068 path.lineTo(9, 9); |
| 2069 path.lineTo(1, 9); |
| 2070 path.lineTo(1, 1); |
| 2071 REPORTER_ASSERT(reporter, path.isNestedFillRects(NULL)); |
| 2072 |
2058 // pass, stroke rect | 2073 // pass, stroke rect |
2059 SkPath src, dst; | 2074 SkPath src, dst; |
2060 src.addRect(1, 1, 7, 7, SkPath::kCW_Direction); | 2075 src.addRect(1, 1, 7, 7, SkPath::kCW_Direction); |
2061 SkPaint strokePaint; | 2076 SkPaint strokePaint; |
2062 strokePaint.setStyle(SkPaint::kStroke_Style); | 2077 strokePaint.setStyle(SkPaint::kStroke_Style); |
2063 strokePaint.setStrokeWidth(2); | 2078 strokePaint.setStrokeWidth(2); |
2064 strokePaint.getFillPath(src, &dst); | 2079 strokePaint.getFillPath(src, &dst); |
2065 REPORTER_ASSERT(reporter, dst.isNestedRects(NULL)); | 2080 REPORTER_ASSERT(reporter, dst.isNestedFillRects(NULL)); |
2066 } | 2081 } |
2067 | 2082 |
2068 static void write_and_read_back(skiatest::Reporter* reporter, | 2083 static void write_and_read_back(skiatest::Reporter* reporter, |
2069 const SkPath& p) { | 2084 const SkPath& p) { |
2070 SkWriter32 writer; | 2085 SkWriter32 writer; |
2071 writer.writePath(p); | 2086 writer.writePath(p); |
2072 size_t size = writer.bytesWritten(); | 2087 size_t size = writer.bytesWritten(); |
2073 SkAutoMalloc storage(size); | 2088 SkAutoMalloc storage(size); |
2074 writer.flatten(storage.get()); | 2089 writer.flatten(storage.get()); |
2075 SkReader32 reader(storage.get(), size); | 2090 SkReader32 reader(storage.get(), size); |
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3712 REPORTER_ASSERT(reporter, r == bounds); | 3727 REPORTER_ASSERT(reporter, r == bounds); |
3713 // add a moveTo outside of our bounds | 3728 // add a moveTo outside of our bounds |
3714 p.moveTo(bounds.fLeft + 10, bounds.fBottom + 10); | 3729 p.moveTo(bounds.fLeft + 10, bounds.fBottom + 10); |
3715 REPORTER_ASSERT(reporter, p.isRect(&r)); | 3730 REPORTER_ASSERT(reporter, p.isRect(&r)); |
3716 REPORTER_ASSERT(reporter, r == bounds); | 3731 REPORTER_ASSERT(reporter, r == bounds); |
3717 } | 3732 } |
3718 | 3733 |
3719 test_operatorEqual(reporter); | 3734 test_operatorEqual(reporter); |
3720 test_isLine(reporter); | 3735 test_isLine(reporter); |
3721 test_isRect(reporter); | 3736 test_isRect(reporter); |
3722 test_isNestedRects(reporter); | 3737 test_isNestedFillRects(reporter); |
3723 test_zero_length_paths(reporter); | 3738 test_zero_length_paths(reporter); |
3724 test_direction(reporter); | 3739 test_direction(reporter); |
3725 test_convexity(reporter); | 3740 test_convexity(reporter); |
3726 test_convexity2(reporter); | 3741 test_convexity2(reporter); |
3727 test_conservativelyContains(reporter); | 3742 test_conservativelyContains(reporter); |
3728 test_close(reporter); | 3743 test_close(reporter); |
3729 test_segment_masks(reporter); | 3744 test_segment_masks(reporter); |
3730 test_flattening(reporter); | 3745 test_flattening(reporter); |
3731 test_transform(reporter); | 3746 test_transform(reporter); |
3732 test_bounds(reporter); | 3747 test_bounds(reporter); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3765 test_get_point(reporter); | 3780 test_get_point(reporter); |
3766 test_contains(reporter); | 3781 test_contains(reporter); |
3767 PathTest_Private::TestPathTo(reporter); | 3782 PathTest_Private::TestPathTo(reporter); |
3768 PathRefTest_Private::TestPathRef(reporter); | 3783 PathRefTest_Private::TestPathRef(reporter); |
3769 test_dump(reporter); | 3784 test_dump(reporter); |
3770 test_path_crbug389050(reporter); | 3785 test_path_crbug389050(reporter); |
3771 test_path_crbugskia2820(reporter); | 3786 test_path_crbugskia2820(reporter); |
3772 test_skbug_3469(reporter); | 3787 test_skbug_3469(reporter); |
3773 test_skbug_3239(reporter); | 3788 test_skbug_3239(reporter); |
3774 } | 3789 } |
OLD | NEW |