gdi32: Use NtGdiDoPalette for GetSystemPaletteEntries.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
44313dcb49
commit
1c270965a8
|
@ -550,3 +550,47 @@ BOOL WINAPI AnimatePalette( HPALETTE palette, UINT start, UINT count, const PALE
|
|||
{
|
||||
return NtGdiDoPalette( palette, start, count, (void *)entries, NtGdiAnimatePalette, FALSE );
|
||||
}
|
||||
|
||||
/* first and last 10 entries are the default system palette entries */
|
||||
static const PALETTEENTRY default_system_palette_low[] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00 }, { 0x80, 0x00, 0x00 }, { 0x00, 0x80, 0x00 }, { 0x80, 0x80, 0x00 },
|
||||
{ 0x00, 0x00, 0x80 }, { 0x80, 0x00, 0x80 }, { 0x00, 0x80, 0x80 }, { 0xc0, 0xc0, 0xc0 },
|
||||
{ 0xc0, 0xdc, 0xc0 }, { 0xa6, 0xca, 0xf0 }
|
||||
};
|
||||
static const PALETTEENTRY default_system_palette_high[] =
|
||||
{
|
||||
{ 0xff, 0xfb, 0xf0 }, { 0xa0, 0xa0, 0xa4 }, { 0x80, 0x80, 0x80 }, { 0xff, 0x00, 0x00 },
|
||||
{ 0x00, 0xff, 0x00 }, { 0xff, 0xff, 0x00 }, { 0x00, 0x00, 0xff }, { 0xff, 0x00, 0xff },
|
||||
{ 0x00, 0xff, 0xff }, { 0xff, 0xff, 0xff }
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* GetSystemPaletteEntries (GDI32.@)
|
||||
*
|
||||
* Gets range of palette entries.
|
||||
*/
|
||||
UINT WINAPI GetSystemPaletteEntries( HDC hdc, UINT start, UINT count, PALETTEENTRY *entries )
|
||||
{
|
||||
UINT i, ret;
|
||||
|
||||
ret = NtGdiDoPalette( hdc, start, count, (void *)entries,
|
||||
NtGdiGetSystemPaletteEntries, FALSE );
|
||||
if (ret) return ret;
|
||||
|
||||
/* always fill output, even if hdc is an invalid handle */
|
||||
if (!entries || start >= 256) return 0;
|
||||
if (start + count > 256) count = 256 - start;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (start + i < 10)
|
||||
entries[i] = default_system_palette_low[start + i];
|
||||
else if (start + i >= 246)
|
||||
entries[i] = default_system_palette_high[start + i - 246];
|
||||
else
|
||||
memset( &entries[i], 0, sizeof(entries[i]) );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -333,25 +333,12 @@ UINT WINAPI NtGdiGetSystemPaletteUse( HDC hdc )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetSystemPaletteEntries [GDI32.@]
|
||||
*
|
||||
* Gets range of palette entries.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: Number of entries retrieved from palette
|
||||
* Failure: 0
|
||||
*/
|
||||
UINT WINAPI GetSystemPaletteEntries(
|
||||
HDC hdc, /* [in] Handle of device context */
|
||||
UINT start, /* [in] Index of first entry to be retrieved */
|
||||
UINT count, /* [in] Number of entries to be retrieved */
|
||||
LPPALETTEENTRY entries) /* [out] Array receiving system-palette entries */
|
||||
static UINT get_system_palette_entries( HDC hdc, UINT start, UINT count, PALETTEENTRY *entries )
|
||||
{
|
||||
UINT ret = 0;
|
||||
DC *dc;
|
||||
|
||||
TRACE("hdc=%p,start=%i,count=%i\n", hdc,start,count);
|
||||
TRACE( "hdc=%p,start=%i,count=%i\n", hdc, start, count );
|
||||
|
||||
if ((dc = get_dc_ptr( hdc )))
|
||||
{
|
||||
|
@ -366,31 +353,6 @@ UINT WINAPI GetSystemPaletteEntries(
|
|||
/* null driver fallback implementation for GetSystemPaletteEntries */
|
||||
UINT CDECL 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;
|
||||
}
|
||||
|
||||
|
@ -671,6 +633,8 @@ LONG WINAPI NtGdiDoPalette( HGDIOBJ handle, WORD start, WORD count, void *entrie
|
|||
return set_palette_entries( handle, start, count, entries );
|
||||
case NtGdiGetPaletteEntries:
|
||||
return get_palette_entries( handle, start, count, entries );
|
||||
case NtGdiGetSystemPaletteEntries:
|
||||
return get_system_palette_entries( handle, start, count, entries );
|
||||
default:
|
||||
WARN( "invalid func %u\n", func );
|
||||
return 0;
|
||||
|
|
|
@ -323,6 +323,8 @@ static void test_system_palette_entries(void)
|
|||
|
||||
metafile = CloseMetaFile(metafile_dc);
|
||||
DeleteMetaFile(metafile);
|
||||
|
||||
check_system_palette_entries(ULongToHandle(0xdeadbeef));
|
||||
}
|
||||
|
||||
START_TEST(palette)
|
||||
|
|
Loading…
Reference in New Issue