Test that passing the bitmap object from display DCs to GetDIBits() should succeed.
From: Zhiyi Zhang zzhang@codeweavers.com
Test that passing the bitmap object from display DCs to GetDIBits() should succeed.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54381 --- dlls/user32/tests/monitor.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index d172eb900df..ff9c6f47ed7 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -2227,6 +2227,9 @@ static void test_handles(void) #define check_display_dc(a, b, c) _check_display_dc(__LINE__, a, b, c) static void _check_display_dc(INT line, HDC hdc, const DEVMODEA *dm, BOOL allow_todo) { + unsigned char buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])] = {0}; + BITMAPINFO *bmi = (BITMAPINFO *)buffer; + DIBSECTION dib; BITMAP bitmap; HBITMAP hbmp; INT value; @@ -2265,6 +2268,19 @@ static void _check_display_dc(INT line, HDC hdc, const DEVMODEA *dm, BOOL allow_
hbmp = GetCurrentObject(hdc, OBJ_BITMAP); ok_(__FILE__, line)(!!hbmp, "GetCurrentObject failed, error %#lx.\n", GetLastError()); + + /* Expect hbmp to be a bitmap, not a DIB when GetObjectA() succeeds */ + value = GetObjectA(hbmp, sizeof(dib), &dib); + ok(!value || value == sizeof(BITMAP), "GetObjectA failed, value %d.\n", value); + + /* Expect GetDIBits() to succeed */ + bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + value = GetDIBits(hdc, hbmp, 0, 0, NULL, (LPBITMAPINFO)bmi, DIB_RGB_COLORS); + todo_wine + ok(value, "GetDIBits failed, error %#lx.\n", GetLastError()); + todo_wine + ok(bmi->bmiHeader.biCompression == BI_BITFIELDS, "Got unexpected biCompression %lu.\n", bmi->bmiHeader.biCompression); + ret = GetObjectA(hbmp, sizeof(bitmap), &bitmap); /* GetObjectA fails on Win7 and older */ if (ret)
From: Zhiyi Zhang zzhang@codeweavers.com
TightVNC viewer passes the bitmap object from display DCs to GetDIBits() and expect it to succeed. So merely a bitmap handle no longer suffices. Thus create a real bitmap instead.
Fix a regression from 546cbdc.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54381 --- dlls/user32/tests/monitor.c | 3 --- dlls/win32u/dc.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index ff9c6f47ed7..e93a84242c4 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -2276,9 +2276,7 @@ static void _check_display_dc(INT line, HDC hdc, const DEVMODEA *dm, BOOL allow_ /* Expect GetDIBits() to succeed */ bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); value = GetDIBits(hdc, hbmp, 0, 0, NULL, (LPBITMAPINFO)bmi, DIB_RGB_COLORS); - todo_wine ok(value, "GetDIBits failed, error %#lx.\n", GetLastError()); - todo_wine ok(bmi->bmiHeader.biCompression == BI_BITFIELDS, "Got unexpected biCompression %lu.\n", bmi->bmiHeader.biCompression);
ret = GetObjectA(hbmp, sizeof(bitmap), &bitmap); @@ -2292,7 +2290,6 @@ static void _check_display_dc(INT line, HDC hdc, const DEVMODEA *dm, BOOL allow_ todo_wine ok_(__FILE__, line)(bitmap.bmHeight == GetSystemMetrics(SM_CYVIRTUALSCREEN), "Expected bmHeight %d, got %d.\n", GetSystemMetrics(SM_CYVIRTUALSCREEN), bitmap.bmHeight); - todo_wine ok_(__FILE__, line)(bitmap.bmBitsPixel == 32, "Expected bmBitsPixel %d, got %d.\n", 32, bitmap.bmBitsPixel); ok_(__FILE__, line)(bitmap.bmWidthBytes == get_bitmap_stride(bitmap.bmWidth, bitmap.bmBitsPixel), diff --git a/dlls/win32u/dc.c b/dlls/win32u/dc.c index 2b8a56de5bd..16920e08d33 100644 --- a/dlls/win32u/dc.c +++ b/dlls/win32u/dc.c @@ -278,7 +278,7 @@ void free_dc_ptr( DC *dc ) if (dc->hBitmap) { if (dc->is_display) - NtGdiDeleteClientObj( dc->hBitmap ); + NtGdiDeleteObjectApp( dc->hBitmap ); else GDI_dec_ref_count( dc->hBitmap ); } @@ -731,7 +731,7 @@ HDC WINAPI NtGdiOpenDCW( UNICODE_STRING *device, const DEVMODEW *devmode, UNICOD hdc = dc->hSelf;
if (is_display) - dc->hBitmap = NtGdiCreateClientObj( NTGDI_OBJ_SURF ); + dc->hBitmap = NtGdiCreateCompatibleBitmap( hdc, 1, 1 ); else dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
This merge request was approved by Huw Davies.