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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 if (useCodec || FLAGS_jpgBuildTileIndex) { | 512 if (useCodec || FLAGS_jpgBuildTileIndex) { |
513 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 513 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
514 if (path.endsWith(exts[i])) { | 514 if (path.endsWith(exts[i])) { |
515 return true; | 515 return true; |
516 } | 516 } |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 // Test png in SkCodec, and optionally on SkImageDecoder. SkImageDecoder is | 520 // Test png in SkCodec, and optionally on SkImageDecoder. SkImageDecoder is |
521 // disabled by default because it leaks memory. | 521 // disabled by default because it leaks memory. |
522 // skbug.com/4360 | 522 // https://bug.skia.org/4360 |
523 if ((useCodec || FLAGS_pngBuildTileIndex) && (path.endsWith("png") || path.e
ndsWith("PNG"))) { | 523 if ((useCodec || FLAGS_pngBuildTileIndex) && (path.endsWith("png") || path.e
ndsWith("PNG"))) { |
524 return true; | 524 return true; |
525 } | 525 } |
526 | 526 |
527 if (!useCodec && (path.endsWith("webp") || path.endsWith("WEBP"))) { | 527 if (!useCodec && (path.endsWith("webp") || path.endsWith("WEBP"))) { |
528 return true; | 528 return true; |
529 } | 529 } |
530 | 530 |
531 return false; | 531 return false; |
532 } | 532 } |
(...skipping 27 matching lines...) Expand all Loading... |
560 return false; | 560 return false; |
561 } | 561 } |
562 *width = info.width(); | 562 *width = info.width(); |
563 *height = info.height(); | 563 *height = info.height(); |
564 } else { | 564 } else { |
565 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream)); | 565 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream)); |
566 if (nullptr == decoder) { | 566 if (nullptr == decoder) { |
567 SkDebugf("Could not create decoder for %s. Skipping bench.\n", path
.c_str()); | 567 SkDebugf("Could not create decoder for %s. Skipping bench.\n", path
.c_str()); |
568 return false; | 568 return false; |
569 } | 569 } |
570 //FIXME: See skbug.com/3921 | 570 //FIXME: See https://bug.skia.org/3921 |
571 if (kIndex_8_SkColorType == colorType || kGray_8_SkColorType == colorTyp
e) { | 571 if (kIndex_8_SkColorType == colorType || kGray_8_SkColorType == colorTyp
e) { |
572 SkDebugf("Cannot use image subset decoder for %s with color type %s.
" | 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)); | 573 "Skipping bench.\n", path.c_str(), color_type_to_str(colorTy
pe)); |
574 return false; | 574 return false; |
575 } | 575 } |
576 if (!decoder->buildTileIndex(stream.detach(), width, height)) { | 576 if (!decoder->buildTileIndex(stream.detach(), width, height)) { |
577 SkDebugf("Could not build tile index for %s. Skipping bench.\n", pa
th.c_str()); | 577 SkDebugf("Could not build tile index for %s. Skipping bench.\n", pa
th.c_str()); |
578 return false; | 578 return false; |
579 } | 579 } |
580 } | 580 } |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 // We intend to create benchmarks that model the use cases in | 967 // 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 | 968 // 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 | 969 // 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 | 970 // 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 | 971 // 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 | 972 // 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 | 973 // sampleSize is used, the size of the subset that is decoded is always |
974 // (sampleSize*512)x(sampleSize*512). | 974 // (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: | 975 // 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. | 976 // JPEG decodes using kOriginal_Strategy are broken for non-powers o
f two. |
977 // skbug.com/4319 | 977 // https://bug.skia.org/4319 |
978 // All use cases we are aware of only scale by powers of two. | 978 // 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 | 979 // 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. | 980 // 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 }; | 981 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16, 32, 64 }; |
982 const uint32_t minOutputSize = 512; | 982 const uint32_t minOutputSize = 512; |
983 while (fCurrentBRDImage < fImages.count()) { | 983 while (fCurrentBRDImage < fImages.count()) { |
984 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { | 984 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { |
985 fSourceType = "image"; | 985 fSourceType = "image"; |
986 fBenchType = strategies[fCurrentBRDStrategy].fName; | 986 fBenchType = strategies[fCurrentBRDStrategy].fName; |
987 | 987 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 | 1337 |
1338 return 0; | 1338 return 0; |
1339 } | 1339 } |
1340 | 1340 |
1341 #if !defined SK_BUILD_FOR_IOS | 1341 #if !defined SK_BUILD_FOR_IOS |
1342 int main(int argc, char** argv) { | 1342 int main(int argc, char** argv) { |
1343 SkCommandLineFlags::Parse(argc, argv); | 1343 SkCommandLineFlags::Parse(argc, argv); |
1344 return nanobench_main(); | 1344 return nanobench_main(); |
1345 } | 1345 } |
1346 #endif | 1346 #endif |
OLD | NEW |