From e3d6da3d4b0dbc26736119289bc58cff44ed8d99 Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Fri, 14 Apr 2000 14:50:55 +0000 Subject: [PATCH] Compositing work: fix 16bpp color shift and remove unneeded logic. r=blizzard --- gfx/src/gtk/nsImageGTK.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/gfx/src/gtk/nsImageGTK.cpp b/gfx/src/gtk/nsImageGTK.cpp index 2c83d4af380e..950696b558d6 100644 --- a/gfx/src/gtk/nsImageGTK.cpp +++ b/gfx/src/gtk/nsImageGTK.cpp @@ -450,7 +450,15 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext, } } } - + + unsigned redScale, greenScale, blueScale, redFill, greenFill, blueFill; + redScale = 8-visual->red_prec; + greenScale = 8-visual->green_prec; + blueScale = 8-visual->blue_prec; + redFill = 0xff>>visual->red_prec; + greenFill = 0xff>>visual->green_prec; + blueFill = 0xff>>visual->blue_prec; + for (int row=0; rowheight; row++) { unsigned char *ptr = (unsigned char *)ximage->data + row*ximage->bytes_per_line; @@ -512,11 +520,11 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext, *target++ = ((pix&visual->blue_mask)>>visual->blue_shift); } else { *target++ = - ((pix&visual->red_mask)>>visual->red_shift)<<(8-visual->red_prec); + redFill|((pix&visual->red_mask)>>visual->red_shift)<green_mask)>>visual->green_shift)<<(8-visual->green_prec); + greenFill|((pix&visual->green_mask)>>visual->green_shift)<blue_mask)>>visual->blue_shift)<<(8-visual->blue_prec); + blueFill|((pix&visual->blue_mask)>>visual->blue_shift)<>8); - targetRow[3*i+1] = MIN(255, (targetRow[3*i+1]*(255-alphaRow[i]) + - imageRow[3*i+1]*alphaRow[i])>>8); - targetRow[3*i+2] = MIN(255, (targetRow[3*i+2]*(255-alphaRow[i]) + - imageRow[3*i+2]*alphaRow[i])>>8); + targetRow[3*i] = (targetRow[3*i]*(255-alphaRow[i]) + + imageRow[3*i]*alphaRow[i])>>8; + targetRow[3*i+1] = (targetRow[3*i+1]*(255-alphaRow[i]) + + imageRow[3*i+1]*alphaRow[i])>>8; + targetRow[3*i+2] = (targetRow[3*i+2]*(255-alphaRow[i]) + + imageRow[3*i+2]*alphaRow[i])>>8; } }