Skip to content

Commit

Permalink
From Bug #36:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
icculus committed Jan 8, 2006
1 parent 821fcee commit 7166e34
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/video/SDL_blit_A.c
Expand Up @@ -2145,7 +2145,8 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
return BlitNto1SurfaceAlphaKey;
else
#ifdef USE_ALTIVEC_BLITTERS
if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && SDL_HasAltiVec())
if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 &&
!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return Blit32to32SurfaceAlphaKeyAltivec;
else
#endif
Expand Down Expand Up @@ -2192,15 +2193,16 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
else
#endif
#ifdef USE_ALTIVEC_BLITTERS
if(SDL_HasAltiVec())
if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return BlitRGBtoRGBSurfaceAlphaAltivec;
else
#endif
return BlitRGBtoRGBSurfaceAlpha;
}
else
#ifdef USE_ALTIVEC_BLITTERS
if((sf->BytesPerPixel == 4) && SDL_HasAltiVec())
if((sf->BytesPerPixel == 4) &&
!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return Blit32to32SurfaceAlphaAltivec;
else
#endif
Expand All @@ -2219,9 +2221,9 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)

case 2:
#ifdef USE_ALTIVEC_BLITTERS
if(sf->BytesPerPixel == 4 &&
if(sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) &&
df->Gmask == 0x7e0 &&
df->Bmask == 0x1f)
df->Bmask == 0x1f && SDL_HasAltiVec())
return Blit32to565PixelAlphaAltivec;
else
#endif
Expand Down Expand Up @@ -2252,14 +2254,15 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
else
#endif
#ifdef USE_ALTIVEC_BLITTERS
if(SDL_HasAltiVec())
if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return BlitRGBtoRGBPixelAlphaAltivec;
else
#endif
return BlitRGBtoRGBPixelAlpha;
}
#ifdef USE_ALTIVEC_BLITTERS
if (sf->Amask && sf->BytesPerPixel == 4 && SDL_HasAltiVec())
if (sf->Amask && sf->BytesPerPixel == 4 &&
!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return Blit32to32PixelAlphaAltivec;
else
#endif
Expand Down

0 comments on commit 7166e34

Please sign in to comment.