Commit 18dc14ed authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

gdi32: Return default palette entries from GetSystemPaletteEntries for non-palette-based devices.

parent 6bcbd1b6
......@@ -371,11 +371,6 @@ static UINT nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXT
return 0;
}
static UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
{
return 0;
}
static UINT nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
{
return DEFAULT_CHARSET;
......
......@@ -370,6 +370,7 @@ extern BOOL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT width, IN
extern LONG nulldrv_GetBitmapBits( HBITMAP bitmap, void *bits, LONG size ) DECLSPEC_HIDDEN;
extern COLORREF nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF nulldrv_GetPixel( PHYSDEV dev, INT x, INT y ) DECLSPEC_HIDDEN;
extern UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries ) DECLSPEC_HIDDEN;
extern BOOL nulldrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert,
void * grad_array, ULONG ngrad, ULONG mode ) DECLSPEC_HIDDEN;
extern INT nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
......
......@@ -426,6 +426,37 @@ UINT WINAPI GetSystemPaletteEntries(
}
/* null driver fallback implementation for GetSystemPaletteEntries */
UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
{
if (entries && start < 256)
{
UINT i;
const RGBQUAD *default_entries;
if (start + count > 256) count = 256 - start;
default_entries = get_default_color_table( 8 );
for (i = 0; i < count; ++i)
{
if (start + i < 10 || start + i >= 246)
{
entries[i].peRed = default_entries[start + i].rgbRed;
entries[i].peGreen = default_entries[start + i].rgbGreen;
entries[i].peBlue = default_entries[start + i].rgbBlue;
}
else
{
entries[i].peRed = 0;
entries[i].peGreen = 0;
entries[i].peBlue = 0;
}
entries[i].peFlags = 0;
}
}
return 0;
}
/***********************************************************************
* GetNearestPaletteIndex [GDI32.@]
*
......
......@@ -191,9 +191,135 @@ static void test_halftone_palette(void)
ReleaseDC( 0, hdc );
}
static void check_system_palette_entries(HDC hdc)
{
PALETTEENTRY entries[256];
PALETTEENTRY defpal[20];
int i, count;
memset( defpal, 0xaa, sizeof(defpal) );
count = GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 20, defpal );
ok( count == 20, "wrong size %u\n", count );
memset( entries, 0x55, sizeof(entries) );
count = GetSystemPaletteEntries( hdc, 0, 256, entries );
ok( count == 0, "wrong size %u\n", count);
for (i = 0; i < 10; i++)
{
ok( entries[i].peRed == defpal[i].peRed &&
entries[i].peGreen == defpal[i].peGreen &&
entries[i].peBlue == defpal[i].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
}
for (i = 10; i < 246; ++i)
{
ok( !entries[i].peRed &&
!entries[i].peGreen &&
!entries[i].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of 0,0,0\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags);
}
for (i = 246; i < 256; i++)
{
int idx = i - 246 + 10;
ok( entries[i].peRed == defpal[idx].peRed &&
entries[i].peGreen == defpal[idx].peGreen &&
entries[i].peBlue == defpal[idx].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
}
memset( entries, 0x55, sizeof(entries) );
count = GetSystemPaletteEntries( hdc, 0, 10, entries );
ok( count == 0, "wrong size %u\n", count);
for (i = 0; i < 10; i++)
{
ok( entries[i].peRed == defpal[i].peRed &&
entries[i].peGreen == defpal[i].peGreen &&
entries[i].peBlue == defpal[i].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
}
memset( entries, 0x55, sizeof(entries) );
count = GetSystemPaletteEntries( hdc, 10, 246, entries );
ok( count == 0, "wrong size %u\n", count);
for (i = 0; i < 236; ++i)
{
ok( !entries[i].peRed &&
!entries[i].peGreen &&
!entries[i].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of 0,0,0\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags);
}
for (i = 236; i < 246; i++)
{
int idx = i - 236 + 10;
ok( entries[i].peRed == defpal[idx].peRed &&
entries[i].peGreen == defpal[idx].peGreen &&
entries[i].peBlue == defpal[idx].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
}
memset( entries, 0x55, sizeof(entries) );
count = GetSystemPaletteEntries( hdc, 246, 10, entries );
ok( count == 0, "wrong size %u\n", count);
for (i = 0; i < 10; i++)
{
int idx = i + 10;
ok( entries[i].peRed == defpal[idx].peRed &&
entries[i].peGreen == defpal[idx].peGreen &&
entries[i].peBlue == defpal[idx].peBlue &&
!entries[i].peFlags,
"%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
}
}
static void test_system_palette_entries(void)
{
HDC hdc;
HDC metafile_dc;
HMETAFILE metafile;
hdc = GetDC(0);
if (!(GetDeviceCaps( hdc, RASTERCAPS ) & RC_PALETTE))
{
check_system_palette_entries(hdc);
}
else
{
skip( "device is palette-based, skipping test\n" );
}
ReleaseDC( 0, hdc );
metafile_dc = CreateMetaFileA(NULL);
check_system_palette_entries(metafile_dc);
metafile = CloseMetaFile(metafile_dc);
DeleteMetaFile(metafile);
}
START_TEST(palette)
{
test_DIB_PAL_COLORS();
test_palette_entries();
test_halftone_palette();
test_system_palette_entries();
}
......@@ -1215,6 +1215,11 @@ UINT X11DRV_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, LPPALE
{
UINT i;
if (!palette_size)
{
dev = GET_NEXT_PHYSDEV(dev, pGetSystemPaletteEntries);
return dev->funcs->pGetSystemPaletteEntries(dev, start, count, entries);
}
if (!entries) return palette_size;
if (start >= palette_size) return 0;
if (start + count >= palette_size) count = palette_size - start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment