From: notaz Date: Tue, 15 Nov 2011 23:34:43 +0000 (+0200) Subject: blit: improve BlitNtoNSurfaceAlphaKey for 16bpp X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=211e4bff4e12acc0da1a752980c484604975c396;p=sdl_omap.git blit: improve BlitNtoNSurfaceAlphaKey for 16bpp --- diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 4ecb521..2c52209 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -2641,6 +2641,34 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) unsigned sA = srcfmt->alpha; unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; + if (srcbpp == 2 && srcfmt->Gmask == 0x7e0 && dstbpp == 2 && dstfmt->Gmask == 0x7e0) { + Uint16 *src16 = (Uint16 *)src; + Uint16 *dst16 = (Uint16 *)dst; + sA >>= 3; /* downscale alpha to 5 bits */ + while ( height-- ) { + DUFFS_LOOP4( + { + Uint32 s; + Uint32 d; + s = *src16; + if(sA && s != ckey) { + d = *dst16; + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * sA >> 5; + d &= 0x07e0f81f; + *dst16 = (Uint16)(d | d >> 16); + } + src16++; + dst16++; + }, + width); + src16 += srcskip / 2; + dst16 += dstskip / 2; + } + return; + } + while ( height-- ) { DUFFS_LOOP4( {