dump pathops tests as hex json
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>
This commit is contained in:
parent
ce1db863ef
commit
9c9611fcc1
@ -17,6 +17,7 @@
|
||||
bool PathOpsDebug::gJson;
|
||||
bool PathOpsDebug::gOutFirst;
|
||||
bool PathOpsDebug::gCheckForDuplicateNames;
|
||||
bool PathOpsDebug::gOutputSVG;
|
||||
FILE* PathOpsDebug::gOut;
|
||||
|
||||
inline void DebugDumpDouble(double x) {
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
static bool gJson;
|
||||
static bool gOutFirst;
|
||||
static bool gCheckForDuplicateNames;
|
||||
static bool gOutputSVG;
|
||||
static FILE* gOut;
|
||||
};
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user