Navigation Menu

Skip to content

Commit

Permalink
backport fix for bug #2976:
Browse files Browse the repository at this point in the history
Fix RGBA<->RGBA blit that was broken with the optimization from bug #11
id.zeta@yahoo.com
  • Loading branch information
sezero committed Mar 24, 2018
1 parent 4283569 commit db8ae75
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions src/video/SDL_blit_N.c
Expand Up @@ -2039,6 +2039,30 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
}
}

/* blits 32 bit RGBA<->RGBA with both surfaces having the same R,G,B,A fields */
static void Blit4to4CopyAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint32 *src = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip;
Uint32 *dst = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip;

/* RGBA->RGBA, COPY_ALPHA */
while ( height-- ) {
DUFFS_LOOP(
{
*dst = *src;
++dst;
++src;
},
width);
src = (Uint32*)((Uint8*)src + srcskip);
dst = (Uint32*)((Uint8*)dst + dstskip);
}
}

static void BlitNtoN(SDL_BlitInfo *info)
{
int width = info->d_width;
Expand Down Expand Up @@ -2469,12 +2493,21 @@ SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index)
blitfun = table[which].blitfunc;

if(blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
/* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
if ( srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4 &&
srcfmt->Rmask == dstfmt->Rmask &&
srcfmt->Gmask == dstfmt->Gmask &&
srcfmt->Bmask == dstfmt->Bmask ) {
blitfun = Blit4to4MaskAlpha;
if( a_need == COPY_ALPHA ) {
if( srcfmt->Amask == dstfmt->Amask ) {
/* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
blitfun = Blit4to4CopyAlpha;
} else {
blitfun = BlitNtoNCopyAlpha;
}
} else {
/* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
blitfun = Blit4to4MaskAlpha;
}
} else if ( a_need == COPY_ALPHA ) {
blitfun = BlitNtoNCopyAlpha;
}
Expand Down

0 comments on commit db8ae75

Please sign in to comment.