| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 112 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
| 113 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 113 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
| 114 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 114 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
| 115 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 115 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
| 116 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 116 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
| 117 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 117 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
| 118 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; | 118 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; |
| 119 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t
ime out"); | 119 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t
ime out"); |
| 120 DEFINE_string(useThermalManager, "0,1,10,1000", "enabled,threshold,sleepTimeMs,T
imeoutMs for " | 120 DEFINE_string(useThermalManager, "0,1,10,1000", "enabled,threshold,sleepTimeMs,T
imeoutMs for " |
| 121 "thermalManager\n"); | 121 "thermalManager\n"); |
| 122 DEFINE_bool(simpleCodec, false, "Only decode images to N32 opaque or premul"); |
| 122 | 123 |
| 123 DEFINE_string(sourceType, "", | 124 DEFINE_string(sourceType, "", |
| 124 "Apply usual --match rules to source type: bench, gm, skp, image, etc.")
; | 125 "Apply usual --match rules to source type: bench, gm, skp, image, etc.")
; |
| 125 DEFINE_string(benchType, "", | 126 DEFINE_string(benchType, "", |
| 126 "Apply usual --match rules to bench type: micro, recording, playback, sk
codec, etc."); | 127 "Apply usual --match rules to bench type: micro, recording, playback, sk
codec, etc."); |
| 127 | 128 |
| 128 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } | 129 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
| 129 | 130 |
| 130 static SkString humanize(double ms) { | 131 static SkString humanize(double ms) { |
| 131 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 132 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 613 |
| 613 // Prepare the images for decoding | 614 // Prepare the images for decoding |
| 614 if (!CollectImages(FLAGS_images, &fImages)) { | 615 if (!CollectImages(FLAGS_images, &fImages)) { |
| 615 exit(1); | 616 exit(1); |
| 616 } | 617 } |
| 617 if (!CollectImages(FLAGS_colorImages, &fColorImages)) { | 618 if (!CollectImages(FLAGS_colorImages, &fColorImages)) { |
| 618 exit(1); | 619 exit(1); |
| 619 } | 620 } |
| 620 | 621 |
| 621 // Choose the candidate color types for image decoding | 622 // Choose the candidate color types for image decoding |
| 622 const SkColorType colorTypes[] = | 623 fColorTypes.push_back(kN32_SkColorType); |
| 623 { kN32_SkColorType, | 624 if (!FLAGS_simpleCodec) { |
| 624 kRGB_565_SkColorType, | 625 fColorTypes.push_back(kRGB_565_SkColorType); |
| 625 kAlpha_8_SkColorType, | 626 fColorTypes.push_back(kAlpha_8_SkColorType); |
| 626 kIndex_8_SkColorType, | 627 fColorTypes.push_back(kIndex_8_SkColorType); |
| 627 kGray_8_SkColorType }; | 628 fColorTypes.push_back(kGray_8_SkColorType); |
| 628 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes)); | 629 } |
| 629 } | 630 } |
| 630 | 631 |
| 631 static sk_sp<SkPicture> ReadPicture(const char* path) { | 632 static sk_sp<SkPicture> ReadPicture(const char* path) { |
| 632 // Not strictly necessary, as it will be checked again later, | 633 // 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. | 634 // but helps to avoid a lot of pointless work if we're going to skip it. |
| 634 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path)
.c_str())) { | 635 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path)
.c_str())) { |
| 635 return nullptr; | 636 return nullptr; |
| 636 } | 637 } |
| 637 | 638 |
| 638 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); | 639 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 if (!codec) { | 757 if (!codec) { |
| 757 // Nothing to time. | 758 // Nothing to time. |
| 758 SkDebugf("Cannot find codec for %s\n", path.c_str()); | 759 SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 759 continue; | 760 continue; |
| 760 } | 761 } |
| 761 | 762 |
| 762 while (fCurrentColorType < fColorTypes.count()) { | 763 while (fCurrentColorType < fColorTypes.count()) { |
| 763 const SkColorType colorType = fColorTypes[fCurrentColorType]; | 764 const SkColorType colorType = fColorTypes[fCurrentColorType]; |
| 764 | 765 |
| 765 SkAlphaType alphaType = codec->getInfo().alphaType(); | 766 SkAlphaType alphaType = codec->getInfo().alphaType(); |
| 766 switch (alphaType) { | 767 if (FLAGS_simpleCodec) { |
| 767 case kOpaque_SkAlphaType: | 768 if (kUnpremul_SkAlphaType == alphaType) { |
| 768 // We only need to test one alpha type (opaque). | 769 alphaType = kPremul_SkAlphaType; |
| 769 fCurrentColorType++; | 770 } |
| 770 break; | 771 |
| 771 case kUnpremul_SkAlphaType: | 772 fCurrentColorType++; |
| 772 case kPremul_SkAlphaType: | 773 } else { |
| 773 if (0 == fCurrentAlphaType) { | 774 switch (alphaType) { |
| 774 // Test unpremul first. | 775 case kOpaque_SkAlphaType: |
| 775 alphaType = kUnpremul_SkAlphaType; | 776 // We only need to test one alpha type (opaque). |
| 776 fCurrentAlphaType++; | |
| 777 } else { | |
| 778 // Test premul. | |
| 779 alphaType = kPremul_SkAlphaType; | |
| 780 fCurrentAlphaType = 0; | |
| 781 fCurrentColorType++; | 777 fCurrentColorType++; |
| 782 } | 778 break; |
| 783 break; | 779 case kUnpremul_SkAlphaType: |
| 784 default: | 780 case kPremul_SkAlphaType: |
| 785 SkASSERT(false); | 781 if (0 == fCurrentAlphaType) { |
| 786 fCurrentColorType++; | 782 // Test unpremul first. |
| 787 break; | 783 alphaType = kUnpremul_SkAlphaType; |
| 784 fCurrentAlphaType++; |
| 785 } else { |
| 786 // Test premul. |
| 787 alphaType = kPremul_SkAlphaType; |
| 788 fCurrentAlphaType = 0; |
| 789 fCurrentColorType++; |
| 790 } |
| 791 break; |
| 792 default: |
| 793 SkASSERT(false); |
| 794 fCurrentColorType++; |
| 795 break; |
| 796 } |
| 788 } | 797 } |
| 789 | 798 |
| 790 // Make sure we can decode to this color type and alpha type. | 799 // Make sure we can decode to this color type and alpha type. |
| 791 SkImageInfo info = | 800 SkImageInfo info = |
| 792 codec->getInfo().makeColorType(colorType).makeAlphaType(
alphaType); | 801 codec->getInfo().makeColorType(colorType).makeAlphaType(
alphaType); |
| 793 const size_t rowBytes = info.minRowBytes(); | 802 const size_t rowBytes = info.minRowBytes(); |
| 794 SkAutoMalloc storage(info.getSafeSize(rowBytes)); | 803 SkAutoMalloc storage(info.getSafeSize(rowBytes)); |
| 795 | 804 |
| 796 // Used if fCurrentColorType is kIndex_8_SkColorType | 805 // Used if fCurrentColorType is kIndex_8_SkColorType |
| 797 int colorCount = 256; | 806 int colorCount = 256; |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 | 1299 |
| 1291 return 0; | 1300 return 0; |
| 1292 } | 1301 } |
| 1293 | 1302 |
| 1294 #if !defined SK_BUILD_FOR_IOS | 1303 #if !defined SK_BUILD_FOR_IOS |
| 1295 int main(int argc, char** argv) { | 1304 int main(int argc, char** argv) { |
| 1296 SkCommandLineFlags::Parse(argc, argv); | 1305 SkCommandLineFlags::Parse(argc, argv); |
| 1297 return nanobench_main(); | 1306 return nanobench_main(); |
| 1298 } | 1307 } |
| 1299 #endif | 1308 #endif |
| OLD | NEW |