From 211e4bff4e12acc0da1a752980c484604975c396 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 16 Nov 2011 01:34:43 +0200 Subject: [PATCH] blit: improve BlitNtoNSurfaceAlphaKey for 16bpp --- src/video/SDL_blit_A.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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( { -- 2.39.5