| 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" |
| 11 | 11 |
| 12 #include "Benchmark.h" | 12 #include "Benchmark.h" |
| 13 #include "BitmapRegionDecoderBench.h" | 13 #include "BitmapRegionDecoderBench.h" |
| 14 #include "CodecBench.h" | 14 #include "CodecBench.h" |
| 15 #include "CodecBenchPriv.h" | 15 #include "CodecBenchPriv.h" |
| 16 #include "CrashHandler.h" | 16 #include "CrashHandler.h" |
| 17 #include "DecodingBench.h" | 17 #include "DecodingBench.h" |
| 18 #include "GMBench.h" | 18 #include "GMBench.h" |
| 19 #include "ProcStats.h" | 19 #include "ProcStats.h" |
| 20 #include "ResultsWriter.h" | 20 #include "ResultsWriter.h" |
| 21 #include "RecordingBench.h" | 21 #include "RecordingBench.h" |
| 22 #include "SKPAnimationBench.h" | 22 #include "SKPAnimationBench.h" |
| 23 #include "SKPBench.h" | 23 #include "SKPBench.h" |
| 24 #include "SubsetSingleBench.h" | 24 #include "SubsetSingleBench.h" |
| 25 #include "SubsetTranslateBench.h" | 25 #include "SubsetTranslateBench.h" |
| 26 #include "SubsetZoomBench.h" | 26 #include "SubsetZoomBench.h" |
| 27 #include "Stats.h" | 27 #include "Stats.h" |
| 28 | 28 |
| 29 #include "SkBitmapRegionDecoderInterface.h" | 29 #include "SkBitmapRegionDecoder.h" |
| 30 #include "SkBBoxHierarchy.h" | 30 #include "SkBBoxHierarchy.h" |
| 31 #include "SkCanvas.h" | 31 #include "SkCanvas.h" |
| 32 #include "SkCodec.h" | 32 #include "SkCodec.h" |
| 33 #include "SkCommonFlags.h" | 33 #include "SkCommonFlags.h" |
| 34 #include "SkData.h" | 34 #include "SkData.h" |
| 35 #include "SkForceLinking.h" | 35 #include "SkForceLinking.h" |
| 36 #include "SkGraphics.h" | 36 #include "SkGraphics.h" |
| 37 #include "SkOSFile.h" | 37 #include "SkOSFile.h" |
| 38 #include "SkPictureRecorder.h" | 38 #include "SkPictureRecorder.h" |
| 39 #include "SkPictureUtils.h" | 39 #include "SkPictureUtils.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 581 |
| 582 // Check if the image is large enough for a meaningful subset benchmark. | 582 // Check if the image is large enough for a meaningful subset benchmark. |
| 583 if (*width <= 512 && *height <= 512) { | 583 if (*width <= 512 && *height <= 512) { |
| 584 // This should not print a message since it is not an error. | 584 // This should not print a message since it is not an error. |
| 585 return false; | 585 return false; |
| 586 } | 586 } |
| 587 | 587 |
| 588 return true; | 588 return true; |
| 589 } | 589 } |
| 590 | 590 |
| 591 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoderInterface::Str
ategy strategy, | 591 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoder::Strategy str
ategy, |
| 592 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int*
width, | 592 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int*
width, |
| 593 int* height) { | 593 int* height) { |
| 594 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd( | 594 SkAutoTDelete<SkBitmapRegionDecoder> brd( |
| 595 SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, s
trategy)); | 595 SkBitmapRegionDecoder::Create(encoded, strategy)); |
| 596 if (nullptr == brd.get()) { | 596 if (nullptr == brd.get()) { |
| 597 // This is indicates that subset decoding is not supported for a particu
lar image format. | 597 // This is indicates that subset decoding is not supported for a particu
lar image format. |
| 598 return false; | 598 return false; |
| 599 } | 599 } |
| 600 | 600 |
| 601 SkBitmap bitmap; | 601 SkBitmap bitmap; |
| 602 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, brd->width(
), brd->height()), | 602 if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, brd->width(
), brd->height()), |
| 603 1, colorType, false)) { | 603 1, colorType, false)) { |
| 604 return false; | 604 return false; |
| 605 } | 605 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 fCurrentColorType = 0; | 949 fCurrentColorType = 0; |
| 950 fCurrentSubsetImage++; | 950 fCurrentSubsetImage++; |
| 951 } | 951 } |
| 952 fCurrentSubsetImage = 0; | 952 fCurrentSubsetImage = 0; |
| 953 fUseCodec++; | 953 fUseCodec++; |
| 954 } | 954 } |
| 955 | 955 |
| 956 // Run the BRDBenches | 956 // Run the BRDBenches |
| 957 // We will benchmark multiple BRD strategies. | 957 // We will benchmark multiple BRD strategies. |
| 958 static const struct { | 958 static const struct { |
| 959 SkBitmapRegionDecoderInterface::Strategy fStrategy; | 959 SkBitmapRegionDecoder::Strategy fStrategy; |
| 960 const char* fName; | 960 const char* fName; |
| 961 } strategies[] = { | 961 } strategies[] = { |
| 962 { SkBitmapRegionDecoderInterface::kOriginal_Strategy, "BRD" }, | 962 { SkBitmapRegionDecoder::kOriginal_Strategy, "BRD" }, |
| 963 { SkBitmapRegionDecoderInterface::kCanvas_Strategy, "BRD_canvas
" }, | 963 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" }, |
| 964 { SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy, "BRD_andro
id_codec" }, | 964 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec"
}, |
| 965 }; | 965 }; |
| 966 | 966 |
| 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 // skbug.com/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 |
| 988 const SkString& path = fImages[fCurrentBRDImage]; | 988 const SkString& path = fImages[fCurrentBRDImage]; |
| 989 const SkBitmapRegionDecoderInterface::Strategy strategy = | 989 const SkBitmapRegionDecoder::Strategy strategy = |
| 990 strategies[fCurrentBRDStrategy].fStrategy; | 990 strategies[fCurrentBRDStrategy].fStrategy; |
| 991 | 991 |
| 992 if (SkBitmapRegionDecoderInterface::kOriginal_Strategy == strate
gy) { | 992 if (SkBitmapRegionDecoder::kOriginal_Strategy == strategy) { |
| 993 // Disable png and jpeg for SkImageDecoder: | 993 // Disable png and jpeg for SkImageDecoder: |
| 994 if (!FLAGS_jpgBuildTileIndex) { | 994 if (!FLAGS_jpgBuildTileIndex) { |
| 995 if (path.endsWith("JPEG") || path.endsWith("JPG") || | 995 if (path.endsWith("JPEG") || path.endsWith("JPG") || |
| 996 path.endsWith("jpeg") || path.endsWith("jpg")) | 996 path.endsWith("jpeg") || path.endsWith("jpg")) |
| 997 { | 997 { |
| 998 fCurrentBRDStrategy++; | 998 fCurrentBRDStrategy++; |
| 999 continue; | 999 continue; |
| 1000 } | 1000 } |
| 1001 } | 1001 } |
| 1002 if (!FLAGS_pngBuildTileIndex) { | 1002 if (!FLAGS_pngBuildTileIndex) { |
| (...skipping 334 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 |