Jacek Caban : gdi32: Use NtGdiDoPalette for GetPaletteEntries.

Alexandre Julliard julliard at winehq.org
Mon Aug 16 18:07:24 CDT 2021


Module: wine
Branch: master
Commit: ad00037c279de5ee0e795cf46e6fd1018e8ae1ca
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ad00037c279de5ee0e795cf46e6fd1018e8ae1ca

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Aug 16 10:27:30 2021 +0200

gdi32: Use NtGdiDoPalette for GetPaletteEntries.

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/bitblt.c         |  4 ++--
 dlls/gdi32/dib.c            |  4 ++--
 dlls/gdi32/dibdrv/objects.c |  4 ++--
 dlls/gdi32/ntgdi_private.h  |  2 ++
 dlls/gdi32/objects.c        |  8 ++++++++
 dlls/gdi32/palette.c        | 35 +++++++++++++++++++----------------
 include/ntgdi.h             | 10 ++++++++++
 7 files changed, 45 insertions(+), 22 deletions(-)

diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c
index 0024234ac2d..09bb7a4c683 100644
--- a/dlls/gdi32/bitblt.c
+++ b/dlls/gdi32/bitblt.c
@@ -236,8 +236,8 @@ static RGBQUAD get_dc_rgb_color( DC *dc, int color_table_size, COLORREF color )
     {
         PALETTEENTRY pal;
 
-        if (!GetPaletteEntries( dc->hPalette, LOWORD(color), 1, &pal ))
-            GetPaletteEntries( dc->hPalette, 0, 1, &pal );
+        if (!get_palette_entries( dc->hPalette, LOWORD(color), 1, &pal ))
+            get_palette_entries( dc->hPalette, 0, 1, &pal );
         ret.rgbRed   = pal.peRed;
         ret.rgbGreen = pal.peGreen;
         ret.rgbBlue  = pal.peBlue;
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 59725537bbd..738151aa14d 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -261,7 +261,7 @@ static int fill_color_table_from_palette( BITMAPINFO *info, HDC hdc )
     if (!palette) return 0;
 
     memset( palEntry, 0, sizeof(palEntry) );
-    if (!GetPaletteEntries( palette, 0, colors, palEntry ))
+    if (!get_palette_entries( palette, 0, colors, palEntry ))
         return 0;
 
     for (i = 0; i < colors; i++)
@@ -285,7 +285,7 @@ BOOL fill_color_table_from_pal_colors( BITMAPINFO *info, HDC hdc )
 
     if (!colors) return TRUE;
     if (!(palette = GetCurrentObject( hdc, OBJ_PAL ))) return FALSE;
-    if (!(count = GetPaletteEntries( palette, 0, colors, entries ))) return FALSE;
+    if (!(count = get_palette_entries( palette, 0, colors, entries ))) return FALSE;
 
     for (i = 0; i < colors; i++, index++)
     {
diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c
index c5c805ff77e..4e24de0b3aa 100644
--- a/dlls/gdi32/dibdrv/objects.c
+++ b/dlls/gdi32/dibdrv/objects.c
@@ -145,8 +145,8 @@ static COLORREF make_rgb_colorref( DC *dc, const dib_info *dib, COLORREF color,
     {
         PALETTEENTRY pal_ent;
 
-        if (!GetPaletteEntries( dc->hPalette, LOWORD(color), 1, &pal_ent ))
-            GetPaletteEntries( dc->hPalette, 0, 1, &pal_ent );
+        if (!get_palette_entries( dc->hPalette, LOWORD(color), 1, &pal_ent ))
+            get_palette_entries( dc->hPalette, 0, 1, &pal_ent );
         return RGB( pal_ent.peRed, pal_ent.peGreen, pal_ent.peBlue );
     }
 
diff --git a/dlls/gdi32/ntgdi_private.h b/dlls/gdi32/ntgdi_private.h
index ad4872da5ec..d9b016c213f 100644
--- a/dlls/gdi32/ntgdi_private.h
+++ b/dlls/gdi32/ntgdi_private.h
@@ -482,6 +482,8 @@ extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut ) DECLSPE
 /* palette.c */
 extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) DECLSPEC_HIDDEN;
 extern HPALETTE PALETTE_Init(void) DECLSPEC_HIDDEN;
+extern UINT get_palette_entries( HPALETTE hpalette, UINT start, UINT count,
+                                 PALETTEENTRY *entries ) DECLSPEC_HIDDEN;
 
 /* region.c */
 extern BOOL add_rect_to_region( HRGN rgn, const RECT *rect ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c
index 6516ac533f5..cce783d8cfe 100644
--- a/dlls/gdi32/objects.c
+++ b/dlls/gdi32/objects.c
@@ -525,3 +525,11 @@ HPALETTE WINAPI CreatePalette( const LOGPALETTE *palette )
     if (!palette) return 0;
     return NtGdiCreatePaletteInternal( palette, palette->palNumEntries );
 }
+
+/***********************************************************************
+ *           GetPaletteEntries    (GDI32.@)
+ */
+UINT WINAPI GetPaletteEntries( HPALETTE palette, UINT start, UINT count, PALETTEENTRY *entries )
+{
+    return NtGdiDoPalette( palette, start, count, entries, NtGdiGetPaletteEntries, TRUE );
+}
diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c
index c92b4dfb9d5..804d2ecbf92 100644
--- a/dlls/gdi32/palette.c
+++ b/dlls/gdi32/palette.c
@@ -162,20 +162,7 @@ HPALETTE WINAPI NtGdiCreateHalftonePalette( HDC hdc )
 }
 
 
