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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 int errors2x2; | 282 int errors2x2; |
283 SkPath scaledOne, scaledTwo; | 283 SkPath scaledOne, scaledTwo; |
284 (void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2); | 284 (void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2); |
285 if (errors2x2 == 0) { | 285 if (errors2x2 == 0) { |
286 return 0; | 286 return 0; |
287 } | 287 } |
288 const int MAX_ERRORS = 9; | 288 const int MAX_ERRORS = 9; |
289 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; | 289 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; |
290 } | 290 } |
291 | 291 |
292 const int gTestFirst = 20; | 292 const int gTestFirst = 41; |
293 static int gTestNo = gTestFirst; | 293 static int gTestNo = gTestFirst; |
294 static SkTDArray<SkPathOp> gTestOp; | 294 static SkTDArray<SkPathOp> gTestOp; |
295 | 295 |
296 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath
& two, | 296 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath
& two, |
297 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath&
scaledTwo, | 297 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath&
scaledTwo, |
298 const SkPathOp shapeOp, const SkMatrix& scale) { | 298 const SkPathOp shapeOp, const SkMatrix& scale) { |
299 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); | 299 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); |
300 if (!testName) { | 300 if (!testName) { |
301 testName = "xOp"; | 301 testName = "xOp"; |
302 } | 302 } |
303 SkDebugf("static void %s%d%s(skiatest::Reporter* reporter, const char* filen
ame) {\n", | 303 SkDebugf("static void %s%d%s(skiatest::Reporter* reporter, const char* filen
ame) {\n", |
304 testName, gTestNo, opSuffixes[shapeOp]); | 304 testName, gTestNo, opSuffixes[shapeOp]); |
305 *gTestOp.append() = shapeOp; | 305 *gTestOp.append() = shapeOp; |
306 ++gTestNo; | 306 ++gTestNo; |
307 SkDebugf(" SkPath path, pathB;\n"); | 307 SkDebugf(" SkPath path, pathB;\n"); |
308 SkPathOpsDebug::ShowOnePath(a, "path", false); | 308 SkPathOpsDebug::ShowOnePath(a, "path", false); |
309 SkPathOpsDebug::ShowOnePath(b, "pathB", false); | 309 SkPathOpsDebug::ShowOnePath(b, "pathB", false); |
310 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); | 310 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); |
311 SkDebugf("}\n"); | 311 SkDebugf("}\n"); |
312 drawAsciiPaths(scaledOne, scaledTwo, true); | 312 drawAsciiPaths(scaledOne, scaledTwo, false); |
313 } | 313 } |
314 | 314 |
315 void ShowTestArray(const char* testName) { | 315 void ShowTestArray(const char* testName) { |
316 if (!testName) { | 316 if (!testName) { |
317 testName = "xOp"; | 317 testName = "xOp"; |
318 } | 318 } |
319 for (int x = gTestFirst; x < gTestNo; ++x) { | 319 for (int x = gTestFirst; x < gTestNo; ++x) { |
320 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); | 320 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); |
321 } | 321 } |
322 } | 322 } |
(...skipping 11 matching lines...) Expand all Loading... |
334 if (errors2x2 <= MAX_ERRORS) { | 334 if (errors2x2 <= MAX_ERRORS) { |
335 REPORTER_ASSERT(reporter, 0); | 335 REPORTER_ASSERT(reporter, 0); |
336 } | 336 } |
337 return 0; | 337 return 0; |
338 } | 338 } |
339 if (errors2x2 == 0) { | 339 if (errors2x2 == 0) { |
340 return 0; | 340 return 0; |
341 } | 341 } |
342 if (errors2x2 > MAX_ERRORS) { | 342 if (errors2x2 > MAX_ERRORS) { |
343 SkAutoMutexAcquire autoM(compareDebugOut3); | 343 SkAutoMutexAcquire autoM(compareDebugOut3); |
344 SkDebugf("\n*** this test fails ***\n"); | |
345 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); | 344 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); |
| 345 SkDebugf("\n/*"); |
346 REPORTER_ASSERT(reporter, 0); | 346 REPORTER_ASSERT(reporter, 0); |
| 347 SkDebugf(" */\n"); |
347 } else if (errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) { | 348 } else if (errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) { |
348 SkAutoMutexAcquire autoM(compareDebugOut4); | 349 SkAutoMutexAcquire autoM(compareDebugOut4); |
349 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); | 350 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); |
350 } | 351 } |
351 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; | 352 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; |
352 } | 353 } |
353 | 354 |
354 // Default values for when reporter->verbose() is false. | 355 // Default values for when reporter->verbose() is false. |
355 static int testNumber = 55; | 356 static int testNumber = 55; |
356 static const char* testName = "pathOpTest"; | 357 static const char* testName = "pathOpTest"; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 scaledRgnA.setPath(scaledA, openClip); | 525 scaledRgnA.setPath(scaledA, openClip); |
525 scaledRgnB.setPath(scaledB, openClip); | 526 scaledRgnB.setPath(scaledB, openClip); |
526 scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp); | 527 scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp); |
527 scaledRgnOut.getBoundaryPath(&scaledPathOut); | 528 scaledRgnOut.getBoundaryPath(&scaledPathOut); |
528 SkBitmap bitmap; | 529 SkBitmap bitmap; |
529 SkPath scaledOut; | 530 SkPath scaledOut; |
530 scaledOut.addPath(out, scale); | 531 scaledOut.addPath(out, scale); |
531 scaledOut.setFillType(out.getFillType()); | 532 scaledOut.setFillType(out.getFillType()); |
532 int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, s
caledOut, bitmap, | 533 int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, s
caledOut, bitmap, |
533 a, b, shapeOp, scale, expectSuccess); | 534 a, b, shapeOp, scale, expectSuccess); |
534 if (result) { | |
535 REPORTER_ASSERT(reporter, 0); | |
536 } | |
537 reporter->bumpTestCount(); | 535 reporter->bumpTestCount(); |
538 return result == 0; | 536 return result == 0; |
539 } | 537 } |
540 | 538 |
541 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, | 539 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
542 const SkPathOp shapeOp, const char* testName) { | 540 const SkPathOp shapeOp, const char* testName) { |
543 return innerPathOp(reporter, a, b, shapeOp, testName, false, true); | 541 return innerPathOp(reporter, a, b, shapeOp, testName, false, true); |
544 } | 542 } |
545 | 543 |
546 bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, | 544 bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath
& b, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 if (foundSkip && tests[index].fun != firstTest) { | 676 if (foundSkip && tests[index].fun != firstTest) { |
679 SkDebugf(" %s,\n", tests[index].str); | 677 SkDebugf(" %s,\n", tests[index].str); |
680 } | 678 } |
681 if (tests[index].fun == stopTest || index == last) { | 679 if (tests[index].fun == stopTest || index == last) { |
682 break; | 680 break; |
683 } | 681 } |
684 index += reverse ? -1 : 1; | 682 index += reverse ? -1 : 1; |
685 } while (true); | 683 } while (true); |
686 #endif | 684 #endif |
687 } | 685 } |
OLD | NEW |