winex11: Fix support for PALETTEINDEX mapping and get rid of DIBINDEX support.
This commit is contained in:
parent
b88b6b74f0
commit
c123c2f87a
|
@ -882,39 +882,26 @@ static inline BOOL colour_is_brighter(RGBQUAD c1, RGBQUAD c2)
|
||||||
COLORREF X11DRV_PALETTE_GetColor( X11DRV_PDEVICE *physDev, COLORREF color )
|
COLORREF X11DRV_PALETTE_GetColor( X11DRV_PDEVICE *physDev, COLORREF color )
|
||||||
{
|
{
|
||||||
HPALETTE hPal = GetCurrentObject(physDev->dev.hdc, OBJ_PAL );
|
HPALETTE hPal = GetCurrentObject(physDev->dev.hdc, OBJ_PAL );
|
||||||
unsigned char spec_type = color >> 24;
|
|
||||||
unsigned idx = color & 0xffff;
|
|
||||||
PALETTEENTRY entry;
|
PALETTEENTRY entry;
|
||||||
RGBQUAD quad;
|
|
||||||
|
|
||||||
switch(spec_type)
|
if (color & (1 << 24)) /* PALETTEINDEX */
|
||||||
{
|
{
|
||||||
case 2: /* PALETTERGB */
|
unsigned int idx = LOWORD(color);
|
||||||
idx = GetNearestPaletteIndex( hPal, color );
|
if (!GetPaletteEntries( hPal, idx, 1, &entry )) return 0;
|
||||||
/* fall through to PALETTEINDEX */
|
|
||||||
|
|
||||||
case 1: /* PALETTEINDEX */
|
|
||||||
if (!GetPaletteEntries( hPal, idx, 1, &entry ))
|
|
||||||
{
|
|
||||||
WARN("PALETTEINDEX(%x) : idx %d is out of bounds, assuming black\n", color, idx);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return RGB( entry.peRed, entry.peGreen, entry.peBlue );
|
return RGB( entry.peRed, entry.peGreen, entry.peBlue );
|
||||||
|
|
||||||
case 0x10: /* DIBINDEX */
|
|
||||||
if( GetDIBColorTable( physDev->dev.hdc, idx, 1, &quad ) != 1 ) {
|
|
||||||
WARN("DIBINDEX(%x) : idx %d is out of bounds, assuming black\n", color , idx);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return RGB( quad.rgbRed, quad.rgbGreen, quad.rgbBlue );
|
|
||||||
|
|
||||||
default:
|
|
||||||
color &= 0xffffff;
|
|
||||||
/* fall through to RGB */
|
|
||||||
|
|
||||||
case 0: /* RGB */
|
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (color >> 24 == 2) /* PALETTERGB */
|
||||||
|
{
|
||||||
|
unsigned int idx = GetNearestPaletteIndex( hPal, color & 0xffffff );
|
||||||
|
if (!GetPaletteEntries( hPal, idx, 1, &entry )) return 0;
|
||||||
|
return RGB( entry.peRed, entry.peGreen, entry.peBlue );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color >> 16 == 0x10ff) /* DIBINDEX */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return color & 0xffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -926,7 +913,6 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
||||||
{
|
{
|
||||||
WORD index = 0;
|
WORD index = 0;
|
||||||
HPALETTE hPal = GetCurrentObject(physDev->dev.hdc, OBJ_PAL );
|
HPALETTE hPal = GetCurrentObject(physDev->dev.hdc, OBJ_PAL );
|
||||||
unsigned char spec_type = color >> 24;
|
|
||||||
int *mapping = palette_get_mapping( hPal );
|
int *mapping = palette_get_mapping( hPal );
|
||||||
PALETTEENTRY entry;
|
PALETTEENTRY entry;
|
||||||
ColorShifts *shifts = &X11DRV_PALETTE_default_shifts;
|
ColorShifts *shifts = &X11DRV_PALETTE_default_shifts;
|
||||||
|
@ -939,47 +925,35 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
||||||
/* there is no colormap limitation; we are going to have to compute
|
/* there is no colormap limitation; we are going to have to compute
|
||||||
* the pixel value from the visual information stored earlier
|
* the pixel value from the visual information stored earlier
|
||||||
*/
|
*/
|
||||||
|
unsigned long red, green, blue;
|
||||||
|
|
||||||
unsigned long red, green, blue;
|
if (color & (1 << 24)) /* PALETTEINDEX */
|
||||||
unsigned idx = color & 0xffff;
|
|
||||||
|
|
||||||
switch(spec_type)
|
|
||||||
{
|
{
|
||||||
case 0x10: /* DIBINDEX */
|
unsigned int idx = LOWORD( color );
|
||||||
color = X11DRV_PALETTE_GetColor( physDev, color );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: /* PALETTEINDEX */
|
|
||||||
if (!GetPaletteEntries( hPal, idx, 1, &entry ))
|
if (!GetPaletteEntries( hPal, idx, 1, &entry ))
|
||||||
{
|
{
|
||||||
WARN("PALETTEINDEX(%x) : idx %d is out of bounds, assuming black\n", color, idx);
|
WARN("PALETTEINDEX(%x) : idx %d is out of bounds, assuming black\n", color, idx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (mapping) return mapping[idx];
|
if (mapping) return mapping[idx];
|
||||||
color = RGB( entry.peRed, entry.peGreen, entry.peBlue );
|
red = entry.peRed;
|
||||||
break;
|
green = entry.peGreen;
|
||||||
|
blue = entry.peBlue;
|
||||||
default:
|
}
|
||||||
color &= 0xffffff;
|
else if (color >> 16 == 0x10ff) /* DIBINDEX */
|
||||||
/* fall through to RGB */
|
{
|
||||||
|
return 0;
|
||||||
case 0: /* RGB */
|
}
|
||||||
if (physDev->depth == 1)
|
else /* RGB */
|
||||||
{
|
{
|
||||||
int white = 1;
|
if (physDev->depth == 1)
|
||||||
RGBQUAD table[2];
|
return (((color >> 16) & 0xff) +
|
||||||
|
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
|
||||||
if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
|
red = GetRValue( color );
|
||||||
{
|
green = GetGValue( color );
|
||||||
if(!colour_is_brighter(table[1], table[0])) white = 0;
|
blue = GetBValue( color );
|
||||||
}
|
}
|
||||||
return (((color >> 16) & 0xff) +
|
|
||||||
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? white : 1 - white;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
red = GetRValue(color); green = GetGValue(color); blue = GetBValue(color);
|
|
||||||
|
|
||||||
if (X11DRV_PALETTE_Graymax)
|
if (X11DRV_PALETTE_Graymax)
|
||||||
{
|
{
|
||||||
|
@ -1013,51 +987,33 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
||||||
if (!mapping)
|
if (!mapping)
|
||||||
WARN("Palette %p is not realized\n", hPal);
|
WARN("Palette %p is not realized\n", hPal);
|
||||||
|
|
||||||
switch(spec_type) /* we have to peruse DC and system palette */
|
if (color & (1 << 24)) /* PALETTEINDEX */
|
||||||
{
|
{
|
||||||
default:
|
index = LOWORD( color );
|
||||||
color &= 0xffffff;
|
if (!GetPaletteEntries( hPal, index, 1, &entry ))
|
||||||
/* fall through to RGB */
|
WARN("PALETTEINDEX(%x) : index %i is out of bounds\n", color, index);
|
||||||
|
else if (mapping) index = mapping[index];
|
||||||
|
}
|
||||||
|
else if (color >> 24 == 2) /* PALETTERGB */
|
||||||
|
{
|
||||||
|
index = GetNearestPaletteIndex( hPal, color );
|
||||||
|
if (mapping) index = mapping[index];
|
||||||
|
}
|
||||||
|
else if (color >> 16 == 0x10ff) /* DIBINDEX */
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else /* RGB */
|
||||||
|
{
|
||||||
|
if (physDev->depth == 1)
|
||||||
|
return (((color >> 16) & 0xff) +
|
||||||
|
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
|
||||||
|
|
||||||
case 0: /* RGB */
|
EnterCriticalSection( &palette_cs );
|
||||||
if (physDev->depth == 1)
|
index = X11DRV_SysPaletteLookupPixel( color & 0xffffff, FALSE);
|
||||||
{
|
if (X11DRV_PALETTE_PaletteToXPixel) index = X11DRV_PALETTE_PaletteToXPixel[index];
|
||||||
int white = 1;
|
LeaveCriticalSection( &palette_cs );
|
||||||
RGBQUAD table[2];
|
}
|
||||||
|
|
||||||
if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
|
|
||||||
{
|
|
||||||
if(!colour_is_brighter(table[1], table[0]))
|
|
||||||
white = 0;
|
|
||||||
}
|
|
||||||
return (((color >> 16) & 0xff) +
|
|
||||||
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? white : 1 - white;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnterCriticalSection( &palette_cs );
|
|
||||||
index = X11DRV_SysPaletteLookupPixel( color, FALSE);
|
|
||||||
if (X11DRV_PALETTE_PaletteToXPixel) index = X11DRV_PALETTE_PaletteToXPixel[index];
|
|
||||||
LeaveCriticalSection( &palette_cs );
|
|
||||||
|
|
||||||
/* TRACE(palette,"RGB(%lx) -> pixel %i\n", color, index);
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case 1: /* PALETTEINDEX */
|
|
||||||
index = color & 0xffff;
|
|
||||||
if (!GetPaletteEntries( hPal, index, 1, &entry ))
|
|
||||||
WARN("PALETTEINDEX(%x) : index %i is out of bounds\n", color, index);
|
|
||||||
else if (mapping) index = mapping[index];
|
|
||||||
|
|
||||||
/* TRACE(palette,"PALETTEINDEX(%04x) -> pixel %i\n", (WORD)color, index);
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case 2: /* PALETTERGB */
|
|
||||||
index = GetNearestPaletteIndex( hPal, color );
|
|
||||||
if (mapping) index = mapping[index];
|
|
||||||
/* TRACE(palette,"PALETTERGB(%lx) -> pixel %i\n", color, index);
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue