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

Side by Side Diff: src/codec/SkSwizzler.cpp

Issue 1918943002: Remove SkEncodedInfo kPreSwizzled_Color from public API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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 | « src/codec/SkSwizzler.h ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkOpts.h" 10 #include "SkOpts.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 dst32++; 644 dst32++;
645 src32 += deltaSrc/4; 645 src32 += deltaSrc/4;
646 } 646 }
647 proc(dst32, (const uint8_t*)src32, dstWidth, bpp, deltaSrc, 0, ctable); 647 proc(dst32, (const uint8_t*)src32, dstWidth, bpp, deltaSrc, 0, ctable);
648 } 648 }
649 649
650 SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo, 650 SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo,
651 const SkPMColor* ctable, 651 const SkPMColor* ctable,
652 const SkImageInfo& dstInfo, 652 const SkImageInfo& dstInfo,
653 const SkCodec::Options& options, 653 const SkCodec::Options& options,
654 const SkIRect* frame) { 654 const SkIRect* frame,
655 bool preSwizzled) {
655 if (SkEncodedInfo::kPalette_Color == encodedInfo.color() && nullptr == ctabl e) { 656 if (SkEncodedInfo::kPalette_Color == encodedInfo.color() && nullptr == ctabl e) {
656 return nullptr; 657 return nullptr;
657 } 658 }
658 659
659 RowProc fastProc = nullptr; 660 RowProc fastProc = nullptr;
660 RowProc proc = nullptr; 661 RowProc proc = nullptr;
661 SkCodec::ZeroInitialized zeroInit = options.fZeroInitialized; 662 if (preSwizzled) {
msarett 2016/04/25 16:58:45 Original kPreSwizzled block is moved here - nothin
662 const bool premultiply = (SkEncodedInfo::kOpaque_Alpha != encodedInfo.alpha( )) && 663 switch (dstInfo.colorType()) {
663 (kPremul_SkAlphaType == dstInfo.alphaType()); 664 case kGray_8_SkColorType:
664 switch (encodedInfo.color()) { 665 proc = &sample1;
665 case SkEncodedInfo::kGray_Color: 666 fastProc = ©
666 switch (encodedInfo.bitsPerComponent()) { 667 break;
667 case 1: 668 case kRGB_565_SkColorType:
668 switch (dstInfo.colorType()) { 669 proc = &sample2;
669 case kRGBA_8888_SkColorType: 670 fastProc = ©
670 case kBGRA_8888_SkColorType: 671 break;
671 proc = &swizzle_bit_to_n32; 672 case kRGBA_8888_SkColorType:
672 break; 673 case kBGRA_8888_SkColorType:
673 case kIndex_8_SkColorType: 674 proc = &sample4;
674 proc = &swizzle_bit_to_index; 675 fastProc = ©
675 break; 676 break;
676 case kRGB_565_SkColorType: 677 default:
677 proc = &swizzle_bit_to_565; 678 return nullptr;
678 break; 679 }
679 case kGray_8_SkColorType: 680 } else {
680 proc = &swizzle_bit_to_grayscale; 681 SkCodec::ZeroInitialized zeroInit = options.fZeroInitialized;
681 break; 682 const bool premultiply = (SkEncodedInfo::kOpaque_Alpha != encodedInfo.al pha()) &&
682 default: 683 (kPremul_SkAlphaType == dstInfo.alphaType());
683 return nullptr; 684
684 } 685 switch (encodedInfo.color()) {
685 break; 686 case SkEncodedInfo::kGray_Color:
686 case 8: 687 switch (encodedInfo.bitsPerComponent()) {
687 switch (dstInfo.colorType()) { 688 case 1:
688 case kRGBA_8888_SkColorType: 689 switch (dstInfo.colorType()) {
689 case kBGRA_8888_SkColorType: 690 case kRGBA_8888_SkColorType:
690 proc = &swizzle_gray_to_n32; 691 case kBGRA_8888_SkColorType:
691 fastProc = &fast_swizzle_gray_to_n32; 692 proc = &swizzle_bit_to_n32;
692 break; 693 break;
693 case kGray_8_SkColorType: 694 case kIndex_8_SkColorType:
694 proc = &sample1; 695 proc = &swizzle_bit_to_index;
695 fastProc = © 696 break;
696 break; 697 case kRGB_565_SkColorType:
697 case kRGB_565_SkColorType: 698 proc = &swizzle_bit_to_565;
698 proc = &swizzle_gray_to_565; 699 break;
699 break; 700 case kGray_8_SkColorType:
700 default: 701 proc = &swizzle_bit_to_grayscale;
701 return nullptr; 702 break;
702 } 703 default:
703 break; 704 return nullptr;
704 default: 705 }
705 return nullptr; 706 break;
706 } 707 case 8:
707 break; 708 switch (dstInfo.colorType()) {
708 case SkEncodedInfo::kGrayAlpha_Color: 709 case kRGBA_8888_SkColorType:
709 switch (dstInfo.colorType()) { 710 case kBGRA_8888_SkColorType:
710 case kRGBA_8888_SkColorType: 711 proc = &swizzle_gray_to_n32;
711 case kBGRA_8888_SkColorType: 712 fastProc = &fast_swizzle_gray_to_n32;
712 if (premultiply) { 713 break;
713 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 714 case kGray_8_SkColorType:
714 proc = &SkipLeadingGrayAlphaZerosThen<swizzle_grayal pha_to_n32_premul>; 715 proc = &sample1;
715 fastProc = &SkipLeadingGrayAlphaZerosThen 716 fastProc = &copy;
716 <fast_swizzle_grayalpha_to_n32_premul>; 717 break;
717 } else { 718 case kRGB_565_SkColorType:
718 proc = &swizzle_grayalpha_to_n32_premul; 719 proc = &swizzle_gray_to_565;
719 fastProc = &fast_swizzle_grayalpha_to_n32_premul; 720 break;
720 } 721 default:
721 } else { 722 return nullptr;
722 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 723 }
723 proc = &SkipLeadingGrayAlphaZerosThen 724 break;
724 <swizzle_grayalpha_to_n32_unpremul>; 725 default:
725 fastProc = &SkipLeadingGrayAlphaZerosThen 726 return nullptr;
726 <fast_swizzle_grayalpha_to_n32_unpremul>; 727 }
727 } else { 728 break;
728 proc = &swizzle_grayalpha_to_n32_unpremul; 729 case SkEncodedInfo::kGrayAlpha_Color:
729 fastProc = &fast_swizzle_grayalpha_to_n32_unpremul; 730 switch (dstInfo.colorType()) {
730 } 731 case kRGBA_8888_SkColorType:
731 } 732 case kBGRA_8888_SkColorType:
732 break; 733 if (premultiply) {
733 default: 734 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
734 return nullptr; 735 proc = &SkipLeadingGrayAlphaZerosThen
735 } 736 <swizzle_grayalpha_to_n32_premul>;
736 break; 737 fastProc = &SkipLeadingGrayAlphaZerosThen
737 case SkEncodedInfo::kPalette_Color: 738 <fast_swizzle_grayalpha_to_n32_premul>;
738 // We assume that the color table is premultiplied and swizzled 739 } else {
739 // as desired. 740 proc = &swizzle_grayalpha_to_n32_premul;
740 switch (encodedInfo.bitsPerComponent()) { 741 fastProc = &fast_swizzle_grayalpha_to_n32_premul ;
741 case 1: 742 }
742 case 2: 743 } else {
743 case 4: 744 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
744 switch (dstInfo.colorType()) { 745 proc = &SkipLeadingGrayAlphaZerosThen
745 case kRGBA_8888_SkColorType: 746 <swizzle_grayalpha_to_n32_unpremul>;
746 case kBGRA_8888_SkColorType: 747 fastProc = &SkipLeadingGrayAlphaZerosThen
747 proc = &swizzle_small_index_to_n32; 748 <fast_swizzle_grayalpha_to_n32_unpremul> ;
748 break; 749 } else {
749 case kRGB_565_SkColorType: 750 proc = &swizzle_grayalpha_to_n32_unpremul;
750 proc = &swizzle_small_index_to_565; 751 fastProc = &fast_swizzle_grayalpha_to_n32_unprem ul;
751 break; 752 }
752 case kIndex_8_SkColorType: 753 }
753 proc = &swizzle_small_index_to_index; 754 break;
754 break; 755 default:
755 default: 756 return nullptr;
756 return nullptr; 757 }
757 } 758 break;
758 break; 759 case SkEncodedInfo::kPalette_Color:
759 case 8: 760 // We assume that the color table is premultiplied and swizzled
760 switch (dstInfo.colorType()) { 761 // as desired.
761 case kRGBA_8888_SkColorType: 762 switch (encodedInfo.bitsPerComponent()) {
762 case kBGRA_8888_SkColorType: 763 case 1:
763 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 764 case 2:
764 proc = &swizzle_index_to_n32_skipZ; 765 case 4:
765 } else { 766 switch (dstInfo.colorType()) {
766 proc = &swizzle_index_to_n32; 767 case kRGBA_8888_SkColorType:
767 } 768 case kBGRA_8888_SkColorType:
768 break; 769 proc = &swizzle_small_index_to_n32;
769 case kRGB_565_SkColorType: 770 break;
770 proc = &swizzle_index_to_565; 771 case kRGB_565_SkColorType:
771 break; 772 proc = &swizzle_small_index_to_565;
772 case kIndex_8_SkColorType: 773 break;
773 proc = &sample1; 774 case kIndex_8_SkColorType:
774 fastProc = &copy; 775 proc = &swizzle_small_index_to_index;
775 break; 776 break;
776 default: 777 default:
777 return nullptr; 778 return nullptr;
778 } 779 }
779 break; 780 break;
780 default: 781 case 8:
781 return nullptr; 782 switch (dstInfo.colorType()) {
782 } 783 case kRGBA_8888_SkColorType:
783 break; 784 case kBGRA_8888_SkColorType:
784 case SkEncodedInfo::kRGB_Color: 785 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
785 switch (dstInfo.colorType()) { 786 proc = &swizzle_index_to_n32_skipZ;
786 case kRGBA_8888_SkColorType: 787 } else {
787 proc = &swizzle_rgb_to_rgba; 788 proc = &swizzle_index_to_n32;
788 fastProc = &fast_swizzle_rgb_to_rgba; 789 }
789 break; 790 break;
790 case kBGRA_8888_SkColorType: 791 case kRGB_565_SkColorType:
791 proc = &swizzle_rgb_to_bgra; 792 proc = &swizzle_index_to_565;
792 fastProc = &fast_swizzle_rgb_to_bgra; 793 break;
793 break; 794 case kIndex_8_SkColorType:
794 case kRGB_565_SkColorType: 795 proc = &sample1;
795 proc = &swizzle_rgb_to_565; 796 fastProc = &copy;
796 break; 797 break;
797 default: 798 default:
798 return nullptr; 799 return nullptr;
799 } 800 }
800 break; 801 break;
801 case SkEncodedInfo::kRGBA_Color: 802 default:
802 switch (dstInfo.colorType()) { 803 return nullptr;
803 case kRGBA_8888_SkColorType: 804 }
804 if (premultiply) { 805 break;
805 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 806 case SkEncodedInfo::kRGB_Color:
806 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_rgb a_premul>; 807 switch (dstInfo.colorType()) {
807 fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rg ba_to_rgba_premul>; 808 case kRGBA_8888_SkColorType:
808 } else { 809 proc = &swizzle_rgb_to_rgba;
809 proc = &swizzle_rgba_to_rgba_premul; 810 fastProc = &fast_swizzle_rgb_to_rgba;
810 fastProc = &fast_swizzle_rgba_to_rgba_premul; 811 break;
811 } 812 case kBGRA_8888_SkColorType:
812 } else { 813 proc = &swizzle_rgb_to_bgra;
813 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 814 fastProc = &fast_swizzle_rgb_to_bgra;
814 proc = &SkipLeading8888ZerosThen<sample4>; 815 break;
815 fastProc = &SkipLeading8888ZerosThen<copy>; 816 case kRGB_565_SkColorType:
816 } else { 817 proc = &swizzle_rgb_to_565;
817 proc = &sample4; 818 break;
818 fastProc = &copy; 819 default:
819 } 820 return nullptr;
820 } 821 }
821 break; 822 break;
822 case kBGRA_8888_SkColorType: 823 case SkEncodedInfo::kRGBA_Color:
823 if (premultiply) { 824 switch (dstInfo.colorType()) {
824 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 825 case kRGBA_8888_SkColorType:
825 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_bgr a_premul>; 826 if (premultiply) {
826 fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rg ba_to_bgra_premul>; 827 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
827 } else { 828 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to _rgba_premul>;
828 proc = &swizzle_rgba_to_bgra_premul; 829 fastProc = &SkipLeading8888ZerosThen
829 fastProc = &fast_swizzle_rgba_to_bgra_premul; 830 <fast_swizzle_rgba_to_rgba_premul>;
830 } 831 } else {
831 } else { 832 proc = &swizzle_rgba_to_rgba_premul;
832 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 833 fastProc = &fast_swizzle_rgba_to_rgba_premul;
833 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_bgr a_unpremul>; 834 }
834 fastProc = &SkipLeading8888ZerosThen 835 } else {
835 <fast_swizzle_rgba_to_bgra_unpremul>; 836 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
836 } else { 837 proc = &SkipLeading8888ZerosThen<sample4>;
837 proc = &swizzle_rgba_to_bgra_unpremul; 838 fastProc = &SkipLeading8888ZerosThen<copy>;
838 fastProc = &fast_swizzle_rgba_to_bgra_unpremul; 839 } else {
839 } 840 proc = &sample4;
840 } 841 fastProc = &copy;
841 break; 842 }
842 default: 843 }
843 return nullptr; 844 break;
844 } 845 case kBGRA_8888_SkColorType:
845 break; 846 if (premultiply) {
846 case SkEncodedInfo::kBGR_Color: 847 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
847 switch (dstInfo.colorType()) { 848 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to _bgra_premul>;
848 case kBGRA_8888_SkColorType: 849 fastProc = &SkipLeading8888ZerosThen
849 proc = &swizzle_rgb_to_rgba; 850 <fast_swizzle_rgba_to_bgra_premul>;
850 fastProc = &fast_swizzle_rgb_to_rgba; 851 } else {
851 break; 852 proc = &swizzle_rgba_to_bgra_premul;
852 case kRGBA_8888_SkColorType: 853 fastProc = &fast_swizzle_rgba_to_bgra_premul;
853 proc = &swizzle_rgb_to_bgra; 854 }
854 fastProc = &fast_swizzle_rgb_to_bgra; 855 } else {
855 break; 856 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
856 case kRGB_565_SkColorType: 857 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to _bgra_unpremul>;
857 proc = &swizzle_bgr_to_565; 858 fastProc = &SkipLeading8888ZerosThen
858 break; 859 <fast_swizzle_rgba_to_bgra_unpremul>;
859 default: 860 } else {
860 return nullptr; 861 proc = &swizzle_rgba_to_bgra_unpremul;
861 } 862 fastProc = &fast_swizzle_rgba_to_bgra_unpremul;
862 break; 863 }
863 case SkEncodedInfo::kBGRX_Color: 864 }
864 switch (dstInfo.colorType()) { 865 break;
865 case kBGRA_8888_SkColorType: 866 default:
866 proc = &swizzle_rgb_to_rgba; 867 return nullptr;
867 break; 868 }
868 case kRGBA_8888_SkColorType: 869 break;
869 proc = &swizzle_rgb_to_bgra; 870 case SkEncodedInfo::kBGR_Color:
870 break; 871 switch (dstInfo.colorType()) {
871 case kRGB_565_SkColorType: 872 case kBGRA_8888_SkColorType:
872 proc = &swizzle_bgr_to_565; 873 proc = &swizzle_rgb_to_rgba;
873 break; 874 fastProc = &fast_swizzle_rgb_to_rgba;
874 default: 875 break;
875 return nullptr; 876 case kRGBA_8888_SkColorType:
876 } 877 proc = &swizzle_rgb_to_bgra;
877 break; 878 fastProc = &fast_swizzle_rgb_to_bgra;
878 case SkEncodedInfo::kBGRA_Color: 879 break;
879 switch (dstInfo.colorType()) { 880 case kRGB_565_SkColorType:
880 case kBGRA_8888_SkColorType: 881 proc = &swizzle_bgr_to_565;
881 if (premultiply) { 882 break;
882 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 883 default:
883 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_rgb a_premul>; 884 return nullptr;
884 fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rg ba_to_rgba_premul>; 885 }
885 } else { 886 break;
886 proc = &swizzle_rgba_to_rgba_premul; 887 case SkEncodedInfo::kBGRX_Color:
887 fastProc = &fast_swizzle_rgba_to_rgba_premul; 888 switch (dstInfo.colorType()) {
888 } 889 case kBGRA_8888_SkColorType:
889 } else { 890 proc = &swizzle_rgb_to_rgba;
890 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 891 break;
891 proc = &SkipLeading8888ZerosThen<sample4>; 892 case kRGBA_8888_SkColorType:
892 fastProc = &SkipLeading8888ZerosThen<copy>; 893 proc = &swizzle_rgb_to_bgra;
893 } else { 894 break;
894 proc = &sample4; 895 case kRGB_565_SkColorType:
895 fastProc = &copy; 896 proc = &swizzle_bgr_to_565;
896 } 897 break;
897 } 898 default:
898 break; 899 return nullptr;
899 case kRGBA_8888_SkColorType: 900 }
900 if (premultiply) { 901 break;
901 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 902 case SkEncodedInfo::kBGRA_Color:
902 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_bgr a_premul>; 903 switch (dstInfo.colorType()) {
903 fastProc = &SkipLeading8888ZerosThen<fast_swizzle_rg ba_to_bgra_premul>; 904 case kBGRA_8888_SkColorType:
904 } else { 905 if (premultiply) {
905 proc = &swizzle_rgba_to_bgra_premul; 906 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
906 fastProc = &fast_swizzle_rgba_to_bgra_premul; 907 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to _rgba_premul>;
907 } 908 fastProc = &SkipLeading8888ZerosThen
908 } else { 909 <fast_swizzle_rgba_to_rgba_premul>;
909 if (SkCodec::kYes_ZeroInitialized == zeroInit) { 910 } else {
910 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_bgr a_unpremul>; 911 proc = &swizzle_rgba_to_rgba_premul;
911 fastProc = &SkipLeading8888ZerosThen 912 fastProc = &fast_swizzle_rgba_to_rgba_premul;
912 <fast_swizzle_rgba_to_bgra_unpremul>; 913 }
913 } else { 914 } else {
914 proc = &swizzle_rgba_to_bgra_unpremul; 915 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
915 fastProc = &fast_swizzle_rgba_to_bgra_unpremul; 916 proc = &SkipLeading8888ZerosThen<sample4>;
916 } 917 fastProc = &SkipLeading8888ZerosThen<copy>;
917 } 918 } else {
918 break; 919 proc = &sample4;
919 default: 920 fastProc = &copy;
920 return nullptr; 921 }
921 } 922 }
922 break; 923 break;
923 case SkEncodedInfo::kInvertedCMYK_Color: 924 case kRGBA_8888_SkColorType:
924 switch (dstInfo.colorType()) { 925 if (premultiply) {
925 case kRGBA_8888_SkColorType: 926 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
926 proc = &swizzle_cmyk_to_rgba; 927 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to _bgra_premul>;
927 fastProc = &fast_swizzle_cmyk_to_rgba; 928 fastProc = &SkipLeading8888ZerosThen
928 break; 929 <fast_swizzle_rgba_to_bgra_premul>;
929 case kBGRA_8888_SkColorType: 930 } else {
930 proc = &swizzle_cmyk_to_bgra; 931 proc = &swizzle_rgba_to_bgra_premul;
931 fastProc = &fast_swizzle_cmyk_to_bgra; 932 fastProc = &fast_swizzle_rgba_to_bgra_premul;
932 break; 933 }
933 case kRGB_565_SkColorType: 934 } else {
934 proc = &swizzle_cmyk_to_565; 935 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
935 break; 936 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to _bgra_unpremul>;
936 default: 937 fastProc = &SkipLeading8888ZerosThen
937 return nullptr; 938 <fast_swizzle_rgba_to_bgra_unpremul>;
938 } 939 } else {
939 break; 940 proc = &swizzle_rgba_to_bgra_unpremul;
940 case SkEncodedInfo::kPreSwizzled_Color: 941 fastProc = &fast_swizzle_rgba_to_bgra_unpremul;
941 switch (dstInfo.colorType()) { 942 }
942 case kGray_8_SkColorType: 943 }
943 proc = &sample1; 944 break;
944 fastProc = &copy; 945 default:
945 break; 946 return nullptr;
946 case kRGB_565_SkColorType: 947 }
947 proc = &sample2; 948 break;
948 fastProc = &copy; 949 case SkEncodedInfo::kInvertedCMYK_Color:
949 break; 950 switch (dstInfo.colorType()) {
950 case kRGBA_8888_SkColorType: 951 case kRGBA_8888_SkColorType:
951 case kBGRA_8888_SkColorType: 952 proc = &swizzle_cmyk_to_rgba;
952 proc = &sample4; 953 fastProc = &fast_swizzle_cmyk_to_rgba;
953 fastProc = &copy; 954 break;
954 break; 955 case kBGRA_8888_SkColorType:
955 default: 956 proc = &swizzle_cmyk_to_bgra;
956 return nullptr; 957 fastProc = &fast_swizzle_cmyk_to_bgra;
957 } 958 break;
958 break; 959 case kRGB_565_SkColorType:
959 default: 960 proc = &swizzle_cmyk_to_565;
960 return nullptr; 961 break;
962 default:
963 return nullptr;
964 }
965 break;
966 default:
967 return nullptr;
968 }
961 } 969 }
962 970
963 int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType());
964 int srcBPP; 971 int srcBPP;
965 if (SkEncodedInfo::kPreSwizzled_Color == encodedInfo.color()) { 972 const int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType());
973 if (preSwizzled) {
966 srcBPP = dstBPP; 974 srcBPP = dstBPP;
967 } else { 975 } else {
968 // Store bpp in bytes if it is an even multiple, otherwise use bits 976 // Store bpp in bytes if it is an even multiple, otherwise use bits
969 uint8_t bitsPerPixel = encodedInfo.bitsPerPixel(); 977 uint8_t bitsPerPixel = encodedInfo.bitsPerPixel();
970 srcBPP = SkIsAlign8(bitsPerPixel) ? bitsPerPixel / 8 : bitsPerPixel; 978 srcBPP = SkIsAlign8(bitsPerPixel) ? bitsPerPixel / 8 : bitsPerPixel;
971 } 979 }
972 980
973 int srcOffset = 0; 981 int srcOffset = 0;
974 int srcWidth = dstInfo.width(); 982 int srcWidth = dstInfo.width();
975 int dstOffset = 0; 983 int dstOffset = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 } 1036 }
1029 1037
1030 return fAllocatedWidth; 1038 return fAllocatedWidth;
1031 } 1039 }
1032 1040
1033 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { 1041 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) {
1034 SkASSERT(nullptr != dst && nullptr != src); 1042 SkASSERT(nullptr != dst && nullptr != src);
1035 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS rcBPP, 1043 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS rcBPP,
1036 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable); 1044 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable);
1037 } 1045 }
OLDNEW
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698