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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 SkDebugf("}\n"); | 309 SkDebugf("}\n"); |
310 drawAsciiPaths(scaledOne, scaledTwo, true); | 310 drawAsciiPaths(scaledOne, scaledTwo, true); |
311 } | 311 } |
312 | 312 |
313 void ShowTestArray() { | 313 void ShowTestArray() { |
314 for (int x = gTestFirst; x < gTestNo; ++x) { | 314 for (int x = gTestFirst; x < gTestNo; ++x) { |
315 SkDebugf(" TEST(xOp%d%s),\n", x, opSuffixes[gTestOp[x - gTestFirst]])
; | 315 SkDebugf(" TEST(xOp%d%s),\n", x, opSuffixes[gTestOp[x - gTestFirst]])
; |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
| 319 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); |
| 320 SK_DECLARE_STATIC_MUTEX(compareDebugOut4); |
319 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
t SkPath& one, | 321 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
t SkPath& one, |
320 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB
itmap& bitmap, | 322 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB
itmap& bitmap, |
321 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix
& scale) { | 323 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix
& scale) { |
322 int errors2x2; | 324 int errors2x2; |
323 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); | 325 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); |
324 if (errors2x2 == 0) { | 326 if (errors2x2 == 0) { |
325 if (gShowPath) { | 327 if (gShowPath) { |
326 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shape
Op, scale); | 328 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shape
Op, scale); |
327 } | 329 } |
328 return 0; | 330 return 0; |
329 } | 331 } |
330 const int MAX_ERRORS = 8; | 332 const int MAX_ERRORS = 8; |
331 if (errors2x2 > MAX_ERRORS && gComparePathsAssert) { | 333 if (errors2x2 > MAX_ERRORS && gComparePathsAssert) { |
332 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); | |
333 SkAutoMutexAcquire autoM(compareDebugOut3); | 334 SkAutoMutexAcquire autoM(compareDebugOut3); |
334 SkDebugf("\n*** this test fails ***\n"); | 335 SkDebugf("\n*** this test fails ***\n"); |
335 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); | 336 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); |
336 REPORTER_ASSERT(reporter, 0); | 337 REPORTER_ASSERT(reporter, 0); |
337 } else if (gShowPath || errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS -
1) { | 338 } else if (gShowPath || errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS -
1) { |
338 SK_DECLARE_STATIC_MUTEX(compareDebugOut4); | |
339 SkAutoMutexAcquire autoM(compareDebugOut4); | 339 SkAutoMutexAcquire autoM(compareDebugOut4); |
340 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); | 340 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp,
scale); |
341 } | 341 } |
342 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; | 342 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; |
343 } | 343 } |
344 | 344 |
345 // Default values for when reporter->verbose() is false. | 345 // Default values for when reporter->verbose() is false. |
346 static int testNumber = 55; | 346 static int testNumber = 55; |
347 static const char* testName = "pathOpTest"; | 347 static const char* testName = "pathOpTest"; |
348 | 348 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 outFile.writeText(" void (*fun)();\n"); | 395 outFile.writeText(" void (*fun)();\n"); |
396 outFile.writeText(" const char* str;\n"); | 396 outFile.writeText(" const char* str;\n"); |
397 outFile.writeText("} tests[] = {\n"); | 397 outFile.writeText("} tests[] = {\n"); |
398 outFile.writeText(" TEST("); | 398 outFile.writeText(" TEST("); |
399 writeTestName(nameSuffix, outFile); | 399 writeTestName(nameSuffix, outFile); |
400 outFile.writeText("),\n"); | 400 outFile.writeText("),\n"); |
401 #endif | 401 #endif |
402 outFile.flush(); | 402 outFile.flush(); |
403 } | 403 } |
404 | 404 |
| 405 SK_DECLARE_STATIC_MUTEX(simplifyDebugOut); |
405 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st
ate, | 406 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st
ate, |
406 const char* pathStr) { | 407 const char* pathStr) { |
407 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi
nding_FillType; | 408 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi
nding_FillType; |
408 path.setFillType(fillType); | 409 path.setFillType(fillType); |
409 #if DEBUG_SHOW_TEST_NAME | 410 #if DEBUG_SHOW_TEST_NAME |
410 if (gShowPath) { | 411 if (gShowPath) { |
411 SkPathOpsDebug::ShowOnePath(path, "path", false); | 412 SkPathOpsDebug::ShowOnePath(path, "path", false); |
412 } | 413 } |
413 #endif | 414 #endif |
414 if (!Simplify(path, &out)) { | 415 if (!Simplify(path, &out)) { |
415 SkDebugf("%s did not expect failure\n", __FUNCTION__); | 416 SkDebugf("%s did not expect failure\n", __FUNCTION__); |
416 REPORTER_ASSERT(state.fReporter, 0); | 417 REPORTER_ASSERT(state.fReporter, 0); |
417 return false; | 418 return false; |
418 } | 419 } |
419 if (!state.fReporter->verbose()) { | 420 if (!state.fReporter->verbose()) { |
420 return true; | 421 return true; |
421 } | 422 } |
422 int result = comparePaths(state.fReporter, NULL, path, out, *state.fBitmap); | 423 int result = comparePaths(state.fReporter, NULL, path, out, *state.fBitmap); |
423 if (result && gPathStrAssert) { | 424 if (result && gPathStrAssert) { |
424 SK_DECLARE_STATIC_MUTEX(simplifyDebugOut); | |
425 SkAutoMutexAcquire autoM(simplifyDebugOut); | 425 SkAutoMutexAcquire autoM(simplifyDebugOut); |
426 char temp[8192]; | 426 char temp[8192]; |
427 sk_bzero(temp, sizeof(temp)); | 427 sk_bzero(temp, sizeof(temp)); |
428 SkMemoryWStream stream(temp, sizeof(temp)); | 428 SkMemoryWStream stream(temp, sizeof(temp)); |
429 const char* pathPrefix = NULL; | 429 const char* pathPrefix = NULL; |
430 const char* nameSuffix = NULL; | 430 const char* nameSuffix = NULL; |
431 if (fillType == SkPath::kEvenOdd_FillType) { | 431 if (fillType == SkPath::kEvenOdd_FillType) { |
432 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; | 432 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; |
433 nameSuffix = "x"; | 433 nameSuffix = "x"; |
434 } | 434 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 if (tests[index].fun == stopTest) { | 620 if (tests[index].fun == stopTest) { |
621 SkDebugf("lastTest\n"); | 621 SkDebugf("lastTest\n"); |
622 break; | 622 break; |
623 } | 623 } |
624 if (index == last) { | 624 if (index == last) { |
625 break; | 625 break; |
626 } | 626 } |
627 index += reverse ? -1 : 1; | 627 index += reverse ? -1 : 1; |
628 } while (true); | 628 } while (true); |
629 } | 629 } |
OLD | NEW |