static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
{
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    char pathStr[1024];
    sk_bzero(pathStr, sizeof(pathStr));
    int ax = state.fA & 0x03;
    int ay = state.fA >> 2;
    int bx = state.fB & 0x03;
    int by = state.fB >> 2;
    int cx = state.fC & 0x03;
    int cy = state.fC >> 2;
    int dx = state.fD & 0x03;
    int dy = state.fD >> 2;
    for (int e = 0 ; e < 16; ++e) {
        int ex = e & 0x03;
        int ey = e >> 2;
        for (int f = e ; f < 16; ++f) {
            int fx = f & 0x03;
            int fy = f >> 2;
            for (int g = f ; g < 16; ++g) {
                int gx = g & 0x03;
                int gy = g >> 2;
                for (int h = g ; h < 16; ++h) {
                    int hx = h & 0x03;
                    int hy = h >> 2;
                    SkPath path, out;
                    path.setFillType(SkPath::kWinding_FillType);
                    path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
                    path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
                    path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
                    path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
                    path.close();
                    path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
                    path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
                    path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
                    path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
                    path.close();
                   // gdb: set print elements 400
                    char* str = pathStr;
                    str += sprintf(str, "    path.moveTo(%d, %d);\n", ax, ay);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", bx, by);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", cx, cy);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", dx, dy);
                    str += sprintf(str, "    path.close();\n");
                    str += sprintf(str, "    path.moveTo(%d, %d);\n", ex, ey);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", fx, fy);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", gx, gy);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", hx, hy);
                    str += sprintf(str, "    path.close();\n");
                    outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
                    testSimplify(path, false, out, state, pathStr);
                    path.setFillType(SkPath::kEvenOdd_FillType);
                    outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
                    testSimplify(path, true, out, state, pathStr);
                }
            }
        }
    }
}
static void testSimplifyDegeneratesMain(PathOpsThreadState* data) {
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    char pathStr[1024];
    bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
    if (progress) {
        sk_bzero(pathStr, sizeof(pathStr));
    }
    int ax = state.fA & 0x03;
    int ay = state.fA >> 2;
    int bx = state.fB & 0x03;
    int by = state.fB >> 2;
    int cx = state.fC & 0x03;
    int cy = state.fC >> 2;
    for (int d = 0; d < 16; ++d) {
        int dx = d & 0x03;
        int dy = d >> 2;
        for (int e = d ; e < 16; ++e) {
            int ex = e & 0x03;
            int ey = e >> 2;
            for (int f = d ; f < 16; ++f) {
                int fx = f & 0x03;
                int fy = f >> 2;
                if (state.fD && (ex - dx) * (fy - dy)
                        != (ey - dy) * (fx - dx)) {
                    continue;
                }
                SkPath path, out;
                path.setFillType(SkPath::kWinding_FillType);
                path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
                path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
                path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
                path.close();
                path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy));
                path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey));
                path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
                path.close();
                if (progress) {
                    char* str = pathStr;
                    str += sprintf(str, "    path.moveTo(%d, %d);\n", ax, ay);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", bx, by);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", cx, cy);
                    str += sprintf(str, "    path.close();\n");
                    str += sprintf(str, "    path.moveTo(%d, %d);\n", dx, dy);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", ex, ey);
                    str += sprintf(str, "    path.lineTo(%d, %d);\n", fx, fy);
                    str += sprintf(str, "    path.close();\n");
                    outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
                }
                testSimplify(path, false, out, state, pathStr);
                path.setFillType(SkPath::kEvenOdd_FillType);
                if (progress) {
                    outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
                }
                testSimplify(path, true, out, state, pathStr);
            }
        }
    }
}
static void testPathOpsRectsMain(PathOpsThreadState* data)
{
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    char pathStr[1024];  // gdb: set print elements 400
    bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
    if (progress) {
        sk_bzero(pathStr, sizeof(pathStr));
    }
    for (int a = 0 ; a < 6; ++a) {
        for (int b = a + 1 ; b < 7; ++b) {
            for (int c = 0 ; c < 6; ++c) {
                for (int d = c + 1 ; d < 7; ++d) {
                    for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
    for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f)   {
        if (progress) {
            char* str = pathStr;
            str += sprintf(str, "    path.setFillType(SkPath::k%s_FillType);\n",
                    e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
                    ? "EvenOdd" : "?UNDEFINED");
            str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                    " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB);
            str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                    " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD);
            str += sprintf(str, "    pathB.setFillType(SkPath::k%s_FillType);\n",
                    f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
                    ? "EvenOdd" : "?UNDEFINED");
            str += sprintf(str, "    pathB.addRect(%d, %d, %d, %d,"
                    " SkPath::kCW_Direction);\n", a, a, b, b);
            str += sprintf(str, "    pathB.addRect(%d, %d, %d, %d,"
                    " SkPath::kCW_Direction);\n", c, c, d, d);
        }
        SkPath pathA, pathB;
        pathA.setFillType((SkPath::FillType) e);
        pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB),
                SkIntToScalar(state.fB), SkPath::kCW_Direction);
        pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD),
                SkIntToScalar(state.fD), SkPath::kCW_Direction);
        pathA.close();
        pathB.setFillType((SkPath::FillType) f);
        pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b),
                SkIntToScalar(b), SkPath::kCW_Direction);
        pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d),
                SkIntToScalar(d), SkPath::kCW_Direction);
        pathB.close();
        for (int op = 0 ; op <= kXOR_PathOp; ++op)    {
            if (progress) {
                outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
            }
            testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects");
        }
    }
                    }
                }
            }
        }
    }
}
static void testOpLoopsMain(PathOpsThreadState* data) {
#if DEBUG_SHOW_TEST_NAME
    strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
#endif
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    char pathStr[1024];  // gdb: set print elements 400
    bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
    if (progress) {
        sk_bzero(pathStr, sizeof(pathStr));
    }
    for (int a = 0 ; a < 6; ++a) {
        for (int b = a + 1 ; b < 7; ++b) {
            for (int c = 0 ; c < 6; ++c) {
                for (int d = c + 1 ; d < 7; ++d) {
                    // define 4 points that form two lines that often cross; one line is (a, b) (c, d)
                    SkVector v = {SkIntToScalar(a - c), SkIntToScalar(b - d)};
                    SkPoint midA = { SkIntToScalar(a * state.fA + c * (6 - state.fA)) / 6,
                                     SkIntToScalar(b * state.fA + d * (6 - state.fA)) / 6
                                   };
                    SkPoint midB = { SkIntToScalar(a * state.fB + c * (6 - state.fB)) / 6,
                                     SkIntToScalar(b * state.fB + d * (6 - state.fB)) / 6
                                   };
                    SkPoint endC = { midA.fX + v.fY * state.fC / 3,
                                     midA.fY + v.fX * state.fC / 3
                                   };
                    SkPoint endD = { midB.fX - v.fY * state.fD / 3,
                                     midB.fY + v.fX * state.fD / 3
                                   };
                    SkPath pathA, pathB;
                    if (progress) {
                        char* str = pathStr;
                        str += sprintf(str, "    path.moveTo(%d,%d);\n", a, b);
                        str += sprintf(str, "    path.cubicTo(%d,%d, %1.9gf,%1.9gf, %1.9gf,%1.9gf);\n",
                                       c, d, endC.fX, endC.fY, endD.fX, endD.fY);
                        str += sprintf(str, "    path.close();\n");
                        str += sprintf(str, "    pathB.moveTo(%d,%d);\n", c, d);
                        str += sprintf(str, "    pathB.cubicTo(%1.9gf,%1.9gf, %1.9gf,%1.9gf, %d,%d);\n",
                                       endC.fX, endC.fY, endD.fX, endD.fY, a, b);
                        str += sprintf(str, "    pathB.close();\n");
                    }
                    pathA.moveTo(SkIntToScalar(a), SkIntToScalar(b));
                    pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD.fX, endD.fY);
                    pathA.close();
                    pathB.moveTo(SkIntToScalar(c), SkIntToScalar(d));
                    pathB.cubicTo(endC.fX, endC.fY, endD.fX, endD.fY, SkIntToScalar(a), SkIntToScalar(b));
                    pathB.close();
//        SkDebugf("%s\n", pathStr);
                    if (progress) {
                        outputProgress(state.fPathStr, pathStr, kIntersect_PathOp);
                    }
                    testThreadedPathOp(state.fReporter, pathA, pathB, kIntersect_PathOp, "loops");
                }
            }
        }
    }
}
static void* testShapeOps4x4RectsMain(void* data)
{
    SkASSERT(data);
    State4& state = *(State4*) data;
    char pathStr[1024]; // gdb: set print elements 400
    bzero(pathStr, sizeof(pathStr));
    do {
        for (int a = 0 ; a < 6; ++a) {
            for (int b = a + 1 ; b < 7; ++b)  {
                for (int c = 0 ; c < 6; ++c)          {
                    for (int d = c + 1 ; d < 7; ++d)           {
                        for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
                            for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f)   {
                                SkPath pathA, pathB;
                                char* str = pathStr;
                                pathA.setFillType((SkPath::FillType) e);
                                str += sprintf(str, "    path.setFillType(SkPath::k%s_FillType);\n",
                                               e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
                                               ? "EvenOdd" : "?UNDEFINED");
                                pathA.addRect(state.a, state.a, state.b, state.b, SkPath::kCW_Direction);
                                str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                                               " SkPath::kCW_Direction);\n", state.a, state.a, state.b, state.b);
                                pathA.addRect(state.c, state.c, state.d, state.d, SkPath::kCW_Direction);
                                str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                                               " SkPath::kCW_Direction);\n", state.c, state.c, state.d, state.d);
                                pathA.close();
                                pathB.setFillType((SkPath::FillType) f);
                                str += sprintf(str, "    pathB.setFillType(SkPath::k%s_FillType);\n",
                                               f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
                                               ? "EvenOdd" : "?UNDEFINED");
                                pathB.addRect(a, a, b, b, SkPath::kCW_Direction);
                                str += sprintf(str, "    pathB.addRect(%d, %d, %d, %d,"
                                               " SkPath::kCW_Direction);\n", a, a, b, b);
                                pathB.addRect(c, c, d, d, SkPath::kCW_Direction);
                                str += sprintf(str, "    pathB.addRect(%d, %d, %d, %d,"
                                               " SkPath::kCW_Direction);\n", c, c, d, d);
                                pathB.close();
                                for (int op = 0 ; op < kShapeOp_Count; ++op)    {
                                    outputProgress(state, pathStr, (ShapeOp) op);
                                    testShapeOp(pathA, pathB, (ShapeOp) op);
                                    state.testsRun++;
                                }
                            }
                        }
                    }
                }
            }
        }
    } while (runNextTestSet(state));
    return NULL;
}
static void testSimplifyQuadsMain(PathOpsThreadState* data)
{
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    char pathStr[1024];
    bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
    if (progress) {
        sk_bzero(pathStr, sizeof(pathStr));
    }
    int ax = state.fA & 0x03;
    int ay = state.fA >> 2;
    int bx = state.fB & 0x03;
    int by = state.fB >> 2;
    int cx = state.fC & 0x03;
    int cy = state.fC >> 2;
    int dx = state.fD & 0x03;
    int dy = state.fD >> 2;
    for (int e = 0 ; e < 16; ++e) {
        int ex = e & 0x03;
        int ey = e >> 2;
        for (int f = e ; f < 16; ++f) {
            int fx = f & 0x03;
            int fy = f >> 2;
            for (int g = f ; g < 16; ++g) {
                int gx = g & 0x03;
                int gy = g >> 2;
                for (int h = g ; h < 16; ++h) {
                    int hx = h & 0x03;
                    int hy = h >> 2;
                    SkPath path, out;
                    path.setFillType(SkPath::kWinding_FillType);
                    path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
                    path.quadTo(SkIntToScalar(bx), SkIntToScalar(by),
                            SkIntToScalar(cx), SkIntToScalar(cy));
                    path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
                    path.close();
                    path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
                    path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
                    path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy),
                            SkIntToScalar(hx), SkIntToScalar(hy));
                    path.close();
                    if (progress) {
                        static int quadTest = 66;
                        char* str = pathStr;
                        str += sprintf(str, "static void testQuads%d(skiatest::Reporter* reporter,"
                                "const char* filename) {\n", quadTest);
                        str += sprintf(str, "    SkPath path;\n");
                        str += sprintf(str, "    path.moveTo(%d, %d);\n", ax, ay);
                        str += sprintf(str, "    path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy);
                        str += sprintf(str, "    path.lineTo(%d, %d);\n", dx, dy);
                        str += sprintf(str, "    path.close();\n");
                        str += sprintf(str, "    path.moveTo(%d, %d);\n", ex, ey);
                        str += sprintf(str, "    path.lineTo(%d, %d);\n", fx, fy);
                        str += sprintf(str, "    path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy);
                        str += sprintf(str, "    path.close();\n");
                        str += sprintf(str, "    testSimplify(reporter, path, filename);\n");
                        str += sprintf(str, "}\n");
                        outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
                    }
                    testSimplify(path, false, out, state, pathStr);
                    path.setFillType(SkPath::kEvenOdd_FillType);
                    if (progress) {
                        outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
                    }
                    testSimplify(path, true, out, state, pathStr);
                }
            }
        }
    }
}
static void testSimplify4x4RectsMain(PathOpsThreadState* data)
{
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    char pathStr[1024];  // gdb: set print elements 400
    bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
    if (progress) {
        sk_bzero(pathStr, sizeof(pathStr));
    }
    int aShape = state.fA & 0x03;
    SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
    int bShape = state.fB & 0x03;
    SkPath::Direction bCW = state.fB >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
    int cShape = state.fC & 0x03;
    SkPath::Direction cCW = state.fC >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
    int dShape = state.fD & 0x03;
    SkPath::Direction dCW = state.fD >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
    for (int aXAlign = 0; aXAlign < 5; ++aXAlign) {
        for (int aYAlign = 0; aYAlign < 5; ++aYAlign) {
            for (int bXAlign = 0; bXAlign < 5; ++bXAlign) {
                for (int bYAlign = 0; bYAlign < 5; ++bYAlign) {
                    for (int cXAlign = 0; cXAlign < 5; ++cXAlign) {
                         for (int cYAlign = 0; cYAlign < 5; ++cYAlign) {
                            for (int dXAlign = 0; dXAlign < 5; ++dXAlign) {
    for (int dYAlign = 0; dYAlign < 5; ++dYAlign) {
        SkPath path, out;
        char* str = pathStr;
        path.setFillType(SkPath::kWinding_FillType);
        int l, t, r, b;
        if (aShape) {
            switch (aShape) {
                case 1:  // square
                    l =  0; r = 60;
                    t =  0; b = 60;
                    aXAlign = 5;
                    aYAlign = 5;
                    break;
                case 2:
                    l =  aXAlign * 12;
                    r =  l + 30;
                    t =  0; b = 60;
                    aYAlign = 5;
                    break;
                case 3:
                    l =  0; r = 60;
                    t =  aYAlign * 12;
                    b =  l + 30;
                    aXAlign = 5;
                    break;
            }
            path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
                    aCW);
            if (progress) {
                str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                        " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
            }
        } else {
            aXAlign = 5;
            aYAlign = 5;
        }
        if (bShape) {
            switch (bShape) {
                case 1:  // square
                    l =  bXAlign * 10;
                    r =  l + 20;
                    t =  bYAlign * 10;
                    b =  l + 20;
                    break;
                case 2:
                    l =  bXAlign * 10;
                    r =  l + 20;
                    t =  10; b = 40;
                    bYAlign = 5;
                    break;
                case 3:
                    l =  10; r = 40;
                    t =  bYAlign * 10;
                    b =  l + 20;
                    bXAlign = 5;
                    break;
            }
            path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
                    bCW);
            if (progress) {
                str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                        " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
            }
        } else {
            bXAlign = 5;
            bYAlign = 5;
        }
        if (cShape) {
            switch (cShape) {
                case 1:  // square
                    l =  cXAlign * 6;
                    r =  l + 12;
                    t =  cYAlign * 6;
                    b =  l + 12;
                    break;
                case 2:
                    l =  cXAlign * 6;
                    r =  l + 12;
                    t =  20; b = 30;
                    cYAlign = 5;
                    break;
                case 3:
                    l =  20; r = 30;
                    t =  cYAlign * 6;
                    b =  l + 20;
                    cXAlign = 5;
                    break;
            }
            path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
                    cCW);
            if (progress) {
                str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                        " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
            }
        } else {
            cXAlign = 5;
            cYAlign = 5;
        }
        if (dShape) {
            switch (dShape) {
                case 1:  // square
                    l =  dXAlign * 4;
                    r =  l + 9;
                    t =  dYAlign * 4;
                    b =  l + 9;
                    break;
                case 2:
                    l =  dXAlign * 6;
                    r =  l + 9;
                    t =  32; b = 36;
                    dYAlign = 5;
                    break;
                case 3:
                    l =  32; r = 36;
                    t =  dYAlign * 6;
                    b =  l + 9;
                    dXAlign = 5;
                    break;
            }
            path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
                    dCW);
            if (progress) {
                str += sprintf(str, "    path.addRect(%d, %d, %d, %d,"
                        " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
            }
        } else {
            dXAlign = 5;
            dYAlign = 5;
        }
        path.close();
        if (progress) {
            outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
        }
        testSimplify(path, false, out, state, pathStr);
        if (progress) {
            outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
        }
        testSimplify(path, true, out, state, pathStr);
    }
                            }
                        }
                    }
                }
            }
        }
    }
}
static void testOpCubicsMain(PathOpsThreadState* data) {
#if DEBUG_SHOW_TEST_NAME
    strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
#endif
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    SkString pathStr;
    for (int a = 0 ; a < 6; ++a) {
        for (int b = a + 1 ; b < 7; ++b) {
            for (int c = 0 ; c < 6; ++c) {
                for (int d = c + 1 ; d < 7; ++d) {
                    for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
    for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
        SkPath pathA, pathB;
        pathA.setFillType((SkPath::FillType) e);
        pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
        pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b),
                SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
        pathA.close();
        pathB.setFillType((SkPath::FillType) f);
        pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
        pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB),
                SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
        pathB.close();
        for (int op = 0 ; op <= kXOR_SkPathOp; ++op)    {
            if (state.fReporter->verbose()) {
                pathStr.printf("static void cubicOp%d(skiatest::Reporter* reporter,"
                        " const char* filename) {\n", loopNo);
                pathStr.appendf("    SkPath path, pathB;\n");
                pathStr.appendf("    path.setFillType(SkPath::k%s_FillType);\n",
                        e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
                        ? "EvenOdd" : "?UNDEFINED");
                pathStr.appendf("    path.moveTo(%d,%d);\n", state.fA, state.fB);
                pathStr.appendf("    path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
                        b, a, d, c);
                pathStr.appendf("    path.close();\n");
                pathStr.appendf("    pathB.setFillType(SkPath::k%s_FillType);\n",
                        f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
                        ? "EvenOdd" : "?UNDEFINED");
                pathStr.appendf("    pathB.moveTo(%d,%d);\n", a, b);
                pathStr.appendf("    pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
                        state.fB, state.fA, state.fD, state.fC);
                pathStr.appendf("    pathB.close();\n");
                pathStr.appendf("    testPathOp(reporter, path, pathB, %s, filename);\n",
                        SkPathOpsDebug::OpStr((SkPathOp) op));
                pathStr.appendf("}\n");
                outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
            }
            if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
                if (state.fReporter->verbose()) {
                    ++loopNo;
                    goto skipToNext;
                }
            }
        }
    }
                    }
skipToNext: ;
                }
            }
        }
    }
}
static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
{
    SkASSERT(data);
    PathOpsThreadState& state = *data;
    SkString pathStr;
    int ax = state.fA & 0x03;
    int ay = state.fA >> 2;
    int bx = state.fB & 0x03;
    int by = state.fB >> 2;
    int cx = state.fC & 0x03;
    int cy = state.fC >> 2;
    int dx = state.fD & 0x03;
    int dy = state.fD >> 2;
    for (int e = 0 ; e < 16; ++e) {
        int ex = e & 0x03;
        int ey = e >> 2;
        for (int f = e ; f < 16; ++f) {
            int fx = f & 0x03;
            int fy = f >> 2;
            for (int g = f ; g < 16; ++g) {
                int gx = g & 0x03;
                int gy = g >> 2;
                for (int h = g ; h < 16; ++h) {
                    int hx = h & 0x03;
                    int hy = h >> 2;
                    SkPath path, out;
                    path.setFillType(SkPath::kWinding_FillType);
                    path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
                    path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
                    path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
                    path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
                    path.close();
                    path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
                    path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
                    path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
                    path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
                    path.close();
                    if (state.fReporter->verbose()) {
                        pathStr.printf("static void quadralateralSimplify%d(skiatest::Reporter*"
                                "reporter, const char* filename) {\n", loopNo);
                        pathStr.appendf("    SkPath path;\n");
                        pathStr.appendf("    path.moveTo(%d, %d);\n", ax, ay);
                        pathStr.appendf("    path.lineTo(%d, %d);\n", bx, by);
                        pathStr.appendf("    path.lineTo(%d, %d);\n", cx, cy);
                        pathStr.appendf("    path.lineTo(%d, %d);\n", dx, dy);
                        pathStr.appendf("    path.close();\n");
                        pathStr.appendf("    path.moveTo(%d, %d);\n", ex, ey);
                        pathStr.appendf("    path.lineTo(%d, %d);\n", fx, fy);
                        pathStr.appendf("    path.lineTo(%d, %d);\n", gx, gy);
                        pathStr.appendf("    path.lineTo(%d, %d);\n", hx, hy);
                        pathStr.appendf("    path.close();\n");
                        pathStr.appendf("    testPathSimplify(reporter, path, filename);\n");
                        pathStr.appendf("}\n");
                        outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
                    }
                    testSimplify(path, false, out, state, pathStr.c_str());
                    path.setFillType(SkPath::kEvenOdd_FillType);
                    if (state.fReporter->verbose()) {
                        outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
                    }
                    testSimplify(path, true, out, state, pathStr.c_str());
                }
            }
        }
    }
}
static void* testSimplify4x4QuadraticsMain(void* data)
{
    SkASSERT(data);
    State4& state = *(State4*) data;
    char pathStr[1024];
    bzero(pathStr, sizeof(pathStr));
    do {
        int ax = state.a & 0x03;
        int ay = state.a >> 2;
        int bx = state.b & 0x03;
        int by = state.b >> 2;
        int cx = state.c & 0x03;
        int cy = state.c >> 2;
        int dx = state.d & 0x03;
        int dy = state.d >> 2;
        for (int e = 0 ; e < 16; ++e) {
            int ex = e & 0x03;
            int ey = e >> 2;
            for (int f = e ; f < 16; ++f) {
                int fx = f & 0x03;
                int fy = f >> 2;
                for (int g = f ; g < 16; ++g) {
                    int gx = g & 0x03;
                    int gy = g >> 2;
                    for (int h = g ; h < 16; ++h) {
                        int hx = h & 0x03;
                        int hy = h >> 2;
                        SkPath path, out;
                        path.setFillType(SkPath::kWinding_FillType);
                        path.moveTo(ax, ay);
                        path.quadTo(bx, by, cx, cy);
                        path.lineTo(dx, dy);
                        path.close();
                        path.moveTo(ex, ey);
                        path.lineTo(fx, fy);
                        path.quadTo(gx, gy, hx, hy);
                        path.close();
                        if (1) {  // gdb: set print elements 400
                            char* str = pathStr;
                            str += sprintf(str, "    path.moveTo(%d, %d);\n", ax, ay);
                            str += sprintf(str, "    path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy);
                            str += sprintf(str, "    path.lineTo(%d, %d);\n", dx, dy);
                            str += sprintf(str, "    path.close();\n");
                            str += sprintf(str, "    path.moveTo(%d, %d);\n", ex, ey);
                            str += sprintf(str, "    path.lineTo(%d, %d);\n", fx, fy);
                            str += sprintf(str, "    path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy);
                            str += sprintf(str, "    path.close();\n");
                        }
                        outputProgress(state, pathStr, SkPath::kWinding_FillType);
                        testSimplifyx(path, false, out, state, pathStr);
                        state.testsRun++;
                        path.setFillType(SkPath::kEvenOdd_FillType);
                        outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
                        testSimplifyx(path, true, out, state, pathStr);
                        state.testsRun++;
                    }
                }
            }
        }
    } while (runNextTestSet(state));
    return NULL;
}