comparison src/video/SDL_blit_A.c @ 2257:340942cfda48

Moved the colorkey and per-surface alpha into the blit info, in preparation for support for general color channel modulation. Removed and consolidated some data in the blit info.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 00:54:53 +0000
parents 17b2369756be
children 202ddfd1cfb1
comparison
equal deleted inserted replaced
2256:e893d24ad8db 2257:340942cfda48
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
44 const unsigned A = srcfmt->alpha; 44 const unsigned A = (info->cmod >> 24);
45 45
46 while (height--) { 46 while (height--) {
47 /* *INDENT-OFF* */ 47 /* *INDENT-OFF* */
48 DUFFS_LOOP4( 48 DUFFS_LOOP4(
49 { 49 {
150 int dstskip = info->d_skip; 150 int dstskip = info->d_skip;
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 = srcfmt->colorkey; 155 Uint32 ckey = info->ckey;
156 156
157 const int A = srcfmt->alpha; 157 const int A = (info->cmod >> 24);
158 158
159 while (height--) { 159 while (height--) {
160 /* *INDENT-OFF* */ 160 /* *INDENT-OFF* */
161 DUFFS_LOOP( 161 DUFFS_LOOP(
162 { 162 {
259 static void 259 static void
260 BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) 260 BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info)
261 { 261 {
262 SDL_PixelFormat *df = info->dst; 262 SDL_PixelFormat *df = info->dst;
263 Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask; 263 Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask;
264 unsigned alpha = info->src->alpha; 264 unsigned alpha = (info->cmod >> 24);
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 {
716 } 716 }
717 717
718 static void 718 static void
719 Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info) 719 Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info)
720 { 720 {
721 unsigned alpha = info->src->alpha;
722 int height = info->d_height; 721 int height = info->d_height;
723 Uint32 *srcp = (Uint32 *) info->s_pixels; 722 Uint32 *srcp = (Uint32 *) info->s_pixels;
724 int srcskip = info->s_skip >> 2; 723 int srcskip = info->s_skip >> 2;
725 Uint32 *dstp = (Uint32 *) info->d_pixels; 724 Uint32 *dstp = (Uint32 *) info->d_pixels;
726 int dstskip = info->d_skip >> 2; 725 int dstskip = info->d_skip >> 2;
727 SDL_PixelFormat *srcfmt = info->src; 726 SDL_PixelFormat *srcfmt = info->src;
728 SDL_PixelFormat *dstfmt = info->dst; 727 SDL_PixelFormat *dstfmt = info->dst;
729 unsigned sA = srcfmt->alpha; 728 unsigned sA = (info->cmod >> 24);
730 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; 729 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
731 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; 730 Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
732 Uint32 ckey = info->src->colorkey; 731 Uint32 ckey = info->ckey;
733 vector unsigned char mergePermute; 732 vector unsigned char mergePermute;
734 vector unsigned char vsrcPermute; 733 vector unsigned char vsrcPermute;
735 vector unsigned char vdstPermute; 734 vector unsigned char vdstPermute;
736 vector unsigned char vsdstPermute; 735 vector unsigned char vsdstPermute;
737 vector unsigned char valpha; 736 vector unsigned char valpha;
1039 1038
1040 static void 1039 static void
1041 Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) 1040 Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
1042 { 1041 {
1043 /* XXX : 6 */ 1042 /* XXX : 6 */
1044 unsigned alpha = info->src->alpha;
1045 int height = info->d_height; 1043 int height = info->d_height;
1046 Uint32 *srcp = (Uint32 *) info->s_pixels; 1044 Uint32 *srcp = (Uint32 *) info->s_pixels;
1047 int srcskip = info->s_skip >> 2; 1045 int srcskip = info->s_skip >> 2;
1048 Uint32 *dstp = (Uint32 *) info->d_pixels; 1046 Uint32 *dstp = (Uint32 *) info->d_pixels;
1049 int dstskip = info->d_skip >> 2; 1047 int dstskip = info->d_skip >> 2;
1050 SDL_PixelFormat *srcfmt = info->src; 1048 SDL_PixelFormat *srcfmt = info->src;
1051 SDL_PixelFormat *dstfmt = info->dst; 1049 SDL_PixelFormat *dstfmt = info->dst;
1052 unsigned sA = srcfmt->alpha; 1050 unsigned sA = (info->cmod >> 24);
1053 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; 1051 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
1054 vector unsigned char mergePermute; 1052 vector unsigned char mergePermute;
1055 vector unsigned char vsrcPermute; 1053 vector unsigned char vsrcPermute;
1056 vector unsigned char vdstPermute; 1054 vector unsigned char vdstPermute;
1057 vector unsigned char vsdstPermute; 1055 vector unsigned char vsdstPermute;
1136 1134
1137 /* fast RGB888->(A)RGB888 blending */ 1135 /* fast RGB888->(A)RGB888 blending */
1138 static void 1136 static void
1139 BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info) 1137 BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info)
1140 { 1138 {
1141 unsigned alpha = info->src->alpha; 1139 unsigned alpha = (info->cmod >> 24);
1142 int height = info->d_height; 1140 int height = info->d_height;
1143 Uint32 *srcp = (Uint32 *) info->s_pixels; 1141 Uint32 *srcp = (Uint32 *) info->s_pixels;
1144 int srcskip = info->s_skip >> 2; 1142 int srcskip = info->s_skip >> 2;
1145 Uint32 *dstp = (Uint32 *) info->d_pixels; 1143 Uint32 *dstp = (Uint32 *) info->d_pixels;
1146 int dstskip = info->d_skip >> 2; 1144 int dstskip = info->d_skip >> 2;
1249 1247
1250 /* fast RGB888->(A)RGB888 blending with surface alpha */ 1248 /* fast RGB888->(A)RGB888 blending with surface alpha */
1251 static void 1249 static void
1252 BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) 1250 BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
1253 { 1251 {
1254 unsigned alpha = info->src->alpha; 1252 unsigned alpha = (info->cmod >> 24);
1255 if (alpha == 128) { 1253 if (alpha == 128) {
1256 BlitRGBtoRGBSurfaceAlpha128(info); 1254 BlitRGBtoRGBSurfaceAlpha128(info);
1257 } else { 1255 } else {
1258 int width = info->d_width; 1256 int width = info->d_width;
1259 int height = info->d_height; 1257 int height = info->d_height;
1558 1556
1559 /* fast RGB565->RGB565 blending with surface alpha */ 1557 /* fast RGB565->RGB565 blending with surface alpha */
1560 static void 1558 static void
1561 Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) 1559 Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
1562 { 1560 {
1563 unsigned alpha = info->src->alpha; 1561 unsigned alpha = (info->cmod >> 24);
1564 if (alpha == 128) { 1562 if (alpha == 128) {
1565 Blit16to16SurfaceAlpha128(info, 0xf7de); 1563 Blit16to16SurfaceAlpha128(info, 0xf7de);
1566 } else { 1564 } else {
1567 int width = info->d_width; 1565 int width = info->d_width;
1568 int height = info->d_height; 1566 int height = info->d_height;
1695 1693
1696 /* fast RGB555->RGB555 blending with surface alpha */ 1694 /* fast RGB555->RGB555 blending with surface alpha */
1697 static void 1695 static void
1698 Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) 1696 Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
1699 { 1697 {
1700 unsigned alpha = info->src->alpha; 1698 unsigned alpha = (info->cmod >> 24);
1701 if (alpha == 128) { 1699 if (alpha == 128) {
1702 Blit16to16SurfaceAlpha128(info, 0xfbde); 1700 Blit16to16SurfaceAlpha128(info, 0xfbde);
1703 } else { 1701 } else {
1704 int width = info->d_width; 1702 int width = info->d_width;
1705 int height = info->d_height; 1703 int height = info->d_height;
1835 1833
1836 /* fast RGB565->RGB565 blending with surface alpha */ 1834 /* fast RGB565->RGB565 blending with surface alpha */
1837 static void 1835 static void
1838 Blit565to565SurfaceAlpha(SDL_BlitInfo * info) 1836 Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
1839 { 1837 {
1840 unsigned alpha = info->src->alpha; 1838 unsigned alpha = (info->cmod >> 24);
1841 if (alpha == 128) { 1839 if (alpha == 128) {
1842 Blit16to16SurfaceAlpha128(info, 0xf7de); 1840 Blit16to16SurfaceAlpha128(info, 0xf7de);
1843 } else { 1841 } else {
1844 int width = info->d_width; 1842 int width = info->d_width;
1845 int height = info->d_height; 1843 int height = info->d_height;
1874 1872
1875 /* fast RGB555->RGB555 blending with surface alpha */ 1873 /* fast RGB555->RGB555 blending with surface alpha */
1876 static void 1874 static void
1877 Blit555to555SurfaceAlpha(SDL_BlitInfo * info) 1875 Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
1878 { 1876 {
1879 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ 1877 unsigned alpha = (info->cmod >> 24); /* downscale alpha to 5 bits */
1880 if (alpha == 128) { 1878 if (alpha == 128) {
1881 Blit16to16SurfaceAlpha128(info, 0xfbde); 1879 Blit16to16SurfaceAlpha128(info, 0xfbde);
1882 } else { 1880 } else {
1883 int width = info->d_width; 1881 int width = info->d_width;
1884 int height = info->d_height; 1882 int height = info->d_height;
2016 int dstskip = info->d_skip; 2014 int dstskip = info->d_skip;
2017 SDL_PixelFormat *srcfmt = info->src; 2015 SDL_PixelFormat *srcfmt = info->src;
2018 SDL_PixelFormat *dstfmt = info->dst; 2016 SDL_PixelFormat *dstfmt = info->dst;
2019 int srcbpp = srcfmt->BytesPerPixel; 2017 int srcbpp = srcfmt->BytesPerPixel;
2020 int dstbpp = dstfmt->BytesPerPixel; 2018 int dstbpp = dstfmt->BytesPerPixel;
2021 unsigned sA = srcfmt->alpha; 2019 unsigned sA = (info->cmod >> 24);
2022 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; 2020 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
2023 2021
2024 if (sA) { 2022 if (sA) {
2025 while (height--) { 2023 while (height--) {
2026 /* *INDENT-OFF* */ 2024 /* *INDENT-OFF* */
2058 int srcskip = info->s_skip; 2056 int srcskip = info->s_skip;
2059 Uint8 *dst = info->d_pixels; 2057 Uint8 *dst = info->d_pixels;
2060 int dstskip = info->d_skip; 2058 int dstskip = info->d_skip;
2061 SDL_PixelFormat *srcfmt = info->src; 2059 SDL_PixelFormat *srcfmt = info->src;
2062 SDL_PixelFormat *dstfmt = info->dst; 2060 SDL_PixelFormat *dstfmt = info->dst;
2063 Uint32 ckey = srcfmt->colorkey; 2061 Uint32 ckey = info->ckey;
2064 int srcbpp = srcfmt->BytesPerPixel; 2062 int srcbpp = srcfmt->BytesPerPixel;
2065 int dstbpp = dstfmt->BytesPerPixel; 2063 int dstbpp = dstfmt->BytesPerPixel;
2066 unsigned sA = srcfmt->alpha; 2064 unsigned sA = (info->cmod >> 24);
2067 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; 2065 unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
2068 2066
2069 while (height--) { 2067 while (height--) {
2070 /* *INDENT-OFF* */ 2068 /* *INDENT-OFF* */
2071 DUFFS_LOOP4( 2069 DUFFS_LOOP4(