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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 scaledOut.setFillType(out.getFillType()); | 506 scaledOut.setFillType(out.getFillType()); |
507 int result = comparePaths(reporter, pathOut, scaledPathOut, out, scaledOut,
bitmap, a, b, | 507 int result = comparePaths(reporter, pathOut, scaledPathOut, out, scaledOut,
bitmap, a, b, |
508 shapeOp, scale); | 508 shapeOp, scale); |
509 if (result && gPathStrAssert) { | 509 if (result && gPathStrAssert) { |
510 REPORTER_ASSERT(reporter, 0); | 510 REPORTER_ASSERT(reporter, 0); |
511 } | 511 } |
512 reporter->bumpTestCount(); | 512 reporter->bumpTestCount(); |
513 return result == 0; | 513 return result == 0; |
514 } | 514 } |
515 | 515 |
516 const int maxThreadsAllocated = 64; | |
517 static int maxThreads = 1; | |
518 | |
519 int initializeTests(skiatest::Reporter* reporter, const char* test) { | 516 int initializeTests(skiatest::Reporter* reporter, const char* test) { |
520 #ifdef SK_DEBUG | 517 #ifdef SK_DEBUG |
521 gDebugMaxWindSum = 4; | 518 gDebugMaxWindSum = 4; |
522 gDebugMaxWindValue = 4; | 519 gDebugMaxWindValue = 4; |
523 #endif | 520 #endif |
524 testName = test; | 521 testName = test; |
525 size_t testNameSize = strlen(test); | 522 size_t testNameSize = strlen(test); |
526 if (reporter->allowThreaded()) { | |
527 int threads = -1; | |
528 #ifdef SK_BUILD_FOR_MAC | |
529 size_t size = sizeof(threads); | |
530 sysctlbyname("hw.logicalcpu_max", &threads, &size, NULL, 0); | |
531 #endif | |
532 if (threads > 0) { | |
533 maxThreads = threads; | |
534 } else { | |
535 maxThreads = 16; | |
536 } | |
537 } | |
538 SkFILEStream inFile("../../experimental/Intersection/op.htm"); | 523 SkFILEStream inFile("../../experimental/Intersection/op.htm"); |
539 if (inFile.isValid()) { | 524 if (inFile.isValid()) { |
540 SkTDArray<char> inData; | 525 SkTDArray<char> inData; |
541 inData.setCount(inFile.getLength()); | 526 inData.setCount(inFile.getLength()); |
542 size_t inLen = inData.count(); | 527 size_t inLen = inData.count(); |
543 inFile.read(inData.begin(), inLen); | 528 inFile.read(inData.begin(), inLen); |
544 inFile.setPath(NULL); | 529 inFile.setPath(NULL); |
545 char* insert = strstr(inData.begin(), marker); | 530 char* insert = strstr(inData.begin(), marker); |
546 if (insert) { | 531 if (insert) { |
547 insert += sizeof(marker) - 1; | 532 insert += sizeof(marker) - 1; |
548 const char* numLoc = insert + 4 /* indent spaces */ + testNameSize -
1; | 533 const char* numLoc = insert + 4 /* indent spaces */ + testNameSize -
1; |
549 testNumber = atoi(numLoc) + 1; | 534 testNumber = atoi(numLoc) + 1; |
550 } | 535 } |
551 } | 536 } |
552 return maxThreads; | 537 return reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 0; |
553 } | 538 } |
554 | 539 |
555 void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill
Type) { | 540 void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill
Type) { |
556 const char testFunction[] = "testSimplify(path);"; | 541 const char testFunction[] = "testSimplify(path);"; |
557 const char* pathPrefix = NULL; | 542 const char* pathPrefix = NULL; |
558 const char* nameSuffix = NULL; | 543 const char* nameSuffix = NULL; |
559 if (pathFillType == SkPath::kEvenOdd_FillType) { | 544 if (pathFillType == SkPath::kEvenOdd_FillType) { |
560 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; | 545 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; |
561 nameSuffix = "x"; | 546 nameSuffix = "x"; |
562 } | 547 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 } | 584 } |
600 if (tests[index].fun == stopTest) { | 585 if (tests[index].fun == stopTest) { |
601 SkDebugf("lastTest\n"); | 586 SkDebugf("lastTest\n"); |
602 } | 587 } |
603 if (index == last) { | 588 if (index == last) { |
604 break; | 589 break; |
605 } | 590 } |
606 index += reverse ? -1 : 1; | 591 index += reverse ? -1 : 1; |
607 } while (true); | 592 } while (true); |
608 } | 593 } |
OLD | NEW |