Commit a92ab086 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

winex11.drv: Support reporting emulated display depth.

parent cad10246
......@@ -4061,7 +4061,7 @@ static void test_create_device_from_clipper1(void)
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
surface_desc.ddpfPixelFormat.dwRGBBitCount);
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
......@@ -4240,7 +4240,7 @@ static void test_create_device_from_clipper2(void)
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
surface_desc.ddpfPixelFormat.dwRGBBitCount);
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
......@@ -4418,7 +4418,7 @@ static void test_create_device_from_clipper3(void)
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x).\n", hr);
todo_wine ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16bpp, got %ubpp.\n",
surface_desc.ddpfPixelFormat.dwRGBBitCount);
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
......
......@@ -297,8 +297,6 @@ static void _expect_dm(INT line, const DEVMODEA *expected, const CHAR *device, D
ok_(__FILE__, line)((dm.dmFields & expected->dmFields) == expected->dmFields,
"Device %s test %d expect dmFields to contain %#x, got %#x\n", device, test, expected->dmFields, dm.dmFields);
/* Wine doesn't support changing color depth yet */
todo_wine_if(expected->dmFields & DM_BITSPERPEL && expected->dmBitsPerPel != 32 && expected->dmBitsPerPel != 24)
ok_(__FILE__, line)(!(expected->dmFields & DM_BITSPERPEL) || dm.dmBitsPerPel == expected->dmBitsPerPel,
"Device %s test %d expect dmBitsPerPel %u, got %u\n", device, test, expected->dmBitsPerPel, dm.dmBitsPerPel);
ok_(__FILE__, line)(!(expected->dmFields & DM_PELSWIDTH) || dm.dmPelsWidth == expected->dmPelsWidth,
......@@ -696,7 +694,6 @@ static void test_ChangeDisplaySettingsEx(void)
dm.dmSize = sizeof(dm);
res = EnumDisplaySettingsA(devices[device].name, ENUM_CURRENT_SETTINGS, &dm);
ok(res, "Device %s EnumDisplaySettingsA failed, error %#x.\n", devices[device].name, GetLastError());
todo_wine_if(depths[test] != 32)
ok(dm.dmBitsPerPel == depths[test], "Device %s expect dmBitsPerPel %u, got %u.\n",
devices[device].name, depths[test], dm.dmBitsPerPel);
/* 2008 resets to the resolution in the registry. Newer versions of Windows doesn't
......
......@@ -45,6 +45,16 @@ struct x11drv_display_setting
DEVMODEW desired_mode;
};
struct x11drv_display_depth
{
struct list entry;
ULONG_PTR display_id;
DWORD depth;
};
/* Display device emulated depth list, protected by modes_section */
static struct list x11drv_display_depth_list = LIST_INIT(x11drv_display_depth_list);
/* All Windows drivers seen so far either support 32 bit depths, or 24 bit depths, but never both. So if we have
* a 32 bit framebuffer, report 32 bit bpps, otherwise 24 bit ones.
*/
......@@ -405,6 +415,54 @@ static int mode_compare(const void *p1, const void *p2)
return a->u1.s2.dmDisplayOrientation - b->u1.s2.dmDisplayOrientation;
}
static void set_display_depth(ULONG_PTR display_id, DWORD depth)
{
struct x11drv_display_depth *display_depth;
EnterCriticalSection(&modes_section);
LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry)
{
if (display_depth->display_id == display_id)
{
display_depth->depth = depth;
LeaveCriticalSection(&modes_section);
return;
}
}
display_depth = heap_alloc(sizeof(*display_depth));
if (!display_depth)
{
ERR("Failed to allocate memory.\n");
LeaveCriticalSection(&modes_section);
return;
}
display_depth->display_id = display_id;
display_depth->depth = depth;
list_add_head(&x11drv_display_depth_list, &display_depth->entry);
LeaveCriticalSection(&modes_section);
}
static DWORD get_display_depth(ULONG_PTR display_id)
{
struct x11drv_display_depth *display_depth;
DWORD depth;
EnterCriticalSection(&modes_section);
LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry)
{
if (display_depth->display_id == display_id)
{
depth = display_depth->depth;
LeaveCriticalSection(&modes_section);
return depth;
}
}
LeaveCriticalSection(&modes_section);
return screen_bpp;
}
/***********************************************************************
* EnumDisplaySettingsEx (X11DRV.@)
*
......@@ -434,6 +492,10 @@ BOOL CDECL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmo
ERR("Failed to get %s current display settings.\n", wine_dbgstr_w(name));
return FALSE;
}
if (!is_detached_mode(devmode))
devmode->dmBitsPerPel = get_display_depth(id);
goto done;
}
......@@ -842,6 +904,8 @@ static LONG apply_display_settings(struct x11drv_display_setting *displays, INT
full_mode->u1.s2.dmDisplayOrientation);
ret = handler.set_current_mode(displays[display_idx].id, full_mode);
if (attached_mode && ret == DISP_CHANGE_SUCCESSFUL)
set_display_depth(displays[display_idx].id, full_mode->dmBitsPerPel);
free_full_mode(full_mode);
if (ret != DISP_CHANGE_SUCCESSFUL)
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment