mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 10:36:58 +00:00
Use the same color conversion algorithm as the DIB code (and Windows),
i.e. shifts, not MulDivs. Fix the grayscale formula.
This commit is contained in:
parent
ea4f32c4eb
commit
88372a6aef
|
@ -51,10 +51,13 @@ Colormap X11DRV_PALETTE_PaletteXColormap = 0;
|
||||||
UINT16 X11DRV_PALETTE_PaletteFlags = 0;
|
UINT16 X11DRV_PALETTE_PaletteFlags = 0;
|
||||||
|
|
||||||
static int X11DRV_PALETTE_Redshift = 0; /* to handle abortive X11DRV_PALETTE_VIRTUAL visuals */
|
static int X11DRV_PALETTE_Redshift = 0; /* to handle abortive X11DRV_PALETTE_VIRTUAL visuals */
|
||||||
|
static int X11DRV_PALETTE_Redscale = 0;
|
||||||
static int X11DRV_PALETTE_Redmax = 0;
|
static int X11DRV_PALETTE_Redmax = 0;
|
||||||
static int X11DRV_PALETTE_Greenshift = 0;
|
static int X11DRV_PALETTE_Greenshift = 0;
|
||||||
|
static int X11DRV_PALETTE_Greenscale = 0;
|
||||||
static int X11DRV_PALETTE_Greenmax = 0;
|
static int X11DRV_PALETTE_Greenmax = 0;
|
||||||
static int X11DRV_PALETTE_Blueshift = 0;
|
static int X11DRV_PALETTE_Blueshift = 0;
|
||||||
|
static int X11DRV_PALETTE_Bluescale = 0;
|
||||||
static int X11DRV_PALETTE_Bluemax = 0;
|
static int X11DRV_PALETTE_Bluemax = 0;
|
||||||
static int X11DRV_PALETTE_Graymax = 0;
|
static int X11DRV_PALETTE_Graymax = 0;
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ int *X11DRV_PALETTE_XPixelToPalette = NULL;
|
||||||
|
|
||||||
static BOOL X11DRV_PALETTE_BuildPrivateMap(void);
|
static BOOL X11DRV_PALETTE_BuildPrivateMap(void);
|
||||||
static BOOL X11DRV_PALETTE_BuildSharedMap(void);
|
static BOOL X11DRV_PALETTE_BuildSharedMap(void);
|
||||||
static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, int *shift, int *max);
|
static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, int *shift, int *max, int *scale);
|
||||||
static void X11DRV_PALETTE_FillDefaultColors(void);
|
static void X11DRV_PALETTE_FillDefaultColors(void);
|
||||||
static void X11DRV_PALETTE_FormatSystemPalette(void);
|
static void X11DRV_PALETTE_FormatSystemPalette(void);
|
||||||
static BOOL X11DRV_PALETTE_CheckSysColor(COLORREF c);
|
static BOOL X11DRV_PALETTE_CheckSysColor(COLORREF c);
|
||||||
|
@ -188,9 +191,9 @@ int X11DRV_PALETTE_Init(void)
|
||||||
X11DRV_PALETTE_PaletteXColormap = TSXCreateColormap(gdi_display, root_window,
|
X11DRV_PALETTE_PaletteXColormap = TSXCreateColormap(gdi_display, root_window,
|
||||||
visual, AllocNone);
|
visual, AllocNone);
|
||||||
X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_FIXED;
|
X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_FIXED;
|
||||||
X11DRV_PALETTE_ComputeShifts(visual->red_mask, &X11DRV_PALETTE_Redshift, &X11DRV_PALETTE_Redmax);
|
X11DRV_PALETTE_ComputeShifts(visual->red_mask, &X11DRV_PALETTE_Redshift, &X11DRV_PALETTE_Redmax, &X11DRV_PALETTE_Redscale);
|
||||||
X11DRV_PALETTE_ComputeShifts(visual->green_mask, &X11DRV_PALETTE_Greenshift, &X11DRV_PALETTE_Greenmax);
|
X11DRV_PALETTE_ComputeShifts(visual->green_mask, &X11DRV_PALETTE_Greenshift, &X11DRV_PALETTE_Greenmax, &X11DRV_PALETTE_Greenscale);
|
||||||
X11DRV_PALETTE_ComputeShifts(visual->blue_mask, &X11DRV_PALETTE_Blueshift, &X11DRV_PALETTE_Bluemax);
|
X11DRV_PALETTE_ComputeShifts(visual->blue_mask, &X11DRV_PALETTE_Blueshift, &X11DRV_PALETTE_Bluemax, &X11DRV_PALETTE_Bluescale);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +240,7 @@ void X11DRV_PALETTE_Cleanup(void)
|
||||||
*
|
*
|
||||||
* Calculate conversion parameters for direct mapped visuals
|
* Calculate conversion parameters for direct mapped visuals
|
||||||
*/
|
*/
|
||||||
static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, int *shift, int *max)
|
static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, int *shift, int *max, int *scale)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -253,6 +256,10 @@ static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, int *shift, int
|
||||||
|
|
||||||
*shift = i;
|
*shift = i;
|
||||||
*max = maskbits;
|
*max = maskbits;
|
||||||
|
|
||||||
|
for(i=0;maskbits!=0;i++)
|
||||||
|
maskbits >>= 1;
|
||||||
|
*scale = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -687,22 +694,26 @@ COLORREF X11DRV_PALETTE_ToLogical(int pixel)
|
||||||
|
|
||||||
/* check for hicolor visuals first */
|
/* check for hicolor visuals first */
|
||||||
|
|
||||||
if ( X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_FIXED && !X11DRV_PALETTE_Graymax )
|
if ( (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_FIXED) && !X11DRV_PALETTE_Graymax )
|
||||||
{
|
{
|
||||||
color.red = (pixel >> X11DRV_PALETTE_Redshift) & X11DRV_PALETTE_Redmax;
|
color.red = (pixel >> X11DRV_PALETTE_Redshift) & X11DRV_PALETTE_Redmax;
|
||||||
color.green = (pixel >> X11DRV_PALETTE_Greenshift) & X11DRV_PALETTE_Greenmax;
|
color.green = (pixel >> X11DRV_PALETTE_Greenshift) & X11DRV_PALETTE_Greenmax;
|
||||||
color.blue = (pixel >> X11DRV_PALETTE_Blueshift) & X11DRV_PALETTE_Bluemax;
|
color.blue = (pixel >> X11DRV_PALETTE_Blueshift) & X11DRV_PALETTE_Bluemax;
|
||||||
return RGB(MulDiv(color.red, 255, X11DRV_PALETTE_Redmax),
|
return RGB(color.red << (8-X11DRV_PALETTE_Redscale) |
|
||||||
MulDiv(color.green, 255, X11DRV_PALETTE_Greenmax),
|
color.red >> (2*X11DRV_PALETTE_Redscale-8),
|
||||||
MulDiv(color.blue, 255, X11DRV_PALETTE_Bluemax));
|
color.green << (8-X11DRV_PALETTE_Greenscale) |
|
||||||
|
color.green >> (2*X11DRV_PALETTE_Greenscale-8),
|
||||||
|
color.blue << (8-X11DRV_PALETTE_Bluescale) |
|
||||||
|
color.blue >> (2*X11DRV_PALETTE_Bluescale-8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if we can bypass X */
|
/* check if we can bypass X */
|
||||||
|
|
||||||
if ((screen_depth <= 8) && (pixel < 256) &&
|
if ((screen_depth <= 8) && (pixel < 256) &&
|
||||||
!(X11DRV_PALETTE_PaletteFlags & (X11DRV_PALETTE_VIRTUAL | X11DRV_PALETTE_FIXED)) )
|
!(X11DRV_PALETTE_PaletteFlags & (X11DRV_PALETTE_VIRTUAL | X11DRV_PALETTE_FIXED)) ) {
|
||||||
return ( *(COLORREF*)(COLOR_sysPal +
|
return ( *(COLORREF*)(COLOR_sysPal +
|
||||||
((X11DRV_PALETTE_XPixelToPalette)?X11DRV_PALETTE_XPixelToPalette[pixel]:pixel)) ) & 0x00ffffff;
|
((X11DRV_PALETTE_XPixelToPalette)?X11DRV_PALETTE_XPixelToPalette[pixel]:pixel)) ) & 0x00ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
color.pixel = pixel;
|
color.pixel = pixel;
|
||||||
TSXQueryColor(gdi_display, X11DRV_PALETTE_PaletteXColormap, &color);
|
TSXQueryColor(gdi_display, X11DRV_PALETTE_PaletteXColormap, &color);
|
||||||
|
@ -773,20 +784,20 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
|
||||||
{
|
{
|
||||||
/* grayscale only; return scaled value */
|
/* grayscale only; return scaled value */
|
||||||
GDI_ReleaseObj( hPal );
|
GDI_ReleaseObj( hPal );
|
||||||
return ( (red * 30 + green * 69 + blue * 11) * X11DRV_PALETTE_Graymax) / 25500;
|
return ( (red * 30 + green * 59 + blue * 11) * X11DRV_PALETTE_Graymax) / 25500;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* scale each individually and construct the TrueColor pixel value */
|
/* scale each individually and construct the TrueColor pixel value */
|
||||||
if (X11DRV_PALETTE_Redmax != 255)
|
if (X11DRV_PALETTE_Redscale != 8)
|
||||||
red = MulDiv(red, X11DRV_PALETTE_Redmax, 255);
|
red = red >> (8-X11DRV_PALETTE_Redscale);
|
||||||
if (X11DRV_PALETTE_Greenmax != 255)
|
if (X11DRV_PALETTE_Greenscale != 8)
|
||||||
green = MulDiv(green, X11DRV_PALETTE_Greenmax, 255);
|
green = green >> (8-X11DRV_PALETTE_Greenscale);
|
||||||
if (X11DRV_PALETTE_Bluemax != 255)
|
if (X11DRV_PALETTE_Bluescale != 8)
|
||||||
blue = MulDiv(blue, X11DRV_PALETTE_Bluemax, 255);
|
blue = blue >> (8-X11DRV_PALETTE_Bluescale);
|
||||||
|
|
||||||
GDI_ReleaseObj( hPal );
|
GDI_ReleaseObj( hPal );
|
||||||
return (red << X11DRV_PALETTE_Redshift) | (green << X11DRV_PALETTE_Greenshift) | (blue << X11DRV_PALETTE_Blueshift);
|
return (red << X11DRV_PALETTE_Redshift) | (green << X11DRV_PALETTE_Greenshift) | (blue << X11DRV_PALETTE_Blueshift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue