static int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap, SkCanvas* canvas) { int errors = pathsDrawTheSame(one, two, bitmap, canvas); if (errors == 0) { return 0; } drawAsciiPaths(one, two, gDrawAllAsciiPaths); for (int x = 9; x <= 33; ++x) { errors = scaledDrawTheSame(one, two, x, x - (x >> 2), gDrawAllAsciiPaths, bitmap, canvas); if (errors == 0) { return 0; } } if (!gDrawAllAsciiPaths) { errors = scaledDrawTheSame(one, two, 9, 7, false, bitmap, canvas); if (errors > 4) { scaledDrawTheSame(one, two, 9, 7, true, bitmap, canvas); } } if (errors > 0) SkDebugf("\n%s errors=%d\n", __FUNCTION__, errors); if (errors > 4 && gComparePathsAssert) { showPath(one); showPath(two, "simplified:"); SkASSERT(0); } return errors; }
static void showShapeOpPath(const SkPath& one, const SkPath& two, const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, const ShapeOp shapeOp) { SkASSERT((unsigned) shapeOp < sizeof(opStrs) / sizeof(opStrs[0])); showPath(a, "minuend:"); SkDebugf("op: %s\n", opStrs[shapeOp]); showPath(b, "subtrahend:"); showPath(one, "region:"); showPath(two, "op result:"); drawAsciiPaths(scaledOne, scaledTwo, true); }
static void testSimplifyQuadratic4() { SkPath path, out; path.moveTo(0, 20); path.quadTo(20, 0, 40, 20); path.close(); path.moveTo(40, 10); path.quadTo(20, 30, 0, 10); path.close(); testSimplify(path, true, out, bitmap); drawAsciiPaths(path, out, true); }
static void showPathOpPath(const SkPath& one, const SkPath& two, const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, const SkPathOp shapeOp, const SkMatrix& scale) { SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); SkDebugf("static void xOp#%s(skiatest::Reporter* reporter) {\n", opSuffixes[shapeOp]); SkDebugf(" SkPath path, pathB;\n"); showPath(a, "path", false); showPath(b, "pathB", false); SkDebugf(" testPathOp(reporter, path, pathB, %s);\n", opStrs[shapeOp]); SkDebugf("}\n"); drawAsciiPaths(scaledOne, scaledTwo, true); }
static void testSimplifyQuadratic8() { SkPath path, out; path.moveTo(0, 0); path.quadTo(0, 0, 0, 0); path.lineTo(0, 0); path.close(); path.moveTo(0, 0); path.lineTo(0, 0); path.quadTo(1, 0, 0, 2); path.close(); testSimplify(path, true, out, bitmap); drawAsciiPaths(path, out, true); }
static void showPathOpPath(const char* testName, const SkPath& one, const SkPath& two, const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, const SkPathOp shapeOp, const SkMatrix& scale) { SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); if (!testName) { testName = "xOp"; } SkDebugf("static void %s_%s(skiatest::Reporter* reporter, const char* filename) {\n", testName, opSuffixes[shapeOp]); *gTestOp.append() = shapeOp; SkDebugf(" SkPath path, pathB;\n"); SkPathOpsDebug::ShowOnePath(a, "path", false); SkPathOpsDebug::ShowOnePath(b, "pathB", false); SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[shapeOp]); SkDebugf("}\n"); drawAsciiPaths(scaledOne, scaledTwo, true); }
static void showPathOpPath(const char* testName, const SkPath& one, const SkPath& two, const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, const SkPathOp shapeOp, const SkMatrix& scale) { SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); SkString defaultTestName; if (!testName) { defaultTestName.printf("xOp%d%s", gTestNo, opSuffixes[shapeOp]); testName = defaultTestName.c_str(); } SkDebugf("static void %s(skiatest::Reporter* reporter, const char* filename) {\n", testName); *gTestOp.append() = shapeOp; ++gTestNo; SkDebugf("\n*** this test fails ***\n"); SkDebugf(" SkPath path, pathB;\n"); showPath(a, "path", false); showPath(b, "pathB", false); SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[shapeOp]); SkDebugf("}\n"); drawAsciiPaths(scaledOne, scaledTwo, true); }
static int scaledDrawTheSame(const SkPath& one, const SkPath& two, int a, int b, bool drawPaths, SkBitmap& bitmap, SkCanvas* canvas) { SkMatrix scale; scale.reset(); float aScale = 1.21f; float bScale = 1.11f; scale.preScale(a * aScale, b * bScale); SkPath scaledOne, scaledTwo; one.transform(scale, &scaledOne); two.transform(scale, &scaledTwo); int errors = pathsDrawTheSame(scaledOne, scaledTwo, bitmap, canvas); if (errors == 0) { return 0; } while (!drawAsciiPaths(scaledOne, scaledTwo, drawPaths)) { scale.reset(); aScale *= 0.5f; bScale *= 0.5f; scale.preScale(a * aScale, b * bScale); one.transform(scale, &scaledOne); two.transform(scale, &scaledTwo); } return errors; }
static void showSimplifiedPath(const SkPath& one, const SkPath& two, const SkPath& scaledOne, const SkPath& scaledTwo) { showPath(one, "path", false); drawAsciiPaths(scaledOne, scaledTwo, true); }
static void showSimplifiedPath(const SkPath& one, const SkPath& two, const SkPath& scaledOne, const SkPath& scaledTwo) { showPath(one, "original:"); showPath(two, "simplified:"); drawAsciiPaths(scaledOne, scaledTwo, true); }