Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_A.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | d910939febfa |
comparison
equal
deleted
inserted
replaced
1360:70a9cfb4cf1b | 1361:19418e4422cb |
---|---|
21 */ | 21 */ |
22 | 22 |
23 #include "SDL_video.h" | 23 #include "SDL_video.h" |
24 #include "SDL_blit.h" | 24 #include "SDL_blit.h" |
25 | 25 |
26 #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT) | 26 #if (defined(i386) || defined(__x86_64__)) && __GNUC__ && SDL_ASSEMBLY_BLITTERS |
27 #define MMX_ASMBLIT | 27 #define MMX_ASMBLIT 1 |
28 #endif | 28 #endif |
29 | 29 |
30 /* Function to check the CPU flags */ | 30 /* Function to check the CPU flags */ |
31 #include "SDL_cpuinfo.h" | 31 #include "SDL_cpuinfo.h" |
32 #ifdef MMX_ASMBLIT | 32 #if MMX_ASMBLIT |
33 #include "mmx.h" | 33 #include "mmx.h" |
34 #endif | 34 #endif |
35 | 35 |
36 /* Functions to perform alpha blended blitting */ | 36 /* Functions to perform alpha blended blitting */ |
37 | 37 |
195 src += srcskip; | 195 src += srcskip; |
196 dst += dstskip; | 196 dst += dstskip; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 #ifdef MMX_ASMBLIT | 200 #if MMX_ASMBLIT |
201 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ | 201 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ |
202 static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info) | 202 static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info) |
203 { | 203 { |
204 int width = info->d_width; | 204 int width = info->d_width; |
205 int height = info->d_height; | 205 int height = info->d_height; |
411 } | 411 } |
412 emms(); | 412 emms(); |
413 } | 413 } |
414 #endif | 414 #endif |
415 | 415 |
416 #ifdef USE_ALTIVEC_BLITTERS | 416 #if SDL_ALTIVEC_BLITTERS |
417 #ifdef HAVE_ALTIVEC_H | 417 #if HAVE_ALTIVEC_H |
418 #include <altivec.h> | 418 #include <altivec.h> |
419 #endif | 419 #endif |
420 #include <assert.h> | 420 #include <assert.h> |
421 | 421 |
422 #if ((defined MACOSX) && (__GNUC__ < 4)) | 422 #if ((defined MACOSX) && (__GNUC__ < 4)) |
1181 | 1181 |
1182 srcp += srcskip; | 1182 srcp += srcskip; |
1183 dstp += dstskip; | 1183 dstp += dstskip; |
1184 } | 1184 } |
1185 } | 1185 } |
1186 #endif /* USE_ALTIVEC_BLITTERS */ | 1186 #endif /* SDL_ALTIVEC_BLITTERS */ |
1187 | 1187 |
1188 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ | 1188 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ |
1189 static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) | 1189 static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) |
1190 { | 1190 { |
1191 int width = info->d_width; | 1191 int width = info->d_width; |
1323 srcp += srcskip; | 1323 srcp += srcskip; |
1324 dstp += dstskip; | 1324 dstp += dstskip; |
1325 } | 1325 } |
1326 } | 1326 } |
1327 | 1327 |
1328 #ifdef MMX_ASMBLIT | 1328 #if MMX_ASMBLIT |
1329 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ | 1329 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ |
1330 inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info) | 1330 inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info) |
1331 { | 1331 { |
1332 int width = info->d_width; | 1332 int width = info->d_width; |
1333 int height = info->d_height; | 1333 int height = info->d_height; |
1525 dstp += dstskip; | 1525 dstp += dstskip; |
1526 } | 1526 } |
1527 } | 1527 } |
1528 } | 1528 } |
1529 | 1529 |
1530 #ifdef MMX_ASMBLIT | 1530 #if MMX_ASMBLIT |
1531 /* fast RGB565->RGB565 blending with surface alpha */ | 1531 /* fast RGB565->RGB565 blending with surface alpha */ |
1532 static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) | 1532 static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) |
1533 { | 1533 { |
1534 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ | 1534 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ |
1535 if(alpha == 128) { | 1535 if(alpha == 128) { |
2134 if(sf->Amask == 0) { | 2134 if(sf->Amask == 0) { |
2135 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { | 2135 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
2136 if(df->BytesPerPixel == 1) | 2136 if(df->BytesPerPixel == 1) |
2137 return BlitNto1SurfaceAlphaKey; | 2137 return BlitNto1SurfaceAlphaKey; |
2138 else | 2138 else |
2139 #ifdef USE_ALTIVEC_BLITTERS | 2139 #if SDL_ALTIVEC_BLITTERS |
2140 if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && | 2140 if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && |
2141 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) | 2141 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) |
2142 return Blit32to32SurfaceAlphaKeyAltivec; | 2142 return Blit32to32SurfaceAlphaKeyAltivec; |
2143 else | 2143 else |
2144 #endif | 2144 #endif |
2151 | 2151 |
2152 case 2: | 2152 case 2: |
2153 if(surface->map->identity) { | 2153 if(surface->map->identity) { |
2154 if(df->Gmask == 0x7e0) | 2154 if(df->Gmask == 0x7e0) |
2155 { | 2155 { |
2156 #ifdef MMX_ASMBLIT | 2156 #if MMX_ASMBLIT |
2157 if(SDL_HasMMX()) | 2157 if(SDL_HasMMX()) |
2158 return Blit565to565SurfaceAlphaMMX; | 2158 return Blit565to565SurfaceAlphaMMX; |
2159 else | 2159 else |
2160 #endif | 2160 #endif |
2161 return Blit565to565SurfaceAlpha; | 2161 return Blit565to565SurfaceAlpha; |
2162 } | 2162 } |
2163 else if(df->Gmask == 0x3e0) | 2163 else if(df->Gmask == 0x3e0) |
2164 { | 2164 { |
2165 #ifdef MMX_ASMBLIT | 2165 #if MMX_ASMBLIT |
2166 if(SDL_HasMMX()) | 2166 if(SDL_HasMMX()) |
2167 return Blit555to555SurfaceAlphaMMX; | 2167 return Blit555to555SurfaceAlphaMMX; |
2168 else | 2168 else |
2169 #endif | 2169 #endif |
2170 return Blit555to555SurfaceAlpha; | 2170 return Blit555to555SurfaceAlpha; |
2177 && sf->Gmask == df->Gmask | 2177 && sf->Gmask == df->Gmask |
2178 && sf->Bmask == df->Bmask | 2178 && sf->Bmask == df->Bmask |
2179 && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff | 2179 && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff |
2180 && sf->BytesPerPixel == 4) | 2180 && sf->BytesPerPixel == 4) |
2181 { | 2181 { |
2182 #ifdef MMX_ASMBLIT | 2182 #if MMX_ASMBLIT |
2183 if(SDL_HasMMX()) | 2183 if(SDL_HasMMX()) |
2184 return BlitRGBtoRGBSurfaceAlphaMMX; | 2184 return BlitRGBtoRGBSurfaceAlphaMMX; |
2185 else | 2185 else |
2186 #endif | 2186 #endif |
2187 #ifdef USE_ALTIVEC_BLITTERS | 2187 #if SDL_ALTIVEC_BLITTERS |
2188 if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) | 2188 if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) |
2189 return BlitRGBtoRGBSurfaceAlphaAltivec; | 2189 return BlitRGBtoRGBSurfaceAlphaAltivec; |
2190 else | 2190 else |
2191 #endif | 2191 #endif |
2192 return BlitRGBtoRGBSurfaceAlpha; | 2192 return BlitRGBtoRGBSurfaceAlpha; |
2193 } | 2193 } |
2194 else | 2194 else |
2195 #ifdef USE_ALTIVEC_BLITTERS | 2195 #if SDL_ALTIVEC_BLITTERS |
2196 if((sf->BytesPerPixel == 4) && | 2196 if((sf->BytesPerPixel == 4) && |
2197 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) | 2197 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) |
2198 return Blit32to32SurfaceAlphaAltivec; | 2198 return Blit32to32SurfaceAlphaAltivec; |
2199 else | 2199 else |
2200 #endif | 2200 #endif |
2210 switch(df->BytesPerPixel) { | 2210 switch(df->BytesPerPixel) { |
2211 case 1: | 2211 case 1: |
2212 return BlitNto1PixelAlpha; | 2212 return BlitNto1PixelAlpha; |
2213 | 2213 |
2214 case 2: | 2214 case 2: |
2215 #ifdef USE_ALTIVEC_BLITTERS | 2215 #if SDL_ALTIVEC_BLITTERS |
2216 if(sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) && | 2216 if(sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) && |
2217 df->Gmask == 0x7e0 && | 2217 df->Gmask == 0x7e0 && |
2218 df->Bmask == 0x1f && SDL_HasAltiVec()) | 2218 df->Bmask == 0x1f && SDL_HasAltiVec()) |
2219 return Blit32to565PixelAlphaAltivec; | 2219 return Blit32to565PixelAlphaAltivec; |
2220 else | 2220 else |
2235 && sf->Rmask == df->Rmask | 2235 && sf->Rmask == df->Rmask |
2236 && sf->Gmask == df->Gmask | 2236 && sf->Gmask == df->Gmask |
2237 && sf->Bmask == df->Bmask | 2237 && sf->Bmask == df->Bmask |
2238 && sf->BytesPerPixel == 4) | 2238 && sf->BytesPerPixel == 4) |
2239 { | 2239 { |
2240 #ifdef MMX_ASMBLIT | 2240 #if MMX_ASMBLIT |
2241 if(SDL_Has3DNow()) | 2241 if(SDL_Has3DNow()) |
2242 return BlitRGBtoRGBPixelAlphaMMX3DNOW; | 2242 return BlitRGBtoRGBPixelAlphaMMX3DNOW; |
2243 else | 2243 else |
2244 if(SDL_HasMMX()) | 2244 if(SDL_HasMMX()) |
2245 return BlitRGBtoRGBPixelAlphaMMX; | 2245 return BlitRGBtoRGBPixelAlphaMMX; |
2246 else | 2246 else |
2247 #endif | 2247 #endif |
2248 #ifdef USE_ALTIVEC_BLITTERS | 2248 #if SDL_ALTIVEC_BLITTERS |
2249 if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) | 2249 if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) |
2250 return BlitRGBtoRGBPixelAlphaAltivec; | 2250 return BlitRGBtoRGBPixelAlphaAltivec; |
2251 else | 2251 else |
2252 #endif | 2252 #endif |
2253 return BlitRGBtoRGBPixelAlpha; | 2253 return BlitRGBtoRGBPixelAlpha; |
2254 } | 2254 } |
2255 #ifdef USE_ALTIVEC_BLITTERS | 2255 #if SDL_ALTIVEC_BLITTERS |
2256 if (sf->Amask && sf->BytesPerPixel == 4 && | 2256 if (sf->Amask && sf->BytesPerPixel == 4 && |
2257 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) | 2257 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec()) |
2258 return Blit32to32PixelAlphaAltivec; | 2258 return Blit32to32PixelAlphaAltivec; |
2259 else | 2259 else |
2260 #endif | 2260 #endif |