From 2ee20ffcdb29dbc25119ab2a3c069179aee60c60 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Wed, 22 Dec 2010 17:37:34 +0300 Subject: [PATCH] 6998323: Unexpected color change after invoking SplashScreen.update() Fix the blendRGB() function Reviewed-by: art, dcherepanov --- .../awt/splashscreen/splashscreen_gfx_impl.h | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h index f2f367c6dfa..a0fd446e94a 100644 --- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h +++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h @@ -88,27 +88,18 @@ ditherColor(rgbquad_t value, ImageFormat * format, int row, int col) /* 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; + const rgbquad_t a = alpha; + const rgbquad_t a1 = 0xFF - alpha; - rgbquad_t drb = srcrb - dstrb; - rgbquad_t dg = srcg - dstg; - - 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.