aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsExtendedTest.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2014-11-13 06:58:52 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 06:58:52 -0800
commit65f553182ab7069378ef863d30094d0327f178d0 (patch)
tree4e7a435941ae82ddd6cab0abcfb2ed7946f79969 /tests/PathOpsExtendedTest.cpp
parentb1cff03325c42bb1cd87204d9b0dd3d6b9678d3e (diff)
These tests stress pathops by describing the union of circle-like paths that have tiny line segments embedded and double back to create near-coincident conditions.
The fixes include - detect when finding the active top loops between two possible answers - preflight chasing winding to ensure answer is consistent - binary search more often when quadratic intersection fails - add more failure paths when an intersect is missed While this fixes the chrome bug, reenabling path ops in svg should be deferred until additional fixes are landed. TBR= BUG=421132 Committed: https://skia.googlesource.com/skia/+/6f726addf3178b01949bb389ef83cf14a1d7b6b2 Review URL: https://codereview.chromium.org/633393002
Diffstat (limited to 'tests/PathOpsExtendedTest.cpp')
-rw-r--r--tests/PathOpsExtendedTest.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index d808ed7ec4..73a23872f8 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -322,16 +322,23 @@ SK_DECLARE_STATIC_MUTEX(compareDebugOut3);
SK_DECLARE_STATIC_MUTEX(compareDebugOut4);
static int comparePaths(skiatest::Reporter* reporter, const char* testName, const SkPath& one,
const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkBitmap& bitmap,
- const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix& scale) {
+ const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix& scale,
+ bool expectSuccess) {
int errors2x2;
+ const int MAX_ERRORS = 8;
(void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2);
+ if (!expectSuccess) {
+ if (errors2x2 <= MAX_ERRORS) {
+ REPORTER_ASSERT(reporter, 0);
+ }
+ return 0;
+ }
if (errors2x2 == 0) {
if (gShowPath) {
showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale);
}
return 0;
}
- const int MAX_ERRORS = 8;
if (errors2x2 > MAX_ERRORS && gComparePathsAssert) {
SkAutoMutexAcquire autoM(compareDebugOut3);
SkDebugf("\n*** this test fails ***\n");
@@ -472,7 +479,7 @@ static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) {
#endif
static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
- const SkPathOp shapeOp, const char* testName, bool threaded) {
+ const SkPathOp shapeOp, const char* testName, bool threaded, bool expectSuccess) {
#if DEBUG_SHOW_TEST_NAME
showName(a, b, shapeOp);
#endif
@@ -510,7 +517,7 @@ static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
scaledOut.addPath(out, scale);
scaledOut.setFillType(out.getFillType());
int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, scaledOut, bitmap,
- a, b, shapeOp, scale);
+ a, b, shapeOp, scale, expectSuccess);
if (result && gPathStrAssert) {
REPORTER_ASSERT(reporter, 0);
}
@@ -519,8 +526,13 @@ static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
}
bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
- const SkPathOp shapeOp, const char* testName) {
- return innerPathOp(reporter, a, b, shapeOp, testName, false);
+ const SkPathOp shapeOp, const char* testName) {
+ return innerPathOp(reporter, a, b, shapeOp, testName, false, true);
+}
+
+bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
+ const SkPathOp shapeOp, const char* testName, bool checkFail) {
+ return innerPathOp(reporter, a, b, shapeOp, testName, false, checkFail);
}
bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
@@ -539,7 +551,7 @@ bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath&
bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
const SkPathOp shapeOp, const char* testName) {
- return innerPathOp(reporter, a, b, shapeOp, testName, true);
+ return innerPathOp(reporter, a, b, shapeOp, testName, true, true);
}
SK_DECLARE_STATIC_MUTEX(gMutex);