| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 <ctype.h> | 8 #include <ctype.h> |
| 9 | 9 |
| 10 #include "nanobench.h" | 10 #include "nanobench.h" |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 614 } |
| 615 } else if (sk_exists(flag)) { | 615 } else if (sk_exists(flag)) { |
| 616 // Also add the value if it is a single image | 616 // Also add the value if it is a single image |
| 617 fImages.push_back() = flag; | 617 fImages.push_back() = flag; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 // Choose the candidate color types for image decoding | 621 // Choose the candidate color types for image decoding |
| 622 const SkColorType colorTypes[] = | 622 const SkColorType colorTypes[] = |
| 623 { kN32_SkColorType, | 623 { kN32_SkColorType, |
| 624 kRGB_565_SkColorType, | 624 /*kRGB_565_SkColorType, |
| 625 kAlpha_8_SkColorType, | 625 kAlpha_8_SkColorType, |
| 626 kIndex_8_SkColorType, | 626 kIndex_8_SkColorType, |
| 627 kGray_8_SkColorType }; | 627 kGray_8_SkColorType*/ }; |
| 628 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes)); | 628 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes)); |
| 629 } | 629 } |
| 630 | 630 |
| 631 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { | 631 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { |
| 632 // Not strictly necessary, as it will be checked again later, | 632 // Not strictly necessary, as it will be checked again later, |
| 633 // but helps to avoid a lot of pointless work if we're going to skip it. | 633 // but helps to avoid a lot of pointless work if we're going to skip it. |
| 634 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { | 634 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { |
| 635 return false; | 635 return false; |
| 636 } | 636 } |
| 637 | 637 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriod
Ms)); | 734 SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriod
Ms)); |
| 735 return new SKPAnimationBench(name.c_str(), pic.get(), fClip, ani
mation, | 735 return new SKPAnimationBench(name.c_str(), pic.get(), fClip, ani
mation, |
| 736 FLAGS_loopSKP); | 736 FLAGS_loopSKP); |
| 737 } | 737 } |
| 738 } | 738 } |
| 739 | 739 |
| 740 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { | 740 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { |
| 741 fSourceType = "image"; | 741 fSourceType = "image"; |
| 742 fBenchType = "skcodec"; | 742 fBenchType = "skcodec"; |
| 743 const SkString& path = fImages[fCurrentCodec]; | 743 const SkString& path = fImages[fCurrentCodec]; |
| 744 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | 744 //if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
| 745 continue; | 745 // continue; |
| 746 } | 746 //} |
| 747 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 747 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
| 748 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 748 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 749 if (!codec) { | 749 if (!codec) { |
| 750 // Nothing to time. | 750 // Nothing to time. |
| 751 SkDebugf("Cannot find codec for %s\n", path.c_str()); | 751 SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 752 continue; | 752 continue; |
| 753 } | 753 } |
| 754 | 754 |
| 755 while (fCurrentColorType < fColorTypes.count()) { | 755 while (fCurrentColorType < fColorTypes.count()) { |
| 756 const SkColorType colorType = fColorTypes[fCurrentColorType]; | 756 const SkColorType colorType = fColorTypes[fCurrentColorType]; |
| 757 | 757 |
| 758 SkAlphaType alphaType = codec->getInfo().alphaType(); | 758 SkAlphaType alphaType = codec->getInfo().alphaType(); |
| 759 switch (alphaType) { | 759 switch (alphaType) { |
| 760 case kOpaque_SkAlphaType: | 760 case kOpaque_SkAlphaType: |
| 761 // We only need to test one alpha type (opaque). | 761 // We only need to test one alpha type (opaque). |
| 762 fCurrentColorType++; | 762 fCurrentColorType++; |
| 763 break; | 763 break; |
| 764 case kUnpremul_SkAlphaType: | 764 case kUnpremul_SkAlphaType: |
| 765 case kPremul_SkAlphaType: | 765 case kPremul_SkAlphaType: |
| 766 if (0 == fCurrentAlphaType) { | 766 if (0 == fCurrentAlphaType) { |
| 767 // Test unpremul first. | 767 // Test unpremul first. |
| 768 alphaType = kUnpremul_SkAlphaType; | 768 alphaType = kPremul_SkAlphaType; |
| 769 fCurrentAlphaType++; | 769 fCurrentColorType++; |
| 770 } else { | 770 } else { |
| 771 // Test premul. | 771 // Test premul. |
| 772 alphaType = kPremul_SkAlphaType; | 772 alphaType = kPremul_SkAlphaType; |
| 773 fCurrentAlphaType = 0; | 773 fCurrentAlphaType = 0; |
| 774 fCurrentColorType++; | 774 fCurrentColorType++; |
| 775 } | 775 } |
| 776 break; | 776 break; |
| 777 default: | 777 default: |
| 778 SkASSERT(false); | 778 SkASSERT(false); |
| 779 fCurrentColorType++; | 779 fCurrentColorType++; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 1238 |
| 1239 return 0; | 1239 return 0; |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 #if !defined SK_BUILD_FOR_IOS | 1242 #if !defined SK_BUILD_FOR_IOS |
| 1243 int main(int argc, char** argv) { | 1243 int main(int argc, char** argv) { |
| 1244 SkCommandLineFlags::Parse(argc, argv); | 1244 SkCommandLineFlags::Parse(argc, argv); |
| 1245 return nanobench_main(); | 1245 return nanobench_main(); |
| 1246 } | 1246 } |
| 1247 #endif | 1247 #endif |
| OLD | NEW |