OLD | NEW |
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 #elif defined(SK_BUILD_FOR_WIN) | 602 #elif defined(SK_BUILD_FOR_WIN) |
603 if (kWEBP_SkEncodedFormat != codec->getEncodedFormat() && | 603 if (kWEBP_SkEncodedFormat != codec->getEncodedFormat() && |
604 kWBMP_SkEncodedFormat != codec->getEncodedFormat()) | 604 kWBMP_SkEncodedFormat != codec->getEncodedFormat()) |
605 { | 605 { |
606 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, fal
se); | 606 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, fal
se); |
607 } | 607 } |
608 #endif | 608 #endif |
609 } | 609 } |
610 } | 610 } |
611 | 611 |
612 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, | 612 static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc:
:Mode mode, |
613 CodecSrc::DstColorType dstColorType) { | 613 uint32_t sampleSize) { |
614 switch (strategy) { | 614 SkString folder("brd_android_codec"); |
615 case SkBitmapRegionDecoder::kCanvas_Strategy: | |
616 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { | |
617 return true; | |
618 } | |
619 return false; | |
620 case SkBitmapRegionDecoder::kAndroidCodec_Strategy: | |
621 switch (dstColorType) { | |
622 case CodecSrc::kGetFromCanvas_DstColorType: | |
623 case CodecSrc::kIndex8_Always_DstColorType: | |
624 case CodecSrc::kGrayscale_Always_DstColorType: | |
625 return true; | |
626 default: | |
627 return false; | |
628 } | |
629 default: | |
630 SkASSERT(false); | |
631 return false; | |
632 } | |
633 } | |
634 | |
635 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, | |
636 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS
ize) { | |
637 SkString folder; | |
638 switch (strategy) { | |
639 case SkBitmapRegionDecoder::kCanvas_Strategy: | |
640 folder.append("brd_canvas"); | |
641 break; | |
642 case SkBitmapRegionDecoder::kAndroidCodec_Strategy: | |
643 folder.append("brd_android_codec"); | |
644 break; | |
645 default: | |
646 SkASSERT(false); | |
647 return; | |
648 } | |
649 | |
650 switch (mode) { | 615 switch (mode) { |
651 case BRDSrc::kFullImage_Mode: | 616 case BRDSrc::kFullImage_Mode: |
652 break; | 617 break; |
653 case BRDSrc::kDivisor_Mode: | 618 case BRDSrc::kDivisor_Mode: |
654 folder.append("_divisor"); | 619 folder.append("_divisor"); |
655 break; | 620 break; |
656 default: | 621 default: |
657 SkASSERT(false); | 622 SkASSERT(false); |
658 return; | 623 return; |
659 } | 624 } |
660 | 625 |
661 switch (dstColorType) { | 626 switch (dstColorType) { |
662 case CodecSrc::kGetFromCanvas_DstColorType: | 627 case CodecSrc::kGetFromCanvas_DstColorType: |
663 break; | 628 break; |
664 case CodecSrc::kIndex8_Always_DstColorType: | 629 case CodecSrc::kIndex8_Always_DstColorType: |
665 folder.append("_kIndex"); | 630 folder.append("_kIndex"); |
666 break; | 631 break; |
667 case CodecSrc::kGrayscale_Always_DstColorType: | 632 case CodecSrc::kGrayscale_Always_DstColorType: |
668 folder.append("_kGray"); | 633 folder.append("_kGray"); |
669 break; | 634 break; |
670 default: | 635 default: |
671 SkASSERT(false); | 636 SkASSERT(false); |
672 return; | 637 return; |
673 } | 638 } |
674 | 639 |
675 if (1 != sampleSize) { | 640 if (1 != sampleSize) { |
676 folder.appendf("_%.3f", 1.0f / (float) sampleSize); | 641 folder.appendf("_%.3f", 1.0f / (float) sampleSize); |
677 } | 642 } |
678 | 643 |
679 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); | 644 BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize); |
680 push_src("image", folder, src); | 645 push_src("image", folder, src); |
681 } | 646 } |
682 | 647 |
683 static void push_brd_srcs(Path path) { | 648 static void push_brd_srcs(Path path) { |
684 | |
685 const SkBitmapRegionDecoder::Strategy strategies[] = { | |
686 SkBitmapRegionDecoder::kCanvas_Strategy, | |
687 SkBitmapRegionDecoder::kAndroidCodec_Strategy, | |
688 }; | |
689 | |
690 // Test on a variety of sampleSizes, making sure to include: | 649 // Test on a variety of sampleSizes, making sure to include: |
691 // - 2, 4, and 8, which are natively supported by jpeg | 650 // - 2, 4, and 8, which are natively supported by jpeg |
692 // - multiples of 2 which are not divisible by 4 (analogous for 4) | 651 // - multiples of 2 which are not divisible by 4 (analogous for 4) |
693 // - larger powers of two, since BRD clients generally use powers of 2 | 652 // - larger powers of two, since BRD clients generally use powers of 2 |
694 // We will only produce output for the larger sizes on large images. | 653 // We will only produce output for the larger sizes on large images. |
695 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64
}; | 654 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64
}; |
696 | 655 |
697 // We will only test to one backend (8888), but we will test all of the | 656 // We will only test to one backend (8888), but we will test all of the |
698 // color types that we need to decode to on this backend. | 657 // color types that we need to decode to on this backend. |
699 const CodecSrc::DstColorType dstColorTypes[] = { | 658 const CodecSrc::DstColorType dstColorTypes[] = { |
700 CodecSrc::kGetFromCanvas_DstColorType, | 659 CodecSrc::kGetFromCanvas_DstColorType, |
701 CodecSrc::kIndex8_Always_DstColorType, | 660 CodecSrc::kIndex8_Always_DstColorType, |
702 CodecSrc::kGrayscale_Always_DstColorType, | 661 CodecSrc::kGrayscale_Always_DstColorType, |
703 }; | 662 }; |
704 | 663 |
705 const BRDSrc::Mode modes[] = { | 664 const BRDSrc::Mode modes[] = { |
706 BRDSrc::kFullImage_Mode, | 665 BRDSrc::kFullImage_Mode, |
707 BRDSrc::kDivisor_Mode, | 666 BRDSrc::kDivisor_Mode, |
708 }; | 667 }; |
709 | 668 |
710 for (SkBitmapRegionDecoder::Strategy strategy : strategies) { | 669 for (uint32_t sampleSize : sampleSizes) { |
711 for (uint32_t sampleSize : sampleSizes) { | 670 for (CodecSrc::DstColorType dstColorType : dstColorTypes) { |
712 for (CodecSrc::DstColorType dstColorType : dstColorTypes) { | 671 for (BRDSrc::Mode mode : modes) { |
713 if (brd_color_type_supported(strategy, dstColorType)) { | 672 push_brd_src(path, dstColorType, mode, sampleSize); |
714 for (BRDSrc::Mode mode : modes) { | |
715 push_brd_src(path, strategy, dstColorType, mode, sampleS
ize); | |
716 } | |
717 } | |
718 } | 673 } |
719 } | 674 } |
720 } | 675 } |
721 } | 676 } |
722 | 677 |
723 static bool brd_supported(const char* ext) { | 678 static bool brd_supported(const char* ext) { |
724 static const char* const exts[] = { | 679 static const char* const exts[] = { |
725 "jpg", "jpeg", "png", "webp", | 680 "jpg", "jpeg", "png", "webp", |
726 "JPG", "JPEG", "PNG", "WEBP", | 681 "JPG", "JPEG", "PNG", "WEBP", |
727 }; | 682 }; |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 #endif | 1377 #endif |
1423 } | 1378 } |
1424 } // namespace skiatest | 1379 } // namespace skiatest |
1425 | 1380 |
1426 #if !defined(SK_BUILD_FOR_IOS) | 1381 #if !defined(SK_BUILD_FOR_IOS) |
1427 int main(int argc, char** argv) { | 1382 int main(int argc, char** argv) { |
1428 SkCommandLineFlags::Parse(argc, argv); | 1383 SkCommandLineFlags::Parse(argc, argv); |
1429 return dm_main(); | 1384 return dm_main(); |
1430 } | 1385 } |
1431 #endif | 1386 #endif |
OLD | NEW |