Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #if !SK_SUPPORT_GPU | 1 #if !SK_SUPPORT_GPU |
| 2 #error "GPU support required" | 2 #error "GPU support required" |
| 3 #endif | 3 #endif |
| 4 | 4 |
| 5 #include "GrContext.h" | 5 #include "GrContext.h" |
| 6 #include "GrContextFactory.h" | 6 #include "GrContextFactory.h" |
| 7 #include "GrRenderTarget.h" | 7 #include "GrRenderTarget.h" |
| 8 #include "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
| 9 #include "gl/GrGLDefines.h" | 9 #include "gl/GrGLDefines.h" |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkDevice.h" | 13 #include "SkDevice.h" |
| 14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
| 15 #include "SkGraphics.h" | 15 #include "SkGraphics.h" |
| 16 #include "SkImageDecoder.h" | 16 #include "SkImageDecoder.h" |
| 17 #include "SkImageEncoder.h" | 17 #include "SkImageEncoder.h" |
| 18 #include "SkStream.h" | 18 #include "SkStream.h" |
| 19 #include "SkOSFile.h" | 19 #include "SkOSFile.h" |
| 20 #include "SkPicture.h" | 20 #include "SkPicture.h" |
| 21 #include "SkRTConf.h" | 21 #include "SkRTConf.h" |
| 22 #include "SkRunnable.h" | 22 #include "SkRunnable.h" |
| 23 #include "SkString.h" | 23 #include "SkString.h" |
| 24 #include "SkTArray.h" | 24 #include "SkTArray.h" |
| 25 #include "SkTDArray.h" | 25 #include "SkTDArray.h" |
| 26 #include "SkThreadPool.h" | 26 #include "SkThreadPool.h" |
| 27 #include "SkTime.h" | 27 #include "SkTime.h" |
| 28 #include "Test.h" | 28 #include "Test.h" |
| 29 #include "TestClassDef.h" | |
| 29 | 30 |
| 30 #ifdef SK_BUILD_FOR_WIN | 31 #ifdef SK_BUILD_FOR_WIN |
| 31 #define PATH_SLASH "\\" | 32 #define PATH_SLASH "\\" |
| 32 #define IN_DIR "D:\\9-30-13\\" | 33 #define IN_DIR "D:\\9-30-13\\" |
| 33 #define OUT_DIR "D:\\skpSkGr\\11\\" | 34 #define OUT_DIR "D:\\skpSkGr\\11\\" |
| 34 #define LINE_FEED "\r\n" | 35 #define LINE_FEED "\r\n" |
| 35 #else | 36 #else |
| 36 #define PATH_SLASH "/" | 37 #define PATH_SLASH "/" |
| 37 #define IN_DIR "/usr/local/google/home/caryclark" PATH_SLASH "9-30-13-skp" | 38 #define IN_DIR "/usr/local/google/home/caryclark" PATH_SLASH "9-30-13-skp" |
| 38 #define OUT_DIR "/media/01CD75512A7F9EE0/4" PATH_SLASH | 39 #define OUT_DIR "/media/01CD75512A7F9EE0/4" PATH_SLASH |
| 39 #define LINE_FEED \n" | 40 #define LINE_FEED "\n" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 #define PATH_STR_SIZE 512 | 43 #define PATH_STR_SIZE 512 |
| 43 | 44 |
| 44 static const struct { | 45 static const struct { |
| 45 int directory; | 46 int directory; |
| 46 const char* filename; | 47 const char* filename; |
| 47 } skipOverSkGr[] = { | 48 } skipOverSkGr[] = { |
| 48 {1, "http___accuweather_com_.skp"}, // Couldn't convert bitmap to texture.h ttp___absoku072_com_ | 49 {1, "http___accuweather_com_.skp"}, // Couldn't convert bitmap to texture.h ttp___absoku072_com_ |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 static const size_t skipOverSkGrCount = 0; // SK_ARRAY_COUNT(skipOverSkGr); | 52 // static const size_t skipOverSkGrCount = 0; // SK_ARRAY_COUNT(skipOverSkGr); |
|
mtklein
2014/01/02 17:51:07
Let's revert everything related to this. It looks
tfarina
2014/01/02 21:09:08
Done.
| |
| 52 | 53 |
| 53 ///////////////////////////////////////// | 54 ///////////////////////////////////////// |
| 54 | 55 |
| 55 class SkpSkGrThreadedRunnable; | 56 class SkpSkGrThreadedRunnable; |
| 56 | 57 |
| 57 enum TestStep { | 58 enum TestStep { |
| 58 kCompareBits, | 59 kCompareBits, |
| 59 kEncodeFiles, | 60 kEncodeFiles, |
| 60 }; | 61 }; |
| 61 | 62 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 return false; | 508 return false; |
| 508 } | 509 } |
| 509 if (c == ' ') { | 510 if (c == ' ') { |
| 510 result->fFilename[i++] = '\0'; | 511 result->fFilename[i++] = '\0'; |
| 511 break; | 512 break; |
| 512 } | 513 } |
| 513 result->fFilename[i++] = c; | 514 result->fFilename[i++] = c; |
| 514 SkASSERT(i < kMaxLength); | 515 SkASSERT(i < kMaxLength); |
| 515 } while (true); | 516 } while (true); |
| 516 do { | 517 do { |
| 517 SkAssertResult(reader.read(&c, 1) != 0); | 518 //SkAssertResult(reader.read(&c, 1) != 0); |
|
mtklein
2014/01/02 17:51:07
This is not a no-op. SkAssertResult always evalua
tfarina
2014/01/02 21:09:08
Done.
tfarina
2014/01/02 21:09:08
Done.
| |
| 518 if (c == ' ') { | 519 if (c == ' ') { |
| 519 break; | 520 break; |
| 520 } | 521 } |
| 521 SkASSERT(c >= '0' && c <= '9'); | 522 SkASSERT(c >= '0' && c <= '9'); |
| 522 result->fPixelError = result->fPixelError * 10 + (c - '0'); | 523 result->fPixelError = result->fPixelError * 10 + (c - '0'); |
| 523 } while (true); | 524 } while (true); |
| 524 bool minus = false; | 525 bool minus = false; |
| 525 do { | 526 do { |
| 526 if (reader.read(&c, 1) == 0) { | 527 if (reader.read(&c, 1) == 0) { |
| 527 break; | 528 break; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 }; | 566 }; |
| 566 | 567 |
| 567 static bool initTest() { | 568 static bool initTest() { |
| 568 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC | 569 #if !defined SK_BUILD_FOR_WIN && !defined SK_BUILD_FOR_MAC |
| 569 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); | 570 SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); |
| 570 SK_CONF_SET("images.png.suppressDecoderWarnings", true); | 571 SK_CONF_SET("images.png.suppressDecoderWarnings", true); |
| 571 #endif | 572 #endif |
| 572 return make_out_dirs(); | 573 return make_out_dirs(); |
| 573 } | 574 } |
| 574 | 575 |
| 575 static void SkpSkGrTest(skiatest::Reporter* reporter) { | 576 DEF_TEST(SkpSkGr, reporter) { |
| 576 SkTArray<TestResult, true> errors; | 577 SkTArray<TestResult, true> errors; |
| 577 if (!initTest()) { | 578 if (!initTest()) { |
| 578 return; | 579 return; |
| 579 } | 580 } |
| 580 SkpSkGrThreadState state; | 581 SkpSkGrThreadState state; |
| 581 state.init(0); | 582 state.init(0); |
| 582 int smallCount = 0; | 583 int smallCount = 0; |
| 583 for (int dirNo = 1; dirNo <= 100; ++dirNo) { | 584 for (int dirNo = 1; dirNo <= 100; ++dirNo) { |
| 584 SkString pictDir = make_in_dir_name(dirNo); | 585 SkString pictDir = make_in_dir_name(dirNo); |
| 585 SkASSERT(pictDir.size()); | 586 SkASSERT(pictDir.size()); |
| 586 if (reporter->verbose()) { | 587 if (reporter->verbose()) { |
| 587 SkDebugf("dirNo=%d\n", dirNo); | 588 SkDebugf("dirNo=%d\n", dirNo); |
| 588 } | 589 } |
| 589 SkOSFile::Iter iter(pictDir.c_str(), "skp"); | 590 SkOSFile::Iter iter(pictDir.c_str(), "skp"); |
| 590 SkString filename; | 591 SkString filename; |
| 591 int testCount = 0; | 592 int testCount = 0; |
| 592 PreParser preParser(dirNo); | 593 PreParser preParser(dirNo); |
| 593 SkFILEWStream statusStream(makeStatusString(dirNo).c_str()); | 594 SkFILEWStream statusStream(makeStatusString(dirNo).c_str()); |
| 594 while (iter.next(&filename)) { | 595 while (iter.next(&filename)) { |
| 595 for (size_t index = 0; index < skipOverSkGrCount; ++index) { | 596 // for (size_t index = 0; index < skipOverSkGrCount; ++index) { |
| 596 if (skipOverSkGr[index].directory == dirNo | 597 // if (skipOverSkGr[index].directory == dirNo |
| 597 && strcmp(filename.c_str(), skipOverSkGr[index].filename ) == 0) { | 598 // && strcmp(filename.c_str(), skipOverSkGr[index].filen ame) == 0) { |
| 598 goto skipOver; | 599 // goto skipOver; |
| 599 } | 600 // } |
| 600 } | 601 // } |
| 601 if (preParser.match(filename, &statusStream, &state.fResult)) { | 602 if (preParser.match(filename, &statusStream, &state.fResult)) { |
| 602 addError(&state); | 603 addError(&state); |
| 603 ++testCount; | 604 ++testCount; |
| 604 goto checkEarlyExit; | 605 goto checkEarlyExit; |
| 605 } | 606 } |
| 606 if (state.fSmallestError > 5000000) { | 607 if (state.fSmallestError > 5000000) { |
| 607 goto breakOut; | 608 goto breakOut; |
| 608 } | 609 } |
| 609 { | 610 { |
| 610 TestResult& result = state.fResult; | 611 TestResult& result = state.fResult; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 621 } else if (++smallCount > 10000) { | 622 } else if (++smallCount > 10000) { |
| 622 goto breakOut; | 623 goto breakOut; |
| 623 } | 624 } |
| 624 } | 625 } |
| 625 ++testCount; | 626 ++testCount; |
| 626 if (reporter->verbose()) { | 627 if (reporter->verbose()) { |
| 627 if (testCount % 100 == 0) { | 628 if (testCount % 100 == 0) { |
| 628 SkDebugf("#%d\n", testCount); | 629 SkDebugf("#%d\n", testCount); |
| 629 } | 630 } |
| 630 } | 631 } |
| 631 skipOver: | 632 // skipOver: |
| 632 reporter->bumpTestCount(); | 633 // reporter->bumpTestCount(); |
| 633 checkEarlyExit: | 634 checkEarlyExit: |
| 634 if (1 && testCount == 20) { | 635 if (1 && testCount == 20) { |
| 635 break; | 636 break; |
| 636 } | 637 } |
| 637 } | 638 } |
| 638 } | 639 } |
| 639 breakOut: | 640 breakOut: |
| 640 if (reporter->verbose()) { | 641 if (reporter->verbose()) { |
| 641 for (int index = 0; index < state.fFoundCount; ++index) { | 642 for (int index = 0; index < state.fFoundCount; ++index) { |
| 642 SkDebugf("%d %s %d\n", state.fDirsFound[index], state.fFilesFound[in dex], | 643 SkDebugf("%d %s %d\n", state.fDirsFound[index], state.fFilesFound[in dex], |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 662 } | 663 } |
| 663 } | 664 } |
| 664 } | 665 } |
| 665 | 666 |
| 666 static void testSkGrMain(SkpSkGrThreadState* data) { | 667 static void testSkGrMain(SkpSkGrThreadState* data) { |
| 667 data->fResult.testOne(); | 668 data->fResult.testOne(); |
| 668 bumpCount(data->fReporter, false); | 669 bumpCount(data->fReporter, false); |
| 669 data->fReporter->bumpTestCount(); | 670 data->fReporter->bumpTestCount(); |
| 670 } | 671 } |
| 671 | 672 |
| 672 static void SkpSkGrThreadedTest(skiatest::Reporter* reporter) { | 673 DEF_TEST(SkpSkGrThreaded, reporter) { |
| 673 if (!initTest()) { | 674 if (!initTest()) { |
| 674 return; | 675 return; |
| 675 } | 676 } |
| 676 int threadCount = reporter->allowThreaded() ? 3 : 1; | 677 int threadCount = reporter->allowThreaded() ? 3 : 1; |
| 677 SkpSkGrThreadedTestRunner testRunner(reporter, threadCount); | 678 SkpSkGrThreadedTestRunner testRunner(reporter, threadCount); |
| 678 for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) { | 679 for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) { |
| 679 SkString pictDir = make_in_dir_name(dirIndex); | 680 SkString pictDir = make_in_dir_name(dirIndex); |
| 680 if (pictDir.size() == 0) { | 681 if (pictDir.size() == 0) { |
| 681 continue; | 682 continue; |
| 682 } | 683 } |
| 683 SkOSFile::Iter iter(pictDir.c_str(), "skp"); | 684 SkOSFile::Iter iter(pictDir.c_str(), "skp"); |
| 684 SkString filename; | 685 SkString filename; |
| 685 while (iter.next(&filename)) { | 686 while (iter.next(&filename)) { |
| 686 SkString pngName = make_png_name(filename.c_str()); | 687 SkString pngName = make_png_name(filename.c_str()); |
| 687 SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str()) ; | 688 SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str()) ; |
| 688 SkString newPng = make_filepath(dirIndex, outGrDir, pngName.c_str()) ; | 689 SkString newPng = make_filepath(dirIndex, outGrDir, pngName.c_str()) ; |
| 689 if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) { | 690 if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) { |
| 690 bumpCount(reporter, true); | 691 bumpCount(reporter, true); |
| 691 continue; | 692 continue; |
| 692 } | 693 } |
| 693 for (size_t index = 0; index < skipOverSkGrCount; ++index) { | 694 // for (size_t index = 0; index < skipoverskgrcount; ++index) { |
| 694 if (skipOverSkGr[index].directory == dirIndex | 695 // if (skipoverskgr[index].directory == dirindex |
| 695 && strcmp(filename.c_str(), skipOverSkGr[index].filename ) == 0) { | 696 // && strcmp(filename.c_str(), skipoverskgr[index].filen ame) == 0) { |
| 696 bumpCount(reporter, true); | 697 // bumpcount(reporter, true); |
| 697 goto skipOver; | 698 // goto skipover; |
| 698 } | 699 // } |
| 699 } | 700 // } |
| 700 *testRunner.fRunnables.append() = SkNEW_ARGS(SkpSkGrThreadedRunnable , | 701 *testRunner.fRunnables.append() = SkNEW_ARGS(SkpSkGrThreadedRunnable , |
| 701 (&testSkGrMain, dirIndex, filename.c_str(), &testRunner)); | 702 (&testSkGrMain, dirIndex, filename.c_str(), &testRunner)); |
| 702 skipOver: | 703 // skipOver: |
| 703 ; | 704 // ; |
| 704 } | 705 } |
| 705 } | 706 } |
| 706 testRunner.render(); | 707 testRunner.render(); |
| 707 SkpSkGrThreadState& max = testRunner.fRunnables[0]->fState; | 708 SkpSkGrThreadState& max = testRunner.fRunnables[0]->fState; |
| 708 for (int dirIndex = 2; dirIndex <= 100; ++dirIndex) { | 709 for (int dirIndex = 2; dirIndex <= 100; ++dirIndex) { |
| 709 SkpSkGrThreadState& state = testRunner.fRunnables[dirIndex - 1]->fState; | 710 SkpSkGrThreadState& state = testRunner.fRunnables[dirIndex - 1]->fState; |
| 710 for (int index = 0; index < state.fFoundCount; ++index) { | 711 for (int index = 0; index < state.fFoundCount; ++index) { |
| 711 int maxIdx = max.fFoundCount; | 712 int maxIdx = max.fFoundCount; |
| 712 if (maxIdx < kMaxFiles) { | 713 if (maxIdx < kMaxFiles) { |
| 713 max.fError[maxIdx] = state.fError[index]; | 714 max.fError[maxIdx] = state.fError[index]; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 729 TestResult encoder; | 730 TestResult encoder; |
| 730 encoder.fTestStep = kEncodeFiles; | 731 encoder.fTestStep = kEncodeFiles; |
| 731 for (int index = 0; index < max.fFoundCount; ++index) { | 732 for (int index = 0; index < max.fFoundCount; ++index) { |
| 732 encoder.fDirNo = max.fDirsFound[index]; | 733 encoder.fDirNo = max.fDirsFound[index]; |
| 733 strcpy(encoder.fFilename, max.fFilesFound[index]); | 734 strcpy(encoder.fFilename, max.fFilesFound[index]); |
| 734 encoder.testOne(); | 735 encoder.testOne(); |
| 735 SkDebugf("+"); | 736 SkDebugf("+"); |
| 736 } | 737 } |
| 737 } | 738 } |
| 738 | 739 |
| 739 static void SkpSkGrOneOffTest(skiatest::Reporter* reporter) { | 740 DEF_TEST(SkpSkGrOneOff, reporter) { |
| 740 if (!initTest()) { | 741 if (!initTest()) { |
| 741 return; | 742 return; |
| 742 } | 743 } |
| 743 int testIndex = 166; | 744 int testIndex = 166; |
| 744 int dirIndex = skipOverSkGr[testIndex - 166].directory; | 745 int dirIndex = skipOverSkGr[testIndex - 166].directory; |
| 745 SkString pictDir = make_in_dir_name(dirIndex); | 746 SkString pictDir = make_in_dir_name(dirIndex); |
| 746 if (pictDir.size() == 0) { | 747 if (pictDir.size() == 0) { |
| 747 return; | 748 return; |
| 748 } | 749 } |
| 749 SkString filename(skipOverSkGr[testIndex - 166].filename); | 750 SkString filename(skipOverSkGr[testIndex - 166].filename); |
| 750 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ()); | 751 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ()); |
| 751 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ()); | 752 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ()); |
| 752 } | 753 } |
| 753 | |
| 754 #include "TestClassDef.h" | |
| 755 DEFINE_TESTCLASS_SHORT(SkpSkGrTest) | |
| 756 | |
| 757 DEFINE_TESTCLASS_SHORT(SkpSkGrOneOffTest) | |
| 758 | |
| 759 DEFINE_TESTCLASS_SHORT(SkpSkGrThreadedTest) | |
| OLD | NEW |