-/***********************************************************************
- * GetPaletteEntries [GDI32.@]
- *
- * Retrieves palette entries.
- *
- * RETURNS
- *    Success: Number of entries from logical palette
- *    Failure: 0
- */
-UINT WINAPI GetPaletteEntries(
-    HPALETTE hpalette,    /* [in]  Handle of logical palette */
-    UINT start,           /* [in]  First entry to receive */
-    UINT count,           /* [in]  Number of entries to receive */
-    LPPALETTEENTRY entries) /* [out] Address of array receiving entries */
+UINT get_palette_entries( HPALETTE hpalette, UINT start, UINT count, PALETTEENTRY *entries )
 {
     PALETTEOBJ * palPtr;
     UINT numEntries;
@@ -495,10 +482,10 @@ COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color )
         else  /* PALETTEINDEX */
             index = LOWORD(color);
 
-        if (!GetPaletteEntries( hpal, index, 1, &entry ))
+        if (!get_palette_entries( hpal, index, 1, &entry ))
         {
             WARN("RGB(%x) : idx %d is out of bounds, assuming NULL\n", color, index );
-            if (!GetPaletteEntries( hpal, 0, 1, &entry )) return CLR_INVALID;
+            if (!get_palette_entries( hpal, 0, 1, &entry )) return CLR_INVALID;
         }
         color = RGB( entry.peRed, entry.peGreen, entry.peBlue );
     }
@@ -695,3 +682,19 @@ BOOL WINAPI NtGdiSetMagicColors( HDC hdc, DWORD magic, ULONG index )
     FIXME( "(%p 0x%08x 0x%08x): stub\n", hdc, magic, index );
     return TRUE;
 }
+
+/*********************************************************************
+ *           NtGdiDoPalette   (win32u.@)
+ */
+LONG WINAPI NtGdiDoPalette( HGDIOBJ handle, WORD start, WORD count, void *entries,
+                            DWORD func, BOOL inbound )
+{
+    switch (func)
+    {
+    case NtGdiGetPaletteEntries:
+        return get_palette_entries( handle, start, count, entries );
+    default:
+        WARN( "invalid func %u\n", func );
+        return 0;
+    }
+}
diff --git a/include/ntgdi.h b/include/ntgdi.h
index 0e9d5cce59a..9da053e10a8 100644
--- a/include/ntgdi.h
+++ b/include/ntgdi.h
@@ -105,6 +105,16 @@ enum
     NtGdiSetMapMode = 8,
 };
 
+enum
+{
+    NtGdiAnimatePalette,
+    NtGdiSetPaletteEntries,
+    NtGdiGetPaletteEntries,
+    NtGdiGetSystemPaletteEntries,
+    NtGdiGetDIBColorTable,
+    NtGdiSetDIBColorTable,
+};
+
 #define MWT_SET  4
 
 /* structs not compatible with native Windows */




More information about the wine-cvs mailing list