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

Side by Side Diff: dm/DM.cpp

Issue 2000783002: Exit before reaching some Nonfatal errors (Closed) Base URL: https://skia.googlesource.com/skia.git@opaque
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | dm/DMSrcSink.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "CrashHandler.h" 8 #include "CrashHandler.h"
9 #include "DMJsonWriter.h" 9 #include "DMJsonWriter.h"
10 #include "DMSrcSink.h" 10 #include "DMSrcSink.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 break; 456 break;
457 default: 457 default:
458 break; 458 break;
459 } 459 }
460 } 460 }
461 461
462 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu); 462 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu);
463 push_src("image", folder, src); 463 push_src("image", folder, src);
464 } 464 }
465 465
466 static void push_codec_srcs(Path path) { 466 static void push_codec_srcs(Path path, SkCodec* codec) {
467 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
468 if (!encoded) {
469 info("Couldn't read %s.", path.c_str());
470 return;
471 }
472 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
473 if (nullptr == codec.get()) {
474 info("Couldn't create codec for %s.", path.c_str());
475 return;
476 }
477
478 // native scaling is only supported by WEBP and JPEG 467 // native scaling is only supported by WEBP and JPEG
479 bool supportsNativeScaling = false; 468 bool supportsNativeScaling = false;
480 469
481 SkTArray<CodecSrc::Mode> nativeModes; 470 SkTArray<CodecSrc::Mode> nativeModes;
482 nativeModes.push_back(CodecSrc::kCodec_Mode); 471 nativeModes.push_back(CodecSrc::kCodec_Mode);
483 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); 472 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode);
484 switch (codec->getEncodedFormat()) { 473 switch (codec->getEncodedFormat()) {
485 case SkEncodedFormat::kJPEG_SkEncodedFormat: 474 case SkEncodedFormat::kJPEG_SkEncodedFormat:
486 nativeModes.push_back(CodecSrc::kScanline_Mode); 475 nativeModes.push_back(CodecSrc::kScanline_Mode);
487 nativeModes.push_back(CodecSrc::kStripe_Mode); 476 nativeModes.push_back(CodecSrc::kStripe_Mode);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 623 }
635 624
636 if (1 != sampleSize) { 625 if (1 != sampleSize) {
637 folder.appendf("_%.3f", 1.0f / (float) sampleSize); 626 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
638 } 627 }
639 628
640 BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize); 629 BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize);
641 push_src("image", folder, src); 630 push_src("image", folder, src);
642 } 631 }
643 632
644 static void push_brd_srcs(Path path) { 633 static void push_brd_srcs(Path path, SkCodec* codec) {
645 // Only run Index8 and grayscale to one sampleSize and Mode. Though interest ing 634 // Only run Index8 and grayscale to one sampleSize and Mode. Though interest ing
646 // to test these color types, they should not reveal anything across various 635 // to test these color types, they should not reveal anything across various
647 // sampleSizes and Modes 636 // sampleSizes and Modes
648 for (auto type : { CodecSrc::kIndex8_Always_DstColorType, 637 for (auto type : { CodecSrc::kIndex8_Always_DstColorType,
649 CodecSrc::kGrayscale_Always_DstColorType }) { 638 CodecSrc::kGrayscale_Always_DstColorType }) {
650 // Arbitrarily choose Mode and sampleSize. 639 // Arbitrarily choose Mode and sampleSize.
651 push_brd_src(path, type, BRDSrc::kFullImage_Mode, 2); 640 push_brd_src(path, type, BRDSrc::kFullImage_Mode, 2);
652 } 641 }
653 642
654 643
655 // Test on a variety of sampleSizes, making sure to include: 644 // Test on a variety of sampleSizes, making sure to include:
656 // - 2, 4, and 8, which are natively supported by jpeg 645 // - 2, 4, and 8, which are natively supported by jpeg
657 // - multiples of 2 which are not divisible by 4 (analogous for 4) 646 // - multiples of 2 which are not divisible by 4 (analogous for 4)
658 // - larger powers of two, since BRD clients generally use powers of 2 647 // - larger powers of two, since BRD clients generally use powers of 2
659 // We will only produce output for the larger sizes on large images. 648 // We will only produce output for the larger sizes on large images.
660 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 }; 649 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 };
661 650
662 const BRDSrc::Mode modes[] = { 651 const BRDSrc::Mode modes[] = {
663 BRDSrc::kFullImage_Mode, 652 BRDSrc::kFullImage_Mode,
664 BRDSrc::kDivisor_Mode, 653 BRDSrc::kDivisor_Mode,
665 }; 654 };
666 655
656 const int width = codec->getInfo().width();
657 const int height = codec->getInfo().height();
667 for (uint32_t sampleSize : sampleSizes) { 658 for (uint32_t sampleSize : sampleSizes) {
659 if ((width / sampleSize <= 10 || height / sampleSize <= 10) && 1 != samp leSize) {
660 // Scaling very small images is uninteresting. After the first itera tion,
661 // the image will only get smaller, so break here.
662 break;
663 }
668 for (BRDSrc::Mode mode : modes) { 664 for (BRDSrc::Mode mode : modes) {
669 push_brd_src(path, CodecSrc::kGetFromCanvas_DstColorType, mode, samp leSize); 665 push_brd_src(path, CodecSrc::kGetFromCanvas_DstColorType, mode, samp leSize);
670 } 666 }
671 } 667 }
672 } 668 }
673 669
674 static bool brd_supported(const char* ext) { 670 static bool brd_supported(const char* ext) {
675 static const char* const exts[] = { 671 static const char* const exts[] = {
676 "jpg", "jpeg", "png", "webp", 672 "jpg", "jpeg", "png", "webp",
677 "JPG", "JPEG", "PNG", "WEBP", 673 "JPG", "JPEG", "PNG", "WEBP",
(...skipping 22 matching lines...) Expand all
700 push_src("skp", "", new SKPSrc(path)); 696 push_src("skp", "", new SKPSrc(path));
701 } 697 }
702 } 698 }
703 699
704 SkTArray<SkString> images; 700 SkTArray<SkString> images;
705 if (!CollectImages(FLAGS_images, &images)) { 701 if (!CollectImages(FLAGS_images, &images)) {
706 return false; 702 return false;
707 } 703 }
708 704
709 for (auto image : images) { 705 for (auto image : images) {
710 push_codec_srcs(image); 706 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(image.c_str()));
707 if (!encoded) {
708 info("Couldn't read %s.", image.c_str());
709 continue;
710 }
711 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
712 if (nullptr == codec.get()) {
713 info("Couldn't create codec for %s.", image.c_str());
714 continue;
715 }
716
717 push_codec_srcs(image, codec);
711 if (FLAGS_simpleCodec) { 718 if (FLAGS_simpleCodec) {
712 continue; 719 continue;
713 } 720 }
714 721
715 const char* ext = strrchr(image.c_str(), '.'); 722 const char* ext = strrchr(image.c_str(), '.');
716 if (ext && brd_supported(ext+1)) { 723 if (ext && brd_supported(ext+1)) {
717 push_brd_srcs(image); 724 push_brd_srcs(image, codec);
718 } 725 }
719 } 726 }
720 727
721 SkTArray<SkString> colorImages; 728 SkTArray<SkString> colorImages;
722 if (!CollectImages(FLAGS_colorImages, &colorImages)) { 729 if (!CollectImages(FLAGS_colorImages, &colorImages)) {
723 return false; 730 return false;
724 } 731 }
725 732
726 for (auto colorImage : colorImages) { 733 for (auto colorImage : colorImages) {
727 ColorCodecSrc* src = new ColorCodecSrc(colorImage, ColorCodecSrc::kBasel ine_Mode); 734 ColorCodecSrc* src = new ColorCodecSrc(colorImage, ColorCodecSrc::kBasel ine_Mode);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 #endif 1380 #endif
1374 } 1381 }
1375 } // namespace skiatest 1382 } // namespace skiatest
1376 1383
1377 #if !defined(SK_BUILD_FOR_IOS) 1384 #if !defined(SK_BUILD_FOR_IOS)
1378 int main(int argc, char** argv) { 1385 int main(int argc, char** argv) {
1379 SkCommandLineFlags::Parse(argc, argv); 1386 SkCommandLineFlags::Parse(argc, argv);
1380 return dm_main(); 1387 return dm_main();
1381 } 1388 }
1382 #endif 1389 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMSrcSink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698