From 3dbe180ea554ee6156c206936ced87f3a6b7b2da Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 27 May 2023 18:42:09 +0200 Subject: [PATCH] win32u: Extend NtGdiSetDIBitsToDeviceInternal for SetDIBits implementation. --- dlls/gdi32/dc.c | 15 +++++++++++++++ dlls/win32u/dib.c | 29 +++++++---------------------- dlls/win32u/gdiobj.c | 1 - dlls/win32u/win32u.spec | 1 - dlls/win32u/win32u_private.h | 3 --- dlls/win32u/wrappers.c | 8 -------- dlls/winex11.drv/bitblt.c | 4 +++- 7 files changed, 25 insertions(+), 36 deletions(-) diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 9a33e343f94..368a38db788 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -1970,6 +1970,21 @@ BOOL WINAPI GdiAlphaBlend( HDC hdc_dst, int x_dst, int y_dst, int width_dst, int *(DWORD *)&blend_function, 0 /* FIXME */ ); } +/****************************************************************************** + * SetDIBits (GDI32.@) + * + * Sets pixels in a bitmap using colors from DIB. + */ +INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan, + UINT lines, const void *bits, const BITMAPINFO *info, + UINT coloruse ) +{ + /* Wine-specific: pass hbitmap to NtGdiSetDIBitsToDeviceInternal */ + return NtGdiSetDIBitsToDeviceInternal( hdc, 0, 0, 0, 0, 0, 0, + startscan, lines, bits, info, coloruse, + 0, 0, FALSE, hbitmap ); +} + /*********************************************************************** * SetDIBitsToDevice (GDI32.@) */ diff --git a/dlls/win32u/dib.c b/dlls/win32u/dib.c index 64f96b268c9..7b6b364fb71 100644 --- a/dlls/win32u/dib.c +++ b/dlls/win32u/dib.c @@ -655,27 +655,10 @@ INT WINAPI NtGdiStretchDIBitsInternal( HDC hdc, INT xDst, INT yDst, INT widthDst } -/****************************************************************************** - * SetDIBits [GDI32.@] - * - * Sets pixels in a bitmap using colors from DIB. - * - * PARAMS - * hdc [I] Handle to device context - * hbitmap [I] Handle to bitmap - * startscan [I] Starting scan line - * lines [I] Number of scan lines - * bits [I] Array of bitmap bits - * info [I] Address of structure with data - * coloruse [I] Type of color indexes to use - * - * RETURNS - * Success: Number of scan lines copied - * Failure: 0 - */ -INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan, - UINT lines, LPCVOID bits, const BITMAPINFO *info, - UINT coloruse ) +/* Sets pixels in a bitmap using colors from DIB, see SetDIBits */ +static int set_di_bits( HDC hdc, HBITMAP hbitmap, UINT startscan, + UINT lines, LPCVOID bits, const BITMAPINFO *info, + UINT coloruse ) { BITMAPOBJ *bitmap; char src_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; @@ -913,6 +896,8 @@ INT WINAPI NtGdiSetDIBitsToDeviceInternal( HDC hdc, INT xDest, INT yDest, DWORD INT ret = 0; DC *dc; + if (xform) return set_di_bits( hdc, xform, startscan, lines, bits, bmi, coloruse ); + if (!bits) return 0; if (!bitmapinfo_from_user_bitmapinfo( info, bmi, coloruse, TRUE )) { @@ -1468,7 +1453,7 @@ HBITMAP WINAPI NtGdiCreateDIBitmapInternal( HDC hdc, INT width, INT height, DWOR { if (init & CBM_INIT) { - if (SetDIBits( hdc, handle, 0, height, bits, data, coloruse ) == 0) + if (set_di_bits( hdc, handle, 0, height, bits, data, coloruse ) == 0) { NtGdiDeleteObjectApp( handle ); handle = 0; diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index be8d3099a49..22cd7dd03ba 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1030,7 +1030,6 @@ BOOL WINAPI NtGdiSetColorAdjustment( HDC hdc, const COLORADJUSTMENT *ca ) static struct unix_funcs unix_funcs = { - SetDIBits, __wine_get_file_outline_text_metric, __wine_get_icm_profile, __wine_send_input, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 219442c30eb..c90505e7d17 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1324,6 +1324,5 @@ @ cdecl __wine_send_input(long ptr ptr) # gdi32 -@ stdcall SetDIBits(long long long long ptr ptr long) @ cdecl __wine_get_icm_profile(long long ptr ptr) @ cdecl __wine_get_file_outline_text_metric(wstr ptr) diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 7b09ff9aa37..3b181fe3121 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -35,9 +35,6 @@ struct unix_funcs { /* Wine-specific functions */ - INT (WINAPI *pSetDIBits)( HDC hdc, HBITMAP hbitmap, UINT startscan, - UINT lines, const void *bits, const BITMAPINFO *info, - UINT coloruse ); BOOL (CDECL *get_file_outline_text_metric)( const WCHAR *path, OUTLINETEXTMETRICW *otm ); BOOL (CDECL *get_icm_profile)( HDC hdc, BOOL allow_default, DWORD *size, WCHAR *filename ); BOOL (CDECL *wine_send_input)( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput ); diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 0327416e018..9e013c64b59 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -24,14 +24,6 @@ static const struct unix_funcs *unix_funcs; -INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan, - UINT lines, const void *bits, const BITMAPINFO *info, - UINT coloruse ) -{ - if (!unix_funcs) return 0; - return unix_funcs->pSetDIBits( hdc, hbitmap, startscan, lines, bits, info, coloruse ); -} - BOOL CDECL __wine_get_icm_profile( HDC hdc, BOOL allow_default, DWORD *size, WCHAR *filename ) { if (!unix_funcs) return FALSE; diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 10388a1cc8f..19fc0b0887c 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1497,7 +1497,9 @@ Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const BITMAPIN { if (src_info->bmiHeader.biBitCount == 1 && !src_info->bmiHeader.biClrUsed) memcpy( src_info->bmiColors, default_colortable, sizeof(default_colortable) ); - SetDIBits( hdc, dib, 0, abs(info->bmiHeader.biHeight), bits->ptr, src_info, coloruse ); + NtGdiSetDIBitsToDeviceInternal( hdc, 0, 0, 0, 0, 0, 0, 0, + abs(info->bmiHeader.biHeight), bits->ptr, src_info, coloruse, + 0, 0, FALSE, dib ); /* SetDIBits */ dst_bits.free = NULL; dst_bits.is_copy = TRUE; err = put_pixmap_image( pixmap, vis, dst_info, &dst_bits ); -- 2.11.4.GIT