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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); | 105 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
106 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " | 106 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " |
107 "function that ping-pongs between 1.0 and zoomMax."
); | 107 "function that ping-pongs between 1.0 and zoomMax."
); |
108 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 108 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
109 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 109 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
110 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 110 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
111 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 111 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
112 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 112 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
113 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 113 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
114 DEFINE_bool(pngBuildTileIndex, false, "If supported, use png buildTileIndex/deco
deSubset."); | 114 DEFINE_bool(pngBuildTileIndex, false, "If supported, use png buildTileIndex/deco
deSubset."); |
| 115 DEFINE_bool(jpgBuildTileIndex, false, "If supported, use jpg buildTileIndex/deco
deSubset."); |
115 | 116 |
116 static SkString humanize(double ms) { | 117 static SkString humanize(double ms) { |
117 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 118 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
118 return HumanizeMs(ms); | 119 return HumanizeMs(ms); |
119 } | 120 } |
120 #define HUMANIZE(ms) humanize(ms).c_str() | 121 #define HUMANIZE(ms) humanize(ms).c_str() |
121 | 122 |
122 bool Target::init(SkImageInfo info, Benchmark* bench) { | 123 bool Target::init(SkImageInfo info, Benchmark* bench) { |
123 if (Benchmark::kRaster_Backend == config.backend) { | 124 if (Benchmark::kRaster_Backend == config.backend) { |
124 this->surface.reset(SkSurface::NewRaster(info)); | 125 this->surface.reset(SkSurface::NewRaster(info)); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 * i.e. PNG, JPEG, and WEBP. We do *not* test WEBP when using codec, since we do
not | 507 * i.e. PNG, JPEG, and WEBP. We do *not* test WEBP when using codec, since we do
not |
507 * have a scanline decoder for WEBP, which is necessary for running the subset b
ench. | 508 * have a scanline decoder for WEBP, which is necessary for running the subset b
ench. |
508 * (Another bench must be used to test WEBP, which decodes subsets natively.) | 509 * (Another bench must be used to test WEBP, which decodes subsets natively.) |
509 */ | 510 */ |
510 static bool run_subset_bench(const SkString& path, bool useCodec) { | 511 static bool run_subset_bench(const SkString& path, bool useCodec) { |
511 static const char* const exts[] = { | 512 static const char* const exts[] = { |
512 "jpg", "jpeg", | 513 "jpg", "jpeg", |
513 "JPG", "JPEG", | 514 "JPG", "JPEG", |
514 }; | 515 }; |
515 | 516 |
516 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 517 if (useCodec || FLAGS_jpgBuildTileIndex) { |
517 if (path.endsWith(exts[i])) { | 518 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
518 return true; | 519 if (path.endsWith(exts[i])) { |
| 520 return true; |
| 521 } |
519 } | 522 } |
520 } | 523 } |
521 | 524 |
522 // Test png in SkCodec, and optionally on SkImageDecoder. SkImageDecoder is | 525 // Test png in SkCodec, and optionally on SkImageDecoder. SkImageDecoder is |
523 // disabled by default because it leaks memory. | 526 // disabled by default because it leaks memory. |
524 // skbug.com/4360 | 527 // skbug.com/4360 |
525 if ((useCodec || FLAGS_pngBuildTileIndex) && (path.endsWith("png") || path.e
ndsWith("PNG"))) { | 528 if ((useCodec || FLAGS_pngBuildTileIndex) && (path.endsWith("png") || path.e
ndsWith("PNG"))) { |
526 return true; | 529 return true; |
527 } | 530 } |
528 | 531 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 // skbug.com/4319 | 979 // skbug.com/4319 |
977 // All use cases we are aware of only scale by powers of two. | 980 // All use cases we are aware of only scale by powers of two. |
978 // PNG decodes use the indicated sampling strategy regardless of the
sample size, so | 981 // PNG decodes use the indicated sampling strategy regardless of the
sample size, so |
979 // these tests are sufficient to provide good coverage of our sc
aling options. | 982 // these tests are sufficient to provide good coverage of our sc
aling options. |
980 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16 }; | 983 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16 }; |
981 const uint32_t minOutputSize = 512; | 984 const uint32_t minOutputSize = 512; |
982 while (fCurrentBRDImage < fImages.count()) { | 985 while (fCurrentBRDImage < fImages.count()) { |
983 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { | 986 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { |
984 fSourceType = "image"; | 987 fSourceType = "image"; |
985 fBenchType = strategies[fCurrentBRDStrategy].fName; | 988 fBenchType = strategies[fCurrentBRDStrategy].fName; |
| 989 |
| 990 const SkString& path = fImages[fCurrentBRDImage]; |
| 991 const SkBitmapRegionDecoderInterface::Strategy strategy = |
| 992 strategies[fCurrentBRDStrategy].fStrategy; |
| 993 |
| 994 if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strate
gy) { |
| 995 // Disable png and jpeg for SkImageDecoder: |
| 996 if (!FLAGS_jpgBuildTileIndex) { |
| 997 if (path.endsWith("JPEG") || path.endsWith("JPG") || |
| 998 path.endsWith("jpeg") || path.endsWith("jpg")) |
| 999 { |
| 1000 fCurrentBRDStrategy++; |
| 1001 continue; |
| 1002 } |
| 1003 } |
| 1004 if (!FLAGS_pngBuildTileIndex) { |
| 1005 if (path.endsWith("PNG") || path.endsWith("png")) { |
| 1006 fCurrentBRDStrategy++; |
| 1007 continue; |
| 1008 } |
| 1009 } |
| 1010 } |
| 1011 |
986 while (fCurrentColorType < fColorTypes.count()) { | 1012 while (fCurrentColorType < fColorTypes.count()) { |
987 while (fCurrentBRDSampleSize < (int) SK_ARRAY_COUNT(sampleSi
zes)) { | 1013 while (fCurrentBRDSampleSize < (int) SK_ARRAY_COUNT(sampleSi
zes)) { |
988 while (fCurrentSubsetType <= kLastSingle_SubsetType) { | 1014 while (fCurrentSubsetType <= kLastSingle_SubsetType) { |
989 const SkString& path = fImages[fCurrentBRDImage]; | 1015 |
990 const SkBitmapRegionDecoderInterface::Strategy strat
egy = | 1016 |
991 strategies[fCurrentBRDStrategy].fStrategy; | |
992 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName
(path.c_str())); | 1017 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName
(path.c_str())); |
993 const SkColorType colorType = fColorTypes[fCurrentCo
lorType]; | 1018 const SkColorType colorType = fColorTypes[fCurrentCo
lorType]; |
994 uint32_t sampleSize = sampleSizes[fCurrentBRDSampleS
ize]; | 1019 uint32_t sampleSize = sampleSizes[fCurrentBRDSampleS
ize]; |
995 int currentSubsetType = fCurrentSubsetType++; | 1020 int currentSubsetType = fCurrentSubsetType++; |
996 | 1021 |
997 int width = 0; | 1022 int width = 0; |
998 int height = 0; | 1023 int height = 0; |
999 if (!valid_brd_bench(encoded.get(), strategy, colorT
ype, sampleSize, | 1024 if (!valid_brd_bench(encoded.get(), strategy, colorT
ype, sampleSize, |
1000 minOutputSize, &width, &height)) { | 1025 minOutputSize, &width, &height)) { |
1001 break; | 1026 break; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 | 1363 |
1339 return 0; | 1364 return 0; |
1340 } | 1365 } |
1341 | 1366 |
1342 #if !defined SK_BUILD_FOR_IOS | 1367 #if !defined SK_BUILD_FOR_IOS |
1343 int main(int argc, char** argv) { | 1368 int main(int argc, char** argv) { |
1344 SkCommandLineFlags::Parse(argc, argv); | 1369 SkCommandLineFlags::Parse(argc, argv); |
1345 return nanobench_main(); | 1370 return nanobench_main(); |
1346 } | 1371 } |
1347 #endif | 1372 #endif |
OLD | NEW |