| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "PathOpsExtendedTest.h" | 8 #include "PathOpsExtendedTest.h" |
| 9 #include "PathOpsThreadedCommon.h" | 9 #include "PathOpsThreadedCommon.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 int errors2x2; | 292 int errors2x2; |
| 293 SkPath scaledOne, scaledTwo; | 293 SkPath scaledOne, scaledTwo; |
| 294 (void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2); | 294 (void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2); |
| 295 if (errors2x2 == 0) { | 295 if (errors2x2 == 0) { |
| 296 return 0; | 296 return 0; |
| 297 } | 297 } |
| 298 const int MAX_ERRORS = 9; | 298 const int MAX_ERRORS = 9; |
| 299 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; | 299 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; |
| 300 } | 300 } |
| 301 | 301 |
| 302 const int gTestFirst = 41; | |
| 303 static int gTestNo = gTestFirst; | |
| 304 static SkTDArray<SkPathOp> gTestOp; | 302 static SkTDArray<SkPathOp> gTestOp; |
| 305 | 303 |
| 306 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath
& two, | 304 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath
& two, |
| 307 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath&
scaledTwo, | 305 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath&
scaledTwo, |
| 308 const SkPathOp shapeOp, const SkMatrix& scale) { | 306 const SkPathOp shapeOp, const SkMatrix& scale) { |
| 309 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); | 307 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); |
| 310 if (!testName) { | 308 if (!testName) { |
| 311 testName = "xOp"; | 309 testName = "xOp"; |
| 312 } | 310 } |
| 313 SkDebugf("static void %s%d%s(skiatest::Reporter* reporter, const char* filen
ame) {\n", | 311 SkDebugf("static void %s_%s(skiatest::Reporter* reporter, const char* filena
me) {\n", |
| 314 testName, gTestNo, opSuffixes[shapeOp]); | 312 testName, opSuffixes[shapeOp]); |
| 315 *gTestOp.append() = shapeOp; | 313 *gTestOp.append() = shapeOp; |
| 316 ++gTestNo; | |
| 317 SkDebugf(" SkPath path, pathB;\n"); | 314 SkDebugf(" SkPath path, pathB;\n"); |
| 318 SkPathOpsDebug::ShowOnePath(a, "path", false); | 315 SkPathOpsDebug::ShowOnePath(a, "path", false); |
| 319 SkPathOpsDebug::ShowOnePath(b, "pathB", false); | 316 SkPathOpsDebug::ShowOnePath(b, "pathB", false); |
| 320 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); | 317 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); |
| 321 SkDebugf("}\n"); | 318 SkDebugf("}\n"); |
| 322 drawAsciiPaths(scaledOne, scaledTwo, true); | 319 drawAsciiPaths(scaledOne, scaledTwo, true); |
| 323 } | 320 } |
| 324 | 321 |
| 325 void ShowTestArray(const char* testName) { | |
| 326 if (!testName) { | |
| 327 testName = "xOp"; | |
| 328 } | |
| 329 for (int x = gTestFirst; x < gTestNo; ++x) { | |
| 330 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); | |
| 331 } | |
| 332 } | |
| 333 | |
| 334 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); | 322 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); |
| 335 | 323 |
| 336 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
t SkPath& one, | 324 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
t SkPath& one, |
| 337 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB
itmap& bitmap, | 325 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB
itmap& bitmap, |
| 338 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix
& scale, | 326 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix
& scale, |
| 339 bool expectSuccess) { | 327 bool expectSuccess) { |
| 340 int errors2x2; | 328 int errors2x2; |
| 341 const int MAX_ERRORS = 8; | 329 const int MAX_ERRORS = 8; |
| 342 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); | 330 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); |
| 343 if (!expectSuccess) { | 331 if (!expectSuccess) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 if (foundSkip && tests[index].fun != firstTest) { | 669 if (foundSkip && tests[index].fun != firstTest) { |
| 682 SkDebugf(" %s,\n", tests[index].str); | 670 SkDebugf(" %s,\n", tests[index].str); |
| 683 } | 671 } |
| 684 if (tests[index].fun == stopTest || index == last) { | 672 if (tests[index].fun == stopTest || index == last) { |
| 685 break; | 673 break; |
| 686 } | 674 } |
| 687 index += reverse ? -1 : 1; | 675 index += reverse ? -1 : 1; |
| 688 } while (true); | 676 } while (true); |
| 689 #endif | 677 #endif |
| 690 } | 678 } |
| OLD | NEW |