Skip to content

Commit

Permalink
dump pathops tests as hex json
Browse files Browse the repository at this point in the history
Dump as hex instead of SVG to more accurately
capture pathops tests.

Use SkBits2Float to reconstruct SkScalar data.

Exclude tests with conics since, for the moment,
pathkit maps conics to quads.

R=kjlubick@google.com

Bug: skia:
Change-Id: Iba2836bde8f737f42c8da31cc26e83ce55de924a
Reviewed-on: https://skia-review.googlesource.com/146165
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Cary Clark <caryclark@skia.org>
  • Loading branch information
Cary Clark authored and Skia Commit-Bot committed Aug 8, 2018
1 parent ce1db86 commit 9c9611f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/PathOpsDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
bool PathOpsDebug::gJson;
bool PathOpsDebug::gOutFirst;
bool PathOpsDebug::gCheckForDuplicateNames;
bool PathOpsDebug::gOutputSVG;
FILE* PathOpsDebug::gOut;

inline void DebugDumpDouble(double x) {
Expand Down
1 change: 1 addition & 0 deletions tests/PathOpsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PathOpsDebug {
static bool gJson;
static bool gOutFirst;
static bool gCheckForDuplicateNames;
static bool gOutputSVG;
static FILE* gOut;
};

Expand Down
59 changes: 56 additions & 3 deletions tests/PathOpsExtendedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,43 @@ static void json_path_out(const SkPath& path, const char* pathName, const char*
"InverseWinding",
"InverseEvenOdd",
};
SkString svg;
SkParsePath::ToSVGString(path, &svg);
fprintf(PathOpsDebug::gOut, " \"%s\": \"%s\",\n", pathName, svg.c_str());
if (PathOpsDebug::gOutputSVG) {
SkString svg;
SkParsePath::ToSVGString(path, &svg);
fprintf(PathOpsDebug::gOut, " \"%s\": \"%s\",\n", pathName, svg.c_str());
} else {
SkPath::RawIter iter(path);
SkPath::Verb verb;
// MOVE, LINE, QUAD, CONIC, CUBIC, CLOSE
const int verbConst[] = { 0, 1, 2, 3, 4, 5 };
const int pointIndex[] = { 0, 1, 1, 1, 1, 0 };
const int pointCount[] = { 1, 2, 3, 3, 4, 0 };
fprintf(PathOpsDebug::gOut, " \"%s\": [", pathName);
bool first = true;
do {
SkPoint points[4];
verb = iter.next(points);
if (SkPath::kDone_Verb == verb) {
break;
}
if (first) {
first = false;
} else {
fprintf(PathOpsDebug::gOut, ",\n ");
}
int verbIndex = (int) verb;
fprintf(PathOpsDebug::gOut, "[%d", verbConst[verbIndex]);
for (int i = pointIndex[verbIndex]; i < pointCount[verbIndex]; ++i) {
fprintf(PathOpsDebug::gOut, ", \"0x%08x\", \"0x%08x\"",
SkFloat2Bits(points[i].fX), SkFloat2Bits(points[i].fY));
}
if (SkPath::kConic_Verb == verb) {
fprintf(PathOpsDebug::gOut, ", \"0x%08x\"", SkFloat2Bits(iter.conicWeight()));
}
fprintf(PathOpsDebug::gOut, "]");
} while (SkPath::kDone_Verb != verb);
fprintf(PathOpsDebug::gOut, "],\n");
}
fprintf(PathOpsDebug::gOut, " \"fillType%s\": \"k%s_FillType\"%s", fillTypeName,
gFillTypeStrs[(int) path.getFillType()], lastField ? "\n}" : ",\n");
}
Expand All @@ -514,12 +548,28 @@ static bool check_for_duplicate_names(const char* testName) {
return false;
}

static bool check_for_conics(const SkPath& path) {
SkPath::RawIter iter(path);
SkPath::Verb verb;
do {
SkPoint pts[4];
verb = iter.next(pts);
if (SkPath::kConic_Verb == verb) {
return true;
}
} while (SkPath::kDone_Verb != verb);
return false;
}

static bool inner_simplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename,
ExpectSuccess expectSuccess, SkipAssert skipAssert, ExpectMatch expectMatch) {
#if 0 && DEBUG_SHOW_TEST_NAME
showPathData(path);
#endif
if (PathOpsDebug::gJson) {
if (check_for_conics(path)) {
return true;
}
if (check_for_duplicate_names(filename)) {
return true;
}
Expand Down Expand Up @@ -604,6 +654,9 @@ static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
showName(a, b, shapeOp);
#endif
if (PathOpsDebug::gJson) {
if (check_for_conics(a) || check_for_conics(b)) {
return true;
}
if (check_for_duplicate_names(testName)) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions tests/skia_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ int main(int argc, char** argv) {
SkPathOpsDebug::gVeryVerbose = FLAGS_veryVerbose;
PathOpsDebug::gOutFirst = true;
PathOpsDebug::gCheckForDuplicateNames = false;
PathOpsDebug::gOutputSVG = false;
if ((PathOpsDebug::gJson = !FLAGS_json.isEmpty())) {
PathOpsDebug::gOut = fopen(FLAGS_json[0], "wb");
fprintf(PathOpsDebug::gOut, "{\n");
Expand Down

0 comments on commit 9c9611f

Please sign in to comment.