diff options
author | 2014-07-18 05:08:14 -0700 | |
---|---|---|
committer | 2014-07-18 05:08:14 -0700 | |
commit | 19eb3b2f0aa6dce5c0335230a8930e90733e5d5d (patch) | |
tree | bb3bd2ef885609b5eda366f238cc31dfaae0884d /tests/PathOpsExtendedTest.cpp | |
parent | 384b0202c040034ba1e8f2e3789a01e4b05a6a2b (diff) |
update pathops core and tests
split out skpclip (the test of 1M pictures) into its own project
TBR=reed
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/400033002
Diffstat (limited to 'tests/PathOpsExtendedTest.cpp')
-rw-r--r-- | tests/PathOpsExtendedTest.cpp | 143 |
1 files changed, 7 insertions, 136 deletions
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp index fe3d24d6a0..2d741261a6 100644 --- a/tests/PathOpsExtendedTest.cpp +++ b/tests/PathOpsExtendedTest.cpp @@ -49,102 +49,6 @@ static bool gShowPath = false; static bool gComparePathsAssert = true; static bool gPathStrAssert = true; -static const char* gFillTypeStr[] = { - "kWinding_FillType", - "kEvenOdd_FillType", - "kInverseWinding_FillType", - "kInverseEvenOdd_FillType" -}; - -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(", "); - } - } - SkDebugf(");\n"); -} - -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); - continue; - case SkPath::kLine_Verb: - SkDebugf(" %s.lineTo(", pathName); - output_points(&pts[1], 1); - break; - case SkPath::kQuad_Verb: - SkDebugf(" %s.quadTo(", pathName); - output_points(&pts[1], 2); - break; - case SkPath::kCubic_Verb: - SkDebugf(" %s.cubicTo(", pathName); - output_points(&pts[1], 3); - break; - case SkPath::kClose_Verb: - SkDebugf(" %s.close();\n", pathName); - break; - default: - SkDEBUGFAIL("bad verb"); - return; - } - } -} - -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; - 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", 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::RawIter iter(path); @@ -225,29 +129,6 @@ void showOp(const SkPathOp op) { } #if DEBUG_SHOW_TEST_NAME - -void ShowFunctionHeader(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_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, filename);\n", pathOne, pathTwo, gOpStrs[op]); - SkDebugf("}\n"); -} -#endif - -#if DEBUG_SHOW_TEST_NAME static char hexorator(int x) { if (x < 10) { return x + '0'; @@ -420,8 +301,10 @@ static void showPathOpPath(const char* testName, const SkPath& one, const SkPath *gTestOp.append() = shapeOp; ++gTestNo; SkDebugf(" SkPath path, pathB;\n"); - showPath(a, "path", false); - showPath(b, "pathB", false); +#if DEBUG_SHOW_TEST_NAME + SkPathOpsDebug::ShowOnePath(a, "path", false); + SkPathOpsDebug::ShowOnePath(b, "pathB", false); +#endif SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[shapeOp]); SkDebugf("}\n"); drawAsciiPaths(scaledOne, scaledTwo, true); @@ -523,9 +406,11 @@ bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st const char* pathStr) { SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType; path.setFillType(fillType); +#if DEBUG_SHOW_TEST_NAME if (gShowPath) { - showPath(path, "path", false); + SkPathOpsDebug::ShowOnePath(path, "path", false); } +#endif if (!Simplify(path, &out)) { SkDebugf("%s did not expect failure\n", __FUNCTION__); REPORTER_ASSERT(state.fReporter, 0); @@ -576,20 +461,6 @@ bool testSimplify(skiatest::Reporter* reporter, const SkPath& path, const char* } #if DEBUG_SHOW_TEST_NAME - -SK_DECLARE_STATIC_MUTEX(gTestMutex); - -void SkPathOpsDebug::ShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp, - const char* testName) { - SkAutoMutexAcquire ac(gTestMutex); - ShowFunctionHeader(testName); - showPath(a, "path", true); - showPath(b, "pathB", true); - ShowOp(shapeOp, "path", "pathB"); -} -#endif - -#if DEBUG_SHOW_TEST_NAME static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) { SkDebugf("\n"); showPathData(a); |