Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_N.c @ 3050:e763aa6db88b
Fixed Altivec blitters for PPC
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 25 Jan 2009 05:14:29 +0000 |
parents | 8cc00819c8d6 |
children | dc1eb82ffdaa |
comparison
equal
deleted
inserted
replaced
3049:ed67e93944b1 | 3050:e763aa6db88b |
---|---|
112 * colors is alpha, and it's one complete byte, since some formats | 112 * colors is alpha, and it's one complete byte, since some formats |
113 * leave alpha with a zero mask, but we should still swizzle the bits. | 113 * leave alpha with a zero mask, but we should still swizzle the bits. |
114 */ | 114 */ |
115 /* ARGB */ | 115 /* ARGB */ |
116 const static struct SDL_PixelFormat default_pixel_format = { | 116 const static struct SDL_PixelFormat default_pixel_format = { |
117 NULL, 0, 0, | 117 NULL, 32, 4, |
118 0, 0, 0, 0, | 118 0, 0, 0, 0, |
119 16, 8, 0, 24, | 119 16, 8, 0, 24, |
120 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, | 120 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 |
121 0, 0 | |
122 }; | 121 }; |
123 if (!srcfmt) { | 122 if (!srcfmt) { |
124 srcfmt = &default_pixel_format; | 123 srcfmt = &default_pixel_format; |
125 } | 124 } |
126 if (!dstfmt) { | 125 if (!dstfmt) { |
161 int height = info->dst_h; | 160 int height = info->dst_h; |
162 Uint8 *src = (Uint8 *) info->src; | 161 Uint8 *src = (Uint8 *) info->src; |
163 int srcskip = info->src_skip; | 162 int srcskip = info->src_skip; |
164 Uint8 *dst = (Uint8 *) info->dst; | 163 Uint8 *dst = (Uint8 *) info->dst; |
165 int dstskip = info->dst_skip; | 164 int dstskip = info->dst_skip; |
166 SDL_PixelFormat *srcfmt = info->src; | 165 SDL_PixelFormat *srcfmt = info->src_fmt; |
167 vector unsigned char valpha = vec_splat_u8(0); | 166 vector unsigned char valpha = vec_splat_u8(0); |
168 vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL); | 167 vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL); |
169 vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06, | 168 vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06, |
170 0x00, 0x0a, 0x00, 0x0e, | 169 0x00, 0x0a, 0x00, 0x0e, |
171 0x00, 0x12, 0x00, 0x16, | 170 0x00, 0x12, 0x00, 0x16, |
265 int height = info->dst_h; | 264 int height = info->dst_h; |
266 Uint8 *src = (Uint8 *) info->src; | 265 Uint8 *src = (Uint8 *) info->src; |
267 int srcskip = info->src_skip; | 266 int srcskip = info->src_skip; |
268 Uint8 *dst = (Uint8 *) info->dst; | 267 Uint8 *dst = (Uint8 *) info->dst; |
269 int dstskip = info->dst_skip; | 268 int dstskip = info->dst_skip; |
270 SDL_PixelFormat *srcfmt = info->src; | 269 SDL_PixelFormat *srcfmt = info->src_fmt; |
271 SDL_PixelFormat *dstfmt = info->dst; | 270 SDL_PixelFormat *dstfmt = info->dst_fmt; |
272 unsigned alpha; | 271 unsigned alpha; |
273 vector unsigned char valpha; | 272 vector unsigned char valpha; |
274 vector unsigned char vpermute; | 273 vector unsigned char vpermute; |
275 vector unsigned short vf800; | 274 vector unsigned short vf800; |
276 vector unsigned int v8 = vec_splat_u32(8); | 275 vector unsigned int v8 = vec_splat_u32(8); |
413 int height = info->dst_h; | 412 int height = info->dst_h; |
414 Uint8 *src = (Uint8 *) info->src; | 413 Uint8 *src = (Uint8 *) info->src; |
415 int srcskip = info->src_skip; | 414 int srcskip = info->src_skip; |
416 Uint8 *dst = (Uint8 *) info->dst; | 415 Uint8 *dst = (Uint8 *) info->dst; |
417 int dstskip = info->dst_skip; | 416 int dstskip = info->dst_skip; |
418 SDL_PixelFormat *srcfmt = info->src; | 417 SDL_PixelFormat *srcfmt = info->src_fmt; |
419 SDL_PixelFormat *dstfmt = info->dst; | 418 SDL_PixelFormat *dstfmt = info->dst_fmt; |
420 unsigned alpha; | 419 unsigned alpha; |
421 vector unsigned char valpha; | 420 vector unsigned char valpha; |
422 vector unsigned char vpermute; | 421 vector unsigned char vpermute; |
423 vector unsigned short vf800; | 422 vector unsigned short vf800; |
424 vector unsigned int v8 = vec_splat_u32(8); | 423 vector unsigned int v8 = vec_splat_u32(8); |
559 static void | 558 static void |
560 Blit32to32KeyAltivec(SDL_BlitInfo * info) | 559 Blit32to32KeyAltivec(SDL_BlitInfo * info) |
561 { | 560 { |
562 int height = info->dst_h; | 561 int height = info->dst_h; |
563 Uint32 *srcp = (Uint32 *) info->src; | 562 Uint32 *srcp = (Uint32 *) info->src; |
564 int srcskip = info->src_skip; | 563 int srcskip = info->src_skip / 4; |
565 Uint32 *dstp = (Uint32 *) info->dst; | 564 Uint32 *dstp = (Uint32 *) info->dst; |
566 int dstskip = info->dst_skip; | 565 int dstskip = info->dst_skip / 4; |
567 SDL_PixelFormat *srcfmt = info->src; | 566 SDL_PixelFormat *srcfmt = info->src_fmt; |
568 int srcbpp = srcfmt->BytesPerPixel; | 567 int srcbpp = srcfmt->BytesPerPixel; |
569 SDL_PixelFormat *dstfmt = info->dst; | 568 SDL_PixelFormat *dstfmt = info->dst_fmt; |
570 int dstbpp = dstfmt->BytesPerPixel; | 569 int dstbpp = dstfmt->BytesPerPixel; |
571 int copy_alpha = (srcfmt->Amask && dstfmt->Amask); | 570 int copy_alpha = (srcfmt->Amask && dstfmt->Amask); |
572 unsigned alpha = dstfmt->Amask ? info->a : 0; | 571 unsigned alpha = dstfmt->Amask ? info->a : 0; |
573 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; | 572 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; |
574 Uint32 ckey = info->colorkey; | 573 Uint32 ckey = info->colorkey; |
664 dstp += 4; | 663 dstp += 4; |
665 vs = voverflow; | 664 vs = voverflow; |
666 } | 665 } |
667 ONE_PIXEL_BLEND((extrawidth), extrawidth); | 666 ONE_PIXEL_BLEND((extrawidth), extrawidth); |
668 #undef ONE_PIXEL_BLEND | 667 #undef ONE_PIXEL_BLEND |
669 srcp += srcskip >> 2; | 668 srcp += srcskip; |
670 dstp += dstskip >> 2; | 669 dstp += dstskip; |
671 } | 670 } |
672 } | 671 } |
673 } | 672 } |
674 | 673 |
675 /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ | 674 /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ |
677 static void | 676 static void |
678 ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) | 677 ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) |
679 { | 678 { |
680 int height = info->dst_h; | 679 int height = info->dst_h; |
681 Uint32 *src = (Uint32 *) info->src; | 680 Uint32 *src = (Uint32 *) info->src; |
682 int srcskip = info->src_skip; | 681 int srcskip = info->src_skip / 4; |
683 Uint32 *dst = (Uint32 *) info->dst; | 682 Uint32 *dst = (Uint32 *) info->dst; |
684 int dstskip = info->dst_skip; | 683 int dstskip = info->dst_skip / 4; |
685 SDL_PixelFormat *srcfmt = info->src; | 684 SDL_PixelFormat *srcfmt = info->src_fmt; |
686 SDL_PixelFormat *dstfmt = info->dst; | 685 SDL_PixelFormat *dstfmt = info->dst_fmt; |
687 vector unsigned int vzero = vec_splat_u32(0); | 686 vector unsigned int vzero = vec_splat_u32(0); |
688 vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); | 687 vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); |
689 if (dstfmt->Amask && !srcfmt->Amask) { | 688 if (dstfmt->Amask && !srcfmt->Amask) { |
690 if (info->a) { | 689 if (info->a) { |
691 vector unsigned char valpha; | 690 vector unsigned char valpha; |
740 RGBA_FROM_8888(bits, srcfmt, r, g, b, a); | 739 RGBA_FROM_8888(bits, srcfmt, r, g, b, a); |
741 *(dst++) = MAKE8888(dstfmt, r, g, b, a); | 740 *(dst++) = MAKE8888(dstfmt, r, g, b, a); |
742 extrawidth--; | 741 extrawidth--; |
743 } | 742 } |
744 | 743 |
745 src += srcskip >> 2; /* move to next row, accounting for pitch. */ | 744 src += srcskip; |
746 dst += dstskip >> 2; | 745 dst += dstskip; |
747 } | 746 } |
748 | 747 |
749 } | 748 } |
750 | 749 |
751 /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ | 750 /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ |
756 const int scalar_dst_lead = sizeof(Uint32) * 4; | 755 const int scalar_dst_lead = sizeof(Uint32) * 4; |
757 const int vector_dst_lead = sizeof(Uint32) * 16; | 756 const int vector_dst_lead = sizeof(Uint32) * 16; |
758 | 757 |
759 int height = info->dst_h; | 758 int height = info->dst_h; |
760 Uint32 *src = (Uint32 *) info->src; | 759 Uint32 *src = (Uint32 *) info->src; |
761 int srcskip = info->src_skip; | 760 int srcskip = info->src_skip / 4; |
762 Uint32 *dst = (Uint32 *) info->dst; | 761 Uint32 *dst = (Uint32 *) info->dst; |
763 int dstskip = info->dst_skip; | 762 int dstskip = info->dst_skip / 4; |
764 SDL_PixelFormat *srcfmt = info->src; | 763 SDL_PixelFormat *srcfmt = info->src_fmt; |
765 SDL_PixelFormat *dstfmt = info->dst; | 764 SDL_PixelFormat *dstfmt = info->dst_fmt; |
766 vector unsigned int vzero = vec_splat_u32(0); | 765 vector unsigned int vzero = vec_splat_u32(0); |
767 vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); | 766 vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); |
768 if (dstfmt->Amask && !srcfmt->Amask) { | 767 if (dstfmt->Amask && !srcfmt->Amask) { |
769 if (info->a) { | 768 if (info->a) { |
770 vector unsigned char valpha; | 769 vector unsigned char valpha; |
827 RGBA_FROM_8888(bits, srcfmt, r, g, b, a); | 826 RGBA_FROM_8888(bits, srcfmt, r, g, b, a); |
828 *(dst++) = MAKE8888(dstfmt, r, g, b, a); | 827 *(dst++) = MAKE8888(dstfmt, r, g, b, a); |
829 extrawidth--; | 828 extrawidth--; |
830 } | 829 } |
831 | 830 |
832 src += srcskip >> 2; /* move to next row, accounting for pitch. */ | 831 src += srcskip; |
833 dst += dstskip >> 2; | 832 dst += dstskip; |
834 } | 833 } |
835 | 834 |
836 vec_dss(DST_CHAN_SRC); | 835 vec_dss(DST_CHAN_SRC); |
837 vec_dss(DST_CHAN_DEST); | 836 vec_dss(DST_CHAN_DEST); |
838 } | 837 } |