| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); | 100 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
| 101 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); | 101 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
| 102 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " | 102 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " |
| 103 "function that ping-pongs between 1.0 and zoomMax."
); | 103 "function that ping-pongs between 1.0 and zoomMax."
); |
| 104 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 104 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
| 105 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 105 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
| 106 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 106 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
| 107 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 107 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
| 108 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 108 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
| 109 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 109 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
| 110 DEFINE_bool(pngBuildTileIndex, false, "If supported, use png buildTileIndex/deco
deSubset."); | |
| 111 DEFINE_bool(jpgBuildTileIndex, false, "If supported, use jpg buildTileIndex/deco
deSubset."); | |
| 112 | 110 |
| 113 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } | 111 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
| 114 | 112 |
| 115 static SkString humanize(double ms) { | 113 static SkString humanize(double ms) { |
| 116 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 114 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
| 117 return HumanizeMs(ms); | 115 return HumanizeMs(ms); |
| 118 } | 116 } |
| 119 #define HUMANIZE(ms) humanize(ms).c_str() | 117 #define HUMANIZE(ms) humanize(ms).c_str() |
| 120 | 118 |
| 121 bool Target::init(SkImageInfo info, Benchmark* bench) { | 119 bool Target::init(SkImageInfo info, Benchmark* bench) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 490 |
| 493 if (!target->init(info, bench)) { | 491 if (!target->init(info, bench)) { |
| 494 delete target; | 492 delete target; |
| 495 return nullptr; | 493 return nullptr; |
| 496 } | 494 } |
| 497 return target; | 495 return target; |
| 498 } | 496 } |
| 499 | 497 |
| 500 /* | 498 /* |
| 501 * We only run our subset benches on files that are supported by BitmapRegionDec
oder: | 499 * We only run our subset benches on files that are supported by BitmapRegionDec
oder: |
| 502 * i.e. PNG, JPEG, and WEBP. We do *not* test WEBP when using codec, since we do
not | 500 * i.e. PNG, JPEG, and WEBP. We do *not* test WEBP, since we do not have a scanl
ine |
| 503 * have a scanline decoder for WEBP, which is necessary for running the subset b
ench. | 501 * decoder for WEBP, which is necessary for running the subset bench. (Another b
ench |
| 504 * (Another bench must be used to test WEBP, which decodes subsets natively.) | 502 * must be used to test WEBP, which decodes subsets natively.) |
| 505 */ | 503 */ |
| 506 static bool run_subset_bench(const SkString& path, bool useCodec) { | 504 static bool run_subset_bench(const SkString& path) { |
| 507 static const char* const exts[] = { | 505 static const char* const exts[] = { |
| 508 "jpg", "jpeg", | 506 "jpg", "jpeg", "png", |
| 509 "JPG", "JPEG", | 507 "JPG", "JPEG", "PNG", |
| 510 }; | 508 }; |
| 511 | 509 |
| 512 if (useCodec || FLAGS_jpgBuildTileIndex) { | 510 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
| 513 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 511 if (path.endsWith(exts[i])) { |
| 514 if (path.endsWith(exts[i])) { | 512 return true; |
| 515 return true; | |
| 516 } | |
| 517 } | 513 } |
| 518 } | 514 } |
| 519 | 515 |
| 520 // Test png in SkCodec, and optionally on SkImageDecoder. SkImageDecoder is | |
| 521 // disabled by default because it leaks memory. | |
| 522 // https://bug.skia.org/4360 | |
| 523 if ((useCodec || FLAGS_pngBuildTileIndex) && (path.endsWith("png") || path.e
ndsWith("PNG"))) { | |
| 524 return true; | |
| 525 } | |
| 526 | |
| 527 if (!useCodec && (path.endsWith("webp") || path.endsWith("WEBP"))) { | |
| 528 return true; | |
| 529 } | |
| 530 | |
| 531 return false; | 516 return false; |
| 532 } | 517 } |
| 533 | 518 |
| 534 /* | 519 /* |
| 535 * Returns true if set up for a subset decode succeeds, false otherwise | 520 * Returns true if set up for a subset decode succeeds, false otherwise |
| 536 * If the set-up succeeds, the width and height parameters will be set | 521 * If the set-up succeeds, the width and height parameters will be set |
| 537 */ | 522 */ |
| 538 static bool valid_subset_bench(const SkString& path, SkColorType colorType, bool
useCodec, | 523 static bool valid_subset_bench(const SkString& path, SkColorType colorType, |
| 539 int* width, int* height) { | 524 int* width, int* height) { |
| 540 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 525 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
| 541 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encoded)); | 526 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encoded)); |
| 542 | 527 |
| 543 // Check that we can create a codec or image decoder. | 528 // Check that we can create a codec. |
| 544 if (useCodec) { | 529 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
| 545 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); | 530 if (nullptr == codec) { |
| 546 if (nullptr == codec) { | 531 SkDebugf("Could not create codec for %s. Skipping bench.\n", path.c_str
()); |
| 547 SkDebugf("Could not create codec for %s. Skipping bench.\n", path.c
_str()); | 532 return false; |
| 548 return false; | 533 } |
| 549 } | |
| 550 | 534 |
| 551 // These will be initialized by SkCodec if the color type is kIndex8 and | 535 // These will be initialized by SkCodec if the color type is kIndex8 and |
| 552 // unused otherwise. | 536 // unused otherwise. |
| 553 SkPMColor colors[256]; | 537 SkPMColor colors[256]; |
| 554 int colorCount; | 538 int colorCount; |
| 555 const SkImageInfo info = codec->getInfo().makeColorType(colorType); | 539 const SkImageInfo info = codec->getInfo().makeColorType(colorType); |
| 556 if (codec->startScanlineDecode(info, nullptr, colors, &colorCount) != Sk
Codec::kSuccess) | 540 if (codec->startScanlineDecode(info, nullptr, colors, &colorCount) != SkCode
c::kSuccess) |
| 557 { | 541 { |
| 558 SkDebugf("Could not create scanline decoder for %s with color type %
s. " | 542 SkDebugf("Could not create scanline decoder for %s with color type %s.
" |
| 559 "Skipping bench.\n", path.c_str(), color_type_to_str(colorTy
pe)); | 543 "Skipping bench.\n", path.c_str(), color_type_to_str(colorType))
; |
| 560 return false; | 544 return false; |
| 561 } | |
| 562 *width = info.width(); | |
| 563 *height = info.height(); | |
| 564 } else { | |
| 565 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream)); | |
| 566 if (nullptr == decoder) { | |
| 567 SkDebugf("Could not create decoder for %s. Skipping bench.\n", path
.c_str()); | |
| 568 return false; | |
| 569 } | |
| 570 //FIXME: See https://bug.skia.org/3921 | |
| 571 if (kIndex_8_SkColorType == colorType || kGray_8_SkColorType == colorTyp
e) { | |
| 572 SkDebugf("Cannot use image subset decoder for %s with color type %s.
" | |
| 573 "Skipping bench.\n", path.c_str(), color_type_to_str(colorTy
pe)); | |
| 574 return false; | |
| 575 } | |
| 576 if (!decoder->buildTileIndex(stream.detach(), width, height)) { | |
| 577 SkDebugf("Could not build tile index for %s. Skipping bench.\n", pa
th.c_str()); | |
| 578 return false; | |
| 579 } | |
| 580 } | 545 } |
| 546 *width = info.width(); |
| 547 *height = info.height(); |
| 581 | 548 |
| 582 // Check if the image is large enough for a meaningful subset benchmark. | 549 // Check if the image is large enough for a meaningful subset benchmark. |
| 583 if (*width <= 512 && *height <= 512) { | 550 if (*width <= 512 && *height <= 512) { |
| 584 // This should not print a message since it is not an error. | 551 // This should not print a message since it is not an error. |
| 585 return false; | 552 return false; |
| 586 } | 553 } |
| 587 | 554 |
| 588 return true; | 555 return true; |
| 589 } | 556 } |
| 590 | 557 |
| 591 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoder::Strategy str
ategy, | 558 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoder::Strategy str
ategy, |
| 592 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int*
width, | 559 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int*
width, |
| 593 int* height) { | 560 int* height) { |
| 594 SkAutoTDelete<SkBitmapRegionDecoder> brd( | 561 SkAutoTDelete<SkBitmapRegionDecoder> brd( |
| 595 SkBitmapRegionDecoder::Create(encoded, strategy)); | 562 SkBitmapRegionDecoder::Create(encoded, strategy)); |
| 596 if (nullptr == brd.get()) { | 563 if (nullptr == brd.get()) { |
| 597 // This is indicates that subset decoding is not supported for a particu
lar image format. | 564 // This is indicates that subset decoding is not supported for a particu
lar image format. |
| 598 return false; | 565 return false; |
| 599 } | 566 } |
| 600 | 567 |
| 601 SkBitmap bitmap; | 568 SkBitmap bitmap; |
| 602 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, brd->width(
), brd->height()), | 569 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, brd->width(
), brd->height()), |
| 603 1, colorType, false)) { | 570 1, colorType, false)) { |
| 604 return false; | 571 return false; |
| 605 } | 572 } |
| 606 if (colorType != bitmap.colorType()) { | |
| 607 // This indicates that conversion to the requested color type is not sup
ported for the | |
| 608 // particular image. | |
| 609 return false; | |
| 610 } | |
| 611 | 573 |
| 612 if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * min
OutputSize > | 574 if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * min
OutputSize > |
| 613 (uint32_t) brd->height()) { | 575 (uint32_t) brd->height()) { |
| 614 // This indicates that the image is not large enough to decode a | 576 // This indicates that the image is not large enough to decode a |
| 615 // minOutputSize x minOutputSize subset at the given sampleSize. | 577 // minOutputSize x minOutputSize subset at the given sampleSize. |
| 616 return false; | 578 return false; |
| 617 } | 579 } |
| 618 | 580 |
| 619 // Set the image width and height. The calling code will use this to choose
subsets to decode. | 581 // Set the image width and height. The calling code will use this to choose
subsets to decode. |
| 620 *width = brd->width(); | 582 *width = brd->width(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 641 , fCurrentRecording(0) | 603 , fCurrentRecording(0) |
| 642 , fCurrentScale(0) | 604 , fCurrentScale(0) |
| 643 , fCurrentSKP(0) | 605 , fCurrentSKP(0) |
| 644 , fCurrentUseMPD(0) | 606 , fCurrentUseMPD(0) |
| 645 , fCurrentCodec(0) | 607 , fCurrentCodec(0) |
| 646 , fCurrentImage(0) | 608 , fCurrentImage(0) |
| 647 , fCurrentSubsetImage(0) | 609 , fCurrentSubsetImage(0) |
| 648 , fCurrentBRDImage(0) | 610 , fCurrentBRDImage(0) |
| 649 , fCurrentColorType(0) | 611 , fCurrentColorType(0) |
| 650 , fCurrentSubsetType(0) | 612 , fCurrentSubsetType(0) |
| 651 , fUseCodec(0) | |
| 652 , fCurrentBRDStrategy(0) | 613 , fCurrentBRDStrategy(0) |
| 653 , fCurrentBRDSampleSize(0) | 614 , fCurrentBRDSampleSize(0) |
| 654 , fCurrentAnimSKP(0) { | 615 , fCurrentAnimSKP(0) { |
| 655 for (int i = 0; i < FLAGS_skps.count(); i++) { | 616 for (int i = 0; i < FLAGS_skps.count(); i++) { |
| 656 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { | 617 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
| 657 fSKPs.push_back() = FLAGS_skps[i]; | 618 fSKPs.push_back() = FLAGS_skps[i]; |
| 658 } else { | 619 } else { |
| 659 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); | 620 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); |
| 660 SkString path; | 621 SkString path; |
| 661 while (it.next(&path)) { | 622 while (it.next(&path)) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 colorType, SkImageDecoder::kDecodePixels_Mode) | 852 colorType, SkImageDecoder::kDecodePixels_Mode) |
| 892 && bitmap.colorType() == colorType) { | 853 && bitmap.colorType() == colorType) { |
| 893 return new DecodingBench(path, colorType); | 854 return new DecodingBench(path, colorType); |
| 894 } | 855 } |
| 895 } | 856 } |
| 896 fCurrentColorType = 0; | 857 fCurrentColorType = 0; |
| 897 fCurrentImage++; | 858 fCurrentImage++; |
| 898 } | 859 } |
| 899 | 860 |
| 900 // Run the SubsetBenches | 861 // Run the SubsetBenches |
| 901 bool useCodecOpts[] = { true, false }; | 862 while (fCurrentSubsetImage < fImages.count()) { |
| 902 while (fUseCodec < 2) { | |
| 903 bool useCodec = useCodecOpts[fUseCodec]; | |
| 904 fSourceType = "image"; | 863 fSourceType = "image"; |
| 905 fBenchType = useCodec ? "skcodec" : "skimagedecoder"; | 864 fBenchType = "skcodec"; |
| 906 while (fCurrentSubsetImage < fImages.count()) { | 865 const SkString& path = fImages[fCurrentSubsetImage]; |
| 907 const SkString& path = fImages[fCurrentSubsetImage]; | 866 if (!run_subset_bench(path)) { |
| 908 if (!run_subset_bench(path, useCodec)) { | 867 fCurrentSubsetImage++; |
| 909 fCurrentSubsetImage++; | 868 continue; |
| 910 continue; | 869 } |
| 870 while (fCurrentColorType < fColorTypes.count()) { |
| 871 SkColorType colorType = fColorTypes[fCurrentColorType]; |
| 872 while (fCurrentSubsetType <= kLast_SubsetType) { |
| 873 int width = 0; |
| 874 int height = 0; |
| 875 int currentSubsetType = fCurrentSubsetType++; |
| 876 if (valid_subset_bench(path, colorType, &width, &height)) { |
| 877 switch (currentSubsetType) { |
| 878 case kTopLeft_SubsetType: |
| 879 return new SubsetSingleBench(path, colorType, wi
dth/3, |
| 880 height/3, 0, 0); |
| 881 case kTopRight_SubsetType: |
| 882 return new SubsetSingleBench(path, colorType, wi
dth/3, |
| 883 height/3, 2*width/3, 0); |
| 884 case kMiddle_SubsetType: |
| 885 return new SubsetSingleBench(path, colorType, wi
dth/3, |
| 886 height/3, width/3, height/3); |
| 887 case kBottomLeft_SubsetType: |
| 888 return new SubsetSingleBench(path, colorType, wi
dth/3, |
| 889 height/3, 0, 2*height/3); |
| 890 case kBottomRight_SubsetType: |
| 891 return new SubsetSingleBench(path, colorType, wi
dth/3, |
| 892 height/3, 2*width/3, 2*height/3); |
| 893 case kTranslate_SubsetType: |
| 894 return new SubsetTranslateBench(path, colorType,
512, 512); |
| 895 case kZoom_SubsetType: |
| 896 return new SubsetZoomBench(path, colorType, 512,
512); |
| 897 } |
| 898 } else { |
| 899 break; |
| 900 } |
| 911 } | 901 } |
| 912 while (fCurrentColorType < fColorTypes.count()) { | 902 fCurrentSubsetType = 0; |
| 913 SkColorType colorType = fColorTypes[fCurrentColorType]; | 903 fCurrentColorType++; |
| 914 while (fCurrentSubsetType <= kLast_SubsetType) { | |
| 915 int width = 0; | |
| 916 int height = 0; | |
| 917 int currentSubsetType = fCurrentSubsetType++; | |
| 918 if (valid_subset_bench(path, colorType, useCodec, &width
, &height)) { | |
| 919 switch (currentSubsetType) { | |
| 920 case kTopLeft_SubsetType: | |
| 921 return new SubsetSingleBench(path, colorType
, width/3, | |
| 922 height/3, 0, 0, useCodec); | |
| 923 case kTopRight_SubsetType: | |
| 924 return new SubsetSingleBench(path, colorType
, width/3, | |
| 925 height/3, 2*width/3, 0, useCodec); | |
| 926 case kMiddle_SubsetType: | |
| 927 return new SubsetSingleBench(path, colorType
, width/3, | |
| 928 height/3, width/3, height/3, useCode
c); | |
| 929 case kBottomLeft_SubsetType: | |
| 930 return new SubsetSingleBench(path, colorType
, width/3, | |
| 931 height/3, 0, 2*height/3, useCodec); | |
| 932 case kBottomRight_SubsetType: | |
| 933 return new SubsetSingleBench(path, colorType
, width/3, | |
| 934 height/3, 2*width/3, 2*height/3, use
Codec); | |
| 935 case kTranslate_SubsetType: | |
| 936 return new SubsetTranslateBench(path, colorT
ype, 512, 512, | |
| 937 useCodec); | |
| 938 case kZoom_SubsetType: | |
| 939 return new SubsetZoomBench(path, colorType,
512, 512, | |
| 940 useCodec); | |
| 941 } | |
| 942 } else { | |
| 943 break; | |
| 944 } | |
| 945 } | |
| 946 fCurrentSubsetType = 0; | |
| 947 fCurrentColorType++; | |
| 948 } | |
| 949 fCurrentColorType = 0; | |
| 950 fCurrentSubsetImage++; | |
| 951 } | 904 } |
| 952 fCurrentSubsetImage = 0; | 905 fCurrentColorType = 0; |
| 953 fUseCodec++; | 906 fCurrentSubsetImage++; |
| 954 } | 907 } |
| 955 | 908 |
| 956 // Run the BRDBenches | 909 // Run the BRDBenches |
| 957 // We will benchmark multiple BRD strategies. | 910 // We will benchmark multiple BRD strategies. |
| 958 static const struct { | 911 static const struct { |
| 959 SkBitmapRegionDecoder::Strategy fStrategy; | 912 SkBitmapRegionDecoder::Strategy fStrategy; |
| 960 const char* fName; | 913 const char* fName; |
| 961 } strategies[] = { | 914 } strategies[] = { |
| 962 { SkBitmapRegionDecoder::kOriginal_Strategy, "BRD" }, | 915 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" }, |
| 963 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" }, | |
| 964 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec"
}, | 916 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec"
}, |
| 965 }; | 917 }; |
| 966 | 918 |
| 967 // We intend to create benchmarks that model the use cases in | 919 // We intend to create benchmarks that model the use cases in |
| 968 // android/libraries/social/tiledimage. In this library, an image is de
coded in 512x512 | 920 // android/libraries/social/tiledimage. In this library, an image is de
coded in 512x512 |
| 969 // tiles. The image can be translated freely, so the location of a tile
may be anywhere in | 921 // tiles. The image can be translated freely, so the location of a tile
may be anywhere in |
| 970 // the image. For that reason, we will benchmark decodes in five repres
entative locations | 922 // the image. For that reason, we will benchmark decodes in five repres
entative locations |
| 971 // in the image. Additionally, this use case utilizes power of two scal
ing, so we will | 923 // in the image. Additionally, this use case utilizes power of two scal
ing, so we will |
| 972 // test on power of two sample sizes. The output tile is always 512x512
, so, when a | 924 // test on power of two sample sizes. The output tile is always 512x512
, so, when a |
| 973 // sampleSize is used, the size of the subset that is decoded is always | 925 // sampleSize is used, the size of the subset that is decoded is always |
| 974 // (sampleSize*512)x(sampleSize*512). | 926 // (sampleSize*512)x(sampleSize*512). |
| 975 // There are a few good reasons to only test on power of two sample size
s at this time: | 927 // There are a few good reasons to only test on power of two sample size
s at this time: |
| 976 // JPEG decodes using kOriginal_Strategy are broken for non-powers o
f two. | 928 // JPEG decodes using kOriginal_Strategy are broken for non-powers o
f two. |
| 977 // https://bug.skia.org/4319 | 929 // https://bug.skia.org/4319 |
| 978 // All use cases we are aware of only scale by powers of two. | 930 // All use cases we are aware of only scale by powers of two. |
| 979 // PNG decodes use the indicated sampling strategy regardless of the
sample size, so | 931 // PNG decodes use the indicated sampling strategy regardless of the
sample size, so |
| 980 // these tests are sufficient to provide good coverage of our sc
aling options. | 932 // these tests are sufficient to provide good coverage of our sc
aling options. |
| 981 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16, 32, 64 }; | 933 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16, 32, 64 }; |
| 982 const uint32_t minOutputSize = 512; | 934 const uint32_t minOutputSize = 512; |
| 983 while (fCurrentBRDImage < fImages.count()) { | 935 while (fCurrentBRDImage < fImages.count()) { |
| 984 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { | 936 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { |
| 985 fSourceType = "image"; | 937 fSourceType = "image"; |
| 986 fBenchType = strategies[fCurrentBRDStrategy].fName; | 938 fBenchType = strategies[fCurrentBRDStrategy].fName; |
| 987 | 939 |
| 988 const SkString& path = fImages[fCurrentBRDImage]; | 940 const SkString& path = fImages[fCurrentBRDImage]; |
| 989 const SkBitmapRegionDecoder::Strategy strategy = | 941 const SkBitmapRegionDecoder::Strategy strategy = |
| 990 strategies[fCurrentBRDStrategy].fStrategy; | 942 strategies[fCurrentBRDStrategy].fStrategy; |
| 991 | 943 |
| 992 if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy) { | |
| 993 // Disable png and jpeg for SkImageDecoder: | |
| 994 if (!FLAGS_jpgBuildTileIndex) { | |
| 995 if (path.endsWith("JPEG") || path.endsWith("JPG") || | |
| 996 path.endsWith("jpeg") || path.endsWith("jpg")) | |
| 997 { | |
| 998 fCurrentBRDStrategy++; | |
| 999 continue; | |
| 1000 } | |
| 1001 } | |
| 1002 if (!FLAGS_pngBuildTileIndex) { | |
| 1003 if (path.endsWith("PNG") || path.endsWith("png")) { | |
| 1004 fCurrentBRDStrategy++; | |
| 1005 continue; | |
| 1006 } | |
| 1007 } | |
| 1008 } | |
| 1009 | |
| 1010 while (fCurrentColorType < fColorTypes.count()) { | 944 while (fCurrentColorType < fColorTypes.count()) { |
| 1011 while (fCurrentBRDSampleSize < (int) SK_ARRAY_COUNT(sampleSi
zes)) { | 945 while (fCurrentBRDSampleSize < (int) SK_ARRAY_COUNT(sampleSi
zes)) { |
| 1012 while (fCurrentSubsetType <= kLastSingle_SubsetType) { | 946 while (fCurrentSubsetType <= kLastSingle_SubsetType) { |
| 1013 | 947 |
| 1014 | 948 |
| 1015 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName
(path.c_str())); | 949 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName
(path.c_str())); |
| 1016 const SkColorType colorType = fColorTypes[fCurrentCo
lorType]; | 950 const SkColorType colorType = fColorTypes[fCurrentCo
lorType]; |
| 1017 uint32_t sampleSize = sampleSizes[fCurrentBRDSampleS
ize]; | 951 uint32_t sampleSize = sampleSizes[fCurrentBRDSampleS
ize]; |
| 1018 int currentSubsetType = fCurrentSubsetType++; | 952 int currentSubsetType = fCurrentSubsetType++; |
| 1019 | 953 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 int fCurrentRecording; | 1060 int fCurrentRecording; |
| 1127 int fCurrentScale; | 1061 int fCurrentScale; |
| 1128 int fCurrentSKP; | 1062 int fCurrentSKP; |
| 1129 int fCurrentUseMPD; | 1063 int fCurrentUseMPD; |
| 1130 int fCurrentCodec; | 1064 int fCurrentCodec; |
| 1131 int fCurrentImage; | 1065 int fCurrentImage; |
| 1132 int fCurrentSubsetImage; | 1066 int fCurrentSubsetImage; |
| 1133 int fCurrentBRDImage; | 1067 int fCurrentBRDImage; |
| 1134 int fCurrentColorType; | 1068 int fCurrentColorType; |
| 1135 int fCurrentSubsetType; | 1069 int fCurrentSubsetType; |
| 1136 int fUseCodec; | |
| 1137 int fCurrentBRDStrategy; | 1070 int fCurrentBRDStrategy; |
| 1138 int fCurrentBRDSampleSize; | 1071 int fCurrentBRDSampleSize; |
| 1139 int fCurrentAnimSKP; | 1072 int fCurrentAnimSKP; |
| 1140 }; | 1073 }; |
| 1141 | 1074 |
| 1142 int nanobench_main(); | 1075 int nanobench_main(); |
| 1143 int nanobench_main() { | 1076 int nanobench_main() { |
| 1144 SetupCrashHandler(); | 1077 SetupCrashHandler(); |
| 1145 SkAutoGraphics ag; | 1078 SkAutoGraphics ag; |
| 1146 SkTaskGroup::Enabler enabled(FLAGS_threads); | 1079 SkTaskGroup::Enabler enabled(FLAGS_threads); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 | 1270 |
| 1338 return 0; | 1271 return 0; |
| 1339 } | 1272 } |
| 1340 | 1273 |
| 1341 #if !defined SK_BUILD_FOR_IOS | 1274 #if !defined SK_BUILD_FOR_IOS |
| 1342 int main(int argc, char** argv) { | 1275 int main(int argc, char** argv) { |
| 1343 SkCommandLineFlags::Parse(argc, argv); | 1276 SkCommandLineFlags::Parse(argc, argv); |
| 1344 return nanobench_main(); | 1277 return nanobench_main(); |
| 1345 } | 1278 } |
| 1346 #endif | 1279 #endif |
| OLD | NEW |