From 5b5ddd73b4baf22752924bf20d097e96236c36f8 Mon Sep 17 00:00:00 2001 From: caryclark Date: Mon, 18 May 2015 05:12:56 -0700 Subject: The path ops builder code needs to determine the winding of each contour added, and reverse windings if the contours are nested in other contours. Cheap (one contour) paths can be evaluated and reversed as needed with a minimum of checking, but multi-contour paths invoke the regular path ops machinery to determine who is contained by whom. More tests need to be added to verify that all corner cases are considered, but this fixes the cases in the bug thus far. R=fmalita@chromium.org TBR=reed@google.com BUG=skia:3838 Review URL: https://codereview.chromium.org/1129193006 --- tests/PathOpsBuilderTest.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'tests/PathOpsBuilderTest.cpp') diff --git a/tests/PathOpsBuilderTest.cpp b/tests/PathOpsBuilderTest.cpp index 8ab92c3124..ea4c567e62 100644 --- a/tests/PathOpsBuilderTest.cpp +++ b/tests/PathOpsBuilderTest.cpp @@ -33,8 +33,10 @@ DEF_TEST(PathOpsBuilder, reporter) { SkPath::Direction dir; REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); REPORTER_ASSERT(reporter, closed); - REPORTER_ASSERT(reporter, dir == SkPath::kCW_Direction); - REPORTER_ASSERT(reporter, rectPath == result); + REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); + SkBitmap bitmap; + int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result, bitmap); + REPORTER_ASSERT(reporter, pixelDiff == 0); rectPath.reset(); rectPath.setFillType(SkPath::kEvenOdd_FillType); @@ -44,7 +46,7 @@ DEF_TEST(PathOpsBuilder, reporter) { REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); REPORTER_ASSERT(reporter, closed); REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); - REPORTER_ASSERT(reporter, rectPath == result); + REPORTER_ASSERT(reporter, rectPath == result); builder.add(rectPath, kDifference_SkPathOp); REPORTER_ASSERT(reporter, builder.resolve(&result)); @@ -74,12 +76,11 @@ DEF_TEST(PathOpsBuilder, reporter) { builder.add(circle2, kUnion_SkPathOp); builder.add(circle3, kDifference_SkPathOp); REPORTER_ASSERT(reporter, builder.resolve(&result)); - SkBitmap bitmap; - int pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result, bitmap); + pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result, bitmap); REPORTER_ASSERT(reporter, pixelDiff == 0); } -DEF_TEST(Issue3838, reporter) { +DEF_TEST(BuilderIssue3838, reporter) { SkPath path; path.moveTo(200, 170); path.lineTo(220, 170); @@ -93,9 +94,6 @@ DEF_TEST(Issue3838, reporter) { path.lineTo(200, 250); path.lineTo(200, 170); path.close(); - testSimplify(reporter, path, __FUNCTION__); - SkPath path3; - Simplify(path, &path3); SkPath path2; SkOpBuilder builder; builder.add(path, kUnion_SkPathOp); @@ -104,3 +102,18 @@ DEF_TEST(Issue3838, reporter) { int pixelDiff = comparePaths(reporter, __FUNCTION__, path, path2, bitmap); REPORTER_ASSERT(reporter, pixelDiff == 0); } + +DEF_TEST(BuilderIssue3838_2, reporter) { + SkPath path; + path.addCircle(100, 100, 50); + + SkOpBuilder builder; + builder.add(path, kUnion_SkPathOp); + builder.add(path, kUnion_SkPathOp); + + SkPath result; + SkBitmap bitmap; + builder.resolve(&result); + int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result, bitmap); + REPORTER_ASSERT(reporter, pixelDiff == 0); +} -- cgit v1.2.3