1876 {
1880
1884 SkPath invLineAB = lineAB;
1885
1887
1891 stroke.setStrokeWidth(2.f);
1897
1898 TestCase fillAB(r, lineAB, fill);
1899 TestCase fillEmpty(r,
SkPath(), fill);
1900 fillAB.compare(r, fillEmpty, TestCase::kAllSame_ComparisonExpecation);
1902
1904 path.toggleInverseFillType();
1905 TestCase fillEmptyInverted(r,
path, fill);
1906 TestCase fillABInverted(r, invLineAB, fill);
1907 fillABInverted.compare(r, fillEmptyInverted, TestCase::kAllSame_ComparisonExpecation);
1908 REPORTER_ASSERT(r, !fillABInverted.baseShape().asLine(
nullptr,
nullptr));
1909
1910 TestCase strokeAB(r, lineAB,
stroke);
1911 TestCase strokeBA(r, lineBA,
stroke);
1912 TestCase strokeAC(r, lineAC,
stroke);
1913
1914 TestCase hairlineAB(r, lineAB, hairline);
1915 TestCase hairlineBA(r, lineBA, hairline);
1916 TestCase hairlineAC(r, lineAC, hairline);
1917
1918 TestCase dashAB(r, lineAB, dash);
1919 TestCase dashBA(r, lineBA, dash);
1920 TestCase dashAC(r, lineAC, dash);
1921
1922 strokeAB.compare(r, fillAB, TestCase::kAllDifferent_ComparisonExpecation);
1923
1924 strokeAB.compare(r, strokeBA, TestCase::kAllSame_ComparisonExpecation);
1925 strokeAB.compare(r, strokeAC, TestCase::kAllDifferent_ComparisonExpecation);
1926
1927 hairlineAB.compare(r, hairlineBA, TestCase::kAllSame_ComparisonExpecation);
1928 hairlineAB.compare(r, hairlineAC, TestCase::kAllDifferent_ComparisonExpecation);
1929
1930 dashAB.compare(r, dashBA, TestCase::kAllDifferent_ComparisonExpecation);
1931 dashAB.compare(r, dashAC, TestCase::kAllDifferent_ComparisonExpecation);
1932
1933 strokeAB.compare(r, hairlineAB, TestCase::kSameUpToStroke_ComparisonExpecation);
1934
1935
1936
1937 bool canonicalizeAsAB;
1939
1940 bool inverted = true;
1941 SkPoint pts[2] {{0, 0}, {0, 0}};
1942 REPORTER_ASSERT(r, strokeAB.baseShape().asLine(pts, &inverted) && !inverted);
1943 if (pts[0] ==
kA && pts[1] ==
kB) {
1944 canonicalizeAsAB = true;
1945 }
else if (pts[1] ==
kA && pts[0] ==
kB) {
1946 canonicalizeAsAB = false;
1948 swap(canonicalPts[0], canonicalPts[1]);
1949 } else {
1950 ERRORF(r,
"Should return pts (a,b) or (b, a)");
1951 return;
1952 }
1953
1954 strokeAB.compare(r, canonicalizeAsAB ? dashAB : dashBA,
1955 TestCase::kSameUpToPE_ComparisonExpecation);
1956 REPORTER_ASSERT(r, strokeAB.baseShape().asLine(pts, &inverted) && !inverted &&
1957 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1958 REPORTER_ASSERT(r, hairlineAB.baseShape().asLine(pts, &inverted) && !inverted &&
1959 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1960 REPORTER_ASSERT(r, dashAB.baseShape().asLine(pts, &inverted) && !inverted &&
1961 pts[0] ==
kA && pts[1] ==
kB);
1962 REPORTER_ASSERT(r, dashBA.baseShape().asLine(pts, &inverted) && !inverted &&
1963 pts[0] ==
kB && pts[1] ==
kA);
1964
1965
1966 TestCase strokeInvAB(r, invLineAB,
stroke);
1967 TestCase hairlineInvAB(r, invLineAB, hairline);
1968 TestCase dashInvAB(r, invLineAB, dash);
1969 strokeInvAB.compare(r, strokeAB, TestCase::kAllDifferent_ComparisonExpecation);
1970 hairlineInvAB.compare(r, hairlineAB, TestCase::kAllDifferent_ComparisonExpecation);
1971
1972 dashInvAB.compare(r, dashAB, TestCase::kAllSame_ComparisonExpecation);
1973
1974 REPORTER_ASSERT(r, strokeInvAB.baseShape().asLine(pts, &inverted) && inverted &&
1975 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1976 REPORTER_ASSERT(r, hairlineInvAB.baseShape().asLine(pts, &inverted) && inverted &&
1977 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1978
1979 REPORTER_ASSERT(r, dashInvAB.baseShape().asLine(pts, &inverted) && !inverted &&
1980 pts[0] ==
kA && pts[1] ==
kB);
1981
1982}
void swap(sk_sp< T > &a, sk_sp< T > &b)
static SkPath Line(const SkPoint a, const SkPoint b)