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

Side by Side Diff: core/src/fxge/dib/fx_dib_composite.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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 | « core/src/fxge/android/fpf_skiafontmgr.cpp ('k') | core/src/fxge/dib/fx_dib_convert.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 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/include/fxge/fx_ge.h" 7 #include "core/include/fxge/fx_ge.h"
8 #include "core/include/fxcodec/fx_codec.h" 8 #include "core/include/fxcodec/fx_codec.h"
9 #include "dib_int.h" 9 #include "dib_int.h"
10 10
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 730 }
731 void _CompositeRow_Argb2Argb(uint8_t* dest_scan, 731 void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
732 const uint8_t* src_scan, 732 const uint8_t* src_scan,
733 int pixel_count, 733 int pixel_count,
734 int blend_type, 734 int blend_type,
735 const uint8_t* clip_scan, 735 const uint8_t* clip_scan,
736 uint8_t* dest_alpha_scan, 736 uint8_t* dest_alpha_scan,
737 const uint8_t* src_alpha_scan) { 737 const uint8_t* src_alpha_scan) {
738 int blended_colors[3]; 738 int blended_colors[3];
739 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 739 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
740 if (dest_alpha_scan == NULL) { 740 if (!dest_alpha_scan) {
741 if (src_alpha_scan == NULL) { 741 if (!src_alpha_scan) {
742 uint8_t back_alpha = 0; 742 uint8_t back_alpha = 0;
743 for (int col = 0; col < pixel_count; col++) { 743 for (int col = 0; col < pixel_count; col++) {
744 back_alpha = dest_scan[3]; 744 back_alpha = dest_scan[3];
745 if (back_alpha == 0) { 745 if (back_alpha == 0) {
746 if (clip_scan) { 746 if (clip_scan) {
747 int src_alpha = clip_scan[col] * src_scan[3] / 255; 747 int src_alpha = clip_scan[col] * src_scan[3] / 255;
748 FXARGB_SETDIB(dest_scan, (FXARGB_GETDIB(src_scan) & 0xffffff) | 748 FXARGB_SETDIB(dest_scan, (FXARGB_GETDIB(src_scan) & 0xffffff) |
749 (src_alpha << 24)); 749 (src_alpha << 24));
750 } else { 750 } else {
751 FXARGB_COPY(dest_scan, src_scan); 751 FXARGB_COPY(dest_scan, src_scan);
752 } 752 }
753 dest_scan += 4; 753 dest_scan += 4;
754 src_scan += 4; 754 src_scan += 4;
755 continue; 755 continue;
756 } 756 }
757 uint8_t src_alpha; 757 uint8_t src_alpha;
758 if (clip_scan == NULL) { 758 if (clip_scan) {
759 src_alpha = clip_scan[col] * src_scan[3] / 255;
760 } else {
759 src_alpha = src_scan[3]; 761 src_alpha = src_scan[3];
760 } else {
761 src_alpha = clip_scan[col] * src_scan[3] / 255;
762 } 762 }
763 if (src_alpha == 0) { 763 if (src_alpha == 0) {
764 dest_scan += 4; 764 dest_scan += 4;
765 src_scan += 4; 765 src_scan += 4;
766 continue; 766 continue;
767 } 767 }
768 uint8_t dest_alpha = 768 uint8_t dest_alpha =
769 back_alpha + src_alpha - back_alpha * src_alpha / 255; 769 back_alpha + src_alpha - back_alpha * src_alpha / 255;
770 dest_scan[3] = dest_alpha; 770 dest_scan[3] = dest_alpha;
771 int alpha_ratio = src_alpha * 255 / dest_alpha; 771 int alpha_ratio = src_alpha * 255 / dest_alpha;
(...skipping 28 matching lines...) Expand all
800 FXARGB_SETDIB(dest_scan, 800 FXARGB_SETDIB(dest_scan,
801 FXARGB_MAKE((*src_alpha_scan << 24), src_scan[2], 801 FXARGB_MAKE((*src_alpha_scan << 24), src_scan[2],
802 src_scan[1], *src_scan)); 802 src_scan[1], *src_scan));
803 } 803 }
804 dest_scan += 4; 804 dest_scan += 4;
805 src_scan += 3; 805 src_scan += 3;
806 src_alpha_scan++; 806 src_alpha_scan++;
807 continue; 807 continue;
808 } 808 }
809 uint8_t src_alpha; 809 uint8_t src_alpha;
810 if (clip_scan == NULL) { 810 if (clip_scan) {
811 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
812 } else {
811 src_alpha = *src_alpha_scan++; 813 src_alpha = *src_alpha_scan++;
812 } else {
813 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
814 } 814 }
815 if (src_alpha == 0) { 815 if (src_alpha == 0) {
816 dest_scan += 4; 816 dest_scan += 4;
817 src_scan += 3; 817 src_scan += 3;
818 continue; 818 continue;
819 } 819 }
820 uint8_t dest_alpha = 820 uint8_t dest_alpha =
821 back_alpha + src_alpha - back_alpha * src_alpha / 255; 821 back_alpha + src_alpha - back_alpha * src_alpha / 255;
822 dest_scan[3] = dest_alpha; 822 dest_scan[3] = dest_alpha;
823 int alpha_ratio = src_alpha * 255 / dest_alpha; 823 int alpha_ratio = src_alpha * 255 / dest_alpha;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 *dest_alpha_scan = *src_alpha_scan; 855 *dest_alpha_scan = *src_alpha_scan;
856 *dest_scan++ = *src_scan++; 856 *dest_scan++ = *src_scan++;
857 *dest_scan++ = *src_scan++; 857 *dest_scan++ = *src_scan++;
858 *dest_scan++ = *src_scan++; 858 *dest_scan++ = *src_scan++;
859 } 859 }
860 dest_alpha_scan++; 860 dest_alpha_scan++;
861 src_alpha_scan++; 861 src_alpha_scan++;
862 continue; 862 continue;
863 } 863 }
864 uint8_t src_alpha; 864 uint8_t src_alpha;
865 if (clip_scan == NULL) { 865 if (clip_scan) {
866 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
867 } else {
866 src_alpha = *src_alpha_scan++; 868 src_alpha = *src_alpha_scan++;
867 } else {
868 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
869 } 869 }
870 if (src_alpha == 0) { 870 if (src_alpha == 0) {
871 dest_scan += 3; 871 dest_scan += 3;
872 src_scan += 3; 872 src_scan += 3;
873 dest_alpha_scan++; 873 dest_alpha_scan++;
874 continue; 874 continue;
875 } 875 }
876 uint8_t dest_alpha = 876 uint8_t dest_alpha =
877 back_alpha + src_alpha - back_alpha * src_alpha / 255; 877 back_alpha + src_alpha - back_alpha * src_alpha / 255;
878 *dest_alpha_scan++ = dest_alpha; 878 *dest_alpha_scan++ = dest_alpha;
(...skipping 29 matching lines...) Expand all
908 *dest_alpha_scan = src_scan[3]; 908 *dest_alpha_scan = src_scan[3];
909 *dest_scan++ = *src_scan++; 909 *dest_scan++ = *src_scan++;
910 *dest_scan++ = *src_scan++; 910 *dest_scan++ = *src_scan++;
911 *dest_scan++ = *src_scan++; 911 *dest_scan++ = *src_scan++;
912 } 912 }
913 dest_alpha_scan++; 913 dest_alpha_scan++;
914 src_scan++; 914 src_scan++;
915 continue; 915 continue;
916 } 916 }
917 uint8_t src_alpha; 917 uint8_t src_alpha;
918 if (clip_scan == NULL) { 918 if (clip_scan) {
919 src_alpha = clip_scan[col] * src_scan[3] / 255;
920 } else {
919 src_alpha = src_scan[3]; 921 src_alpha = src_scan[3];
920 } else {
921 src_alpha = clip_scan[col] * src_scan[3] / 255;
922 } 922 }
923 if (src_alpha == 0) { 923 if (src_alpha == 0) {
924 dest_scan += 3; 924 dest_scan += 3;
925 src_scan += 4; 925 src_scan += 4;
926 dest_alpha_scan++; 926 dest_alpha_scan++;
927 continue; 927 continue;
928 } 928 }
929 uint8_t dest_alpha = 929 uint8_t dest_alpha =
930 back_alpha + src_alpha - back_alpha * src_alpha / 255; 930 back_alpha + src_alpha - back_alpha * src_alpha / 255;
931 *dest_alpha_scan++ = dest_alpha; 931 *dest_alpha_scan++ = dest_alpha;
(...skipping 21 matching lines...) Expand all
953 } 953 }
954 void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan, 954 void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
955 const uint8_t* src_scan, 955 const uint8_t* src_scan,
956 int width, 956 int width,
957 int blend_type, 957 int blend_type,
958 int src_Bpp, 958 int src_Bpp,
959 uint8_t* dest_alpha_scan) { 959 uint8_t* dest_alpha_scan) {
960 int blended_colors[3]; 960 int blended_colors[3];
961 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 961 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
962 int src_gap = src_Bpp - 3; 962 int src_gap = src_Bpp - 3;
963 if (dest_alpha_scan == NULL) { 963 if (dest_alpha_scan) {
964 for (int col = 0; col < width; col++) { 964 for (int col = 0; col < width; col++) {
965 uint8_t back_alpha = dest_scan[3]; 965 uint8_t back_alpha = *dest_alpha_scan;
966 if (back_alpha == 0) { 966 if (back_alpha == 0) {
967 if (src_Bpp == 4) { 967 *dest_scan++ = *src_scan++;
968 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); 968 *dest_scan++ = *src_scan++;
969 } else { 969 *dest_scan++ = *src_scan++;
970 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1], 970 *dest_alpha_scan++ = 0xff;
971 src_scan[0])); 971 src_scan += src_gap;
972 }
973 dest_scan += 4;
974 src_scan += src_Bpp;
975 continue; 972 continue;
976 } 973 }
977 dest_scan[3] = 0xff; 974 *dest_alpha_scan++ = 0xff;
978 if (bNonseparableBlend) { 975 if (bNonseparableBlend) {
979 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); 976 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
980 } 977 }
981 for (int color = 0; color < 3; color++) { 978 for (int color = 0; color < 3; color++) {
982 int src_color = *src_scan; 979 int src_color = *src_scan;
983 int blended = bNonseparableBlend 980 int blended = bNonseparableBlend
984 ? blended_colors[color] 981 ? blended_colors[color]
985 : _BLEND(blend_type, *dest_scan, src_color); 982 : _BLEND(blend_type, *dest_scan, src_color);
986 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); 983 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
987 dest_scan++; 984 dest_scan++;
988 src_scan++; 985 src_scan++;
989 } 986 }
990 dest_scan++;
991 src_scan += src_gap; 987 src_scan += src_gap;
992 } 988 }
993 } else { 989 } else {
994 for (int col = 0; col < width; col++) { 990 for (int col = 0; col < width; col++) {
995 uint8_t back_alpha = *dest_alpha_scan; 991 uint8_t back_alpha = dest_scan[3];
996 if (back_alpha == 0) { 992 if (back_alpha == 0) {
997 *dest_scan++ = *src_scan++; 993 if (src_Bpp == 4) {
998 *dest_scan++ = *src_scan++; 994 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
999 *dest_scan++ = *src_scan++; 995 } else {
1000 *dest_alpha_scan++ = 0xff; 996 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1],
1001 src_scan += src_gap; 997 src_scan[0]));
998 }
999 dest_scan += 4;
1000 src_scan += src_Bpp;
1002 continue; 1001 continue;
1003 } 1002 }
1004 *dest_alpha_scan++ = 0xff; 1003 dest_scan[3] = 0xff;
1005 if (bNonseparableBlend) { 1004 if (bNonseparableBlend) {
1006 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); 1005 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
1007 } 1006 }
1008 for (int color = 0; color < 3; color++) { 1007 for (int color = 0; color < 3; color++) {
1009 int src_color = *src_scan; 1008 int src_color = *src_scan;
1010 int blended = bNonseparableBlend 1009 int blended = bNonseparableBlend
1011 ? blended_colors[color] 1010 ? blended_colors[color]
1012 : _BLEND(blend_type, *dest_scan, src_color); 1011 : _BLEND(blend_type, *dest_scan, src_color);
1013 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); 1012 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
1014 dest_scan++; 1013 dest_scan++;
1015 src_scan++; 1014 src_scan++;
1016 } 1015 }
1016 dest_scan++;
1017 src_scan += src_gap; 1017 src_scan += src_gap;
1018 } 1018 }
1019 } 1019 }
1020 } 1020 }
1021 inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan, 1021 inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
1022 const uint8_t* src_scan, 1022 const uint8_t* src_scan,
1023 int width, 1023 int width,
1024 int blend_type, 1024 int blend_type,
1025 int src_Bpp, 1025 int src_Bpp,
1026 const uint8_t* clip_scan, 1026 const uint8_t* clip_scan,
1027 uint8_t* dest_alpha_scan) { 1027 uint8_t* dest_alpha_scan) {
1028 int blended_colors[3]; 1028 int blended_colors[3];
1029 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 1029 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
1030 int src_gap = src_Bpp - 3; 1030 int src_gap = src_Bpp - 3;
1031 if (dest_alpha_scan == NULL) { 1031 if (dest_alpha_scan) {
1032 for (int col = 0; col < width; col++) { 1032 for (int col = 0; col < width; col++) {
1033 int src_alpha = *clip_scan++; 1033 int src_alpha = *clip_scan++;
1034 uint8_t back_alpha = dest_scan[3]; 1034 uint8_t back_alpha = *dest_alpha_scan;
1035 if (back_alpha == 0) { 1035 if (back_alpha == 0) {
1036 *dest_scan++ = *src_scan++; 1036 *dest_scan++ = *src_scan++;
1037 *dest_scan++ = *src_scan++; 1037 *dest_scan++ = *src_scan++;
1038 *dest_scan++ = *src_scan++; 1038 *dest_scan++ = *src_scan++;
1039 src_scan += src_gap; 1039 src_scan += src_gap;
1040 dest_scan++; 1040 dest_alpha_scan++;
1041 continue; 1041 continue;
1042 } 1042 }
1043 if (src_alpha == 0) { 1043 if (src_alpha == 0) {
1044 dest_scan += 4; 1044 dest_scan += 3;
1045 dest_alpha_scan++;
1045 src_scan += src_Bpp; 1046 src_scan += src_Bpp;
1046 continue; 1047 continue;
1047 } 1048 }
1048 uint8_t dest_alpha = 1049 uint8_t dest_alpha =
1049 back_alpha + src_alpha - back_alpha * src_alpha / 255; 1050 back_alpha + src_alpha - back_alpha * src_alpha / 255;
1050 dest_scan[3] = dest_alpha; 1051 *dest_alpha_scan++ = dest_alpha;
1051 int alpha_ratio = src_alpha * 255 / dest_alpha; 1052 int alpha_ratio = src_alpha * 255 / dest_alpha;
1052 if (bNonseparableBlend) { 1053 if (bNonseparableBlend) {
1053 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); 1054 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
1054 } 1055 }
1055 for (int color = 0; color < 3; color++) { 1056 for (int color = 0; color < 3; color++) {
1056 int src_color = *src_scan; 1057 int src_color = *src_scan;
1057 int blended = bNonseparableBlend 1058 int blended = bNonseparableBlend
1058 ? blended_colors[color] 1059 ? blended_colors[color]
1059 : _BLEND(blend_type, *dest_scan, src_color); 1060 : _BLEND(blend_type, *dest_scan, src_color);
1060 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); 1061 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
1061 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); 1062 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio);
1062 dest_scan++; 1063 dest_scan++;
1063 src_scan++; 1064 src_scan++;
1064 } 1065 }
1065 dest_scan++;
1066 src_scan += src_gap; 1066 src_scan += src_gap;
1067 } 1067 }
1068 } else { 1068 } else {
1069 for (int col = 0; col < width; col++) { 1069 for (int col = 0; col < width; col++) {
1070 int src_alpha = *clip_scan++; 1070 int src_alpha = *clip_scan++;
1071 uint8_t back_alpha = *dest_alpha_scan; 1071 uint8_t back_alpha = dest_scan[3];
1072 if (back_alpha == 0) { 1072 if (back_alpha == 0) {
1073 *dest_scan++ = *src_scan++; 1073 *dest_scan++ = *src_scan++;
1074 *dest_scan++ = *src_scan++; 1074 *dest_scan++ = *src_scan++;
1075 *dest_scan++ = *src_scan++; 1075 *dest_scan++ = *src_scan++;
1076 src_scan += src_gap; 1076 src_scan += src_gap;
1077 dest_alpha_scan++; 1077 dest_scan++;
1078 continue; 1078 continue;
1079 } 1079 }
1080 if (src_alpha == 0) { 1080 if (src_alpha == 0) {
1081 dest_scan += 3; 1081 dest_scan += 4;
1082 dest_alpha_scan++;
1083 src_scan += src_Bpp; 1082 src_scan += src_Bpp;
1084 continue; 1083 continue;
1085 } 1084 }
1086 uint8_t dest_alpha = 1085 uint8_t dest_alpha =
1087 back_alpha + src_alpha - back_alpha * src_alpha / 255; 1086 back_alpha + src_alpha - back_alpha * src_alpha / 255;
1088 *dest_alpha_scan++ = dest_alpha; 1087 dest_scan[3] = dest_alpha;
1089 int alpha_ratio = src_alpha * 255 / dest_alpha; 1088 int alpha_ratio = src_alpha * 255 / dest_alpha;
1090 if (bNonseparableBlend) { 1089 if (bNonseparableBlend) {
1091 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); 1090 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
1092 } 1091 }
1093 for (int color = 0; color < 3; color++) { 1092 for (int color = 0; color < 3; color++) {
1094 int src_color = *src_scan; 1093 int src_color = *src_scan;
1095 int blended = bNonseparableBlend 1094 int blended = bNonseparableBlend
1096 ? blended_colors[color] 1095 ? blended_colors[color]
1097 : _BLEND(blend_type, *dest_scan, src_color); 1096 : _BLEND(blend_type, *dest_scan, src_color);
1098 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); 1097 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
1099 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); 1098 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio);
1100 dest_scan++; 1099 dest_scan++;
1101 src_scan++; 1100 src_scan++;
1102 } 1101 }
1102 dest_scan++;
1103 src_scan += src_gap; 1103 src_scan += src_gap;
1104 } 1104 }
1105 } 1105 }
1106 } 1106 }
1107 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan, 1107 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan,
1108 const uint8_t* src_scan, 1108 const uint8_t* src_scan,
1109 int width, 1109 int width,
1110 int src_Bpp, 1110 int src_Bpp,
1111 const uint8_t* clip_scan, 1111 const uint8_t* clip_scan,
1112 uint8_t* dest_alpha_scan) { 1112 uint8_t* dest_alpha_scan) {
1113 int src_gap = src_Bpp - 3; 1113 int src_gap = src_Bpp - 3;
1114 if (dest_alpha_scan == NULL) { 1114 if (dest_alpha_scan) {
1115 for (int col = 0; col < width; col++) { 1115 for (int col = 0; col < width; col++) {
1116 int src_alpha = clip_scan[col]; 1116 int src_alpha = clip_scan[col];
1117 if (src_alpha == 255) { 1117 if (src_alpha == 255) {
1118 *dest_scan++ = *src_scan++; 1118 *dest_scan++ = *src_scan++;
1119 *dest_scan++ = *src_scan++; 1119 *dest_scan++ = *src_scan++;
1120 *dest_scan++ = *src_scan++; 1120 *dest_scan++ = *src_scan++;
1121 *dest_scan++ = 255; 1121 *dest_alpha_scan++ = 255;
1122 src_scan += src_gap; 1122 src_scan += src_gap;
1123 continue; 1123 continue;
1124 } 1124 }
1125 if (src_alpha == 0) { 1125 if (src_alpha == 0) {
1126 dest_scan += 4; 1126 dest_scan += 3;
1127 dest_alpha_scan++;
1127 src_scan += src_Bpp; 1128 src_scan += src_Bpp;
1128 continue; 1129 continue;
1129 } 1130 }
1130 int back_alpha = dest_scan[3]; 1131 int back_alpha = *dest_alpha_scan;
1131 uint8_t dest_alpha = 1132 uint8_t dest_alpha =
1132 back_alpha + src_alpha - back_alpha * src_alpha / 255; 1133 back_alpha + src_alpha - back_alpha * src_alpha / 255;
1133 dest_scan[3] = dest_alpha; 1134 *dest_alpha_scan++ = dest_alpha;
1134 int alpha_ratio = src_alpha * 255 / dest_alpha; 1135 int alpha_ratio = src_alpha * 255 / dest_alpha;
1135 for (int color = 0; color < 3; color++) { 1136 for (int color = 0; color < 3; color++) {
1136 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); 1137 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
1137 dest_scan++; 1138 dest_scan++;
1138 src_scan++; 1139 src_scan++;
1139 } 1140 }
1140 dest_scan++;
1141 src_scan += src_gap; 1141 src_scan += src_gap;
1142 } 1142 }
1143 } else { 1143 } else {
1144 for (int col = 0; col < width; col++) { 1144 for (int col = 0; col < width; col++) {
1145 int src_alpha = clip_scan[col]; 1145 int src_alpha = clip_scan[col];
1146 if (src_alpha == 255) { 1146 if (src_alpha == 255) {
1147 *dest_scan++ = *src_scan++; 1147 *dest_scan++ = *src_scan++;
1148 *dest_scan++ = *src_scan++; 1148 *dest_scan++ = *src_scan++;
1149 *dest_scan++ = *src_scan++; 1149 *dest_scan++ = *src_scan++;
1150 *dest_alpha_scan++ = 255; 1150 *dest_scan++ = 255;
1151 src_scan += src_gap; 1151 src_scan += src_gap;
1152 continue; 1152 continue;
1153 } 1153 }
1154 if (src_alpha == 0) { 1154 if (src_alpha == 0) {
1155 dest_scan += 3; 1155 dest_scan += 4;
1156 dest_alpha_scan++;
1157 src_scan += src_Bpp; 1156 src_scan += src_Bpp;
1158 continue; 1157 continue;
1159 } 1158 }
1160 int back_alpha = *dest_alpha_scan; 1159 int back_alpha = dest_scan[3];
1161 uint8_t dest_alpha = 1160 uint8_t dest_alpha =
1162 back_alpha + src_alpha - back_alpha * src_alpha / 255; 1161 back_alpha + src_alpha - back_alpha * src_alpha / 255;
1163 *dest_alpha_scan++ = dest_alpha; 1162 dest_scan[3] = dest_alpha;
1164 int alpha_ratio = src_alpha * 255 / dest_alpha; 1163 int alpha_ratio = src_alpha * 255 / dest_alpha;
1165 for (int color = 0; color < 3; color++) { 1164 for (int color = 0; color < 3; color++) {
1166 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); 1165 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
1167 dest_scan++; 1166 dest_scan++;
1168 src_scan++; 1167 src_scan++;
1169 } 1168 }
1169 dest_scan++;
1170 src_scan += src_gap; 1170 src_scan += src_gap;
1171 } 1171 }
1172 } 1172 }
1173 } 1173 }
1174 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan, 1174 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan,
1175 const uint8_t* src_scan, 1175 const uint8_t* src_scan,
1176 int width, 1176 int width,
1177 int src_Bpp, 1177 int src_Bpp,
1178 uint8_t* dest_alpha_scan) { 1178 uint8_t* dest_alpha_scan) {
1179 if (dest_alpha_scan == NULL) { 1179 if (dest_alpha_scan) {
1180 int src_gap = src_Bpp - 3;
1181 for (int col = 0; col < width; col++) {
1182 *dest_scan++ = *src_scan++;
1183 *dest_scan++ = *src_scan++;
1184 *dest_scan++ = *src_scan++;
1185 *dest_alpha_scan++ = 0xff;
1186 src_scan += src_gap;
1187 }
1188 } else {
1180 for (int col = 0; col < width; col++) { 1189 for (int col = 0; col < width; col++) {
1181 if (src_Bpp == 4) { 1190 if (src_Bpp == 4) {
1182 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); 1191 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
1183 } else { 1192 } else {
1184 FXARGB_SETDIB(dest_scan, 1193 FXARGB_SETDIB(dest_scan,
1185 FXARGB_MAKE(0xff, src_scan[2], src_scan[1], src_scan[0])); 1194 FXARGB_MAKE(0xff, src_scan[2], src_scan[1], src_scan[0]));
1186 } 1195 }
1187 dest_scan += 4; 1196 dest_scan += 4;
1188 src_scan += src_Bpp; 1197 src_scan += src_Bpp;
1189 } 1198 }
1190 } else {
1191 int src_gap = src_Bpp - 3;
1192 for (int col = 0; col < width; col++) {
1193 *dest_scan++ = *src_scan++;
1194 *dest_scan++ = *src_scan++;
1195 *dest_scan++ = *src_scan++;
1196 *dest_alpha_scan++ = 0xff;
1197 src_scan += src_gap;
1198 }
1199 } 1199 }
1200 } 1200 }
1201 inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan, 1201 inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
1202 const uint8_t* src_scan, 1202 const uint8_t* src_scan,
1203 int width, 1203 int width,
1204 int blend_type, 1204 int blend_type,
1205 int dest_Bpp, 1205 int dest_Bpp,
1206 const uint8_t* clip_scan, 1206 const uint8_t* clip_scan,
1207 const uint8_t* src_alpha_scan) { 1207 const uint8_t* src_alpha_scan) {
1208 int blended_colors[3]; 1208 int blended_colors[3];
1209 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 1209 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
1210 int dest_gap = dest_Bpp - 3; 1210 int dest_gap = dest_Bpp - 3;
1211 if (src_alpha_scan == NULL) { 1211 if (src_alpha_scan) {
1212 for (int col = 0; col < width; col++) { 1212 for (int col = 0; col < width; col++) {
1213 uint8_t src_alpha; 1213 uint8_t src_alpha;
1214 if (clip_scan) { 1214 if (clip_scan) {
1215 src_alpha = src_scan[3] * (*clip_scan++) / 255; 1215 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
1216 } else { 1216 } else {
1217 src_alpha = src_scan[3]; 1217 src_alpha = *src_alpha_scan++;
1218 } 1218 }
1219 if (src_alpha == 0) { 1219 if (src_alpha == 0) {
1220 dest_scan += dest_Bpp; 1220 dest_scan += dest_Bpp;
1221 src_scan += 4; 1221 src_scan += 3;
1222 continue; 1222 continue;
1223 } 1223 }
1224 if (bNonseparableBlend) { 1224 if (bNonseparableBlend) {
1225 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); 1225 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
1226 } 1226 }
1227 for (int color = 0; color < 3; color++) { 1227 for (int color = 0; color < 3; color++) {
1228 int back_color = *dest_scan; 1228 int back_color = *dest_scan;
1229 int blended = bNonseparableBlend 1229 int blended = bNonseparableBlend
1230 ? blended_colors[color] 1230 ? blended_colors[color]
1231 : _BLEND(blend_type, back_color, *src_scan); 1231 : _BLEND(blend_type, back_color, *src_scan);
1232 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); 1232 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha);
1233 dest_scan++; 1233 dest_scan++;
1234 src_scan++; 1234 src_scan++;
1235 } 1235 }
1236 dest_scan += dest_gap; 1236 dest_scan += dest_gap;
1237 src_scan++;
1238 } 1237 }
1239 } else { 1238 } else {
1240 for (int col = 0; col < width; col++) { 1239 for (int col = 0; col < width; col++) {
1241 uint8_t src_alpha; 1240 uint8_t src_alpha;
1242 if (clip_scan) { 1241 if (clip_scan) {
1243 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; 1242 src_alpha = src_scan[3] * (*clip_scan++) / 255;
1244 } else { 1243 } else {
1245 src_alpha = *src_alpha_scan++; 1244 src_alpha = src_scan[3];
1246 } 1245 }
1247 if (src_alpha == 0) { 1246 if (src_alpha == 0) {
1248 dest_scan += dest_Bpp; 1247 dest_scan += dest_Bpp;
1249 src_scan += 3; 1248 src_scan += 4;
1250 continue; 1249 continue;
1251 } 1250 }
1252 if (bNonseparableBlend) { 1251 if (bNonseparableBlend) {
1253 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); 1252 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
1254 } 1253 }
1255 for (int color = 0; color < 3; color++) { 1254 for (int color = 0; color < 3; color++) {
1256 int back_color = *dest_scan; 1255 int back_color = *dest_scan;
1257 int blended = bNonseparableBlend 1256 int blended = bNonseparableBlend
1258 ? blended_colors[color] 1257 ? blended_colors[color]
1259 : _BLEND(blend_type, back_color, *src_scan); 1258 : _BLEND(blend_type, back_color, *src_scan);
1260 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); 1259 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha);
1261 dest_scan++; 1260 dest_scan++;
1262 src_scan++; 1261 src_scan++;
1263 } 1262 }
1264 dest_scan += dest_gap; 1263 dest_scan += dest_gap;
1264 src_scan++;
1265 } 1265 }
1266 } 1266 }
1267 } 1267 }
1268 inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan, 1268 inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
1269 const uint8_t* src_scan, 1269 const uint8_t* src_scan,
1270 int width, 1270 int width,
1271 int dest_Bpp, 1271 int dest_Bpp,
1272 const uint8_t* clip_scan, 1272 const uint8_t* clip_scan,
1273 const uint8_t* src_alpha_scan) { 1273 const uint8_t* src_alpha_scan) {
1274 int dest_gap = dest_Bpp - 3; 1274 int dest_gap = dest_Bpp - 3;
1275 if (src_alpha_scan == NULL) { 1275 if (src_alpha_scan) {
1276 for (int col = 0; col < width; col++) { 1276 for (int col = 0; col < width; col++) {
1277 uint8_t src_alpha; 1277 uint8_t src_alpha;
1278 if (clip_scan) { 1278 if (clip_scan) {
1279 src_alpha = src_scan[3] * (*clip_scan++) / 255; 1279 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
1280 } else { 1280 } else {
1281 src_alpha = src_scan[3]; 1281 src_alpha = *src_alpha_scan++;
1282 } 1282 }
1283 if (src_alpha == 255) { 1283 if (src_alpha == 255) {
1284 *dest_scan++ = *src_scan++; 1284 *dest_scan++ = *src_scan++;
1285 *dest_scan++ = *src_scan++; 1285 *dest_scan++ = *src_scan++;
1286 *dest_scan++ = *src_scan++; 1286 *dest_scan++ = *src_scan++;
1287 dest_scan += dest_gap; 1287 dest_scan += dest_gap;
1288 src_scan++;
1289 continue; 1288 continue;
1290 } 1289 }
1291 if (src_alpha == 0) { 1290 if (src_alpha == 0) {
1292 dest_scan += dest_Bpp; 1291 dest_scan += dest_Bpp;
1293 src_scan += 4; 1292 src_scan += 3;
1294 continue; 1293 continue;
1295 } 1294 }
1296 for (int color = 0; color < 3; color++) { 1295 for (int color = 0; color < 3; color++) {
1297 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); 1296 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha);
1298 dest_scan++; 1297 dest_scan++;
1299 src_scan++; 1298 src_scan++;
1300 } 1299 }
1301 dest_scan += dest_gap; 1300 dest_scan += dest_gap;
1302 src_scan++;
1303 } 1301 }
1304 } else { 1302 } else {
1305 for (int col = 0; col < width; col++) { 1303 for (int col = 0; col < width; col++) {
1306 uint8_t src_alpha; 1304 uint8_t src_alpha;
1307 if (clip_scan) { 1305 if (clip_scan) {
1308 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; 1306 src_alpha = src_scan[3] * (*clip_scan++) / 255;
1309 } else { 1307 } else {
1310 src_alpha = *src_alpha_scan++; 1308 src_alpha = src_scan[3];
1311 } 1309 }
1312 if (src_alpha == 255) { 1310 if (src_alpha == 255) {
1313 *dest_scan++ = *src_scan++; 1311 *dest_scan++ = *src_scan++;
1314 *dest_scan++ = *src_scan++; 1312 *dest_scan++ = *src_scan++;
1315 *dest_scan++ = *src_scan++; 1313 *dest_scan++ = *src_scan++;
1316 dest_scan += dest_gap; 1314 dest_scan += dest_gap;
1315 src_scan++;
1317 continue; 1316 continue;
1318 } 1317 }
1319 if (src_alpha == 0) { 1318 if (src_alpha == 0) {
1320 dest_scan += dest_Bpp; 1319 dest_scan += dest_Bpp;
1321 src_scan += 3; 1320 src_scan += 4;
1322 continue; 1321 continue;
1323 } 1322 }
1324 for (int color = 0; color < 3; color++) { 1323 for (int color = 0; color < 3; color++) {
1325 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); 1324 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha);
1326 dest_scan++; 1325 dest_scan++;
1327 src_scan++; 1326 src_scan++;
1328 } 1327 }
1329 dest_scan += dest_gap; 1328 dest_scan += dest_gap;
1329 src_scan++;
1330 } 1330 }
1331 } 1331 }
1332 } 1332 }
1333 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip(uint8_t* dest_scan, 1333 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip(uint8_t* dest_scan,
1334 const uint8_t* src_scan, 1334 const uint8_t* src_scan,
1335 int width, 1335 int width,
1336 int blend_type, 1336 int blend_type,
1337 int dest_Bpp, 1337 int dest_Bpp,
1338 int src_Bpp) { 1338 int src_Bpp) {
1339 int blended_colors[3]; 1339 int blended_colors[3];
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 int blend_type, 1444 int blend_type,
1445 const uint8_t* clip_scan, 1445 const uint8_t* clip_scan,
1446 uint8_t* dest_alpha_scan, 1446 uint8_t* dest_alpha_scan,
1447 const uint8_t* src_alpha_scan, 1447 const uint8_t* src_alpha_scan,
1448 uint8_t* src_cache_scan, 1448 uint8_t* src_cache_scan,
1449 void* pIccTransform) { 1449 void* pIccTransform) {
1450 uint8_t* dp = src_cache_scan; 1450 uint8_t* dp = src_cache_scan;
1451 ICodec_IccModule* pIccModule = 1451 ICodec_IccModule* pIccModule =
1452 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 1452 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
1453 if (src_alpha_scan) { 1453 if (src_alpha_scan) {
1454 if (dest_alpha_scan == NULL) { 1454 if (dest_alpha_scan) {
1455 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
1456 } else {
1455 for (int col = 0; col < pixel_count; col++) { 1457 for (int col = 0; col < pixel_count; col++) {
1456 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); 1458 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
1457 dp[3] = *src_alpha_scan++; 1459 dp[3] = *src_alpha_scan++;
1458 src_scan += 3; 1460 src_scan += 3;
1459 dp += 4; 1461 dp += 4;
1460 } 1462 }
1461 src_alpha_scan = NULL; 1463 src_alpha_scan = NULL;
1462 } else {
1463 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
1464 } 1464 }
1465 } else { 1465 } else {
1466 if (dest_alpha_scan == NULL) { 1466 if (dest_alpha_scan) {
1467 for (int col = 0; col < pixel_count; col++) {
1468 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
1469 dp[3] = src_scan[3];
1470 src_scan += 4;
1471 dp += 4;
1472 }
1473 } else {
1474 int blended_colors[3]; 1467 int blended_colors[3];
1475 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 1468 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
1476 for (int col = 0; col < pixel_count; col++) { 1469 for (int col = 0; col < pixel_count; col++) {
1477 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, 1470 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
1478 1); 1471 1);
1479 uint8_t back_alpha = *dest_alpha_scan; 1472 uint8_t back_alpha = *dest_alpha_scan;
1480 if (back_alpha == 0) { 1473 if (back_alpha == 0) {
1481 if (clip_scan) { 1474 if (clip_scan) {
1482 int src_alpha = clip_scan[col] * src_scan[3] / 255; 1475 int src_alpha = clip_scan[col] * src_scan[3] / 255;
1483 *dest_alpha_scan = src_alpha; 1476 *dest_alpha_scan = src_alpha;
1484 *dest_scan++ = *src_cache_scan++; 1477 *dest_scan++ = *src_cache_scan++;
1485 *dest_scan++ = *src_cache_scan++; 1478 *dest_scan++ = *src_cache_scan++;
1486 *dest_scan++ = *src_cache_scan++; 1479 *dest_scan++ = *src_cache_scan++;
1487 } else { 1480 } else {
1488 *dest_alpha_scan = src_scan[3]; 1481 *dest_alpha_scan = src_scan[3];
1489 *dest_scan++ = *src_cache_scan++; 1482 *dest_scan++ = *src_cache_scan++;
1490 *dest_scan++ = *src_cache_scan++; 1483 *dest_scan++ = *src_cache_scan++;
1491 *dest_scan++ = *src_cache_scan++; 1484 *dest_scan++ = *src_cache_scan++;
1492 } 1485 }
1493 dest_alpha_scan++; 1486 dest_alpha_scan++;
1494 src_scan += 4; 1487 src_scan += 4;
1495 continue; 1488 continue;
1496 } 1489 }
1497 uint8_t src_alpha; 1490 uint8_t src_alpha;
1498 if (clip_scan == NULL) { 1491 if (clip_scan) {
1492 src_alpha = clip_scan[col] * src_scan[3] / 255;
1493 } else {
1499 src_alpha = src_scan[3]; 1494 src_alpha = src_scan[3];
1500 } else {
1501 src_alpha = clip_scan[col] * src_scan[3] / 255;
1502 } 1495 }
1503 src_scan += 4; 1496 src_scan += 4;
1504 if (src_alpha == 0) { 1497 if (src_alpha == 0) {
1505 dest_scan += 3; 1498 dest_scan += 3;
1506 src_cache_scan += 3; 1499 src_cache_scan += 3;
1507 dest_alpha_scan++; 1500 dest_alpha_scan++;
1508 continue; 1501 continue;
1509 } 1502 }
1510 uint8_t dest_alpha = 1503 uint8_t dest_alpha =
1511 back_alpha + src_alpha - back_alpha * src_alpha / 255; 1504 back_alpha + src_alpha - back_alpha * src_alpha / 255;
(...skipping 12 matching lines...) Expand all
1524 } else { 1517 } else {
1525 *dest_scan = 1518 *dest_scan =
1526 FXDIB_ALPHA_MERGE(*dest_scan, *src_cache_scan, alpha_ratio); 1519 FXDIB_ALPHA_MERGE(*dest_scan, *src_cache_scan, alpha_ratio);
1527 } 1520 }
1528 dest_scan++; 1521 dest_scan++;
1529 src_cache_scan++; 1522 src_cache_scan++;
1530 } 1523 }
1531 } 1524 }
1532 return; 1525 return;
1533 } 1526 }
1527 for (int col = 0; col < pixel_count; col++) {
1528 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
1529 dp[3] = src_scan[3];
1530 src_scan += 4;
1531 dp += 4;
1532 }
1534 } 1533 }
1535 _CompositeRow_Argb2Argb(dest_scan, src_cache_scan, pixel_count, blend_type, 1534 _CompositeRow_Argb2Argb(dest_scan, src_cache_scan, pixel_count, blend_type,
1536 clip_scan, dest_alpha_scan, src_alpha_scan); 1535 clip_scan, dest_alpha_scan, src_alpha_scan);
1537 } 1536 }
1538 void _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(uint8_t* dest_scan, 1537 void _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(uint8_t* dest_scan,
1539 const uint8_t* src_scan, 1538 const uint8_t* src_scan,
1540 int width, 1539 int width,
1541 int blend_type, 1540 int blend_type,
1542 int src_Bpp, 1541 int src_Bpp,
1543 uint8_t* dest_alpha_scan, 1542 uint8_t* dest_alpha_scan,
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); 1999 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
2001 dest_scan++; 2000 dest_scan++;
2002 } 2001 }
2003 } else { 2002 } else {
2004 if (blend_type) { 2003 if (blend_type) {
2005 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 2004 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
2006 int blended_color; 2005 int blended_color;
2007 for (int col = 0; col < pixel_count; col++) { 2006 for (int col = 0; col < pixel_count; col++) {
2008 uint8_t gray = pPalette[*src_scan]; 2007 uint8_t gray = pPalette[*src_scan];
2009 src_scan++; 2008 src_scan++;
2010 if (clip_scan == NULL || clip_scan[col] == 255) { 2009 if (!clip_scan || clip_scan[col] == 255) {
2011 *dest_scan++ = gray; 2010 *dest_scan++ = gray;
2012 *dest_alpha_scan++ = 255; 2011 *dest_alpha_scan++ = 255;
2013 continue; 2012 continue;
2014 } 2013 }
2015 int src_alpha = clip_scan[col]; 2014 int src_alpha = clip_scan[col];
2016 if (src_alpha == 0) { 2015 if (src_alpha == 0) {
2017 dest_scan++; 2016 dest_scan++;
2018 dest_alpha_scan++; 2017 dest_alpha_scan++;
2019 continue; 2018 continue;
2020 } 2019 }
2021 int back_alpha = *dest_alpha_scan; 2020 int back_alpha = *dest_alpha_scan;
2022 uint8_t dest_alpha = 2021 uint8_t dest_alpha =
2023 back_alpha + src_alpha - back_alpha * src_alpha / 255; 2022 back_alpha + src_alpha - back_alpha * src_alpha / 255;
2024 *dest_alpha_scan++ = dest_alpha; 2023 *dest_alpha_scan++ = dest_alpha;
2025 int alpha_ratio = src_alpha * 255 / dest_alpha; 2024 int alpha_ratio = src_alpha * 255 / dest_alpha;
2026 if (bNonseparableBlend) { 2025 if (bNonseparableBlend) {
2027 blended_color = 2026 blended_color =
2028 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; 2027 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
2029 } 2028 }
2030 gray = bNonseparableBlend ? blended_color 2029 gray = bNonseparableBlend ? blended_color
2031 : _BLEND(blend_type, *dest_scan, gray); 2030 : _BLEND(blend_type, *dest_scan, gray);
2032 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); 2031 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
2033 dest_scan++; 2032 dest_scan++;
2034 } 2033 }
2035 return; 2034 return;
2036 } 2035 }
2037 for (int col = 0; col < pixel_count; col++) { 2036 for (int col = 0; col < pixel_count; col++) {
2038 uint8_t gray = pPalette[*src_scan]; 2037 uint8_t gray = pPalette[*src_scan];
2039 src_scan++; 2038 src_scan++;
2040 if (clip_scan == NULL || clip_scan[col] == 255) { 2039 if (!clip_scan || clip_scan[col] == 255) {
2041 *dest_scan++ = gray; 2040 *dest_scan++ = gray;
2042 *dest_alpha_scan++ = 255; 2041 *dest_alpha_scan++ = 255;
2043 continue; 2042 continue;
2044 } 2043 }
2045 int src_alpha = clip_scan[col]; 2044 int src_alpha = clip_scan[col];
2046 if (src_alpha == 0) { 2045 if (src_alpha == 0) {
2047 dest_scan++; 2046 dest_scan++;
2048 dest_alpha_scan++; 2047 dest_alpha_scan++;
2049 continue; 2048 continue;
2050 } 2049 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 int reset_gray = pPalette[0]; 2113 int reset_gray = pPalette[0];
2115 int set_gray = pPalette[1]; 2114 int set_gray = pPalette[1];
2116 if (blend_type) { 2115 if (blend_type) {
2117 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; 2116 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
2118 int blended_color; 2117 int blended_color;
2119 for (int col = 0; col < pixel_count; col++) { 2118 for (int col = 0; col < pixel_count; col++) {
2120 uint8_t gray = 2119 uint8_t gray =
2121 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) 2120 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
2122 ? set_gray 2121 ? set_gray
2123 : reset_gray; 2122 : reset_gray;
2124 if (clip_scan == NULL || clip_scan[col] == 255) { 2123 if (!clip_scan || clip_scan[col] == 255) {
2125 *dest_scan++ = gray; 2124 *dest_scan++ = gray;
2126 *dest_alpha_scan++ = 255; 2125 *dest_alpha_scan++ = 255;
2127 continue; 2126 continue;
2128 } 2127 }
2129 int src_alpha = clip_scan[col]; 2128 int src_alpha = clip_scan[col];
2130 if (src_alpha == 0) { 2129 if (src_alpha == 0) {
2131 dest_scan++; 2130 dest_scan++;
2132 dest_alpha_scan++; 2131 dest_alpha_scan++;
2133 continue; 2132 continue;
2134 } 2133 }
(...skipping 11 matching lines...) Expand all
2146 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); 2145 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
2147 dest_scan++; 2146 dest_scan++;
2148 } 2147 }
2149 return; 2148 return;
2150 } 2149 }
2151 for (int col = 0; col < pixel_count; col++) { 2150 for (int col = 0; col < pixel_count; col++) {
2152 uint8_t gray = 2151 uint8_t gray =
2153 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) 2152 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
2154 ? set_gray 2153 ? set_gray
2155 : reset_gray; 2154 : reset_gray;
2156 if (clip_scan == NULL || clip_scan[col] == 255) { 2155 if (!clip_scan || clip_scan[col] == 255) {
2157 *dest_scan++ = gray; 2156 *dest_scan++ = gray;
2158 *dest_alpha_scan++ = 255; 2157 *dest_alpha_scan++ = 255;
2159 continue; 2158 continue;
2160 } 2159 }
2161 int src_alpha = clip_scan[col]; 2160 int src_alpha = clip_scan[col];
2162 if (src_alpha == 0) { 2161 if (src_alpha == 0) {
2163 dest_scan++; 2162 dest_scan++;
2164 dest_alpha_scan++; 2163 dest_alpha_scan++;
2165 continue; 2164 continue;
2166 } 2165 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); 2301 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b));
2303 } else { 2302 } else {
2304 FXARGB_SETDIB(dest_scan, 2303 FXARGB_SETDIB(dest_scan,
2305 FXARGB_MAKE(*src_alpha_scan, src_r, src_g, src_b)); 2304 FXARGB_MAKE(*src_alpha_scan, src_r, src_g, src_b));
2306 } 2305 }
2307 dest_scan += 4; 2306 dest_scan += 4;
2308 src_alpha_scan++; 2307 src_alpha_scan++;
2309 continue; 2308 continue;
2310 } 2309 }
2311 uint8_t src_alpha; 2310 uint8_t src_alpha;
2312 if (clip_scan == NULL) { 2311 if (clip_scan) {
2312 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
2313 } else {
2313 src_alpha = *src_alpha_scan++; 2314 src_alpha = *src_alpha_scan++;
2314 } else {
2315 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
2316 } 2315 }
2317 if (src_alpha == 0) { 2316 if (src_alpha == 0) {
2318 dest_scan += 4; 2317 dest_scan += 4;
2319 continue; 2318 continue;
2320 } 2319 }
2321 uint8_t dest_alpha = 2320 uint8_t dest_alpha =
2322 back_alpha + src_alpha - back_alpha * src_alpha / 255; 2321 back_alpha + src_alpha - back_alpha * src_alpha / 255;
2323 dest_scan[3] = dest_alpha; 2322 dest_scan[3] = dest_alpha;
2324 int alpha_ratio = src_alpha * 255 / dest_alpha; 2323 int alpha_ratio = src_alpha * 255 / dest_alpha;
2325 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); 2324 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio);
2326 dest_scan++; 2325 dest_scan++;
2327 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); 2326 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio);
2328 dest_scan++; 2327 dest_scan++;
2329 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); 2328 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio);
2330 dest_scan++; 2329 dest_scan++;
2331 dest_scan++; 2330 dest_scan++;
2332 } 2331 }
2333 } else 2332 } else
2334 for (int col = 0; col < width; col++) { 2333 for (int col = 0; col < width; col++) {
2335 FX_ARGB argb = pPalette[*src_scan]; 2334 FX_ARGB argb = pPalette[*src_scan];
2336 int src_r = FXARGB_R(argb); 2335 int src_r = FXARGB_R(argb);
2337 int src_g = FXARGB_G(argb); 2336 int src_g = FXARGB_G(argb);
2338 int src_b = FXARGB_B(argb); 2337 int src_b = FXARGB_B(argb);
2339 if (clip_scan == NULL || clip_scan[col] == 255) { 2338 if (!clip_scan || clip_scan[col] == 255) {
2340 *dest_scan++ = src_b; 2339 *dest_scan++ = src_b;
2341 *dest_scan++ = src_g; 2340 *dest_scan++ = src_g;
2342 *dest_scan++ = src_r; 2341 *dest_scan++ = src_r;
2343 *dest_scan++ = 255; 2342 *dest_scan++ = 255;
2344 src_scan++; 2343 src_scan++;
2345 continue; 2344 continue;
2346 } 2345 }
2347 int src_alpha = clip_scan[col]; 2346 int src_alpha = clip_scan[col];
2348 if (src_alpha == 0) { 2347 if (src_alpha == 0) {
2349 dest_scan += 4; 2348 dest_scan += 4;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 } else { 2386 } else {
2388 *dest_alpha_scan++ = *src_alpha_scan; 2387 *dest_alpha_scan++ = *src_alpha_scan;
2389 } 2388 }
2390 *dest_scan++ = src_b; 2389 *dest_scan++ = src_b;
2391 *dest_scan++ = src_g; 2390 *dest_scan++ = src_g;
2392 *dest_scan++ = src_r; 2391 *dest_scan++ = src_r;
2393 src_alpha_scan++; 2392 src_alpha_scan++;
2394 continue; 2393 continue;
2395 } 2394 }
2396 uint8_t src_alpha; 2395 uint8_t src_alpha;
2397 if (clip_scan == NULL) { 2396 if (clip_scan) {
2397 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
2398 } else {
2398 src_alpha = *src_alpha_scan++; 2399 src_alpha = *src_alpha_scan++;
2399 } else {
2400 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
2401 } 2400 }
2402 if (src_alpha == 0) { 2401 if (src_alpha == 0) {
2403 dest_scan += 3; 2402 dest_scan += 3;
2404 dest_alpha_scan++; 2403 dest_alpha_scan++;
2405 continue; 2404 continue;
2406 } 2405 }
2407 uint8_t dest_alpha = 2406 uint8_t dest_alpha =
2408 back_alpha + src_alpha - back_alpha * src_alpha / 255; 2407 back_alpha + src_alpha - back_alpha * src_alpha / 255;
2409 *dest_alpha_scan++ = dest_alpha; 2408 *dest_alpha_scan++ = dest_alpha;
2410 int alpha_ratio = src_alpha * 255 / dest_alpha; 2409 int alpha_ratio = src_alpha * 255 / dest_alpha;
2411 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); 2410 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio);
2412 dest_scan++; 2411 dest_scan++;
2413 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); 2412 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio);
2414 dest_scan++; 2413 dest_scan++;
2415 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); 2414 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio);
2416 dest_scan++; 2415 dest_scan++;
2417 } 2416 }
2418 } else 2417 } else
2419 for (int col = 0; col < width; col++) { 2418 for (int col = 0; col < width; col++) {
2420 FX_ARGB argb = pPalette[*src_scan]; 2419 FX_ARGB argb = pPalette[*src_scan];
2421 int src_r = FXARGB_R(argb); 2420 int src_r = FXARGB_R(argb);
2422 int src_g = FXARGB_G(argb); 2421 int src_g = FXARGB_G(argb);
2423 int src_b = FXARGB_B(argb); 2422 int src_b = FXARGB_B(argb);
2424 if (clip_scan == NULL || clip_scan[col] == 255) { 2423 if (!clip_scan || clip_scan[col] == 255) {
2425 *dest_scan++ = src_b; 2424 *dest_scan++ = src_b;
2426 *dest_scan++ = src_g; 2425 *dest_scan++ = src_g;
2427 *dest_scan++ = src_r; 2426 *dest_scan++ = src_r;
2428 *dest_alpha_scan++ = 255; 2427 *dest_alpha_scan++ = 255;
2429 src_scan++; 2428 src_scan++;
2430 continue; 2429 continue;
2431 } 2430 }
2432 int src_alpha = clip_scan[col]; 2431 int src_alpha = clip_scan[col];
2433 if (src_alpha == 0) { 2432 if (src_alpha == 0) {
2434 dest_scan += 3; 2433 dest_scan += 3;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 int src_r, src_g, src_b; 2467 int src_r, src_g, src_b;
2469 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { 2468 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) {
2470 src_r = set_r; 2469 src_r = set_r;
2471 src_g = set_g; 2470 src_g = set_g;
2472 src_b = set_b; 2471 src_b = set_b;
2473 } else { 2472 } else {
2474 src_r = reset_r; 2473 src_r = reset_r;
2475 src_g = reset_g; 2474 src_g = reset_g;
2476 src_b = reset_b; 2475 src_b = reset_b;
2477 } 2476 }
2478 if (clip_scan == NULL || clip_scan[col] == 255) { 2477 if (!clip_scan || clip_scan[col] == 255) {
2479 *dest_scan++ = src_b; 2478 *dest_scan++ = src_b;
2480 *dest_scan++ = src_g; 2479 *dest_scan++ = src_g;
2481 *dest_scan++ = src_r; 2480 *dest_scan++ = src_r;
2482 *dest_scan++ = 255; 2481 *dest_scan++ = 255;
2483 continue; 2482 continue;
2484 } 2483 }
2485 int src_alpha = clip_scan[col]; 2484 int src_alpha = clip_scan[col];
2486 if (src_alpha == 0) { 2485 if (src_alpha == 0) {
2487 dest_scan += 4; 2486 dest_scan += 4;
2488 continue; 2487 continue;
(...skipping 30 matching lines...) Expand all
2519 int src_r, src_g, src_b; 2518 int src_r, src_g, src_b;
2520 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { 2519 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) {
2521 src_r = set_r; 2520 src_r = set_r;
2522 src_g = set_g; 2521 src_g = set_g;
2523 src_b = set_b; 2522 src_b = set_b;
2524 } else { 2523 } else {
2525 src_r = reset_r; 2524 src_r = reset_r;
2526 src_g = reset_g; 2525 src_g = reset_g;
2527 src_b = reset_b; 2526 src_b = reset_b;
2528 } 2527 }
2529 if (clip_scan == NULL || clip_scan[col] == 255) { 2528 if (!clip_scan || clip_scan[col] == 255) {
2530 *dest_scan++ = src_b; 2529 *dest_scan++ = src_b;
2531 *dest_scan++ = src_g; 2530 *dest_scan++ = src_g;
2532 *dest_scan++ = src_r; 2531 *dest_scan++ = src_r;
2533 *dest_alpha_scan++ = 255; 2532 *dest_alpha_scan++ = 255;
2534 continue; 2533 continue;
2535 } 2534 }
2536 int src_alpha = clip_scan[col]; 2535 int src_alpha = clip_scan[col];
2537 if (src_alpha == 0) { 2536 if (src_alpha == 0) {
2538 dest_scan += 3; 2537 dest_scan += 3;
2539 dest_alpha_scan++; 2538 dest_alpha_scan++;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 void _CompositeRow_BitMask2Argb(uint8_t* dest_scan, 2815 void _CompositeRow_BitMask2Argb(uint8_t* dest_scan,
2817 const uint8_t* src_scan, 2816 const uint8_t* src_scan,
2818 int mask_alpha, 2817 int mask_alpha,
2819 int src_r, 2818 int src_r,
2820 int src_g, 2819 int src_g,
2821 int src_b, 2820 int src_b,
2822 int src_left, 2821 int src_left,
2823 int pixel_count, 2822 int pixel_count,
2824 int blend_type, 2823 int blend_type,
2825 const uint8_t* clip_scan) { 2824 const uint8_t* clip_scan) {
2826 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && 2825 if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
2827 mask_alpha == 255) {
2828 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b); 2826 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
2829 for (int col = 0; col < pixel_count; col++) { 2827 for (int col = 0; col < pixel_count; col++) {
2830 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { 2828 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
2831 FXARGB_SETDIB(dest_scan, argb); 2829 FXARGB_SETDIB(dest_scan, argb);
2832 } 2830 }
2833 dest_scan += 4; 2831 dest_scan += 4;
2834 } 2832 }
2835 return; 2833 return;
2836 } 2834 }
2837 for (int col = 0; col < pixel_count; col++) { 2835 for (int col = 0; col < pixel_count; col++) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 const uint8_t* src_scan, 2893 const uint8_t* src_scan,
2896 int mask_alpha, 2894 int mask_alpha,
2897 int src_r, 2895 int src_r,
2898 int src_g, 2896 int src_g,
2899 int src_b, 2897 int src_b,
2900 int src_left, 2898 int src_left,
2901 int pixel_count, 2899 int pixel_count,
2902 int blend_type, 2900 int blend_type,
2903 const uint8_t* clip_scan, 2901 const uint8_t* clip_scan,
2904 uint8_t* dest_alpha_scan) { 2902 uint8_t* dest_alpha_scan) {
2905 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && 2903 if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
2906 mask_alpha == 255) {
2907 for (int col = 0; col < pixel_count; col++) { 2904 for (int col = 0; col < pixel_count; col++) {
2908 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { 2905 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
2909 dest_scan[0] = src_b; 2906 dest_scan[0] = src_b;
2910 dest_scan[1] = src_g; 2907 dest_scan[1] = src_g;
2911 dest_scan[2] = src_r; 2908 dest_scan[2] = src_r;
2912 *dest_alpha_scan = mask_alpha; 2909 *dest_alpha_scan = mask_alpha;
2913 } 2910 }
2914 dest_scan += 3; 2911 dest_scan += 3;
2915 dest_alpha_scan++; 2912 dest_alpha_scan++;
2916 } 2913 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 const uint8_t* src_scan, 2979 const uint8_t* src_scan,
2983 int mask_alpha, 2980 int mask_alpha,
2984 int src_r, 2981 int src_r,
2985 int src_g, 2982 int src_g,
2986 int src_b, 2983 int src_b,
2987 int src_left, 2984 int src_left,
2988 int pixel_count, 2985 int pixel_count,
2989 int blend_type, 2986 int blend_type,
2990 int Bpp, 2987 int Bpp,
2991 const uint8_t* clip_scan) { 2988 const uint8_t* clip_scan) {
2992 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && 2989 if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
2993 mask_alpha == 255) {
2994 for (int col = 0; col < pixel_count; col++) { 2990 for (int col = 0; col < pixel_count; col++) {
2995 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { 2991 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
2996 dest_scan[2] = src_r; 2992 dest_scan[2] = src_r;
2997 dest_scan[1] = src_g; 2993 dest_scan[1] = src_g;
2998 dest_scan[0] = src_b; 2994 dest_scan[0] = src_b;
2999 } 2995 }
3000 dest_scan += Bpp; 2996 dest_scan += Bpp;
3001 } 2997 }
3002 return; 2998 return;
3003 } 2999 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 dest_scan[1] = src_scan[1]; 3148 dest_scan[1] = src_scan[1];
3153 dest_scan[2] = src_scan[0]; 3149 dest_scan[2] = src_scan[0];
3154 } else { 3150 } else {
3155 FXARGB_RGBORDERCOPY(dest_scan, src_scan); 3151 FXARGB_RGBORDERCOPY(dest_scan, src_scan);
3156 } 3152 }
3157 dest_scan += 4; 3153 dest_scan += 4;
3158 src_scan += 4; 3154 src_scan += 4;
3159 continue; 3155 continue;
3160 } 3156 }
3161 uint8_t src_alpha; 3157 uint8_t src_alpha;
3162 if (clip_scan == NULL) { 3158 if (clip_scan) {
3159 src_alpha = clip_scan[col] * src_scan[3] / 255;
3160 } else {
3163 src_alpha = src_scan[3]; 3161 src_alpha = src_scan[3];
3164 } else {
3165 src_alpha = clip_scan[col] * src_scan[3] / 255;
3166 } 3162 }
3167 if (src_alpha == 0) { 3163 if (src_alpha == 0) {
3168 dest_scan += 4; 3164 dest_scan += 4;
3169 src_scan += 4; 3165 src_scan += 4;
3170 continue; 3166 continue;
3171 } 3167 }
3172 uint8_t dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; 3168 uint8_t dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255;
3173 dest_scan[3] = dest_alpha; 3169 dest_scan[3] = dest_alpha;
3174 int alpha_ratio = src_alpha * 255 / dest_alpha; 3170 int alpha_ratio = src_alpha * 255 / dest_alpha;
3175 if (bNonseparableBlend) { 3171 if (bNonseparableBlend) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3616 for (int col = 0; col < width; col++) { 3612 for (int col = 0; col < width; col++) {
3617 int src_r, src_g, src_b; 3613 int src_r, src_g, src_b;
3618 if (pPalette) { 3614 if (pPalette) {
3619 FX_ARGB argb = pPalette[*src_scan]; 3615 FX_ARGB argb = pPalette[*src_scan];
3620 src_r = FXARGB_R(argb); 3616 src_r = FXARGB_R(argb);
3621 src_g = FXARGB_G(argb); 3617 src_g = FXARGB_G(argb);
3622 src_b = FXARGB_B(argb); 3618 src_b = FXARGB_B(argb);
3623 } else { 3619 } else {
3624 src_r = src_g = src_b = *src_scan; 3620 src_r = src_g = src_b = *src_scan;
3625 } 3621 }
3626 if (clip_scan == NULL || clip_scan[col] == 255) { 3622 if (!clip_scan || clip_scan[col] == 255) {
3627 dest_scan[2] = FX_GAMMA(src_b); 3623 dest_scan[2] = FX_GAMMA(src_b);
3628 dest_scan[1] = FX_GAMMA(src_g); 3624 dest_scan[1] = FX_GAMMA(src_g);
3629 dest_scan[0] = FX_GAMMA(src_r); 3625 dest_scan[0] = FX_GAMMA(src_r);
3630 dest_scan[3] = 255; 3626 dest_scan[3] = 255;
3631 src_scan++; 3627 src_scan++;
3632 dest_scan += 4; 3628 dest_scan += 4;
3633 continue; 3629 continue;
3634 } 3630 }
3635 int src_alpha = clip_scan[col]; 3631 int src_alpha = clip_scan[col];
3636 if (src_alpha == 0) { 3632 if (src_alpha == 0) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3676 int src_r, src_g, src_b; 3672 int src_r, src_g, src_b;
3677 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { 3673 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) {
3678 src_r = set_r; 3674 src_r = set_r;
3679 src_g = set_g; 3675 src_g = set_g;
3680 src_b = set_b; 3676 src_b = set_b;
3681 } else { 3677 } else {
3682 src_r = reset_r; 3678 src_r = reset_r;
3683 src_g = reset_g; 3679 src_g = reset_g;
3684 src_b = reset_b; 3680 src_b = reset_b;
3685 } 3681 }
3686 if (clip_scan == NULL || clip_scan[col] == 255) { 3682 if (!clip_scan || clip_scan[col] == 255) {
3687 dest_scan[2] = FX_GAMMA(src_b); 3683 dest_scan[2] = FX_GAMMA(src_b);
3688 dest_scan[1] = FX_GAMMA(src_g); 3684 dest_scan[1] = FX_GAMMA(src_g);
3689 dest_scan[0] = FX_GAMMA(src_r); 3685 dest_scan[0] = FX_GAMMA(src_r);
3690 dest_scan[3] = 255; 3686 dest_scan[3] = 255;
3691 dest_scan += 4; 3687 dest_scan += 4;
3692 continue; 3688 continue;
3693 } 3689 }
3694 int src_alpha = clip_scan[col]; 3690 int src_alpha = clip_scan[col];
3695 if (src_alpha == 0) { 3691 if (src_alpha == 0) {
3696 dest_scan += 4; 3692 dest_scan += 4;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3830 void _CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan, 3826 void _CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan,
3831 const uint8_t* src_scan, 3827 const uint8_t* src_scan,
3832 int mask_alpha, 3828 int mask_alpha,
3833 int src_r, 3829 int src_r,
3834 int src_g, 3830 int src_g,
3835 int src_b, 3831 int src_b,
3836 int src_left, 3832 int src_left,
3837 int pixel_count, 3833 int pixel_count,
3838 int blend_type, 3834 int blend_type,
3839 const uint8_t* clip_scan) { 3835 const uint8_t* clip_scan) {
3840 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && 3836 if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
3841 mask_alpha == 255) {
3842 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b); 3837 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
3843 for (int col = 0; col < pixel_count; col++) { 3838 for (int col = 0; col < pixel_count; col++) {
3844 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { 3839 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
3845 FXARGB_SETRGBORDERDIB(dest_scan, argb); 3840 FXARGB_SETRGBORDERDIB(dest_scan, argb);
3846 } 3841 }
3847 dest_scan += 4; 3842 dest_scan += 4;
3848 } 3843 }
3849 return; 3844 return;
3850 } 3845 }
3851 for (int col = 0; col < pixel_count; col++) { 3846 for (int col = 0; col < pixel_count; col++) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 const uint8_t* src_scan, 3903 const uint8_t* src_scan,
3909 int mask_alpha, 3904 int mask_alpha,
3910 int src_r, 3905 int src_r,
3911 int src_g, 3906 int src_g,
3912 int src_b, 3907 int src_b,
3913 int src_left, 3908 int src_left,
3914 int pixel_count, 3909 int pixel_count,
3915 int blend_type, 3910 int blend_type,
3916 int Bpp, 3911 int Bpp,
3917 const uint8_t* clip_scan) { 3912 const uint8_t* clip_scan) {
3918 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && 3913 if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
3919 mask_alpha == 255) {
3920 for (int col = 0; col < pixel_count; col++) { 3914 for (int col = 0; col < pixel_count; col++) {
3921 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { 3915 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
3922 dest_scan[2] = src_b; 3916 dest_scan[2] = src_b;
3923 dest_scan[1] = src_g; 3917 dest_scan[1] = src_g;
3924 dest_scan[0] = src_r; 3918 dest_scan[0] = src_r;
3925 } 3919 }
3926 dest_scan += Bpp; 3920 dest_scan += Bpp;
3927 } 3921 }
3928 return; 3922 return;
3929 } 3923 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 int alpha_flag, 4202 int alpha_flag,
4209 void* pIccTransform) { 4203 void* pIccTransform) {
4210 m_SrcFormat = src_format; 4204 m_SrcFormat = src_format;
4211 m_DestFormat = dest_format; 4205 m_DestFormat = dest_format;
4212 m_BlendType = blend_type; 4206 m_BlendType = blend_type;
4213 m_bRgbByteOrder = bRgbByteOrder; 4207 m_bRgbByteOrder = bRgbByteOrder;
4214 ICodec_IccModule* pIccModule = NULL; 4208 ICodec_IccModule* pIccModule = NULL;
4215 if (CFX_GEModule::Get()->GetCodecModule()) { 4209 if (CFX_GEModule::Get()->GetCodecModule()) {
4216 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 4210 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
4217 } 4211 }
4218 if (pIccModule == NULL) { 4212 if (!pIccModule) {
4219 pIccTransform = NULL; 4213 pIccTransform = NULL;
4220 } 4214 }
4221 m_pIccTransform = pIccTransform; 4215 m_pIccTransform = pIccTransform;
4222 if ((dest_format & 0xff) == 1) { 4216 if ((dest_format & 0xff) == 1) {
4223 return FALSE; 4217 return FALSE;
4224 } 4218 }
4225 if (m_SrcFormat == FXDIB_1bppMask || m_SrcFormat == FXDIB_8bppMask) { 4219 if (m_SrcFormat == FXDIB_1bppMask || m_SrcFormat == FXDIB_8bppMask) {
4226 return _ScanlineCompositor_InitSourceMask( 4220 return _ScanlineCompositor_InitSourceMask(
4227 dest_format, alpha_flag, mask_color, m_MaskAlpha, m_MaskRed, 4221 dest_format, alpha_flag, mask_color, m_MaskAlpha, m_MaskRed,
4228 m_MaskGreen, m_MaskBlue, m_MaskBlack, pIccModule, pIccTransform); 4222 m_MaskGreen, m_MaskBlue, m_MaskBlack, pIccModule, pIccTransform);
4229 } 4223 }
4230 if (pIccTransform == NULL && (~src_format & 0x0400) && 4224 if (!pIccTransform && (~src_format & 0x0400) && (dest_format & 0x0400)) {
4231 (dest_format & 0x0400)) {
4232 return FALSE; 4225 return FALSE;
4233 } 4226 }
4234 if ((m_SrcFormat & 0xff) <= 8) { 4227 if ((m_SrcFormat & 0xff) <= 8) {
4235 if (dest_format == FXDIB_8bppMask) { 4228 if (dest_format == FXDIB_8bppMask) {
4236 return TRUE; 4229 return TRUE;
4237 } 4230 }
4238 _ScanlineCompositor_InitSourcePalette(src_format, dest_format, 4231 _ScanlineCompositor_InitSourcePalette(src_format, dest_format,
4239 m_pSrcPalette, pSrcPalette, 4232 m_pSrcPalette, pSrcPalette,
4240 pIccModule, pIccTransform); 4233 pIccModule, pIccTransform);
4241 m_Transparency = 4234 m_Transparency =
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
4655 int dest_top, 4648 int dest_top,
4656 int width, 4649 int width,
4657 int height, 4650 int height,
4658 const CFX_DIBSource* pSrcBitmap, 4651 const CFX_DIBSource* pSrcBitmap,
4659 int src_left, 4652 int src_left,
4660 int src_top, 4653 int src_top,
4661 int blend_type, 4654 int blend_type,
4662 const CFX_ClipRgn* pClipRgn, 4655 const CFX_ClipRgn* pClipRgn,
4663 FX_BOOL bRgbByteOrder, 4656 FX_BOOL bRgbByteOrder,
4664 void* pIccTransform) { 4657 void* pIccTransform) {
4665 if (m_pBuffer == NULL) { 4658 if (!m_pBuffer) {
4666 return FALSE; 4659 return FALSE;
4667 } 4660 }
4668 ASSERT(!pSrcBitmap->IsAlphaMask()); 4661 ASSERT(!pSrcBitmap->IsAlphaMask());
4669 ASSERT(m_bpp >= 8); 4662 ASSERT(m_bpp >= 8);
4670 if (pSrcBitmap->IsAlphaMask() || m_bpp < 8) { 4663 if (pSrcBitmap->IsAlphaMask() || m_bpp < 8) {
4671 return FALSE; 4664 return FALSE;
4672 } 4665 }
4673 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), 4666 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(),
4674 pSrcBitmap->GetHeight(), src_left, src_top, pClipRgn); 4667 pSrcBitmap->GetHeight(), src_left, src_top, pClipRgn);
4675 if (width == 0 || height == 0) { 4668 if (width == 0 || height == 0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4728 int height, 4721 int height,
4729 const CFX_DIBSource* pMask, 4722 const CFX_DIBSource* pMask,
4730 FX_DWORD color, 4723 FX_DWORD color,
4731 int src_left, 4724 int src_left,
4732 int src_top, 4725 int src_top,
4733 int blend_type, 4726 int blend_type,
4734 const CFX_ClipRgn* pClipRgn, 4727 const CFX_ClipRgn* pClipRgn,
4735 FX_BOOL bRgbByteOrder, 4728 FX_BOOL bRgbByteOrder,
4736 int alpha_flag, 4729 int alpha_flag,
4737 void* pIccTransform) { 4730 void* pIccTransform) {
4738 if (m_pBuffer == NULL) { 4731 if (!m_pBuffer) {
4739 return FALSE; 4732 return FALSE;
4740 } 4733 }
4741 ASSERT(pMask->IsAlphaMask()); 4734 ASSERT(pMask->IsAlphaMask());
4742 ASSERT(m_bpp >= 8); 4735 ASSERT(m_bpp >= 8);
4743 if (!pMask->IsAlphaMask() || m_bpp < 8) { 4736 if (!pMask->IsAlphaMask() || m_bpp < 8) {
4744 return FALSE; 4737 return FALSE;
4745 } 4738 }
4746 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), 4739 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(),
4747 pMask->GetHeight(), src_left, src_top, pClipRgn); 4740 pMask->GetHeight(), src_left, src_top, pClipRgn);
4748 if (width == 0 || height == 0) { 4741 if (width == 0 || height == 0) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4792 } 4785 }
4793 return TRUE; 4786 return TRUE;
4794 } 4787 }
4795 FX_BOOL CFX_DIBitmap::CompositeRect(int left, 4788 FX_BOOL CFX_DIBitmap::CompositeRect(int left,
4796 int top, 4789 int top,
4797 int width, 4790 int width,
4798 int height, 4791 int height,
4799 FX_DWORD color, 4792 FX_DWORD color,
4800 int alpha_flag, 4793 int alpha_flag,
4801 void* pIccTransform) { 4794 void* pIccTransform) {
4802 if (m_pBuffer == NULL) { 4795 if (!m_pBuffer) {
4803 return FALSE; 4796 return FALSE;
4804 } 4797 }
4805 int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color); 4798 int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color);
4806 if (src_alpha == 0) { 4799 if (src_alpha == 0) {
4807 return TRUE; 4800 return TRUE;
4808 } 4801 }
4809 FX_RECT rect(left, top, left + width, top + height); 4802 FX_RECT rect(left, top, left + width, top + height);
4810 rect.Intersect(0, 0, m_Width, m_Height); 4803 rect.Intersect(0, 0, m_Width, m_Height);
4811 if (rect.IsEmpty()) { 4804 if (rect.IsEmpty()) {
4812 return TRUE; 4805 return TRUE;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4852 } 4845 }
4853 } 4846 }
4854 return TRUE; 4847 return TRUE;
4855 } 4848 }
4856 if (m_bpp == 1) { 4849 if (m_bpp == 1) {
4857 ASSERT(!IsCmykImage() && (uint8_t)(alpha_flag >> 8) == 0); 4850 ASSERT(!IsCmykImage() && (uint8_t)(alpha_flag >> 8) == 0);
4858 int left_shift = rect.left % 8; 4851 int left_shift = rect.left % 8;
4859 int right_shift = rect.right % 8; 4852 int right_shift = rect.right % 8;
4860 int width = rect.right / 8 - rect.left / 8; 4853 int width = rect.right / 8 - rect.left / 8;
4861 int index = 0; 4854 int index = 0;
4862 if (m_pPalette == NULL) { 4855 if (m_pPalette) {
4863 index = ((uint8_t)color == 0xff) ? 1 : 0; 4856 for (int i = 0; i < 2; i++) {
4864 } else {
4865 for (int i = 0; i < 2; i++)
4866 if (m_pPalette[i] == color) { 4857 if (m_pPalette[i] == color) {
4867 index = i; 4858 index = i;
4868 } 4859 }
4860 }
4861 } else {
4862 index = ((uint8_t)color == 0xff) ? 1 : 0;
4869 } 4863 }
4870 for (int row = rect.top; row < rect.bottom; row++) { 4864 for (int row = rect.top; row < rect.bottom; row++) {
4871 uint8_t* dest_scan_top = (uint8_t*)GetScanline(row) + rect.left / 8; 4865 uint8_t* dest_scan_top = (uint8_t*)GetScanline(row) + rect.left / 8;
4872 uint8_t* dest_scan_top_r = (uint8_t*)GetScanline(row) + rect.right / 8; 4866 uint8_t* dest_scan_top_r = (uint8_t*)GetScanline(row) + rect.right / 8;
4873 uint8_t left_flag = *dest_scan_top & (255 << (8 - left_shift)); 4867 uint8_t left_flag = *dest_scan_top & (255 << (8 - left_shift));
4874 uint8_t right_flag = *dest_scan_top_r & (255 >> right_shift); 4868 uint8_t right_flag = *dest_scan_top_r & (255 >> right_shift);
4875 if (width) { 4869 if (width) {
4876 FXSYS_memset(dest_scan_top + 1, index ? 255 : 0, width - 1); 4870 FXSYS_memset(dest_scan_top + 1, index ? 255 : 0, width - 1);
4877 if (!index) { 4871 if (!index) {
4878 *dest_scan_top &= left_flag; 4872 *dest_scan_top &= left_flag;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
5190 } 5184 }
5191 src_alpha_scan = m_pScanlineAlphaV; 5185 src_alpha_scan = m_pScanlineAlphaV;
5192 dest_alpha_scan = dest_alpha_buf; 5186 dest_alpha_scan = dest_alpha_buf;
5193 if (dest_alpha_scan) { 5187 if (dest_alpha_scan) {
5194 for (i = 0; i < m_DestHeight; i++) { 5188 for (i = 0; i < m_DestHeight; i++) {
5195 *dest_alpha_scan = *src_alpha_scan++; 5189 *dest_alpha_scan = *src_alpha_scan++;
5196 dest_alpha_scan += y_alpha_step; 5190 dest_alpha_scan += y_alpha_step;
5197 } 5191 }
5198 } 5192 }
5199 } 5193 }
OLDNEW
« no previous file with comments | « core/src/fxge/android/fpf_skiafontmgr.cpp ('k') | core/src/fxge/dib/fx_dib_convert.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698