Jacek Caban : gdi32: Use NtGdiDoPalette for GetSystemPaletteEntries.
Alexandre Julliard
julliard at winehq.org
Mon Aug 16 18:07:24 CDT 2021
Module: wine
Branch: master
Commit: 1c270965a8c1f2dd9ec72c876a2ebbe8812febcc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=1c270965a8c1f2dd9ec72c876a2ebbe8812febcc
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Aug 16 10:28:00 2021 +0200
gdi32: Use NtGdiDoPalette for GetSystemPaletteEntries.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/objects.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
dlls/gdi32/palette.c | 44 ++++----------------------------------------
dlls/gdi32/tests/palette.c | 2 ++
3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c
index 4f7932be329..38a26afe774 100644
--- a/dlls/gdi32/objects.c
+++ b/dlls/gdi32/objects.c
@@ -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;
+}
diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c
index cd4fac217be..36335083c48 100644
--- a/dlls/gdi32/palette.c
+++ b/dlls/gdi32/palette.c
@@ -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;
diff --git a/dlls/gdi32/tests/palette.c b/dlls/gdi32/tests/palette.c
index 0043f5560c4..126a53310bd 100644
--- a/dlls/gdi32/tests/palette.c
+++ b/dlls/gdi32/tests/palette.c
@@ -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)
More information about the wine-cvs
mailing list