comparison src/video/SDL_blit_A.c @ 2262:bee005ace1bf

Work in progress: merging new texture features into SDL blit system
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 06:21:58 +0000
parents c20476d7d7b3
children c785543d1843
comparison
equal deleted inserted replaced
2261:c20476d7d7b3 2262:bee005ace1bf
28 28
29 /* N->1 blending with per-surface alpha */ 29 /* N->1 blending with per-surface alpha */
30 static void 30 static void
31 BlitNto1SurfaceAlpha(SDL_BlitInfo * info) 31 BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
32 { 32 {
33 int width = info->d_width; 33 int width = info->dst_w;
34 int height = info->d_height; 34 int height = info->dst_h;
35 Uint8 *src = info->s_pixels; 35 Uint8 *src = info->src;
36 int srcskip = info->s_skip; 36 int srcskip = info->s_skip;
37 Uint8 *dst = info->d_pixels; 37 Uint8 *dst = info->dst;
38 int dstskip = info->d_skip; 38 int dstskip = info->dst_pitch;
39 Uint8 *palmap = info->table; 39 Uint8 *palmap = info->table;
40 SDL_PixelFormat *srcfmt = info->src; 40 SDL_PixelFormat *srcfmt = info->src;
41 SDL_PixelFormat *dstfmt = info->dst; 41 SDL_PixelFormat *dstfmt = info->dst;
42 int srcbpp = srcfmt->BytesPerPixel; 42 int srcbpp = srcfmt->BytesPerPixel;
43 43
84 84
85 /* N->1 blending with pixel alpha */ 85 /* N->1 blending with pixel alpha */
86 static void 86 static void
87 BlitNto1PixelAlpha(SDL_BlitInfo * info) 87 BlitNto1PixelAlpha(SDL_BlitInfo * info)
88 { 88 {
89 int width = info->d_width; 89 int width = info->dst_w;
90 int height = info->d_height; 90 int height = info->dst_h;
91 Uint8 *src = info->s_pixels; 91 Uint8 *src = info->src;
92 int srcskip = info->s_skip; 92 int srcskip = info->s_skip;
93 Uint8 *dst = info->d_pixels; 93 Uint8 *dst = info->dst;
94 int dstskip = info->d_skip; 94 int dstskip = info->dst_pitch;
95 Uint8 *palmap = info->table; 95 Uint8 *palmap = info->table;
96 SDL_PixelFormat *srcfmt = info->src; 96 SDL_PixelFormat *srcfmt = info->src;
97 SDL_PixelFormat *dstfmt = info->dst; 97 SDL_PixelFormat *dstfmt = info->dst;
98 int srcbpp = srcfmt->BytesPerPixel; 98 int srcbpp = srcfmt->BytesPerPixel;
99 99
140 140
141 /* colorkeyed N->1 blending with per-surface alpha */ 141 /* colorkeyed N->1 blending with per-surface alpha */
142 static void 142 static void
143 BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) 143 BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
144 { 144 {
145 int width = info->d_width; 145 int width = info->dst_w;
146 int height = info->d_height; 146 int height = info->dst_h;
147 Uint8 *src = info->s_pixels; 147 Uint8 *src = info->src;
148 int srcskip = info->s_skip; 148 int srcskip = info->s_skip;
149 Uint8 *dst = info->d_pixels; 149 Uint8 *dst = info->dst;
150 int dstskip = info->d_skip; 150 int dstskip = info->dst_pitch;
151 Uint8 *palmap = info->table; 151 Uint8 *palmap = info->table;
152 SDL_PixelFormat *srcfmt = info->src; 152 SDL_PixelFormat *srcfmt = info->src;
153 SDL_PixelFormat *dstfmt = info->dst; 153 SDL_PixelFormat *dstfmt = info->dst;
154 int srcbpp = srcfmt->BytesPerPixel; 154 int srcbpp = srcfmt->BytesPerPixel;
155 Uint32 ckey = info->ckey; 155 Uint32 ckey = info->ckey;
201 201
202 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ 202 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
203 static void 203 static void
204 BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info) 204 BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info)
205 { 205 {
206 int width = info->d_width; 206 int width = info->dst_w;
207 int height = info->d_height; 207 int height = info->dst_h;
208 Uint32 *srcp = (Uint32 *) info->s_pixels; 208 Uint32 *srcp = (Uint32 *) info->src;
209 int srcskip = info->s_skip >> 2; 209 int srcskip = info->s_skip >> 2;
210 Uint32 *dstp = (Uint32 *) info->d_pixels; 210 Uint32 *dstp = (Uint32 *) info->dst;
211 int dstskip = info->d_skip >> 2; 211 int dstskip = info->dst_pitch >> 2;
212 Uint32 dalpha = info->dst->Amask; 212 Uint32 dalpha = info->dst->Amask;
213 213
214 __m64 src1, src2, dst1, dst2, lmask, hmask, dsta; 214 __m64 src1, src2, dst1, dst2, lmask, hmask, dsta;
215 215
216 hmask = _mm_set_pi32(0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ 216 hmask = _mm_set_pi32(0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */
265 265
266 if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { 266 if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) {
267 /* only call a128 version when R,G,B occupy lower bits */ 267 /* only call a128 version when R,G,B occupy lower bits */
268 BlitRGBtoRGBSurfaceAlpha128MMX(info); 268 BlitRGBtoRGBSurfaceAlpha128MMX(info);
269 } else { 269 } else {
270 int width = info->d_width; 270 int width = info->dst_w;
271 int height = info->d_height; 271 int height = info->dst_h;
272 Uint32 *srcp = (Uint32 *) info->s_pixels; 272 Uint32 *srcp = (Uint32 *) info->src;
273 int srcskip = info->s_skip >> 2; 273 int srcskip = info->s_skip >> 2;
274 Uint32 *dstp = (Uint32 *) info->d_pixels; 274 Uint32 *dstp = (Uint32 *) info->dst;
275 int dstskip = info->d_skip >> 2; 275 int dstskip = info->dst_pitch >> 2;
276 Uint32 dalpha = df->Amask; 276 Uint32 dalpha = df->Amask;
277 Uint32 amult; 277 Uint32 amult;
278 278
279 __m64 src1, src2, dst1, dst2, mm_alpha, mm_zero, dsta; 279 __m64 src1, src2, dst1, dst2, mm_alpha, mm_zero, dsta;
280 280
354 354
355 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ 355 /* fast ARGB888->(A)RGB888 blending with pixel alpha */
356 static void 356 static void
357 BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) 357 BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
358 { 358 {
359 int width = info->d_width; 359 int width = info->dst_w;
360 int height = info->d_height; 360 int height = info->dst_h;
361 Uint32 *srcp = (Uint32 *) info->s_pixels; 361 Uint32 *srcp = (Uint32 *) info->src;
362 int srcskip = info->s_skip >> 2; 362 int srcskip = info->s_skip >> 2;
363 Uint32 *dstp = (Uint32 *) info->d_pixels; 363 Uint32 *dstp = (Uint32 *) info->dst;
364 int dstskip = info->d_skip >> 2; 364 int dstskip = info->dst_pitch >> 2;
365 SDL_PixelFormat *sf = info->src; 365 SDL_PixelFormat *sf = info->src;
366 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; 366 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask;
367 Uint32 amask = sf->Amask; 367 Uint32 amask = sf->Amask;
368 Uint32 ashift = sf->Ashift; 368 Uint32 ashift = sf->Ashift;
369 Uint64 multmask; 369 Uint64 multmask;
540 } 540 }
541 541
542 static void 542 static void
543 Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info) 543 Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info)
544 { 544 {
545 int height = info->d_height; 545 int height = info->dst_h;
546 Uint8 *src = (Uint8 *) info->s_pixels; 546 Uint8 *src = (Uint8 *) info->src;
547 int srcskip = info->s_skip; 547 int srcskip = info->s_skip;
548 Uint8 *dst = (Uint8 *) info->d_pixels; 548 Uint8 *dst = (Uint8 *) info->dst;
549 int dstskip = info->d_skip; 549 int dstskip = info->dst_pitch;
550 SDL_PixelFormat *srcfmt = info->src; 550 SDL_PixelFormat *srcfmt = info->src;
551 551
552 vector unsigned char v0 = vec_splat_u8(0); 552 vector unsigned char v0 = vec_splat_u8(0);
553 vector unsigned short v8_16 = vec_splat_u16(8); 553 vector unsigned short v8_16 = vec_splat_u16(8);
554 vector unsigned short v1_16 = vec_splat_u16(1); 554 vector unsigned short v1_16 = vec_splat_u16(1);
615 while (height--) { 615 while (height--) {
616 int extrawidth; 616 int extrawidth;
617 vector unsigned char valigner; 617 vector unsigned char valigner;
618 vector unsigned char vsrc; 618 vector unsigned char vsrc;
619 vector unsigned char voverflow; 619 vector unsigned char voverflow;
620 int width = info->d_width; 620 int width = info->dst_w;
621 621
622 #define ONE_PIXEL_BLEND(condition, widthvar) \ 622 #define ONE_PIXEL_BLEND(condition, widthvar) \
623 while (condition) { \ 623 while (condition) { \
624 Uint32 Pixel; \ 624 Uint32 Pixel; \
625 unsigned sR, sG, sB, dR, dG, dB, sA; \ 625 unsigned sR, sG, sB, dR, dG, dB, sA; \
716 } 716 }
717 717
718 static void 718 static void
719 Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info) 719 Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info)
720 { 720 {
721 int height = info->d_height; 721 int height = info->dst_h;
722 Uint32 *srcp = (Uint32 *) info->s_pixels; 722 Uint32 *srcp = (Uint32 *) info->src;
723 int srcskip = info->s_skip >> 2; 723 int srcskip = info->s_skip >> 2;
724 Uint32 *dstp = (Uint32 *) info->d_pixels; 724 Uint32 *dstp = (Uint32 *) info->dst;
725 int dstskip = info->d_skip >> 2; 725 int dstskip = info->dst_pitch >> 2;
726 SDL_PixelFormat *srcfmt = info->src; 726 SDL_PixelFormat *srcfmt = info->src;
727 SDL_PixelFormat *dstfmt = info->dst; 727 SDL_PixelFormat *dstfmt = info->dst;
728 unsigned sA = (info->cmod >> 24); 728 unsigned sA = (info->cmod >> 24);
729 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; 729 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
730 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; 730 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
764 vckey = vec_splat(vckey, 0); 764 vckey = vec_splat(vckey, 0);
765 ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask; 765 ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask;
766 vrgbmask = vec_splat(vrgbmask, 0); 766 vrgbmask = vec_splat(vrgbmask, 0);
767 767
768 while (height--) { 768 while (height--) {
769 int width = info->d_width; 769 int width = info->dst_w;
770 #define ONE_PIXEL_BLEND(condition, widthvar) \ 770 #define ONE_PIXEL_BLEND(condition, widthvar) \
771 while (condition) { \ 771 while (condition) { \
772 Uint32 Pixel; \ 772 Uint32 Pixel; \
773 unsigned sR, sG, sB, dR, dG, dB; \ 773 unsigned sR, sG, sB, dR, dG, dB; \
774 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \ 774 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \
842 842
843 843
844 static void 844 static void
845 Blit32to32PixelAlphaAltivec(SDL_BlitInfo * info) 845 Blit32to32PixelAlphaAltivec(SDL_BlitInfo * info)
846 { 846 {
847 int width = info->d_width; 847 int width = info->dst_w;
848 int height = info->d_height; 848 int height = info->dst_h;
849 Uint32 *srcp = (Uint32 *) info->s_pixels; 849 Uint32 *srcp = (Uint32 *) info->src;
850 int srcskip = info->s_skip >> 2; 850 int srcskip = info->s_skip >> 2;
851 Uint32 *dstp = (Uint32 *) info->d_pixels; 851 Uint32 *dstp = (Uint32 *) info->dst;
852 int dstskip = info->d_skip >> 2; 852 int dstskip = info->dst_pitch >> 2;
853 SDL_PixelFormat *srcfmt = info->src; 853 SDL_PixelFormat *srcfmt = info->src;
854 SDL_PixelFormat *dstfmt = info->dst; 854 SDL_PixelFormat *dstfmt = info->dst;
855 vector unsigned char mergePermute; 855 vector unsigned char mergePermute;
856 vector unsigned char valphaPermute; 856 vector unsigned char valphaPermute;
857 vector unsigned char vsrcPermute; 857 vector unsigned char vsrcPermute;
873 vsrcPermute = calc_swizzle32(srcfmt, NULL); 873 vsrcPermute = calc_swizzle32(srcfmt, NULL);
874 vdstPermute = calc_swizzle32(NULL, dstfmt); 874 vdstPermute = calc_swizzle32(NULL, dstfmt);
875 vsdstPermute = calc_swizzle32(dstfmt, NULL); 875 vsdstPermute = calc_swizzle32(dstfmt, NULL);
876 876
877 while (height--) { 877 while (height--) {
878 width = info->d_width; 878 width = info->dst_w;
879 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ 879 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
880 Uint32 Pixel; \ 880 Uint32 Pixel; \
881 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \ 881 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
882 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \ 882 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \
883 if(sA) { \ 883 if(sA) { \
940 940
941 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ 941 /* fast ARGB888->(A)RGB888 blending with pixel alpha */
942 static void 942 static void
943 BlitRGBtoRGBPixelAlphaAltivec(SDL_BlitInfo * info) 943 BlitRGBtoRGBPixelAlphaAltivec(SDL_BlitInfo * info)
944 { 944 {
945 int width = info->d_width; 945 int width = info->dst_w;
946 int height = info->d_height; 946 int height = info->dst_h;
947 Uint32 *srcp = (Uint32 *) info->s_pixels; 947 Uint32 *srcp = (Uint32 *) info->src;
948 int srcskip = info->s_skip >> 2; 948 int srcskip = info->s_skip >> 2;
949 Uint32 *dstp = (Uint32 *) info->d_pixels; 949 Uint32 *dstp = (Uint32 *) info->dst;
950 int dstskip = info->d_skip >> 2; 950 int dstskip = info->dst_pitch >> 2;
951 vector unsigned char mergePermute; 951 vector unsigned char mergePermute;
952 vector unsigned char valphaPermute; 952 vector unsigned char valphaPermute;
953 vector unsigned char valphamask; 953 vector unsigned char valphamask;
954 vector unsigned char vpixelmask; 954 vector unsigned char vpixelmask;
955 vector unsigned char v0; 955 vector unsigned char v0;
963 valphaPermute = vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC)); 963 valphaPermute = vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC));
964 964
965 965
966 vpixelmask = vec_nor(valphamask, v0); 966 vpixelmask = vec_nor(valphamask, v0);
967 while (height--) { 967 while (height--) {
968 width = info->d_width; 968 width = info->dst_w;
969 #define ONE_PIXEL_BLEND(condition, widthvar) \ 969 #define ONE_PIXEL_BLEND(condition, widthvar) \
970 while ((condition)) { \ 970 while ((condition)) { \
971 Uint32 dalpha; \ 971 Uint32 dalpha; \
972 Uint32 d; \ 972 Uint32 d; \
973 Uint32 s1; \ 973 Uint32 s1; \
1038 1038
1039 static void 1039 static void
1040 Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) 1040 Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
1041 { 1041 {
1042 /* XXX : 6 */ 1042 /* XXX : 6 */
1043 int height = info->d_height; 1043 int height = info->dst_h;
1044 Uint32 *srcp = (Uint32 *) info->s_pixels; 1044 Uint32 *srcp = (Uint32 *) info->src;
1045 int srcskip = info->s_skip >> 2; 1045 int srcskip = info->s_skip >> 2;
1046 Uint32 *dstp = (Uint32 *) info->d_pixels; 1046 Uint32 *dstp = (Uint32 *) info->dst;
1047 int dstskip = info->d_skip >> 2; 1047 int dstskip = info->dst_pitch >> 2;
1048 SDL_PixelFormat *srcfmt = info->src; 1048 SDL_PixelFormat *srcfmt = info->src;
1049 SDL_PixelFormat *dstfmt = info->dst; 1049 SDL_PixelFormat *dstfmt = info->dst;
1050 unsigned sA = (info->cmod >> 24); 1050 unsigned sA = (info->cmod >> 24);
1051 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; 1051 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
1052 vector unsigned char mergePermute; 1052 vector unsigned char mergePermute;
1074 ((unsigned char *) &valpha)[0] = alpha; 1074 ((unsigned char *) &valpha)[0] = alpha;
1075 valpha = vec_splat(valpha, 0); 1075 valpha = vec_splat(valpha, 0);
1076 vbits = (vector unsigned char) vec_splat_s8(-1); 1076 vbits = (vector unsigned char) vec_splat_s8(-1);
1077 1077
1078 while (height--) { 1078 while (height--) {
1079 int width = info->d_width; 1079 int width = info->dst_w;
1080 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ 1080 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
1081 Uint32 Pixel; \ 1081 Uint32 Pixel; \
1082 unsigned sR, sG, sB, dR, dG, dB; \ 1082 unsigned sR, sG, sB, dR, dG, dB; \
1083 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \ 1083 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \
1084 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ 1084 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
1135 /* fast RGB888->(A)RGB888 blending */ 1135 /* fast RGB888->(A)RGB888 blending */
1136 static void 1136 static void
1137 BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info) 1137 BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info)
1138 { 1138 {
1139 unsigned alpha = (info->cmod >> 24); 1139 unsigned alpha = (info->cmod >> 24);
1140 int height = info->d_height; 1140 int height = info->dst_h;
1141 Uint32 *srcp = (Uint32 *) info->s_pixels; 1141 Uint32 *srcp = (Uint32 *) info->src;
1142 int srcskip = info->s_skip >> 2; 1142 int srcskip = info->s_skip >> 2;
1143 Uint32 *dstp = (Uint32 *) info->d_pixels; 1143 Uint32 *dstp = (Uint32 *) info->dst;
1144 int dstskip = info->d_skip >> 2; 1144 int dstskip = info->dst_pitch >> 2;
1145 vector unsigned char mergePermute; 1145 vector unsigned char mergePermute;
1146 vector unsigned char valpha; 1146 vector unsigned char valpha;
1147 vector unsigned char valphamask; 1147 vector unsigned char valphamask;
1148 vector unsigned short v1; 1148 vector unsigned short v1;
1149 vector unsigned short v8; 1149 vector unsigned short v8;
1158 /* set a vector full of alpha and 255-alpha */ 1158 /* set a vector full of alpha and 255-alpha */
1159 ((unsigned char *) &valpha)[0] = alpha; 1159 ((unsigned char *) &valpha)[0] = alpha;
1160 valpha = vec_splat(valpha, 0); 1160 valpha = vec_splat(valpha, 0);
1161 1161
1162 while (height--) { 1162 while (height--) {
1163 int width = info->d_width; 1163 int width = info->dst_w;
1164 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ 1164 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
1165 Uint32 s = *srcp; \ 1165 Uint32 s = *srcp; \
1166 Uint32 d = *dstp; \ 1166 Uint32 d = *dstp; \
1167 Uint32 s1 = s & 0xff00ff; \ 1167 Uint32 s1 = s & 0xff00ff; \
1168 Uint32 d1 = d & 0xff00ff; \ 1168 Uint32 d1 = d & 0xff00ff; \
1222 1222
1223 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ 1223 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
1224 static void 1224 static void
1225 BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) 1225 BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
1226 { 1226 {
1227 int width = info->d_width; 1227 int width = info->dst_w;
1228 int height = info->d_height; 1228 int height = info->dst_h;
1229 Uint32 *srcp = (Uint32 *) info->s_pixels; 1229 Uint32 *srcp = (Uint32 *) info->src;
1230 int srcskip = info->s_skip >> 2; 1230 int srcskip = info->s_skip >> 2;
1231 Uint32 *dstp = (Uint32 *) info->d_pixels; 1231 Uint32 *dstp = (Uint32 *) info->dst;
1232 int dstskip = info->d_skip >> 2; 1232 int dstskip = info->dst_pitch >> 2;
1233 1233
1234 while (height--) { 1234 while (height--) {
1235 /* *INDENT-OFF* */ 1235 /* *INDENT-OFF* */
1236 DUFFS_LOOP4({ 1236 DUFFS_LOOP4({
1237 Uint32 s = *srcp++; 1237 Uint32 s = *srcp++;
1251 { 1251 {
1252 unsigned alpha = (info->cmod >> 24); 1252 unsigned alpha = (info->cmod >> 24);
1253 if (alpha == 128) { 1253 if (alpha == 128) {
1254 BlitRGBtoRGBSurfaceAlpha128(info); 1254 BlitRGBtoRGBSurfaceAlpha128(info);
1255 } else { 1255 } else {
1256 int width = info->d_width; 1256 int width = info->dst_w;
1257 int height = info->d_height; 1257 int height = info->dst_h;
1258 Uint32 *srcp = (Uint32 *) info->s_pixels; 1258 Uint32 *srcp = (Uint32 *) info->src;
1259 int srcskip = info->s_skip >> 2; 1259 int srcskip = info->s_skip >> 2;
1260 Uint32 *dstp = (Uint32 *) info->d_pixels; 1260 Uint32 *dstp = (Uint32 *) info->dst;
1261 int dstskip = info->d_skip >> 2; 1261 int dstskip = info->dst_pitch >> 2;
1262 Uint32 s; 1262 Uint32 s;
1263 Uint32 d; 1263 Uint32 d;
1264 Uint32 s1; 1264 Uint32 s1;
1265 Uint32 d1; 1265 Uint32 d1;
1266 1266
1319 1319
1320 /* fast ARGB888->(A)RGB888 blending with pixel alpha */ 1320 /* fast ARGB888->(A)RGB888 blending with pixel alpha */
1321 static void 1321 static void
1322 BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) 1322 BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
1323 { 1323 {
1324 int width = info->d_width; 1324 int width = info->dst_w;
1325 int height = info->d_height; 1325 int height = info->dst_h;
1326 Uint32 *srcp = (Uint32 *) info->s_pixels; 1326 Uint32 *srcp = (Uint32 *) info->src;
1327 int srcskip = info->s_skip >> 2; 1327 int srcskip = info->s_skip >> 2;
1328 Uint32 *dstp = (Uint32 *) info->d_pixels; 1328 Uint32 *dstp = (Uint32 *) info->dst;
1329 int dstskip = info->d_skip >> 2; 1329 int dstskip = info->dst_pitch >> 2;
1330 1330
1331 while (height--) { 1331 while (height--) {
1332 /* *INDENT-OFF* */ 1332 /* *INDENT-OFF* */
1333 DUFFS_LOOP4({ 1333 DUFFS_LOOP4({
1334 Uint32 dalpha; 1334 Uint32 dalpha;
1372 #ifdef __3dNOW__ 1372 #ifdef __3dNOW__
1373 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ 1373 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
1374 static void 1374 static void
1375 BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) 1375 BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
1376 { 1376 {
1377 int width = info->d_width; 1377 int width = info->dst_w;
1378 int height = info->d_height; 1378 int height = info->dst_h;
1379 Uint32 *srcp = (Uint32 *) info->s_pixels; 1379 Uint32 *srcp = (Uint32 *) info->src;
1380 int srcskip = info->s_skip >> 2; 1380 int srcskip = info->s_skip >> 2;
1381 Uint32 *dstp = (Uint32 *) info->d_pixels; 1381 Uint32 *dstp = (Uint32 *) info->dst;
1382 int dstskip = info->d_skip >> 2; 1382 int dstskip = info->dst_pitch >> 2;
1383 SDL_PixelFormat *sf = info->src; 1383 SDL_PixelFormat *sf = info->src;
1384 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask; 1384 Uint32 chanmask = sf->Rmask | sf->Gmask | sf->Bmask;
1385 Uint32 amask = sf->Amask; 1385 Uint32 amask = sf->Amask;
1386 Uint32 ashift = sf->Ashift; 1386 Uint32 ashift = sf->Ashift;
1387 Uint64 multmask; 1387 Uint64 multmask;
1454 + (s & d & (~(mask | mask << 16)))) 1454 + (s & d & (~(mask | mask << 16))))
1455 1455
1456 static void 1456 static void
1457 Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) 1457 Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask)
1458 { 1458 {
1459 int width = info->d_width; 1459 int width = info->dst_w;
1460 int height = info->d_height; 1460 int height = info->dst_h;
1461 Uint16 *srcp = (Uint16 *) info->s_pixels; 1461 Uint16 *srcp = (Uint16 *) info->src;
1462 int srcskip = info->s_skip >> 1; 1462 int srcskip = info->s_skip >> 1;
1463 Uint16 *dstp = (Uint16 *) info->d_pixels; 1463 Uint16 *dstp = (Uint16 *) info->dst;
1464 int dstskip = info->d_skip >> 1; 1464 int dstskip = info->dst_pitch >> 1;
1465 1465
1466 while (height--) { 1466 while (height--) {
1467 if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) { 1467 if (((uintptr_t) srcp ^ (uintptr_t) dstp) & 2) {
1468 /* 1468 /*
1469 * Source and destination not aligned, pipeline it. 1469 * Source and destination not aligned, pipeline it.
1560 { 1560 {
1561 unsigned alpha = (info->cmod >> 24); 1561 unsigned alpha = (info->cmod >> 24);
1562 if (alpha == 128) { 1562 if (alpha == 128) {
1563 Blit16to16SurfaceAlpha128(info, 0xf7de); 1563 Blit16to16SurfaceAlpha128(info, 0xf7de);
1564 } else { 1564 } else {
1565 int width = info->d_width; 1565 int width = info->dst_w;
1566 int height = info->d_height; 1566 int height = info->dst_h;
1567 Uint16 *srcp = (Uint16 *) info->s_pixels; 1567 Uint16 *srcp = (Uint16 *) info->src;
1568 int srcskip = info->s_skip >> 1; 1568 int srcskip = info->s_skip >> 1;
1569 Uint16 *dstp = (Uint16 *) info->d_pixels; 1569 Uint16 *dstp = (Uint16 *) info->dst;
1570 int dstskip = info->d_skip >> 1; 1570 int dstskip = info->dst_pitch >> 1;
1571 Uint32 s, d; 1571 Uint32 s, d;
1572 1572
1573 __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha; 1573 __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha;
1574 1574
1575 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ 1575 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */
1697 { 1697 {
1698 unsigned alpha = (info->cmod >> 24); 1698 unsigned alpha = (info->cmod >> 24);
1699 if (alpha == 128) { 1699 if (alpha == 128) {
1700 Blit16to16SurfaceAlpha128(info, 0xfbde); 1700 Blit16to16SurfaceAlpha128(info, 0xfbde);
1701 } else { 1701 } else {
1702 int width = info->d_width; 1702 int width = info->dst_w;
1703 int height = info->d_height; 1703 int height = info->dst_h;
1704 Uint16 *srcp = (Uint16 *) info->s_pixels; 1704 Uint16 *srcp = (Uint16 *) info->src;
1705 int srcskip = info->s_skip >> 1; 1705 int srcskip = info->s_skip >> 1;
1706 Uint16 *dstp = (Uint16 *) info->d_pixels; 1706 Uint16 *dstp = (Uint16 *) info->dst;
1707 int dstskip = info->d_skip >> 1; 1707 int dstskip = info->dst_pitch >> 1;
1708 Uint32 s, d; 1708 Uint32 s, d;
1709 1709
1710 __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha; 1710 __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha;
1711 1711
1712 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ 1712 alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */
1837 { 1837 {
1838 unsigned alpha = (info->cmod >> 24); 1838 unsigned alpha = (info->cmod >> 24);
1839 if (alpha == 128) { 1839 if (alpha == 128) {
1840 Blit16to16SurfaceAlpha128(info, 0xf7de); 1840 Blit16to16SurfaceAlpha128(info, 0xf7de);
1841 } else { 1841 } else {
1842 int width = info->d_width; 1842 int width = info->dst_w;
1843 int height = info->d_height; 1843 int height = info->dst_h;
1844 Uint16 *srcp = (Uint16 *) info->s_pixels; 1844 Uint16 *srcp = (Uint16 *) info->src;
1845 int srcskip = info->s_skip >> 1; 1845 int srcskip = info->s_skip >> 1;
1846 Uint16 *dstp = (Uint16 *) info->d_pixels; 1846 Uint16 *dstp = (Uint16 *) info->dst;
1847 int dstskip = info->d_skip >> 1; 1847 int dstskip = info->dst_pitch >> 1;
1848 alpha >>= 3; /* downscale alpha to 5 bits */ 1848 alpha >>= 3; /* downscale alpha to 5 bits */
1849 1849
1850 while (height--) { 1850 while (height--) {
1851 /* *INDENT-OFF* */ 1851 /* *INDENT-OFF* */
1852 DUFFS_LOOP4({ 1852 DUFFS_LOOP4({
1876 { 1876 {
1877 unsigned alpha = (info->cmod >> 24); /* downscale alpha to 5 bits */ 1877 unsigned alpha = (info->cmod >> 24); /* downscale alpha to 5 bits */
1878 if (alpha == 128) { 1878 if (alpha == 128) {
1879 Blit16to16SurfaceAlpha128(info, 0xfbde); 1879 Blit16to16SurfaceAlpha128(info, 0xfbde);
1880 } else { 1880 } else {
1881 int width = info->d_width; 1881 int width = info->dst_w;
1882 int height = info->d_height; 1882 int height = info->dst_h;
1883 Uint16 *srcp = (Uint16 *) info->s_pixels; 1883 Uint16 *srcp = (Uint16 *) info->src;
1884 int srcskip = info->s_skip >> 1; 1884 int srcskip = info->s_skip >> 1;
1885 Uint16 *dstp = (Uint16 *) info->d_pixels; 1885 Uint16 *dstp = (Uint16 *) info->dst;
1886 int dstskip = info->d_skip >> 1; 1886 int dstskip = info->dst_pitch >> 1;
1887 alpha >>= 3; /* downscale alpha to 5 bits */ 1887 alpha >>= 3; /* downscale alpha to 5 bits */
1888 1888
1889 while (height--) { 1889 while (height--) {
1890 /* *INDENT-OFF* */ 1890 /* *INDENT-OFF* */
1891 DUFFS_LOOP4({ 1891 DUFFS_LOOP4({
1911 1911
1912 /* fast ARGB8888->RGB565 blending with pixel alpha */ 1912 /* fast ARGB8888->RGB565 blending with pixel alpha */
1913 static void 1913 static void
1914 BlitARGBto565PixelAlpha(SDL_BlitInfo * info) 1914 BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
1915 { 1915 {
1916 int width = info->d_width; 1916 int width = info->dst_w;
1917 int height = info->d_height; 1917 int height = info->dst_h;
1918 Uint32 *srcp = (Uint32 *) info->s_pixels; 1918 Uint32 *srcp = (Uint32 *) info->src;
1919 int srcskip = info->s_skip >> 2; 1919 int srcskip = info->s_skip >> 2;
1920 Uint16 *dstp = (Uint16 *) info->d_pixels; 1920 Uint16 *dstp = (Uint16 *) info->dst;
1921 int dstskip = info->d_skip >> 1; 1921 int dstskip = info->dst_pitch >> 1;
1922 1922
1923 while (height--) { 1923 while (height--) {
1924 /* *INDENT-OFF* */ 1924 /* *INDENT-OFF* */
1925 DUFFS_LOOP4({ 1925 DUFFS_LOOP4({
1926 Uint32 s = *srcp; 1926 Uint32 s = *srcp;
1957 1957
1958 /* fast ARGB8888->RGB555 blending with pixel alpha */ 1958 /* fast ARGB8888->RGB555 blending with pixel alpha */
1959 static void 1959 static void
1960 BlitARGBto555PixelAlpha(SDL_BlitInfo * info) 1960 BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
1961 { 1961 {
1962 int width = info->d_width; 1962 int width = info->dst_w;
1963 int height = info->d_height; 1963 int height = info->dst_h;
1964 Uint32 *srcp = (Uint32 *) info->s_pixels; 1964 Uint32 *srcp = (Uint32 *) info->src;
1965 int srcskip = info->s_skip >> 2; 1965 int srcskip = info->s_skip >> 2;
1966 Uint16 *dstp = (Uint16 *) info->d_pixels; 1966 Uint16 *dstp = (Uint16 *) info->dst;
1967 int dstskip = info->d_skip >> 1; 1967 int dstskip = info->dst_pitch >> 1;
1968 1968
1969 while (height--) { 1969 while (height--) {
1970 /* *INDENT-OFF* */ 1970 /* *INDENT-OFF* */
1971 DUFFS_LOOP4({ 1971 DUFFS_LOOP4({
1972 unsigned alpha; 1972 unsigned alpha;
2004 2004
2005 /* General (slow) N->N blending with per-surface alpha */ 2005 /* General (slow) N->N blending with per-surface alpha */
2006 static void 2006 static void
2007 BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) 2007 BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
2008 { 2008 {
2009 int width = info->d_width; 2009 int width = info->dst_w;
2010 int height = info->d_height; 2010 int height = info->dst_h;
2011 Uint8 *src = info->s_pixels; 2011 Uint8 *src = info->src;
2012 int srcskip = info->s_skip; 2012 int srcskip = info->s_skip;
2013 Uint8 *dst = info->d_pixels; 2013 Uint8 *dst = info->dst;
2014 int dstskip = info->d_skip; 2014 int dstskip = info->dst_pitch;
2015 SDL_PixelFormat *srcfmt = info->src; 2015 SDL_PixelFormat *srcfmt = info->src;
2016 SDL_PixelFormat *dstfmt = info->dst; 2016 SDL_PixelFormat *dstfmt = info->dst;
2017 int srcbpp = srcfmt->BytesPerPixel; 2017 int srcbpp = srcfmt->BytesPerPixel;
2018 int dstbpp = dstfmt->BytesPerPixel; 2018 int dstbpp = dstfmt->BytesPerPixel;
2019 unsigned sA = (info->cmod >> 24); 2019 unsigned sA = (info->cmod >> 24);
2048 2048
2049 /* General (slow) colorkeyed N->N blending with per-surface alpha */ 2049 /* General (slow) colorkeyed N->N blending with per-surface alpha */
2050 static void 2050 static void
2051 BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) 2051 BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
2052 { 2052 {
2053 int width = info->d_width; 2053 int width = info->dst_w;
2054 int height = info->d_height; 2054 int height = info->dst_h;
2055 Uint8 *src = info->s_pixels; 2055 Uint8 *src = info->src;
2056 int srcskip = info->s_skip; 2056 int srcskip = info->s_skip;
2057 Uint8 *dst = info->d_pixels; 2057 Uint8 *dst = info->dst;
2058 int dstskip = info->d_skip; 2058 int dstskip = info->dst_pitch;
2059 SDL_PixelFormat *srcfmt = info->src; 2059 SDL_PixelFormat *srcfmt = info->src;
2060 SDL_PixelFormat *dstfmt = info->dst; 2060 SDL_PixelFormat *dstfmt = info->dst;
2061 Uint32 ckey = info->ckey; 2061 Uint32 ckey = info->ckey;
2062 int srcbpp = srcfmt->BytesPerPixel; 2062 int srcbpp = srcfmt->BytesPerPixel;
2063 int dstbpp = dstfmt->BytesPerPixel; 2063 int dstbpp = dstfmt->BytesPerPixel;
2094 2094
2095 /* General (slow) N->N blending with pixel alpha */ 2095 /* General (slow) N->N blending with pixel alpha */
2096 static void 2096 static void
2097 BlitNtoNPixelAlpha(SDL_BlitInfo * info) 2097 BlitNtoNPixelAlpha(SDL_BlitInfo * info)
2098 { 2098 {
2099 int width = info->d_width; 2099 int width = info->dst_w;
2100 int height = info->d_height; 2100 int height = info->dst_h;
2101 Uint8 *src = info->s_pixels; 2101 Uint8 *src = info->src;
2102 int srcskip = info->s_skip; 2102 int srcskip = info->s_skip;
2103 Uint8 *dst = info->d_pixels; 2103 Uint8 *dst = info->dst;
2104 int dstskip = info->d_skip; 2104 int dstskip = info->dst_pitch;
2105 SDL_PixelFormat *srcfmt = info->src; 2105 SDL_PixelFormat *srcfmt = info->src;
2106 SDL_PixelFormat *dstfmt = info->dst; 2106 SDL_PixelFormat *dstfmt = info->dst;
2107 2107
2108 int srcbpp; 2108 int srcbpp;
2109 int dstbpp; 2109 int dstbpp;