# HG changeset patch # User anthony # Date 1293028654 -10800 # Node ID 42c1e9741ed0eeb686150d6e0658f4181b67dd5d # Parent a9e4a2c0600e288c75b5115bdd18802f831277cf 6998323: Unexpected color change after invoking SplashScreen.update() Summary: Fix the blendRGB() function Reviewed-by: art, dcherepanov diff -r a9e4a2c0600e -r 42c1e9741ed0 jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h --- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h Thu Dec 16 21:48:30 2010 +0300 +++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h Wed Dec 22 17:37:34 2010 +0300 @@ -88,27 +88,18 @@ /* blend (lerp between) two rgb quads src and dst alpha is ignored the algorithm: src*alpha+dst*(1-alpha)=(src-dst)*alpha+dst, rb and g are done separately - it's possible to verify that it's almost accurate indeed */ - +*/ INLINE rgbquad_t blendRGB(rgbquad_t dst, rgbquad_t src, rgbquad_t alpha) { - const rgbquad_t dstrb = dst & 0xFF00FF; - const rgbquad_t dstg = dst & 0xFF00; - const rgbquad_t srcrb = src & 0xFF00FF; - const rgbquad_t srcg = src & 0xFF00; - - rgbquad_t drb = srcrb - dstrb; - rgbquad_t dg = srcg - dstg; + const rgbquad_t a = alpha; + const rgbquad_t a1 = 0xFF - alpha; - alpha += 1; - - drb *= alpha; - dg *= alpha; - drb >>= 8; - dg >>= 8; - - return ((drb + dstrb) & 0xFF00FF) | ((dg + dstg) & 0xFF00); + return MAKE_QUAD( + (rgbquad_t)((QUAD_RED(src) * a + QUAD_RED(dst) * a1) / 0xFF), + (rgbquad_t)((QUAD_GREEN(src) * a + QUAD_GREEN(dst) * a1) / 0xFF), + (rgbquad_t)((QUAD_BLUE(src) * a + QUAD_BLUE(dst) * a1) / 0xFF), + 0); } /* scales rgb quad by alpha. basically similar to what's above. src alpha is retained.