winex11.drv: Get rid of the DIB color table now that it's stored in gdi32.
This commit is contained in:
parent
f7ffbe4581
commit
3cb51cd3c4
|
@ -299,11 +299,11 @@ static int *X11DRV_DIB_GenColorMap( X11DRV_PDEVICE *physDev, int *colorMapping,
|
|||
if (depth == 1) /* Monochrome */
|
||||
{
|
||||
BOOL invert = FALSE;
|
||||
if(physDev && physDev->bitmap && physDev->bitmap->colorTable)
|
||||
{
|
||||
if(!colour_is_brighter(physDev->bitmap->colorTable[1], physDev->bitmap->colorTable[0]))
|
||||
invert = TRUE;
|
||||
}
|
||||
RGBQUAD table[2];
|
||||
|
||||
if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
|
||||
invert = !colour_is_brighter(table[1], table[0]);
|
||||
|
||||
for (i = start; i < end; i++, rgb++)
|
||||
colorMapping[i] = ((rgb->rgbRed + rgb->rgbGreen +
|
||||
rgb->rgbBlue > 255*3/2 && !invert) ||
|
||||
|
@ -323,11 +323,11 @@ static int *X11DRV_DIB_GenColorMap( X11DRV_PDEVICE *physDev, int *colorMapping,
|
|||
if (depth == 1) /* Monochrome */
|
||||
{
|
||||
BOOL invert = FALSE;
|
||||
if(physDev && physDev->bitmap && physDev->bitmap->colorTable)
|
||||
{
|
||||
if(!colour_is_brighter(physDev->bitmap->colorTable[1], physDev->bitmap->colorTable[0]))
|
||||
invert = TRUE;
|
||||
}
|
||||
RGBQUAD table[2];
|
||||
|
||||
if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
|
||||
invert = !colour_is_brighter(table[1], table[0]);
|
||||
|
||||
for (i = start; i < end; i++, rgb++)
|
||||
colorMapping[i] = ((rgb->rgbtRed + rgb->rgbtGreen +
|
||||
rgb->rgbtBlue > 255*3/2 && !invert) ||
|
||||
|
@ -402,84 +402,6 @@ static int *X11DRV_DIB_BuildColorMap( X11DRV_PDEVICE *physDev, WORD coloruse, WO
|
|||
isInfo, colorPtr, 0, colors);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_DIB_BuildColorTable
|
||||
*
|
||||
* Build the dib color table. This either keeps a copy of the bmiColors array if
|
||||
* usage is DIB_RGB_COLORS, or looks up the palette indices if usage is
|
||||
* DIB_PAL_COLORS.
|
||||
* Should not be called for a >8-bit deep bitmap.
|
||||
*/
|
||||
static RGBQUAD *X11DRV_DIB_BuildColorTable( X11DRV_PDEVICE *physDev, WORD coloruse, WORD depth,
|
||||
const BITMAPINFO *info )
|
||||
{
|
||||
RGBQUAD *colorTable;
|
||||
unsigned int colors;
|
||||
int i;
|
||||
BOOL core_info = info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER);
|
||||
|
||||
if (core_info)
|
||||
{
|
||||
colors = 1 << ((const BITMAPCOREINFO*) info)->bmciHeader.bcBitCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = info->bmiHeader.biClrUsed;
|
||||
if (!colors) colors = 1 << info->bmiHeader.biBitCount;
|
||||
}
|
||||
|
||||
if (colors > 256) {
|
||||
ERR("called with >256 colors!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(colorTable = HeapAlloc(GetProcessHeap(), 0, colors * sizeof(RGBQUAD) )))
|
||||
return NULL;
|
||||
|
||||
if(coloruse == DIB_RGB_COLORS)
|
||||
{
|
||||
if (core_info)
|
||||
{
|
||||
/* Convert RGBTRIPLEs to RGBQUADs */
|
||||
for (i=0; i < colors; i++)
|
||||
{
|
||||
colorTable[i].rgbRed = ((const BITMAPCOREINFO*) info)->bmciColors[i].rgbtRed;
|
||||
colorTable[i].rgbGreen = ((const BITMAPCOREINFO*) info)->bmciColors[i].rgbtGreen;
|
||||
colorTable[i].rgbBlue = ((const BITMAPCOREINFO*) info)->bmciColors[i].rgbtBlue;
|
||||
colorTable[i].rgbReserved = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(colorTable, (const BYTE*) info + (WORD) info->bmiHeader.biSize, colors * sizeof(RGBQUAD));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HPALETTE hpal = GetCurrentObject(physDev->hdc, OBJ_PAL);
|
||||
PALETTEENTRY * pal_ents;
|
||||
const WORD *index = (const WORD*) ((const BYTE*) info + (WORD) info->bmiHeader.biSize);
|
||||
int logcolors, entry;
|
||||
|
||||
logcolors = GetPaletteEntries( hpal, 0, 0, NULL );
|
||||
pal_ents = HeapAlloc(GetProcessHeap(), 0, logcolors * sizeof(*pal_ents));
|
||||
logcolors = GetPaletteEntries( hpal, 0, logcolors, pal_ents );
|
||||
|
||||
for(i = 0; i < colors; i++, index++)
|
||||
{
|
||||
entry = *index % logcolors;
|
||||
colorTable[i].rgbRed = pal_ents[entry].peRed;
|
||||
colorTable[i].rgbGreen = pal_ents[entry].peGreen;
|
||||
colorTable[i].rgbBlue = pal_ents[entry].peBlue;
|
||||
colorTable[i].rgbReserved = 0;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pal_ents);
|
||||
}
|
||||
return colorTable;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_DIB_MapColor
|
||||
*/
|
||||
|
@ -4663,7 +4585,6 @@ HBITMAP X11DRV_CreateDIBSection( X11DRV_PDEVICE *physDev, HBITMAP hbitmap,
|
|||
/* create color map */
|
||||
if (dib.dsBm.bmBitsPixel <= 8)
|
||||
{
|
||||
physBitmap->colorTable = X11DRV_DIB_BuildColorTable( physDev, usage, dib.dsBm.bmBitsPixel, bmi );
|
||||
physBitmap->colorMap = X11DRV_DIB_BuildColorMap( physDev,
|
||||
usage, dib.dsBm.bmBitsPixel, bmi,
|
||||
&physBitmap->nColorMap );
|
||||
|
@ -4742,7 +4663,6 @@ void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, DIBSECTION *dib)
|
|||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, physBitmap->colorMap);
|
||||
HeapFree(GetProcessHeap(), 0, physBitmap->colorTable);
|
||||
DeleteCriticalSection(&physBitmap->lock);
|
||||
}
|
||||
|
||||
|
@ -4771,7 +4691,6 @@ UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, c
|
|||
* at least for a 1 bpp dibsection
|
||||
*/
|
||||
X11DRV_DIB_Lock( physBitmap, DIB_Status_AppMod, FALSE );
|
||||
memcpy(physBitmap->colorTable + start, colors, (end - start) * sizeof(RGBQUAD));
|
||||
X11DRV_DIB_GenColorMap( physDev, physBitmap->colorMap, DIB_RGB_COLORS,
|
||||
dib.dsBm.bmBitsPixel,
|
||||
TRUE, colors, start, end );
|
||||
|
@ -4781,23 +4700,6 @@ UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, c
|
|||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetDIBColorTable (X11DRV.@)
|
||||
*/
|
||||
UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, RGBQUAD *colors )
|
||||
{
|
||||
UINT ret = 0;
|
||||
X_PHYSBITMAP *physBitmap = physDev->bitmap;
|
||||
|
||||
if (physBitmap && physBitmap->colorTable && start < physBitmap->nColorMap) {
|
||||
if (start + count > physBitmap->nColorMap) count = physBitmap->nColorMap - start;
|
||||
memcpy(colors, physBitmap->colorTable + start, count * sizeof(RGBQUAD));
|
||||
ret = count;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_DIB_CreateDIBFromBitmap
|
||||
|
|
|
@ -843,7 +843,7 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
|||
switch(spec_type)
|
||||
{
|
||||
case 0x10: /* DIBINDEX */
|
||||
if( X11DRV_GetDIBColorTable( physDev, idx, 1, &quad ) != 1 ) {
|
||||
if( GetDIBColorTable( physDev->hdc, idx, 1, &quad ) != 1 ) {
|
||||
WARN("DIBINDEX(%x) : idx %d is out of bounds, assuming black\n", color , idx);
|
||||
GDI_ReleaseObj( hPal );
|
||||
return 0;
|
||||
|
@ -877,12 +877,12 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
|||
if (physDev && (physDev->depth == 1) )
|
||||
{
|
||||
int white = 1;
|
||||
RGBQUAD table[2];
|
||||
|
||||
GDI_ReleaseObj( hPal );
|
||||
if (physDev->bitmap && physDev->bitmap->colorTable)
|
||||
if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
|
||||
{
|
||||
if(!colour_is_brighter(physDev->bitmap->colorTable[1], physDev->bitmap->colorTable[0]))
|
||||
white = 0;
|
||||
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;
|
||||
|
@ -937,11 +937,12 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
|||
if (physDev && (physDev->depth == 1) )
|
||||
{
|
||||
int white = 1;
|
||||
RGBQUAD table[2];
|
||||
|
||||
GDI_ReleaseObj( hPal );
|
||||
if (physDev->bitmap && physDev->bitmap->colorTable)
|
||||
if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
|
||||
{
|
||||
if(!colour_is_brighter(physDev->bitmap->colorTable[1], physDev->bitmap->colorTable[0]))
|
||||
if(!colour_is_brighter(table[1], table[0]))
|
||||
white = 0;
|
||||
}
|
||||
return (((color >> 16) & 0xff) +
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
@ cdecl GetBitmapBits(long ptr long) X11DRV_GetBitmapBits
|
||||
@ cdecl GetCharWidth(ptr long long ptr) X11DRV_GetCharWidth
|
||||
@ cdecl GetDCOrgEx(ptr ptr) X11DRV_GetDCOrgEx
|
||||
@ cdecl GetDIBColorTable(ptr long long ptr) X11DRV_GetDIBColorTable
|
||||
@ cdecl GetDIBits(ptr long long long ptr ptr long) X11DRV_GetDIBits
|
||||
@ cdecl GetDeviceCaps(ptr long) X11DRV_GetDeviceCaps
|
||||
@ cdecl GetDeviceGammaRamp(ptr ptr) X11DRV_GetDeviceGammaRamp
|
||||
|
|
|
@ -103,7 +103,6 @@ typedef struct
|
|||
XImage *image; /* cached XImage */
|
||||
int *colorMap; /* color map info */
|
||||
int nColorMap;
|
||||
RGBQUAD *colorTable; /* original dib color table converted to rgb values if usage was DIB_PAL_COLORS */
|
||||
CRITICAL_SECTION lock; /* GDI access lock */
|
||||
#ifdef HAVE_LIBXXSHM
|
||||
XShmSegmentInfo shminfo; /* shared memory segment info */
|
||||
|
@ -422,7 +421,6 @@ extern INT X11DRV_LockDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL);
|
|||
extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev,BOOL);
|
||||
|
||||
extern void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, DIBSECTION *dib);
|
||||
extern UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, RGBQUAD *colors );
|
||||
extern void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDevDst,
|
||||
DWORD xSrc, DWORD ySrc, DWORD xDest, DWORD yDest,
|
||||
DWORD width, DWORD height);
|
||||
|
|
Loading…
Reference in New Issue