Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: bench/nanobench.cpp

Issue 1387233002: Update Subset benches to support interlacing and fix bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@limitScaled
Patch Set: Initialize colorCount before reading from it. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 494 }
495 495
496 if (!target->init(info, bench)) { 496 if (!target->init(info, bench)) {
497 delete target; 497 delete target;
498 return nullptr; 498 return nullptr;
499 } 499 }
500 return target; 500 return target;
501 } 501 }
502 502
503 /* 503 /*
504 * We only run our subset benches on files that are supported by BitmapRegionDec oder:
505 * i.e. PNG, JPEG, and WEBP. We do *not* test WEBP when using codec, since we do not
506 * have a scanline decoder for WEBP, which is necessary for running the subset b ench.
507 * (Another bench must be used to test WEBP, which decodes subsets natively.)
508 */
509 static bool run_subset_bench(const SkString& path, bool useCodec) {
510 static const char* const exts[] = {
511 "jpg", "jpeg", "png",
512 "JPG", "JPEG", "PNG",
513 };
514
515 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
516 if (path.endsWith(exts[i])) {
517 return true;
518 }
519 }
520
521 return !useCodec && (path.endsWith("webp") || path.endsWith("WEBP"));
522 }
523
524 /*
504 * Returns true if set up for a subset decode succeeds, false otherwise 525 * Returns true if set up for a subset decode succeeds, false otherwise
505 * If the set-up succeeds, the width and height parameters will be set 526 * If the set-up succeeds, the width and height parameters will be set
506 */ 527 */
507 static bool valid_subset_bench(const SkString& path, SkColorType colorType, bool useCodec, 528 static bool valid_subset_bench(const SkString& path, SkColorType colorType, bool useCodec,
508 int* width, int* height) { 529 int* width, int* height) {
509 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); 530 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
510 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encoded)); 531 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encoded));
511 532
512 // Check that we can create a codec or image decoder. 533 // Check that we can create a codec or image decoder.
513 if (useCodec) { 534 if (useCodec) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 fCurrentImage++; 886 fCurrentImage++;
866 } 887 }
867 888
868 // Run the SubsetBenches 889 // Run the SubsetBenches
869 bool useCodecOpts[] = { true, false }; 890 bool useCodecOpts[] = { true, false };
870 while (fUseCodec < 2) { 891 while (fUseCodec < 2) {
871 bool useCodec = useCodecOpts[fUseCodec]; 892 bool useCodec = useCodecOpts[fUseCodec];
872 fSourceType = "image"; 893 fSourceType = "image";
873 fBenchType = useCodec ? "skcodec" : "skimagedecoder"; 894 fBenchType = useCodec ? "skcodec" : "skimagedecoder";
874 while (fCurrentSubsetImage < fImages.count()) { 895 while (fCurrentSubsetImage < fImages.count()) {
896 const SkString& path = fImages[fCurrentSubsetImage];
897 if (!run_subset_bench(path, useCodec)) {
898 fCurrentSubsetImage++;
899 continue;
900 }
875 while (fCurrentColorType < fColorTypes.count()) { 901 while (fCurrentColorType < fColorTypes.count()) {
876 const SkString& path = fImages[fCurrentSubsetImage];
877 SkColorType colorType = fColorTypes[fCurrentColorType]; 902 SkColorType colorType = fColorTypes[fCurrentColorType];
878 while (fCurrentSubsetType <= kLast_SubsetType) { 903 while (fCurrentSubsetType <= kLast_SubsetType) {
879 int width = 0; 904 int width = 0;
880 int height = 0; 905 int height = 0;
881 int currentSubsetType = fCurrentSubsetType++; 906 int currentSubsetType = fCurrentSubsetType++;
882 if (valid_subset_bench(path, colorType, useCodec, &width , &height)) { 907 if (valid_subset_bench(path, colorType, useCodec, &width , &height)) {
883 switch (currentSubsetType) { 908 switch (currentSubsetType) {
884 case kTopLeft_SubsetType: 909 case kTopLeft_SubsetType:
885 return new SubsetSingleBench(path, colorType , width/3, 910 return new SubsetSingleBench(path, colorType , width/3,
886 height/3, 0, 0, useCodec); 911 height/3, 0, 0, useCodec);
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 1327
1303 return 0; 1328 return 0;
1304 } 1329 }
1305 1330
1306 #if !defined SK_BUILD_FOR_IOS 1331 #if !defined SK_BUILD_FOR_IOS
1307 int main(int argc, char** argv) { 1332 int main(int argc, char** argv) {
1308 SkCommandLineFlags::Parse(argc, argv); 1333 SkCommandLineFlags::Parse(argc, argv);
1309 return nanobench_main(); 1334 return nanobench_main();
1310 } 1335 }
1311 #endif 1336 #endif
OLDNEW
« no previous file with comments | « no previous file | bench/subset/SubsetSingleBench.cpp » ('j') | bench/subset/SubsetTranslateBench.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698