| Index: src/pathops/SkPathOpsDebug.cpp
|
| diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp
|
| index 0331f34e8a74d91ffb34f8b6d0b0d7f88f7cab25..61bca42fcf31aa6892c7639181c3c72aeb7b388c 100644
|
| --- a/src/pathops/SkPathOpsDebug.cpp
|
| +++ b/src/pathops/SkPathOpsDebug.cpp
|
| @@ -7,9 +7,8 @@
|
|
|
| #include "SkPathOpsDebug.h"
|
| #include "SkPath.h"
|
| -#if DEBUG_ANGLE
|
| #include "SkString.h"
|
| -#endif
|
| +#include "SkThread.h"
|
|
|
| #if DEBUG_VALIDATE
|
| extern bool FLAGS_runFail;
|
| @@ -101,10 +100,36 @@ void SkPathOpsDebug::BumpTestName(char* test) {
|
| }
|
| #endif
|
|
|
| -#if !DEBUG_SHOW_TEST_NAME // enable when building without extended test
|
| -void SkPathOpsDebug::ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name) {
|
| +static void show_function_header(const char* functionName) {
|
| + SkDebugf("\nstatic void %s(skiatest::Reporter* reporter, const char* filename) {\n", functionName);
|
| + if (strcmp("skphealth_com76", functionName) == 0) {
|
| + SkDebugf("found it\n");
|
| + }
|
| +}
|
| +
|
| +static const char* gOpStrs[] = {
|
| + "kDifference_SkPathOp",
|
| + "kIntersect_SkPathOp",
|
| + "kUnion_SkPathOp",
|
| + "kXor_PathOp",
|
| + "kReverseDifference_SkPathOp",
|
| +};
|
| +
|
| +static void show_op(SkPathOp op, const char* pathOne, const char* pathTwo) {
|
| + SkDebugf(" testPathOp(reporter, %s, %s, %s, filename);\n", pathOne, pathTwo, gOpStrs[op]);
|
| + SkDebugf("}\n");
|
| +}
|
| +
|
| +SK_DECLARE_STATIC_MUTEX(gTestMutex);
|
| +
|
| +void SkPathOpsDebug::ShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp,
|
| + const char* testName) {
|
| + SkAutoMutexAcquire ac(gTestMutex);
|
| + show_function_header(testName);
|
| + ShowOnePath(a, "path", true);
|
| + ShowOnePath(b, "pathB", true);
|
| + show_op(shapeOp, "path", "pathB");
|
| }
|
| -#endif
|
|
|
| #include "SkOpAngle.h"
|
| #include "SkOpSegment.h"
|
| @@ -134,7 +159,7 @@ SkOpAngle* SkOpSegment::debugLastAngle() {
|
| }
|
|
|
| void SkOpSegment::debugReset() {
|
| - this->init(this->fPts, this->contour(), this->verb());
|
| + this->init(this->fPts, this->fWeight, this->contour(), this->verb());
|
| }
|
|
|
| #if DEBUG_ACTIVE_SPANS
|
| @@ -150,16 +175,19 @@ void SkOpSegment::debugShowActiveSpans() const {
|
| if (span->done()) {
|
| continue;
|
| }
|
| - if (lastId == fID && lastT == span->t()) {
|
| + if (lastId == this->debugID() && lastT == span->t()) {
|
| continue;
|
| }
|
| - lastId = fID;
|
| + lastId = this->debugID();
|
| lastT = span->t();
|
| - SkDebugf("%s id=%d", __FUNCTION__, fID);
|
| + SkDebugf("%s id=%d", __FUNCTION__, this->debugID());
|
| SkDebugf(" (%1.9g,%1.9g", fPts[0].fX, fPts[0].fY);
|
| for (int vIndex = 1; vIndex <= SkPathOpsVerbToPoints(fVerb); ++vIndex) {
|
| SkDebugf(" %1.9g,%1.9g", fPts[vIndex].fX, fPts[vIndex].fY);
|
| }
|
| + if (SkPath::kConic_Verb == fVerb) {
|
| + SkDebugf(" %1.9gf", fWeight);
|
| + }
|
| const SkOpPtT* ptT = span->ptT();
|
| SkDebugf(") t=%1.9g (%1.9g,%1.9g)", ptT->fT, ptT->fPt.fX, ptT->fPt.fY);
|
| SkDebugf(" tEnd=%1.9g", span->next()->t());
|
| @@ -178,7 +206,7 @@ void SkOpSegment::debugShowActiveSpans() const {
|
| #if DEBUG_MARK_DONE
|
| void SkOpSegment::debugShowNewWinding(const char* fun, const SkOpSpan* span, int winding) {
|
| const SkPoint& pt = span->ptT()->fPt;
|
| - SkDebugf("%s id=%d", fun, fID);
|
| + SkDebugf("%s id=%d", fun, this->debugID());
|
| SkDebugf(" (%1.9g,%1.9g", fPts[0].fX, fPts[0].fY);
|
| for (int vIndex = 1; vIndex <= SkPathOpsVerbToPoints(fVerb); ++vIndex) {
|
| SkDebugf(" %1.9g,%1.9g", fPts[vIndex].fX, fPts[vIndex].fY);
|
| @@ -202,7 +230,7 @@ void SkOpSegment::debugShowNewWinding(const char* fun, const SkOpSpan* span, int
|
| void SkOpSegment::debugShowNewWinding(const char* fun, const SkOpSpan* span, int winding,
|
| int oppWinding) {
|
| const SkPoint& pt = span->ptT()->fPt;
|
| - SkDebugf("%s id=%d", fun, fID);
|
| + SkDebugf("%s id=%d", fun, this->debugID());
|
| SkDebugf(" (%1.9g,%1.9g", fPts[0].fX, fPts[0].fY);
|
| for (int vIndex = 1; vIndex <= SkPathOpsVerbToPoints(fVerb); ++vIndex) {
|
| SkDebugf(" %1.9g,%1.9g", fPts[vIndex].fX, fPts[vIndex].fY);
|
| @@ -249,6 +277,11 @@ SkString SkOpAngle::debugPart() const {
|
| result.printf(QUAD_DEBUG_STR " id=%d", QUAD_DEBUG_DATA(fCurvePart),
|
| this->segment()->debugID());
|
| break;
|
| + case SkPath::kConic_Verb:
|
| + result.printf(CONIC_DEBUG_STR " id=%d",
|
| + CONIC_DEBUG_DATA(fCurvePart, fCurvePart.fConic.fWeight),
|
| + this->segment()->debugID());
|
| + break;
|
| case SkPath::kCubic_Verb:
|
| result.printf(CUBIC_DEBUG_STR " id=%d", CUBIC_DEBUG_DATA(fCurvePart),
|
| this->segment()->debugID());
|
| @@ -471,3 +504,107 @@ void SkOpPtT::debugValidate() const {
|
| SkASSERT(debugLoopLimit(false) == 0);
|
| #endif
|
| }
|
| +
|
| +static void output_scalar(SkScalar num) {
|
| + if (num == (int) num) {
|
| + SkDebugf("%d", (int) num);
|
| + } else {
|
| + SkString str;
|
| + str.printf("%1.9g", num);
|
| + int width = (int) str.size();
|
| + const char* cStr = str.c_str();
|
| + while (cStr[width - 1] == '0') {
|
| + --width;
|
| + }
|
| + str.resize(width);
|
| + SkDebugf("%sf", str.c_str());
|
| + }
|
| +}
|
| +
|
| +static void output_points(const SkPoint* pts, int count) {
|
| + for (int index = 0; index < count; ++index) {
|
| + output_scalar(pts[index].fX);
|
| + SkDebugf(", ");
|
| + output_scalar(pts[index].fY);
|
| + if (index + 1 < count) {
|
| + SkDebugf(", ");
|
| + }
|
| + }
|
| +}
|
| +
|
| +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(" %s.moveTo(", pathName);
|
| + output_points(&pts[0], 1);
|
| + SkDebugf(");\n");
|
| + continue;
|
| + case SkPath::kLine_Verb:
|
| + SkDebugf(" %s.lineTo(", pathName);
|
| + output_points(&pts[1], 1);
|
| + SkDebugf(");\n");
|
| + break;
|
| + case SkPath::kQuad_Verb:
|
| + SkDebugf(" %s.quadTo(", pathName);
|
| + output_points(&pts[1], 2);
|
| + SkDebugf(");\n");
|
| + break;
|
| + case SkPath::kConic_Verb:
|
| + SkDebugf(" %s.conicTo(", pathName);
|
| + output_points(&pts[1], 2);
|
| + SkDebugf(", %1.9gf);\n", iter.conicWeight());
|
| + break;
|
| + case SkPath::kCubic_Verb:
|
| + SkDebugf(" %s.cubicTo(", pathName);
|
| + output_points(&pts[1], 3);
|
| + SkDebugf(");\n");
|
| + break;
|
| + case SkPath::kClose_Verb:
|
| + SkDebugf(" %s.close();\n", pathName);
|
| + break;
|
| + default:
|
| + SkDEBUGFAIL("bad verb");
|
| + return;
|
| + }
|
| + }
|
| +}
|
| +
|
| +static const char* gFillTypeStr[] = {
|
| + "kWinding_FillType",
|
| + "kEvenOdd_FillType",
|
| + "kInverseWinding_FillType",
|
| + "kInverseEvenOdd_FillType"
|
| +};
|
| +
|
| +void SkPathOpsDebug::ShowOnePath(const SkPath& path, const char* name, 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;
|
| + if (rectCount > 0) {
|
| + SkTDArray<SkRect> rects;
|
| + SkTDArray<SkPath::Direction> directions;
|
| + rects.setCount(rectCount);
|
| + directions.setCount(rectCount);
|
| + path.rectContours(rects.begin(), directions.begin());
|
| + for (int contour = 0; contour < rectCount; ++contour) {
|
| + const SkRect& rect = rects[contour];
|
| + SkDebugf("path.addRect(%1.9g, %1.9g, %1.9g, %1.9g, %s);\n", rect.fLeft, rect.fTop,
|
| + rect.fRight, rect.fBottom, directions[contour] == SkPath::kCCW_Direction
|
| + ? "SkPath::kCCW_Direction" : "SkPath::kCW_Direction");
|
| + }
|
| + return;
|
| + }
|
| +#endif
|
| + SkPath::FillType fillType = path.getFillType();
|
| + SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInverseEvenOdd_FillType);
|
| + if (includeDeclaration) {
|
| + SkDebugf(" SkPath %s;\n", name);
|
| + }
|
| + SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]);
|
| + iter.setPath(path);
|
| + showPathContours(iter, name);
|
| +}
|
|
|