comparison src/video/SDL_blit_A.c @ 1240:3b8a43c428bb

From Bug #36: There are a couple of issues with the selection of Altivec alpha-blitting routines in CalculateAlphaBlit() in src/video/SDL_Blit_A.c. 1) There's no check for the presence of Altivec when checking if the Blit32to565PixelAlphaAltivec() routine can be selected. 2) Altivec cannot be used in video memory, and there's no check if the destination surface is a hardware surface. (Alpha-blitting to a hardware surface with GPU support is a bad idea, but somebody's bound to do it anyway.) Patch to fix these attached.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 08 Jan 2006 21:18:15 +0000
parents 867f521591e5
children c9b51268668f
comparison
equal deleted inserted replaced
1239:cbdb2c156aca 1240:3b8a43c428bb
2143 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { 2143 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
2144 if(df->BytesPerPixel == 1) 2144 if(df->BytesPerPixel == 1)
2145 return BlitNto1SurfaceAlphaKey; 2145 return BlitNto1SurfaceAlphaKey;
2146 else 2146 else
2147 #ifdef USE_ALTIVEC_BLITTERS 2147 #ifdef USE_ALTIVEC_BLITTERS
2148 if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && SDL_HasAltiVec()) 2148 if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 &&
2149 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
2149 return Blit32to32SurfaceAlphaKeyAltivec; 2150 return Blit32to32SurfaceAlphaKeyAltivec;
2150 else 2151 else
2151 #endif 2152 #endif
2152 return BlitNtoNSurfaceAlphaKey; 2153 return BlitNtoNSurfaceAlphaKey;
2153 } else { 2154 } else {
2190 if(SDL_HasMMX()) 2191 if(SDL_HasMMX())
2191 return BlitRGBtoRGBSurfaceAlphaMMX; 2192 return BlitRGBtoRGBSurfaceAlphaMMX;
2192 else 2193 else
2193 #endif 2194 #endif
2194 #ifdef USE_ALTIVEC_BLITTERS 2195 #ifdef USE_ALTIVEC_BLITTERS
2195 if(SDL_HasAltiVec()) 2196 if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
2196 return BlitRGBtoRGBSurfaceAlphaAltivec; 2197 return BlitRGBtoRGBSurfaceAlphaAltivec;
2197 else 2198 else
2198 #endif 2199 #endif
2199 return BlitRGBtoRGBSurfaceAlpha; 2200 return BlitRGBtoRGBSurfaceAlpha;
2200 } 2201 }
2201 else 2202 else
2202 #ifdef USE_ALTIVEC_BLITTERS 2203 #ifdef USE_ALTIVEC_BLITTERS
2203 if((sf->BytesPerPixel == 4) && SDL_HasAltiVec()) 2204 if((sf->BytesPerPixel == 4) &&
2205 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
2204 return Blit32to32SurfaceAlphaAltivec; 2206 return Blit32to32SurfaceAlphaAltivec;
2205 else 2207 else
2206 #endif 2208 #endif
2207 return BlitNtoNSurfaceAlpha; 2209 return BlitNtoNSurfaceAlpha;
2208 2210
2217 case 1: 2219 case 1:
2218 return BlitNto1PixelAlpha; 2220 return BlitNto1PixelAlpha;
2219 2221
2220 case 2: 2222 case 2:
2221 #ifdef USE_ALTIVEC_BLITTERS 2223 #ifdef USE_ALTIVEC_BLITTERS
2222 if(sf->BytesPerPixel == 4 && 2224 if(sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) &&
2223 df->Gmask == 0x7e0 && 2225 df->Gmask == 0x7e0 &&
2224 df->Bmask == 0x1f) 2226 df->Bmask == 0x1f && SDL_HasAltiVec())
2225 return Blit32to565PixelAlphaAltivec; 2227 return Blit32to565PixelAlphaAltivec;
2226 else 2228 else
2227 #endif 2229 #endif
2228 if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 2230 if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
2229 && sf->Gmask == 0xff00 2231 && sf->Gmask == 0xff00
2250 if(SDL_HasMMX()) 2252 if(SDL_HasMMX())
2251 return BlitRGBtoRGBPixelAlphaMMX; 2253 return BlitRGBtoRGBPixelAlphaMMX;
2252 else 2254 else
2253 #endif 2255 #endif
2254 #ifdef USE_ALTIVEC_BLITTERS 2256 #ifdef USE_ALTIVEC_BLITTERS
2255 if(SDL_HasAltiVec()) 2257 if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
2256 return BlitRGBtoRGBPixelAlphaAltivec; 2258 return BlitRGBtoRGBPixelAlphaAltivec;
2257 else 2259 else
2258 #endif 2260 #endif
2259 return BlitRGBtoRGBPixelAlpha; 2261 return BlitRGBtoRGBPixelAlpha;
2260 } 2262 }
2261 #ifdef USE_ALTIVEC_BLITTERS 2263 #ifdef USE_ALTIVEC_BLITTERS
2262 if (sf->Amask && sf->BytesPerPixel == 4 && SDL_HasAltiVec()) 2264 if (sf->Amask && sf->BytesPerPixel == 4 &&
2265 !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
2263 return Blit32to32PixelAlphaAltivec; 2266 return Blit32to32PixelAlphaAltivec;
2264 else 2267 else
2265 #endif 2268 #endif
2266 return BlitNtoNPixelAlpha; 2269 return BlitNtoNPixelAlpha;
2267 2270