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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 // This should not print a message since it is not an error. | 589 // This should not print a message since it is not an error. |
590 return false; | 590 return false; |
591 } | 591 } |
592 | 592 |
593 return true; | 593 return true; |
594 } | 594 } |
595 | 595 |
596 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoderInterface::Str
ategy strategy, | 596 static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoderInterface::Str
ategy strategy, |
597 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int*
width, | 597 SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int*
width, |
598 int* height) { | 598 int* height) { |
599 SkStreamRewindable* stream = new SkMemoryStream(encoded); | |
600 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd( | 599 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd( |
601 SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(stream, st
rategy)); | 600 SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, s
trategy)); |
602 if (nullptr == brd.get()) { | 601 if (nullptr == brd.get()) { |
603 // This is indicates that subset decoding is not supported for a particu
lar image format. | 602 // This is indicates that subset decoding is not supported for a particu
lar image format. |
604 return false; | 603 return false; |
605 } | 604 } |
606 | 605 |
607 SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(0, 0, brd->width(), brd->he
ight(), 1, | 606 SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(0, 0, brd->width(), brd->he
ight(), 1, |
608 colorType)); | 607 colorType)); |
609 if (nullptr == bitmap.get() || colorType != bitmap->colorType()) { | 608 if (nullptr == bitmap.get() || colorType != bitmap->colorType()) { |
610 // This indicates that conversion to the requested color type is not sup
ported for the | 609 // This indicates that conversion to the requested color type is not sup
ported for the |
611 // particular image. | 610 // particular image. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 fCurrentSubsetImage = 0; | 954 fCurrentSubsetImage = 0; |
956 fUseCodec++; | 955 fUseCodec++; |
957 } | 956 } |
958 | 957 |
959 // Run the BRDBenches | 958 // Run the BRDBenches |
960 // We will benchmark multiple BRD strategies. | 959 // We will benchmark multiple BRD strategies. |
961 static const struct { | 960 static const struct { |
962 SkBitmapRegionDecoderInterface::Strategy fStrategy; | 961 SkBitmapRegionDecoderInterface::Strategy fStrategy; |
963 const char* fName; | 962 const char* fName; |
964 } strategies[] = { | 963 } strategies[] = { |
965 { SkBitmapRegionDecoderInterface::kOriginal_Strategy, "BRD" }, | 964 { SkBitmapRegionDecoderInterface::kOriginal_Strategy, "BRD" }, |
966 { SkBitmapRegionDecoderInterface::kCanvas_Strategy, "BRD_canvas"
}, | 965 { SkBitmapRegionDecoderInterface::kCanvas_Strategy, "BRD_canvas
" }, |
| 966 { SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy, "BRD_andro
id_codec" }, |
967 }; | 967 }; |
968 | 968 |
969 // We intend to create benchmarks that model the use cases in | 969 // We intend to create benchmarks that model the use cases in |
970 // android/libraries/social/tiledimage. In this library, an image is de
coded in 512x512 | 970 // android/libraries/social/tiledimage. In this library, an image is de
coded in 512x512 |
971 // tiles. The image can be translated freely, so the location of a tile
may be anywhere in | 971 // tiles. The image can be translated freely, so the location of a tile
may be anywhere in |
972 // the image. For that reason, we will benchmark decodes in five repres
entative locations | 972 // the image. For that reason, we will benchmark decodes in five repres
entative locations |
973 // in the image. Additionally, this use case utilizes power of two scal
ing, so we will | 973 // in the image. Additionally, this use case utilizes power of two scal
ing, so we will |
974 // test on power of two sample sizes. The output tile is always 512x512
, so, when a | 974 // test on power of two sample sizes. The output tile is always 512x512
, so, when a |
975 // sampleSize is used, the size of the subset that is decoded is always | 975 // sampleSize is used, the size of the subset that is decoded is always |
976 // (sampleSize*512)x(sampleSize*512). | 976 // (sampleSize*512)x(sampleSize*512). |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 | 1364 |
1365 return 0; | 1365 return 0; |
1366 } | 1366 } |
1367 | 1367 |
1368 #if !defined SK_BUILD_FOR_IOS | 1368 #if !defined SK_BUILD_FOR_IOS |
1369 int main(int argc, char** argv) { | 1369 int main(int argc, char** argv) { |
1370 SkCommandLineFlags::Parse(argc, argv); | 1370 SkCommandLineFlags::Parse(argc, argv); |
1371 return nanobench_main(); | 1371 return nanobench_main(); |
1372 } | 1372 } |
1373 #endif | 1373 #endif |
OLD | NEW |