| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 break; | 522 break; |
| 523 } | 523 } |
| 524 | 524 |
| 525 if (!target->init(info, bench)) { | 525 if (!target->init(info, bench)) { |
| 526 delete target; | 526 delete target; |
| 527 return nullptr; | 527 return nullptr; |
| 528 } | 528 } |
| 529 return target; | 529 return target; |
| 530 } | 530 } |
| 531 | 531 |
| 532 static bool valid_brd_bench(SkData* encoded, SkColorType colorType, uint32_t sam
pleSize, | 532 static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32
_t sampleSize, |
| 533 uint32_t minOutputSize, int* width, int* height) { | 533 uint32_t minOutputSize, int* width, int* height) { |
| 534 SkAutoTDelete<SkBitmapRegionDecoder> brd( | 534 SkAutoTDelete<SkBitmapRegionDecoder> brd( |
| 535 SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndro
idCodec_Strategy)); | 535 SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndro
idCodec_Strategy)); |
| 536 if (nullptr == brd.get()) { | 536 if (nullptr == brd.get()) { |
| 537 // This is indicates that subset decoding is not supported for a particu
lar image format. | 537 // This is indicates that subset decoding is not supported for a particu
lar image format. |
| 538 return false; | 538 return false; |
| 539 } | 539 } |
| 540 | 540 |
| 541 if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * min
OutputSize > | 541 if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * min
OutputSize > |
| 542 (uint32_t) brd->height()) { | 542 (uint32_t) brd->height()) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } | 749 } |
| 750 | 750 |
| 751 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { | 751 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { |
| 752 fSourceType = "image"; | 752 fSourceType = "image"; |
| 753 fBenchType = "skcodec"; | 753 fBenchType = "skcodec"; |
| 754 const SkString& path = fImages[fCurrentCodec]; | 754 const SkString& path = fImages[fCurrentCodec]; |
| 755 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | 755 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
| 756 continue; | 756 continue; |
| 757 } | 757 } |
| 758 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); | 758 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
| 759 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded.get())); | 759 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 760 if (!codec) { | 760 if (!codec) { |
| 761 // Nothing to time. | 761 // Nothing to time. |
| 762 SkDebugf("Cannot find codec for %s\n", path.c_str()); | 762 SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 763 continue; | 763 continue; |
| 764 } | 764 } |
| 765 | 765 |
| 766 while (fCurrentColorType < fColorTypes.count()) { | 766 while (fCurrentColorType < fColorTypes.count()) { |
| 767 const SkColorType colorType = fColorTypes[fCurrentColorType]; | 767 const SkColorType colorType = fColorTypes[fCurrentColorType]; |
| 768 | 768 |
| 769 SkAlphaType alphaType = codec->getInfo().alphaType(); | 769 SkAlphaType alphaType = codec->getInfo().alphaType(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 const int sampleSizes[] = { 2, 4, 8 }; | 833 const int sampleSizes[] = { 2, 4, 8 }; |
| 834 for (; fCurrentAndroidCodec < fImages.count(); fCurrentAndroidCodec++) { | 834 for (; fCurrentAndroidCodec < fImages.count(); fCurrentAndroidCodec++) { |
| 835 fSourceType = "image"; | 835 fSourceType = "image"; |
| 836 fBenchType = "skandroidcodec"; | 836 fBenchType = "skandroidcodec"; |
| 837 | 837 |
| 838 const SkString& path = fImages[fCurrentAndroidCodec]; | 838 const SkString& path = fImages[fCurrentAndroidCodec]; |
| 839 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | 839 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
| 840 continue; | 840 continue; |
| 841 } | 841 } |
| 842 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); | 842 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
| 843 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(enco
ded.get())); | 843 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(enco
ded)); |
| 844 if (!codec) { | 844 if (!codec) { |
| 845 // Nothing to time. | 845 // Nothing to time. |
| 846 SkDebugf("Cannot find codec for %s\n", path.c_str()); | 846 SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 847 continue; | 847 continue; |
| 848 } | 848 } |
| 849 | 849 |
| 850 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) { | 850 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) { |
| 851 int sampleSize = sampleSizes[fCurrentSampleSize]; | 851 int sampleSize = sampleSizes[fCurrentSampleSize]; |
| 852 fCurrentSampleSize++; | 852 fCurrentSampleSize++; |
| 853 if (10 * sampleSize > SkTMin(codec->getInfo().width(), codec->ge
tInfo().height())) { | 853 if (10 * sampleSize > SkTMin(codec->getInfo().width(), codec->ge
tInfo().height())) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)
) { | 889 while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)
) { |
| 890 while (fCurrentSubsetType <= kLastSingle_SubsetType) { | 890 while (fCurrentSubsetType <= kLastSingle_SubsetType) { |
| 891 | 891 |
| 892 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_st
r())); | 892 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_st
r())); |
| 893 const SkColorType colorType = fColorTypes[fCurrentColorT
ype]; | 893 const SkColorType colorType = fColorTypes[fCurrentColorT
ype]; |
| 894 uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize]
; | 894 uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize]
; |
| 895 int currentSubsetType = fCurrentSubsetType++; | 895 int currentSubsetType = fCurrentSubsetType++; |
| 896 | 896 |
| 897 int width = 0; | 897 int width = 0; |
| 898 int height = 0; | 898 int height = 0; |
| 899 if (!valid_brd_bench(encoded.get(), colorType, sampleSiz
e, minOutputSize, | 899 if (!valid_brd_bench(encoded, colorType, sampleSize, min
OutputSize, |
| 900 &width, &height)) { | 900 &width, &height)) { |
| 901 break; | 901 break; |
| 902 } | 902 } |
| 903 | 903 |
| 904 SkString basename = SkOSPath::Basename(path.c_str()); | 904 SkString basename = SkOSPath::Basename(path.c_str()); |
| 905 SkIRect subset; | 905 SkIRect subset; |
| 906 const uint32_t subsetSize = sampleSize * minOutputSize; | 906 const uint32_t subsetSize = sampleSize * minOutputSize; |
| 907 switch (currentSubsetType) { | 907 switch (currentSubsetType) { |
| 908 case kTopLeft_SubsetType: | 908 case kTopLeft_SubsetType: |
| 909 basename.append("_TopLeft"); | 909 basename.append("_TopLeft"); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 | 1303 |
| 1304 return 0; | 1304 return 0; |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 #if !defined SK_BUILD_FOR_IOS | 1307 #if !defined SK_BUILD_FOR_IOS |
| 1308 int main(int argc, char** argv) { | 1308 int main(int argc, char** argv) { |
| 1309 SkCommandLineFlags::Parse(argc, argv); | 1309 SkCommandLineFlags::Parse(argc, argv); |
| 1310 return nanobench_main(); | 1310 return nanobench_main(); |
| 1311 } | 1311 } |
| 1312 #endif | 1312 #endif |
| OLD | NEW |