aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsBuilderTest.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-05-18 05:12:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-18 05:12:56 -0700
commit5b5ddd73b4baf22752924bf20d097e96236c36f8 (patch)
treee4ae4c9db97d4a19fe504b9aabf5f6d373aeeffa /tests/PathOpsBuilderTest.cpp
parent2e0303f91bdada6dddb73105a82f17601265379d (diff)
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
Diffstat (limited to 'tests/PathOpsBuilderTest.cpp')
-rw-r--r--tests/PathOpsBuilderTest.cpp31
1 files changed, 22 insertions, 9 deletions
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);
+}