| 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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { | 750 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { |
| 751 fSourceType = "image"; | 751 fSourceType = "image"; |
| 752 fBenchType = "skcodec"; | 752 fBenchType = "skcodec"; |
| 753 const SkString& path = fImages[fCurrentCodec]; | 753 const SkString& path = fImages[fCurrentCodec]; |
| 754 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | 754 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
| 755 continue; | 755 continue; |
| 756 } | 756 } |
| 757 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 757 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
| 758 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 758 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded.get())); |
| 759 if (!codec) { | 759 if (!codec) { |
| 760 // Nothing to time. | 760 // Nothing to time. |
| 761 SkDebugf("Cannot find codec for %s\n", path.c_str()); | 761 SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 762 continue; | 762 continue; |
| 763 } | 763 } |
| 764 | 764 |
| 765 while (fCurrentColorType < fColorTypes.count()) { | 765 while (fCurrentColorType < fColorTypes.count()) { |
| 766 const SkColorType colorType = fColorTypes[fCurrentColorType]; | 766 const SkColorType colorType = fColorTypes[fCurrentColorType]; |
| 767 | 767 |
| 768 SkAlphaType alphaType = codec->getInfo().alphaType(); | 768 SkAlphaType alphaType = codec->getInfo().alphaType(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 int colorCount = 256; | 808 int colorCount = 256; |
| 809 SkPMColor colors[256]; | 809 SkPMColor colors[256]; |
| 810 | 810 |
| 811 const SkCodec::Result result = codec->getPixels( | 811 const SkCodec::Result result = codec->getPixels( |
| 812 info, storage.get(), rowBytes, nullptr, colors, | 812 info, storage.get(), rowBytes, nullptr, colors, |
| 813 &colorCount); | 813 &colorCount); |
| 814 switch (result) { | 814 switch (result) { |
| 815 case SkCodec::kSuccess: | 815 case SkCodec::kSuccess: |
| 816 case SkCodec::kIncompleteInput: | 816 case SkCodec::kIncompleteInput: |
| 817 return new CodecBench(SkOSPath::Basename(path.c_str()), | 817 return new CodecBench(SkOSPath::Basename(path.c_str()), |
| 818 encoded, colorType, alphaType); | 818 encoded.get(), colorType, alphaTyp
e); |
| 819 case SkCodec::kInvalidConversion: | 819 case SkCodec::kInvalidConversion: |
| 820 // This is okay. Not all conversions are valid. | 820 // This is okay. Not all conversions are valid. |
| 821 break; | 821 break; |
| 822 default: | 822 default: |
| 823 // This represents some sort of failure. | 823 // This represents some sort of failure. |
| 824 SkASSERT(false); | 824 SkASSERT(false); |
| 825 break; | 825 break; |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 fCurrentColorType = 0; | 828 fCurrentColorType = 0; |
| 829 } | 829 } |
| 830 | 830 |
| 831 // Run AndroidCodecBenches | 831 // Run AndroidCodecBenches |
| 832 const int sampleSizes[] = { 2, 4, 8 }; | 832 const int sampleSizes[] = { 2, 4, 8 }; |
| 833 for (; fCurrentAndroidCodec < fImages.count(); fCurrentAndroidCodec++) { | 833 for (; fCurrentAndroidCodec < fImages.count(); fCurrentAndroidCodec++) { |
| 834 fSourceType = "image"; | 834 fSourceType = "image"; |
| 835 fBenchType = "skandroidcodec"; | 835 fBenchType = "skandroidcodec"; |
| 836 | 836 |
| 837 const SkString& path = fImages[fCurrentAndroidCodec]; | 837 const SkString& path = fImages[fCurrentAndroidCodec]; |
| 838 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | 838 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
| 839 continue; | 839 continue; |
| 840 } | 840 } |
| 841 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 841 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
| 842 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(enco
ded)); | 842 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(enco
ded.get())); |
| 843 if (!codec) { | 843 if (!codec) { |
| 844 // Nothing to time. | 844 // Nothing to time. |
| 845 SkDebugf("Cannot find codec for %s\n", path.c_str()); | 845 SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 846 continue; | 846 continue; |
| 847 } | 847 } |
| 848 | 848 |
| 849 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) { | 849 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) { |
| 850 int sampleSize = sampleSizes[fCurrentSampleSize]; | 850 int sampleSize = sampleSizes[fCurrentSampleSize]; |
| 851 fCurrentSampleSize++; | 851 fCurrentSampleSize++; |
| 852 if (10 * sampleSize > SkTMin(codec->getInfo().width(), codec->ge
tInfo().height())) { | 852 if (10 * sampleSize > SkTMin(codec->getInfo().width(), codec->ge
tInfo().height())) { |
| 853 // Avoid benchmarking scaled decodes of already small images
. | 853 // Avoid benchmarking scaled decodes of already small images
. |
| 854 break; | 854 break; |
| 855 } | 855 } |
| 856 | 856 |
| 857 return new AndroidCodecBench(SkOSPath::Basename(path.c_str()), e
ncoded, sampleSize); | 857 return new AndroidCodecBench(SkOSPath::Basename(path.c_str()), |
| 858 encoded.get(), sampleSize); |
| 858 } | 859 } |
| 859 fCurrentSampleSize = 0; | 860 fCurrentSampleSize = 0; |
| 860 } | 861 } |
| 861 | 862 |
| 862 // Run the BRDBenches | 863 // Run the BRDBenches |
| 863 // We intend to create benchmarks that model the use cases in | 864 // We intend to create benchmarks that model the use cases in |
| 864 // android/libraries/social/tiledimage. In this library, an image is de
coded in 512x512 | 865 // android/libraries/social/tiledimage. In this library, an image is de
coded in 512x512 |
| 865 // tiles. The image can be translated freely, so the location of a tile
may be anywhere in | 866 // tiles. The image can be translated freely, so the location of a tile
may be anywhere in |
| 866 // the image. For that reason, we will benchmark decodes in five repres
entative locations | 867 // the image. For that reason, we will benchmark decodes in five repres
entative locations |
| 867 // in the image. Additionally, this use case utilizes power of two scal
ing, so we will | 868 // in the image. Additionally, this use case utilizes power of two scal
ing, so we will |
| (...skipping 12 matching lines...) Expand all Loading... |
| 880 | 881 |
| 881 const SkString& path = fImages[fCurrentBRDImage]; | 882 const SkString& path = fImages[fCurrentBRDImage]; |
| 882 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | 883 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
| 883 continue; | 884 continue; |
| 884 } | 885 } |
| 885 | 886 |
| 886 while (fCurrentColorType < fColorTypes.count()) { | 887 while (fCurrentColorType < fColorTypes.count()) { |
| 887 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)
) { | 888 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)
) { |
| 888 while (fCurrentSubsetType <= kLastSingle_SubsetType) { | 889 while (fCurrentSubsetType <= kLastSingle_SubsetType) { |
| 889 | 890 |
| 890 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(pat
h.c_str())); | 891 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_st
r())); |
| 891 const SkColorType colorType = fColorTypes[fCurrentColorT
ype]; | 892 const SkColorType colorType = fColorTypes[fCurrentColorT
ype]; |
| 892 uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize]
; | 893 uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize]
; |
| 893 int currentSubsetType = fCurrentSubsetType++; | 894 int currentSubsetType = fCurrentSubsetType++; |
| 894 | 895 |
| 895 int width = 0; | 896 int width = 0; |
| 896 int height = 0; | 897 int height = 0; |
| 897 if (!valid_brd_bench(encoded.get(), colorType, sampleSiz
e, minOutputSize, | 898 if (!valid_brd_bench(encoded.get(), colorType, sampleSiz
e, minOutputSize, |
| 898 &width, &height)) { | 899 &width, &height)) { |
| 899 break; | 900 break; |
| 900 } | 901 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 | 1302 |
| 1302 return 0; | 1303 return 0; |
| 1303 } | 1304 } |
| 1304 | 1305 |
| 1305 #if !defined SK_BUILD_FOR_IOS | 1306 #if !defined SK_BUILD_FOR_IOS |
| 1306 int main(int argc, char** argv) { | 1307 int main(int argc, char** argv) { |
| 1307 SkCommandLineFlags::Parse(argc, argv); | 1308 SkCommandLineFlags::Parse(argc, argv); |
| 1308 return nanobench_main(); | 1309 return nanobench_main(); |
| 1309 } | 1310 } |
| 1310 #endif | 1311 #endif |
| OLD | NEW |