aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-08 17:17:02 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-08 17:17:02 +0000
commit07e97fccd2d85076cd22ef411b0773ab92a18abe (patch)
tree0a764160f5eb642f4fe46c06df9fbffe0e9f8eda /tests
parenta95959c3fb4c502b45bc78f15b65cda1f21620e6 (diff)
path ops work in progress
BUG= Review URL: https://codereview.chromium.org/18058007 git-svn-id: http://skia.googlecode.com/svn/trunk@9908 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/PathOpsAngleTest.cpp154
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp4
-rw-r--r--tests/PathOpsCubicLineIntersectionTest.cpp98
-rw-r--r--tests/PathOpsExtendedTest.cpp106
-rw-r--r--tests/PathOpsExtendedTest.h5
-rw-r--r--tests/PathOpsLineIntersectionTest.cpp129
-rw-r--r--tests/PathOpsOpTest.cpp147
-rw-r--r--tests/PathOpsSimplifyTest.cpp76
-rw-r--r--tests/PathOpsSkpClipTest.cpp153
-rw-r--r--tests/PathOpsThreadedCommon.h10
-rw-r--r--tests/Test.h1
-rw-r--r--tests/skia_test.cpp12
12 files changed, 651 insertions, 244 deletions
diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp
index 1986a506bd..34a77b1fd9 100644
--- a/tests/PathOpsAngleTest.cpp
+++ b/tests/PathOpsAngleTest.cpp
@@ -28,6 +28,7 @@ static const SkPoint cubics[][4] = {
/* 15 */ {{808,11417}, {808,11418.1044921875f}, {807.10455322265625f,11419}, {806,11419}},
/* 16 */ {{132,11419}, {130.89543151855469f,11419}, {130,11418.1044921875f}, {130,11417}},
/* 17 */ {{130.04275512695312f,11417.4130859375f}, {130.23312377929687f,11418.3193359375f}, {131.03707885742187f,11419}, {132,11419}},
+/* 18 */ {{1006.6951293945312f,291}, {1023.263671875f,291}, {1033.8402099609375f,304.43145751953125f}, {1030.318359375f,321}},
};
static const SkPoint quads[][3] = {
@@ -49,6 +50,7 @@ static const SkPoint lines[][2] = {
/* 8 */ {{4,3}, {0,1}},
/* 9 */ {{3,2}, {1,2}},
/* 10 */ {{6,4}, {3,4}},
+/* 11 */ {{979.30487060546875f,561}, {1036.695068359375f,291}},
};
struct SortSet {
@@ -192,6 +194,13 @@ static const SortSet set16[] = {
{cubics[17], 4, 0.0682619216, 1, {132,11419}},
};
+static const SortSet set17[] = {
+ {lines[11], 2, 0.888889581, 1, {0, 0}},
+ {cubics[18], 4, 0.999996241, 0, {0, 0}},
+ {lines[11], 2, 0.888889581, 0, {0, 0}},
+ {cubics[18], 4, 0.999996241, 1, {0, 0}},
+};
+
struct SortSetTests {
const char* name;
const SortSet* set;
@@ -202,6 +211,7 @@ struct SortSetTests {
#define TEST_ENTRY(name) #name, name, SK_ARRAY_COUNT(name)
static const SortSetTests tests[] = {
+ { TEST_ENTRY(set17), {0, 0}},
{ TEST_ENTRY(set16), {130.090179f,11417.5957f} },
// { TEST_ENTRY(set15), {0, 0}},
{ TEST_ENTRY(set14), {0, 0}},
@@ -294,90 +304,100 @@ static void setup(const SortSet* set, const size_t idx,
} while (++tIndex);
}
-static void PathOpsAngleTest(skiatest::Reporter* reporter) {
- for (size_t index = 0; index < SK_ARRAY_COUNT(tests); ++index) {
- const SortSetTests& test = tests[index];
- SkTDArray<SkOpAngle> angles;
- bool unsortable = false;
- bool unorderable = false;
- SkTArray<SkOpSegment> segs;
- for (size_t idx = 0; idx < test.count; ++idx) {
- int ts[2];
- const SortSet* set = test.set;
- SkOpSegment& seg = segs.push_back();
- setup(set, idx, &seg, ts, test.startPt);
- SkOpAngle* angle = angles.append();
- angle->set(&seg, ts[0], ts[1]);
+static void testOne(skiatest::Reporter* reporter, const SortSetTests& test) {
+ SkTDArray<SkOpAngle> angles;
+ bool unsortable = false;
+ bool unorderable = false;
+ SkTArray<SkOpSegment> segs;
+ for (size_t idx = 0; idx < test.count; ++idx) {
+ int ts[2];
+ const SortSet* set = test.set;
+ SkOpSegment& seg = segs.push_back();
+ setup(set, idx, &seg, ts, test.startPt);
+ SkOpAngle* angle = angles.append();
+ angle->set(&seg, ts[0], ts[1]);
#if DEBUG_ANGLE
- angle->setID(idx);
+ angle->setID(idx);
#endif
- if (angle->unsortable()) {
+ if (angle->unsortable()) {
#if DEBUG_ANGLE
- SkDebugf("%s test[%s]: angle[%d] unsortable\n", __FUNCTION__, test.name, idx);
+ SkDebugf("%s test[%s]: angle[%d] unsortable\n", __FUNCTION__, test.name, idx);
#endif
- unsortable = true;
- }
- if (angle->unorderable()) {
+ unsortable = true;
+ }
+ if (angle->unorderable()) {
#if DEBUG_ANGLE
- SkDebugf("%s test[%s]: angle[%d] unorderable\n", __FUNCTION__, test.name, idx);
+ SkDebugf("%s test[%s]: angle[%d] unorderable\n", __FUNCTION__, test.name, idx);
#endif
- unorderable = true;
- }
- reporter->bumpTestCount();
- }
- if (unsortable || unorderable) {
- continue;
+ unorderable = true;
}
+ reporter->bumpTestCount();
+ }
+ if (unsortable || unorderable) {
+ return;
+ }
#if DEBUG_ANGLE
- SkDebugf("%s test[%s]\n", __FUNCTION__, test.name);
+ SkDebugf("%s test[%s]\n", __FUNCTION__, test.name);
#endif
- for (size_t idxL = 0; idxL < test.count; ++idxL) {
- const SkOpAngle& first = angles[idxL];
- for (size_t idxG = 0; idxG < test.count; ++idxG) {
- if (idxL == idxG) {
- continue;
+ for (size_t idxL = 0; idxL < test.count; ++idxL) {
+ const SkOpAngle& first = angles[idxL];
+ for (size_t idxG = 0; idxG < test.count; ++idxG) {
+ if (idxL == idxG) {
+ continue;
+ }
+ const SkOpAngle& second = angles[idxG];
+ bool compare = first < second;
+ if (idxL < idxG) {
+ if (!compare) {
+ SkDebugf("%s test[%s]: first[%d] > second[%d]\n", __FUNCTION__,
+ test.name, idxL, idxG);
+ compare = first < second;
+ }
+ REPORTER_ASSERT(reporter, compare);
+ } else {
+ SkASSERT(idxL > idxG);
+ if (compare) {
+ SkDebugf("%s test[%s]: first[%d] < second[%d]\n", __FUNCTION__,
+ test.name, idxL, idxG);
+ compare = first < second;
}
- const SkOpAngle& second = angles[idxG];
- bool compare = first < second;
- if (idxL < idxG) {
- if (!compare) {
- SkDebugf("%s test[%s]: first[%d] > second[%d]\n", __FUNCTION__,
- test.name, idxL, idxG);
- compare = first < second;
- }
- REPORTER_ASSERT(reporter, compare);
- } else {
- SkASSERT(idxL > idxG);
- if (compare) {
- SkDebugf("%s test[%s]: first[%d] < second[%d]\n", __FUNCTION__,
- test.name, idxL, idxG);
- compare = first < second;
- }
- REPORTER_ASSERT(reporter, !compare);
+ REPORTER_ASSERT(reporter, !compare);
+ }
+ compare = second < first;
+ if (idxL < idxG) {
+ if (compare) {
+ SkDebugf("%s test[%s]: second[%d] < first[%d]\n", __FUNCTION__,
+ test.name, idxL, idxG);
+ compare = second < first;
}
- compare = second < first;
- if (idxL < idxG) {
- if (compare) {
- SkDebugf("%s test[%s]: second[%d] < first[%d]\n", __FUNCTION__,
- test.name, idxL, idxG);
- compare = second < first;
- }
- REPORTER_ASSERT(reporter, !compare);
- } else {
- SkASSERT(idxL > idxG);
- if (!compare) {
- SkDebugf("%s test[%s]: second[%d] > first[%d]\n", __FUNCTION__,
- test.name, idxL, idxG);
- compare = second < first;
- }
- REPORTER_ASSERT(reporter, compare);
+ REPORTER_ASSERT(reporter, !compare);
+ } else {
+ SkASSERT(idxL > idxG);
+ if (!compare) {
+ SkDebugf("%s test[%s]: second[%d] > first[%d]\n", __FUNCTION__,
+ test.name, idxL, idxG);
+ compare = second < first;
}
+ REPORTER_ASSERT(reporter, compare);
}
}
+ }
+}
+
+static void PathOpsAngleTest(skiatest::Reporter* reporter) {
+ for (size_t index = 0; index < SK_ARRAY_COUNT(tests); ++index) {
+ const SortSetTests& test = tests[index];
+ testOne(reporter, test);
reporter->bumpTestCount();
}
}
+static void PathOpsAngleTestOne(skiatest::Reporter* reporter) {
+ size_t index = 0;
+ const SortSetTests& test = tests[index];
+ testOne(reporter, test);
+}
+
#if 0
static int find_slop(double x, double y, double rx, double ry) {
int slopBits = 0;
@@ -446,4 +466,6 @@ static void PathOpsAngleFindSlop(skiatest::Reporter* reporter) {
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsAngleTest)
+DEFINE_TESTCLASS_SHORT(PathOpsAngleTestOne)
+
// DEFINE_TESTCLASS_SHORT(PathOpsAngleFindSlop)
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index 7f5f4cd040..e00ba1674c 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -490,8 +490,8 @@ static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
max[idx2], cubic.xyAtT(max[idx2]).fX, cubic.xyAtT(max[idx2]).fY);
}
- SkTDArray<double> ts1;
- SkTDArray<SkDQuad> quads1;
+ SkTArray<double, true> ts1;
+ SkTArray<SkDQuad, true> quads1;
cubic.toQuadraticTs(cubic.calcPrecision(), &ts1);
for (idx2 = 0; idx2 < ts1.count(); ++idx2) {
SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]);
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp
index 7af7b26e45..c5f05f6f6d 100644
--- a/tests/PathOpsCubicLineIntersectionTest.cpp
+++ b/tests/PathOpsCubicLineIntersectionTest.cpp
@@ -14,47 +14,85 @@ static struct lineCubic {
SkDCubic cubic;
SkDLine line;
} lineCubicTests[] = {
+ {{{{1006.6951293945312,291}, {1023.263671875,291}, {1033.8402099609375,304.43145751953125},
+ {1030.318359375,321}}},
+ {{{979.30487060546875,561}, {1036.695068359375,291}}}},
+ {{{{259.30487060546875,561}, {242.73631286621094,561}, {232.15980529785156,547.56854248046875},
+ {235.68154907226562,531}}},
+ {{{286.69512939453125,291}, {229.30485534667969,561}}}},
{{{{1, 2}, {2, 6}, {2, 0}, {1, 0}}}, {{{1, 0}, {1, 2}}}},
{{{{0, 0}, {0, 1}, {0, 1}, {1, 1}}}, {{{0, 1}, {1, 0}}}},
};
static const size_t lineCubicTests_count = SK_ARRAY_COUNT(lineCubicTests);
+static void testOne(skiatest::Reporter* reporter, int iIndex) {
+ const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
+ const SkDLine& line = lineCubicTests[iIndex].line;
+ SkReduceOrder reduce1;
+ SkReduceOrder reduce2;
+ int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics,
+ SkReduceOrder::kFill_Style);
+ int order2 = reduce2.reduce(line);
+ if (order1 < 4) {
+ SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
+ REPORTER_ASSERT(reporter, 0);
+ }
+ if (order2 < 2) {
+ SkDebugf("[%d] line order=%d\n", iIndex, order2);
+ REPORTER_ASSERT(reporter, 0);
+ }
+ if (order1 == 4 && order2 == 2) {
+ SkIntersections i;
+ int roots = i.intersect(cubic, line);
+ for (int pt = 0; pt < roots; ++pt) {
+ double tt1 = i[0][pt];
+ SkDPoint xy1 = cubic.xyAtT(tt1);
+ double tt2 = i[1][pt];
+ SkDPoint xy2 = line.xyAtT(tt2);
+ if (!xy1.approximatelyEqual(xy2)) {
+ SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
+ __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
+ }
+ REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
+ }
+ }
+}
+
static void PathOpsCubicLineIntersectionTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < lineCubicTests_count; ++index) {
int iIndex = static_cast<int>(index);
- const SkDCubic& cubic = lineCubicTests[index].cubic;
- const SkDLine& line = lineCubicTests[index].line;
- SkReduceOrder reduce1;
- SkReduceOrder reduce2;
- int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics,
- SkReduceOrder::kFill_Style);
- int order2 = reduce2.reduce(line);
- if (order1 < 4) {
- SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
- REPORTER_ASSERT(reporter, 0);
- }
- if (order2 < 2) {
- SkDebugf("[%d] line order=%d\n", iIndex, order2);
- REPORTER_ASSERT(reporter, 0);
- }
- if (order1 == 4 && order2 == 2) {
- SkIntersections i;
- int roots = i.intersect(cubic, line);
- for (int pt = 0; pt < roots; ++pt) {
- double tt1 = i[0][pt];
- SkDPoint xy1 = cubic.xyAtT(tt1);
- double tt2 = i[1][pt];
- SkDPoint xy2 = line.xyAtT(tt2);
- if (!xy1.approximatelyEqual(xy2)) {
- SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
- __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
- }
- REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
- }
- }
+ testOne(reporter, iIndex);
+ reporter->bumpTestCount();
}
}
+static void PathOpsCubicLineIntersectionTestOne(skiatest::Reporter* reporter) {
+ int iIndex = 0;
+ testOne(reporter, iIndex);
+ const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
+ const SkDLine& line = lineCubicTests[iIndex].line;
+ SkIntersections i;
+ i.intersect(cubic, line);
+ SkASSERT(i.used() == 1);
+#if ONE_OFF_DEBUG
+ double cubicT = i[0][0];
+ SkDPoint prev = cubic.xyAtT(cubicT * 2 - 1);
+ SkDPoint sect = cubic.xyAtT(cubicT);
+ double left[3] = { line.isLeft(prev), line.isLeft(sect), line.isLeft(cubic[3]) };
+ SkDebugf("cubic=(%1.9g, %1.9g, %1.9g)\n", left[0], left[1], left[2]);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prev.fX, prev.fY, sect.fX, sect.fY);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", sect.fX, sect.fY, cubic[3].fX, cubic[3].fY);
+ SkDPoint prevL = line.xyAtT(i[1][0] - 0.0000007);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prevL.fX, prevL.fY, i.pt(0).fX, i.pt(0).fY);
+ SkDPoint nextL = line.xyAtT(i[1][0] + 0.0000007);
+ SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL.fX, nextL.fY);
+ SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
+ sect.distance(i.pt(0)), cubic[3].distance(prevL));
+#endif
+}
+
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionTestOne)
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index a9ca58b1e9..7a7dcb3759 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -45,27 +45,34 @@ static bool gComparePaths = true;
static bool gComparePathsAssert = true;
static bool gPathStrAssert = true;
-static void showPathContours(SkPath::Iter& iter, const char* suffix) {
+static const char* gFillTypeStr[] = {
+ "kWinding_FillType",
+ "kEvenOdd_FillType",
+ "kInverseWinding_FillType",
+ "kInverseEvenOdd_FillType"
+};
+
+static void showPathContours(SkPath::RawIter& iter, const char* pathName) {
uint8_t verb;
SkPoint pts[4];
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
case SkPath::kMove_Verb:
- SkDebugf(" path%s.moveTo(%1.9g,%1.9g);\n", suffix, pts[0].fX, pts[0].fY);
+ SkDebugf(" %s.moveTo(%#1.9gf, %#1.9gf);\n", pathName, pts[0].fX, pts[0].fY);
continue;
case SkPath::kLine_Verb:
- SkDebugf(" path%s.lineTo(%1.9g,%1.9g);\n", suffix, pts[1].fX, pts[1].fY);
+ SkDebugf(" %s.lineTo(%#1.9gf, %#1.9gf);\n", pathName, pts[1].fX, pts[1].fY);
break;
case SkPath::kQuad_Verb:
- SkDebugf(" path%s.quadTo(%1.9g,%1.9g, %1.9g,%1.9g);\n", suffix,
+ SkDebugf(" %s.quadTo(%#1.9gf, %#1.9gf, %#1.9gf, %#1.9gf);\n", pathName,
pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY);
break;
case SkPath::kCubic_Verb:
- SkDebugf(" path%s.cubicTo(%1.9g,%1.9g, %1.9g,%1.9g, %1.9g,%1.9g);\n", suffix,
- pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY);
+ SkDebugf(" %s.cubicTo(%#1.9gf, %#1.9gf, %#1.9gf, %#1.9gf, %#1.9gf, %#1.9gf);\n",
+ pathName, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY);
break;
case SkPath::kClose_Verb:
- SkDebugf(" path%s.close();\n", suffix);
+ SkDebugf(" %s.close();\n", pathName);
break;
default:
SkDEBUGFAIL("bad verb");
@@ -74,15 +81,8 @@ static void showPathContours(SkPath::Iter& iter, const char* suffix) {
}
}
-static const char* fillTypeStr[] = {
- "kWinding_FillType",
- "kEvenOdd_FillType",
- "kInverseWinding_FillType",
- "kInverseEvenOdd_FillType"
-};
-
-static void showPath(const SkPath& path, const char* suffix) {
- SkPath::Iter iter(path, true);
+static void showPath(const SkPath& path, const char* pathName, bool includeDeclaration) {
+ SkPath::RawIter iter(path);
#define SUPPORT_RECT_CONTOUR_DETECTION 0
#if SUPPORT_RECT_CONTOUR_DETECTION
int rectCount = path.isRectContours() ? path.rectContours(NULL, NULL) : 0;
@@ -103,14 +103,17 @@ static void showPath(const SkPath& path, const char* suffix) {
#endif
SkPath::FillType fillType = path.getFillType();
SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInverseEvenOdd_FillType);
- SkDebugf(" path%s.setFillType(SkPath::%s);\n", suffix, fillTypeStr[fillType]);
- iter.setPath(path, true);
- showPathContours(iter, suffix);
+ if (includeDeclaration) {
+ SkDebugf(" SkPath %s;\n", pathName);
+ }
+ SkDebugf(" %s.setFillType(SkPath::%s);\n", pathName, gFillTypeStr[fillType]);
+ iter.setPath(path);
+ showPathContours(iter, pathName);
}
#if DEBUG_SHOW_TEST_NAME
static void showPathData(const SkPath& path) {
- SkPath::Iter iter(path, true);
+ SkPath::RawIter iter(path);
uint8_t verb;
SkPoint pts[4];
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
@@ -162,16 +165,26 @@ void showOp(const SkPathOp op) {
}
}
-#if 0
-static void showPath(const SkPath& path, const char* str, const SkMatrix& scale) {
- SkPath scaled;
- SkMatrix inverse;
- bool success = scale.invert(&inverse);
- if (!success) {
- SkASSERT(0);
+#if DEBUG_SHOW_TEST_NAME
+
+void ShowFunctionHeader(const char* functionName) {
+ SkDebugf("\nstatic void %s(skiatest::Reporter* reporter) {\n", functionName);
+ if (strcmp("skphealth_com76", functionName) == 0) {
+ SkDebugf("found it\n");
}
- path.transform(inverse, &scaled);
- showPath(scaled, str);
+}
+
+static const char* gOpStrs[] = {
+ "kDifference_PathOp",
+ "kIntersect_PathOp",
+ "kUnion_PathOp",
+ "kXor_PathOp",
+ "kReverseDifference_PathOp",
+};
+
+void ShowOp(SkPathOp op, const char* pathOne, const char* pathTwo) {
+ SkDebugf(" testPathOp(reporter, %s, %s, %s);\n", pathOne, pathTwo, gOpStrs[op]);
+ SkDebugf("}\n");
}
#endif
@@ -325,8 +338,7 @@ bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths) {
static void showSimplifiedPath(const SkPath& one, const SkPath& two,
const SkPath& scaledOne, const SkPath& scaledTwo) {
- showPath(one, "");
- // showPath(two, "simplified:");
+ showPath(one, "path", false);
drawAsciiPaths(scaledOne, scaledTwo, true);
}
@@ -356,13 +368,10 @@ static void showPathOpPath(const SkPath& one, const SkPath& two, const SkPath& a
SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs));
SkDebugf("static void xOp#%s(skiatest::Reporter* reporter) {\n", opSuffixes[shapeOp]);
SkDebugf(" SkPath path, pathB;\n");
- showPath(a, "");
- showPath(b, "B");
+ showPath(a, "path", false);
+ showPath(b, "pathB", false);
SkDebugf(" testPathOp(reporter, path, pathB, %s);\n", opStrs[shapeOp]);
SkDebugf("}\n");
- // the region often isn't very helpful since it approximates curves with a lot of line-tos
- // if (0) showPath(scaledOne, "region:", scale);
- // showPath(two, "op result:");
drawAsciiPaths(scaledOne, scaledTwo, true);
}
@@ -450,7 +459,7 @@ bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st
SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
path.setFillType(fillType);
if (gShowPath) {
- showPath(path, "");
+ showPath(path, "path", false);
}
if (!Simplify(path, &out)) {
SkDebugf("%s did not expect failure\n", __FUNCTION__);
@@ -499,12 +508,25 @@ bool testSimplify(skiatest::Reporter* reporter, const SkPath& path) {
return result == 0;
}
+#if DEBUG_SHOW_TEST_NAME
+void DebugShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp, const char* testName) {
+ ShowFunctionHeader(testName);
+ showPath(a, "path", true);
+ showPath(b, "pathB", true);
+ ShowOp(shapeOp, "path", "pathB");
+}
+#endif
+
bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
- const SkPathOp shapeOp) {
+ const SkPathOp shapeOp, const char* testName) {
#if DEBUG_SHOW_TEST_NAME
- showPathData(a);
- showOp(shapeOp);
- showPathData(b);
+ if (testName == NULL) {
+ showPathData(a);
+ showOp(shapeOp);
+ showPathData(b);
+ } else {
+ DebugShowPath(a, b, shapeOp, testName);
+ }
#endif
SkPath out;
if (!Op(a, b, shapeOp, &out) ) {
@@ -566,7 +588,7 @@ int initializeTests(skiatest::Reporter* reporter, const char* test) {
testNumber = atoi(numLoc) + 1;
}
}
- return reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 0;
+ return reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1;
}
void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFillType) {
diff --git a/tests/PathOpsExtendedTest.h b/tests/PathOpsExtendedTest.h
index 5e91dc1fd3..723135a33b 100644
--- a/tests/PathOpsExtendedTest.h
+++ b/tests/PathOpsExtendedTest.h
@@ -27,7 +27,7 @@ extern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap);
extern bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths);
extern void showOp(const SkPathOp op);
extern bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
- const SkPathOp );
+ const SkPathOp , const char* testName = NULL);
extern bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& state,
const char* pathStr);
extern bool testSimplify(skiatest::Reporter* reporter, const SkPath& path);
@@ -40,5 +40,8 @@ void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
void (*firstTest)(skiatest::Reporter* ),
void (*stopTest)(skiatest::Reporter* ), bool reverse);
void ShowTestName(PathOpsThreadState* data, int a, int b, int c, int d);
+void ShowFunctionHeader(const char* name);
+void ShowPath(const SkPath& path, const char* pathName);
+void ShowOp(SkPathOp op, const char* pathOne, const char* pathTwo);
#endif
diff --git a/tests/PathOpsLineIntersectionTest.cpp b/tests/PathOpsLineIntersectionTest.cpp
index db6003da9d..be40ae418f 100644
--- a/tests/PathOpsLineIntersectionTest.cpp
+++ b/tests/PathOpsLineIntersectionTest.cpp
@@ -10,6 +10,11 @@
// FIXME: add tests for intersecting, non-intersecting, degenerate, coincident
static const SkDLine tests[][2] = {
+#if 0 // FIXME: these fail because one line is too short and appears quasi-coincident
+ {{{{158.000000, 926.000000}, {1108.00000, 926.000000}}},
+ {{{1108.00000, 926.000000}, {1108.00000, 925.999634}}}},
+ {{{{1108,926}, {1108,925.9996337890625}}}, {{{158,926}, {1108,926}}}},
+#endif
{{{{192, 4}, {243, 4}}}, {{{246, 4}, {189, 4}}}},
{{{{246, 4}, {189, 4}}}, {{{192, 4}, {243, 4}}}},
{{{{5, 0}, {0, 5}}}, {{{5, 4}, {1, 4}}}},
@@ -34,6 +39,13 @@ static const SkDLine noIntersect[][2] = {
static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect);
+static const SkDLine coincidentTests[][2] = {
+ {{{{235.681549, 531.000000}, {280.318420, 321.000000}}},
+ {{{286.695129, 291.000000}, {229.304855, 561.000000}}}},
+};
+
+static const size_t coincidentTests_count = SK_ARRAY_COUNT(coincidentTests);
+
static void check_results(skiatest::Reporter* reporter, const SkDLine& line1, const SkDLine& line2,
const SkIntersections& ts) {
for (int i = 0; i < ts.used(); ++i) {
@@ -48,43 +60,75 @@ static void check_results(skiatest::Reporter* reporter, const SkDLine& line1, co
}
}
+static void testOne(skiatest::Reporter* reporter, const SkDLine& line1, const SkDLine& line2) {
+ SkIntersections i;
+ int pts = i.intersect(line1, line2);
+ REPORTER_ASSERT(reporter, pts);
+ REPORTER_ASSERT(reporter, pts == i.used());
+ check_results(reporter, line1, line2, i);
+ if (line1[0] == line1[1] || line2[0] == line2[1]) {
+ return;
+ }
+ if (line1[0].fY == line1[1].fY) {
+ double left = SkTMin(line1[0].fX, line1[1].fX);
+ double right = SkTMax(line1[0].fX, line1[1].fX);
+ SkIntersections ts;
+ ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
+ check_results(reporter, line2, line1, ts);
+ }
+ if (line2[0].fY == line2[1].fY) {
+ double left = SkTMin(line2[0].fX, line2[1].fX);
+ double right = SkTMax(line2[0].fX, line2[1].fX);
+ SkIntersections ts;
+ ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
+ check_results(reporter, line1, line2, ts);
+ }
+ if (line1[0].fX == line1[1].fX) {
+ double top = SkTMin(line1[0].fY, line1[1].fY);
+ double bottom = SkTMax(line1[0].fY, line1[1].fY);
+ SkIntersections ts;
+ ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
+ check_results(reporter, line2, line1, ts);
+ }
+ if (line2[0].fX == line2[1].fX) {
+ double top = SkTMin(line2[0].fY, line2[1].fY);
+ double bottom = SkTMax(line2[0].fY, line2[1].fY);
+ SkIntersections ts;
+ ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
+ check_results(reporter, line1, line2, ts);
+ }
+}
+
+static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1,
+ const SkDLine& line2) {
+ SkIntersections ts2;
+ int pts2 = ts2.intersect(line1, line2);
+ REPORTER_ASSERT(reporter, pts2 == 2);
+ REPORTER_ASSERT(reporter, pts2 == ts2.used());
+ check_results(reporter, line1, line2, ts2);
+#if 0
+ SkIntersections ts;
+ int pts = ts.intersect(line1, line2);
+ REPORTER_ASSERT(reporter, pts == pts2);
+ REPORTER_ASSERT(reporter, pts == 2);
+ REPORTER_ASSERT(reporter, pts == ts.used());
+ check_results(reporter, line1, line2, ts);
+#endif
+}
+
static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) {
size_t index;
+ for (index = 0; index < coincidentTests_count; ++index) {
+ const SkDLine& line1 = coincidentTests[index][0];
+ const SkDLine& line2 = coincidentTests[index][1];
+ testOneCoincident(reporter, line1, line2);
+ reporter->bumpTestCount();
+ }
for (index = 0; index < tests_count; ++index) {
const SkDLine& line1 = tests[index][0];
const SkDLine& line2 = tests[index][1];
- SkIntersections ts;
- int pts = ts.intersect(line1, line2);
- REPORTER_ASSERT(reporter, pts);
- REPORTER_ASSERT(reporter, pts == ts.used());
- check_results(reporter, line1, line2, ts);
- if (line1[0] == line1[1] || line2[0] == line2[1]) {
- continue;
- }
- if (line1[0].fY == line1[1].fY) {
- double left = SkTMin(line1[0].fX, line1[1].fX);
- double right = SkTMax(line1[0].fX, line1[1].fX);
- ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
- check_results(reporter, line2, line1, ts);
- }
- if (line2[0].fY == line2[1].fY) {
- double left = SkTMin(line2[0].fX, line2[1].fX);
- double right = SkTMax(line2[0].fX, line2[1].fX);
- ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
- check_results(reporter, line1, line2, ts);
- }
- if (line1[0].fX == line1[1].fX) {
- double top = SkTMin(line1[0].fY, line1[1].fY);
- double bottom = SkTMax(line1[0].fY, line1[1].fY);
- ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
- check_results(reporter, line2, line1, ts);
- }
- if (line2[0].fX == line2[1].fX) {
- double top = SkTMin(line2[0].fY, line2[1].fY);
- double bottom = SkTMax(line2[0].fY, line2[1].fY);
- ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
- check_results(reporter, line1, line2, ts);
- }
+ testOne(reporter, line1, line2);
+ reporter->bumpTestCount();
}
for (index = 0; index < noIntersect_count; ++index) {
const SkDLine& line1 = noIntersect[index][0];
@@ -93,8 +137,29 @@ static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) {
int pts = ts.intersect(line1, line2);
REPORTER_ASSERT(reporter, !pts);
REPORTER_ASSERT(reporter, pts == ts.used());
+ reporter->bumpTestCount();
}
}
+static void PathOpsLineIntersectionTestOne(skiatest::Reporter* reporter) {
+ int index = 0;
+ SkASSERT(index < (int) tests_count);
+ const SkDLine& line1 = tests[index][0];
+ const SkDLine& line2 = tests[index][1];
+ testOne(reporter, line1, line2);
+}
+
+static void PathOpsLineIntersectionTestOneCoincident(skiatest::Reporter* reporter) {
+ int index = 0;
+ SkASSERT(index < (int) coincidentTests_count);
+ const SkDLine& line1 = coincidentTests[index][0];
+ const SkDLine& line2 = coincidentTests[index][1];
+ testOneCoincident(reporter, line1, line2);
+}
+
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTestOne)
+
+DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTestOneCoincident)
diff --git a/tests/PathOpsOpTest.cpp b/tests/PathOpsOpTest.cpp
index 9a48f7812f..e06bc8f57c 100644
--- a/tests/PathOpsOpTest.cpp
+++ b/tests/PathOpsOpTest.cpp
@@ -1144,7 +1144,6 @@ static void cubicOp69d(skiatest::Reporter* reporter) {
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
-
SkPathOp ops[] = {
kUnion_PathOp,
kXOR_PathOp,
@@ -1572,7 +1571,6 @@ static void skpClip1(skiatest::Reporter* reporter) {
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
-#if 1 // FIXME: work in progress -- coincident cubic undetected
static void skpClip2(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
@@ -1598,14 +1596,152 @@ static void skpClip2(skiatest::Reporter* reporter) {
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
+
+static void skp96prezzi1(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(157.464005f, 670.463989f);
+ path.quadTo(158.928925f, 669.000000f, 161.000000f, 669.000000f);
+ path.lineTo(248.000000f, 669.000000f);
+ path.quadTo(250.071075f, 669.000000f, 251.535995f, 670.463989f);
+ path.quadTo(253.000000f, 671.928955f, 253.000000f, 674.000000f);
+ path.lineTo(253.000000f, 706.000000f);
+ path.lineTo(251.000000f, 706.000000f);
+ path.lineTo(251.000000f, 675.000000f);
+ path.cubicTo(251.000000f, 672.790833f, 249.209137f, 671.000000f, 247.000000f, 671.000000f);
+ path.lineTo(162.000000f, 671.000000f);
+ path.cubicTo(159.790863f, 671.000000f, 158.000000f, 672.790833f, 158.000000f, 675.000000f);
+ path.lineTo(158.000000f, 706.000000f);
+ path.lineTo(156.000000f, 706.000000f);
+ path.lineTo(156.000000f, 674.000000f);
+ path.quadTo(156.000000f, 671.928955f, 157.464005f, 670.463989f);
+ path.close();
+ SkPath pathB;
+ pathB.setFillType(SkPath::kWinding_FillType);
+ pathB.moveTo(156.000000f, 669.000000f);
+ pathB.lineTo(178.500000f, 691.500000f);
+ pathB.lineTo(230.500000f, 691.500000f);
+ pathB.lineTo(253.000000f, 669.000000f);
+ pathB.lineTo(156.000000f, 669.000000f);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+}
+
+static void skpancestry_com1(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(161.000000f, 925.000000f);
+ path.cubicTo(159.874390f, 925.000000f, 158.835663f, 925.371948f, 158.000000f, 925.999634f);
+ path.lineTo(158.000000f, 926.000000f);
+ path.lineTo(1108.00000f, 926.000000f);
+ path.lineTo(1108.00000f, 925.999634f);
+ path.cubicTo(1107.16443f, 925.371948f, 1106.12561f, 925.000000f, 1105.00000f, 925.000000f);
+ path.lineTo(161.000000f, 925.000000f);
+ path.close();
+ SkPath pathB;
+ pathB.setFillType(SkPath::kEvenOdd_FillType);
+ pathB.moveTo(161.000000f, 926.000000f);
+ pathB.lineTo(1105.00000f, 926.000000f);
+ pathB.cubicTo(1107.20911f, 926.000000f, 1109.00000f, 927.790833f, 1109.00000f, 930.000000f);
+ pathB.lineTo(1109.00000f, 956.000000f);
+ pathB.cubicTo(1109.00000f, 958.209167f, 1107.20911f, 960.000000f, 1105.00000f, 960.000000f);
+ pathB.lineTo(161.000000f, 960.000000f);
+ pathB.cubicTo(158.790863f, 960.000000f, 157.000000f, 958.209167f, 157.000000f, 956.000000f);
+ pathB.lineTo(157.000000f, 930.000000f);
+ pathB.cubicTo(157.000000f, 927.790833f, 158.790863f, 926.000000f, 161.000000f, 926.000000f);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+}
+
+static void skpeldorado_com_ua1(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(286.695129f, 291.000000f);
+ path.lineTo(229.304855f, 561.000000f);
+ path.lineTo(979.304871f, 561.000000f);
+ path.lineTo(1036.69507f, 291.000000f);
+ path.lineTo(286.695129f, 291.000000f);
+ path.close();
+ SkPath pathB;
+ pathB.setFillType(SkPath::kWinding_FillType);
+ pathB.moveTo(1006.69513f, 291.000000f);
+ pathB.cubicTo(1023.26367f, 291.000000f, 1033.84021f, 304.431458f, 1030.31836f, 321.000000f);
+ pathB.lineTo(985.681519f, 531.000000f);
+ pathB.cubicTo(982.159790f, 547.568542f, 965.873413f, 561.000000f, 949.304871f, 561.000000f);
+ pathB.lineTo(259.304871f, 561.000000f);
+ pathB.cubicTo(242.736313f, 561.000000f, 232.159805f, 547.568542f, 235.681549f, 531.000000f);
+ pathB.lineTo(280.318420f, 321.000000f);
+ pathB.cubicTo(283.840179f, 304.431458f, 300.126587f, 291.000000f, 316.695129f, 291.000000f);
+ pathB.lineTo(1006.69513f, 291.000000f);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+}
+
+static void skpbyte_com1(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(968.000000f, 14.0000000f);
+ path.cubicTo(965.238586f, 14.0000000f, 963.000000f, 16.2385769f, 963.000000f, 19.0000000f);
+ path.lineTo(963.000000f, 32.0000000f);
+ path.cubicTo(963.000000f, 34.7614250f, 965.238586f, 37.0000000f, 968.000000f, 37.0000000f);
+ path.lineTo(1034.00000f, 37.0000000f);
+ path.cubicTo(1036.76147f, 37.0000000f, 1039.00000f, 34.7614250f, 1039.00000f, 32.0000000f);
+ path.lineTo(1039.00000f, 19.0000000f);
+ path.cubicTo(1039.00000f, 16.2385769f, 1036.76147f, 14.0000000f, 1034.00000f, 14.0000000f);
+ path.lineTo(968.000000f, 14.0000000f);
+ path.close();
+ SkPath pathB;
+ pathB.setFillType(SkPath::kInverseWinding_FillType);
+ pathB.moveTo(968.000000f, 14.0000000f);
+ pathB.lineTo(1034.00000f, 14.0000000f);
+ pathB.cubicTo(1036.76147f, 14.0000000f, 1039.00000f, 16.2385750f, 1039.00000f, 19.0000000f);
+ pathB.lineTo(1039.00000f, 32.0000000f);
+ pathB.cubicTo(1039.00000f, 34.2091408f, 1036.76147f, 36.0000000f, 1034.00000f, 36.0000000f);
+ pathB.lineTo(968.000000f, 36.0000000f);
+ pathB.cubicTo(965.238586f, 36.0000000f, 963.000000f, 34.2091408f, 963.000000f, 32.0000000f);
+ pathB.lineTo(963.000000f, 19.0000000f);
+ pathB.cubicTo(963.000000f, 16.2385750f, 965.238586f, 14.0000000f, 968.000000f, 14.0000000f);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+}
+
+static void skphealth_com76(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(708.099182f, 7.09919119f);
+ path.lineTo(708.099182f, 7.09920025f);
+ path.quadTo(704.000000f, 11.2010098f, 704.000000f, 17.0000000f);
+ path.lineTo(704.000000f, 33.0000000f);
+ path.lineTo(705.000000f, 33.0000000f);
+ path.lineTo(705.000000f, 17.0000000f);
+ path.cubicTo(705.000000f, 13.4101496f, 706.455078f, 10.1601505f, 708.807617f, 7.80761385f);
+ path.lineTo(708.099182f, 7.09919119f);
+ path.close();
+ SkPath pathB;
+ pathB.setFillType(SkPath::kWinding_FillType);
+ pathB.moveTo(704.000000f, 3.00000000f);
+#if 0
+ pathB.lineTo(719.500000f, 3.00000000f);
+ pathB.lineTo(705.000000f, 33.0000000f);
+ pathB.lineTo(704.000000f, 33.0000000f);
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
+#else
+ pathB.lineTo(704.000000f, 33.0000000f);
+ pathB.lineTo(705.000000f, 33.0000000f);
+ pathB.lineTo(719.500000f, 3.00000000f);
+ testPathOp(reporter, path, pathB, kIntersect_PathOp);
#endif
+}
static void (*firstTest)(skiatest::Reporter* ) = 0;
static struct TestDesc tests[] = {
-#if 1 // FIXME: work in progress -- coincident cubic undetected
+ TEST(skphealth_com76),
+ TEST(skpancestry_com1),
+ TEST(skpbyte_com1),
+ TEST(skpeldorado_com_ua1),
+ TEST(skp96prezzi1),
TEST(skpClip2),
-#endif
TEST(skpClip1),
TEST(cubicOp84d),
TEST(cubicOp83i),
@@ -1746,6 +1882,9 @@ static void PathOpsOpTest(skiatest::Reporter* reporter) {
gDebugMaxWindSum = 4;
gDebugMaxWindValue = 4;
#endif
+#if DEBUG_SHOW_TEST_NAME
+ strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
+#endif
if (runSubTestsFirst) {
RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, runReverse);
}
diff --git a/tests/PathOpsSimplifyTest.cpp b/tests/PathOpsSimplifyTest.cpp
index fe5f4e145d..85f6685c3f 100644
--- a/tests/PathOpsSimplifyTest.cpp
+++ b/tests/PathOpsSimplifyTest.cpp
@@ -2859,33 +2859,33 @@ path.close();
static void testQuadratic58(skiatest::Reporter* reporter) {
SkPath path;
-path.moveTo(283.714233f, 240);
-path.lineTo(283.714233f, 141.299606f);
-path.lineTo(303.12088f, 141.299606f);
-path.lineTo(330.463562f, 217.659027f);
-path.lineTo(358.606506f, 141.299606f);
-path.lineTo(362.874634f, 159.705902f);
-path.lineTo(335.665344f, 233.397751f);
-path.lineTo(322.12738f, 233.397751f);
-path.lineTo(295.718353f, 159.505829f);
-path.lineTo(295.718353f, 240);
-path.lineTo(283.714233f, 240);
-path.close();
-path.moveTo(322.935669f, 231.030273f);
-path.quadTo(312.832214f, 220.393295f, 312.832214f, 203.454178f);
-path.quadTo(312.832214f, 186.981888f, 321.73526f, 176.444946f);
-path.quadTo(330.638306f, 165.90802f, 344.509705f, 165.90802f);
-path.quadTo(357.647522f, 165.90802f, 364.81665f, 175.244537f);
-path.lineTo(371.919067f, 205.854996f);
-path.lineTo(326.236786f, 205.854996f);
-path.quadTo(329.104431f, 231.663818f, 351.512085f, 231.663818f);
-path.lineTo(322.935669f, 231.030273f);
-path.close();
-path.moveTo(326.837006f, 195.984955f);
-path.lineTo(358.78125f, 195.984955f);
-path.quadTo(358.78125f, 175.778046f, 343.709442f, 175.778046f);
-path.quadTo(328.570923f, 175.778046f, 326.837006f, 195.984955f);
-path.close();
+ path.moveTo(283.714233f, 240);
+ path.lineTo(283.714233f, 141.299606f);
+ path.lineTo(303.12088f, 141.299606f);
+ path.lineTo(330.463562f, 217.659027f);
+ path.lineTo(358.606506f, 141.299606f);
+ path.lineTo(362.874634f, 159.705902f);
+ path.lineTo(335.665344f, 233.397751f);
+ path.lineTo(322.12738f, 233.397751f);
+ path.lineTo(295.718353f, 159.505829f);
+ path.lineTo(295.718353f, 240);
+ path.lineTo(283.714233f, 240);
+ path.close();
+ path.moveTo(322.935669f, 231.030273f);
+ path.quadTo(312.832214f, 220.393295f, 312.832214f, 203.454178f);
+ path.quadTo(312.832214f, 186.981888f, 321.73526f, 176.444946f);
+ path.quadTo(330.638306f, 165.90802f, 344.509705f, 165.90802f);
+ path.quadTo(357.647522f, 165.90802f, 364.81665f, 175.244537f);
+ path.lineTo(371.919067f, 205.854996f);
+ path.lineTo(326.236786f, 205.854996f);
+ path.quadTo(329.104431f, 231.663818f, 351.512085f, 231.663818f);
+ path.lineTo(322.935669f, 231.030273f);
+ path.close();
+ path.moveTo(326.837006f, 195.984955f);
+ path.lineTo(358.78125f, 195.984955f);
+ path.quadTo(358.78125f, 175.778046f, 343.709442f, 175.778046f);
+ path.quadTo(328.570923f, 175.778046f, 326.837006f, 195.984955f);
+ path.close();
testSimplify(reporter, path);
}
@@ -3557,7 +3557,6 @@ static void testCubic2(skiatest::Reporter* reporter) {
testSimplify(reporter, path);
}
-#if 01 // FIXME: enable and fix
static void testQuad1(skiatest::Reporter* reporter) {
SkPath path;
path.moveTo(0,0);
@@ -3569,7 +3568,6 @@ static void testQuad1(skiatest::Reporter* reporter) {
path.close();
testSimplify(reporter, path);
}
-#endif
static void testQuadralateral2(skiatest::Reporter* reporter) {
SkPath path;
@@ -3811,9 +3809,29 @@ static void testQuadLineIntersect3(skiatest::Reporter* reporter) {
testSimplify(reporter, path);
}
+static void skphealth_com76(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.setFillType(SkPath::kWinding_FillType);
+ path.moveTo(708.099182f, 7.09919119f);
+ path.lineTo(708.099182f, 7.09920025f);
+ path.quadTo(704.000000f, 11.2010098f, 704.000000f, 17.0000000f);
+ path.lineTo(704.000000f, 33.0000000f);
+ path.lineTo(705.000000f, 33.0000000f);
+ path.lineTo(705.000000f, 17.0000000f);
+ path.cubicTo(705.000000f, 13.4101496f, 706.455078f, 10.1601505f, 708.807617f, 7.80761385f);
+ path.lineTo(708.099182f, 7.09919119f);
+ path.close();
+ path.moveTo(704.000000f, 3.00000000f);
+ path.lineTo(704.000000f, 33.0000000f);
+ path.lineTo(705.000000f, 33.0000000f);
+ path.lineTo(719.500000f, 3.00000000f);
+ testSimplify(reporter, path);
+}
+
static void (*firstTest)(skiatest::Reporter* ) = 0;
static TestDesc tests[] = {
+ TEST(skphealth_com76),
TEST(testQuadLineIntersect1),
TEST(testQuadLineIntersect2),
TEST(testQuadLineIntersect3),
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index 98e55539ef..f46ad976d5 100644
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -1,3 +1,5 @@
+#include "PathOpsExtendedTest.h"
+#include "PathOpsThreadedCommon.h"
#include "SkBitmap.h"
#include "SkDevice.h"
#include "SkCanvas.h"
@@ -7,60 +9,143 @@
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkString.h"
-#include "Test.h"
+
+#ifdef SK_BUILD_FOR_WIN
+#define PATH_SLASH "\\"
+#define IN_DIR "D:" PATH_SLASH "skp"
+#define OUT_DIR "D:" PATH_SLASH
+#else
+#define PATH_SLASH "/"
+#define IN_DIR "/Volumes/Untitled" PATH_SLASH
+#define OUT_DIR PATH_SLASH
+#endif
+
+static const char pictDir[] = IN_DIR ;
+static const char outSkpClipDir[] = OUT_DIR "skpClip";
+static const char outOldClipDir[] = OUT_DIR "oldClip";
static void make_filepath(SkString* path, const char* dir, const SkString& name) {
size_t len = strlen(dir);
path->set(dir);
- if (len > 0 && dir[len - 1] != '/') {
- path->append("\\");
+ if (len > 0 && dir[len - 1] != PATH_SLASH[0]) {
+ path->append(PATH_SLASH);
}
path->append(name);
}
+static void testOne(const SkString& filename) {
+#if DEBUG_SHOW_TEST_NAME
+ SkString testName(filename);
+ const char http[] = "http";
+ if (testName.startsWith(http)) {
+ testName.remove(0, sizeof(http) - 1);
+ }
+ while (testName.startsWith("_")) {
+ testName.remove(0, 1);
+ }
+ const char dotSkp[] = ".skp";
+ if (testName.endsWith(dotSkp)) {
+ size_t len = testName.size();
+ testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1);
+ }
+ testName.prepend("skp");
+ testName.append("1");
+ strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGTH);
+#endif
+ SkString path;
+ make_filepath(&path, pictDir, filename);
+ SkFILEStream stream(path.c_str());
+ if (!stream.isValid()) {
+ return;
+ }
+ bool success;
+ SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecoder::DecodeMemory));
+ if (!success) {
+ SkDebugf("unable to decode %s\n", filename.c_str());
+ return;
+ }
+ int width = pic->width();
+ int height = pic->height();
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ success = bitmap.allocPixels();
+ if (!success) {
+ SkDebugf("unable to allocate bitmap for %s\n", filename.c_str());
+ return;
+ }
+ SkCanvas canvas(bitmap);
+ SkString pngName(filename);
+ pngName.remove(pngName.size() - 3, 3);
+ pngName.append("png");
+ for (int i = 0; i < 2; ++i) {
+ bool useOp = i ? true : false;
+ canvas.setAllowSimplifyClip(useOp);
+ pic->draw(&canvas);
+ SkString outFile;
+ make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, pngName);
+ SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
+ }
+ SkDELETE(pic);
+}
+
+const char skipBefore[] = "http___health_com.skp";
+
static void PathOpsSkpClipTest(skiatest::Reporter* reporter) {
- const char pictDir[] = "D:\\skp";
- const char outSkpClipDir[] = "D:\\skpClip";
- const char outOldClipDir[] = "D:\\oldClip";
SkOSFile::Iter iter(pictDir, "skp");
SkString filename;
+ int testCount = 0;
while (iter.next(&filename)) {
-#if 01
- if (strcmp(filename.c_str(), "desk_15min-lt.skp")) {
+ if (strcmp(filename.c_str(), skipBefore) < 0) {
continue;
}
-#endif
- SkString path;
- make_filepath(&path, pictDir, filename);
- SkFILEStream stream(path.c_str());
- if (!stream.isValid()) {
- continue;
+ testOne(filename);
+ if (reporter->verbose()) {
+ SkDebugf(".");
+ if (++testCount % 100 == 0) {
+ SkDebugf("\n");
+ }
}
- bool success;
- SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecoder::DecodeMemory));
- if (!success) {
- continue;
+ reporter->bumpTestCount();
+ }
+}
+
+static void testSkpClipMain(PathOpsThreadState* data) {
+ SkString str(data->fSerialNo);
+ testOne(str);
+ if (data->fReporter->verbose()) {
+ SkDebugf(".");
+ static int threadTestCount;
+ sk_atomic_inc(&threadTestCount);
+ if (threadTestCount % 100 == 0) {
+ SkDebugf("\n");
+ }
}
- int width = pic->width();
- int height = pic->height();
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap.allocPixels();
- SkCanvas canvas(bitmap);
- filename.remove(filename.size() - 3, 3);
- filename.append("png");
- for (int i = 0; i < 2; ++i) {
- bool useOp = i ? true : false;
- canvas.setAllowSimplifyClip(useOp);
- pic->draw(&canvas);
- SkString outFile;
- make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, filename);
- SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
+}
+
+static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) {
+ int threadCount = initializeTests(reporter, "skpClipThreadedTest");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
+ SkOSFile::Iter iter(pictDir, "skp");
+ SkString filename;
+ while (iter.next(&filename)) {
+ if (strcmp(filename.c_str(), skipBefore) < 0) {
+ continue;
}
- SkDELETE(pic);
+ *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
+ (&testSkpClipMain, filename.c_str(), &testRunner));
reporter->bumpTestCount();
}
+ testRunner.render();
+}
+
+static void PathOpsSkpClipTestOne(skiatest::Reporter* reporter) {
+ SkString filename(skipBefore);
+ testOne(filename);
}
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest)
+
+DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTestOne)
+
+DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest)
diff --git a/tests/PathOpsThreadedCommon.h b/tests/PathOpsThreadedCommon.h
index 833f24fe5d..e6d3bed725 100644
--- a/tests/PathOpsThreadedCommon.h
+++ b/tests/PathOpsThreadedCommon.h
@@ -25,7 +25,7 @@ struct PathOpsThreadState {
unsigned char fD;
char* fPathStr;
const char* fKey;
- char fSerialNo[9];
+ char fSerialNo[64];
skiatest::Reporter* fReporter;
SkBitmap* fBitmap;
};
@@ -59,6 +59,14 @@ public:
fTestFun = testFun;
}
+ PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), const char* str,
+ PathOpsThreadedTestRunner* runner) {
+ SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1);
+ strcpy(fState.fSerialNo, str);
+ fState.fReporter = runner->fReporter;
+ fTestFun = testFun;
+ }
+
virtual void run() SK_OVERRIDE {
SkBitmap bitmap;
fState.fBitmap = &bitmap;
diff --git a/tests/Test.h b/tests/Test.h
index fa62afeab3..27b31df94d 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -33,6 +33,7 @@ namespace skiatest {
virtual bool allowExtendedTest() const { return false; }
virtual bool allowThreaded() const { return false; }
+ virtual bool verbose() const { return false; }
virtual void bumpTestCount() { sk_atomic_inc(&fTestCount); }
protected:
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 98168c55dd..dc1015d6d5 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -57,12 +57,13 @@ private:
class DebugfReporter : public Reporter {
public:
- DebugfReporter(bool allowExtendedTest, bool allowThreaded)
+ DebugfReporter(bool allowExtendedTest, bool allowThreaded, bool verbose)
: fNextIndex(0)
, fPending(0)
, fTotal(0)
, fAllowExtendedTest(allowExtendedTest)
- , fAllowThreaded(allowThreaded) {
+ , fAllowThreaded(allowThreaded)
+ , fVerbose(verbose) {
}
void setTotal(int total) {
@@ -77,6 +78,10 @@ public:
return fAllowThreaded;
}
+ virtual bool verbose() const SK_OVERRIDE {
+ return fVerbose;
+ }
+
protected:
virtual void onStart(Test* test) {
const int index = sk_atomic_inc(&fNextIndex);
@@ -106,6 +111,7 @@ private:
int fTotal;
bool fAllowExtendedTest;
bool fAllowThreaded;
+ bool fVerbose;
};
DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n" \
@@ -231,7 +237,7 @@ int tool_main(int argc, char** argv) {
SkDebugf("%s\n", header.c_str());
}
- DebugfReporter reporter(FLAGS_extendedTest, FLAGS_threaded);
+ DebugfReporter reporter(FLAGS_extendedTest, FLAGS_threaded, FLAGS_verbose);
Iter iter(&reporter);
// Count tests first.