d3d9/tests: The device restores the mode settings from the registry.
This commit is contained in:
parent
a5d569934f
commit
7fb22f502e
|
@ -3900,56 +3900,115 @@ done:
|
|||
|
||||
static void test_mode_change(void)
|
||||
{
|
||||
RECT fullscreen_rect, focus_rect, r;
|
||||
RECT d3d_rect, focus_rect, r;
|
||||
struct device_desc device_desc;
|
||||
IDirect3DSurface9 *backbuffer;
|
||||
IDirect3DDevice9 *device;
|
||||
D3DSURFACE_DESC desc;
|
||||
IDirect3D9 *d3d9;
|
||||
DEVMODEW devmode;
|
||||
UINT refcount;
|
||||
ULONG refcount;
|
||||
UINT adapter_mode_count, i;
|
||||
HRESULT hr;
|
||||
DWORD ret;
|
||||
LONG change_ret;
|
||||
D3DDISPLAYMODE d3ddm;
|
||||
DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
|
||||
|
||||
focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
|
||||
device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
|
||||
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
ok(!!d3d9, "Failed to create a D3D object.\n");
|
||||
|
||||
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
|
||||
GetWindowRect(focus_window, &focus_rect);
|
||||
|
||||
device_desc.device_window = device_window;
|
||||
device_desc.width = registry_mode.dmPelsWidth;
|
||||
device_desc.height = registry_mode.dmPelsHeight;
|
||||
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||
if (!(device = create_device(d3d9, focus_window, &device_desc)))
|
||||
adapter_mode_count = IDirect3D9_GetAdapterModeCount(d3d9, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);
|
||||
for (i = 0; i < adapter_mode_count; ++i)
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
goto done;
|
||||
hr = IDirect3D9_EnumAdapterModes(d3d9, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i, &d3ddm);
|
||||
ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
|
||||
|
||||
if (d3ddm.Width == registry_mode.dmPelsWidth && d3ddm.Height == registry_mode.dmPelsHeight)
|
||||
continue;
|
||||
/* The r200 driver on Windows XP enumerates modes like 320x200 and 320x240 but
|
||||
* refuses to create a device at these sizes. */
|
||||
if (d3ddm.Width < 640 || d3ddm.Height < 480)
|
||||
continue;
|
||||
|
||||
if (!user32_width)
|
||||
{
|
||||
user32_width = d3ddm.Width;
|
||||
user32_height = d3ddm.Height;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Make sure the d3d mode is smaller in width or height and at most
|
||||
* equal in the other dimension than the mode passed to
|
||||
* ChangeDisplaySettings. Otherwise Windows shrinks the window to
|
||||
* the ChangeDisplaySettings parameters + 12. */
|
||||
if (d3ddm.Width == user32_width && d3ddm.Height == user32_height)
|
||||
continue;
|
||||
if (d3ddm.Width <= user32_width && d3ddm.Height <= user32_height)
|
||||
{
|
||||
d3d_width = d3ddm.Width;
|
||||
d3d_height = d3ddm.Height;
|
||||
break;
|
||||
}
|
||||
if (user32_width <= d3ddm.Width && user32_height <= d3ddm.Height)
|
||||
{
|
||||
d3d_width = user32_width;
|
||||
d3d_height = user32_height;
|
||||
user32_width = d3ddm.Width;
|
||||
user32_height = d3ddm.Height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!d3d_width)
|
||||
{
|
||||
skip("Could not find adequate modes, skipping mode tests.\n");
|
||||
IDirect3D9_Release(d3d9);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
devmode.dmPelsWidth = 640;
|
||||
devmode.dmPelsHeight = 480;
|
||||
devmode.dmPelsWidth = user32_width;
|
||||
devmode.dmPelsHeight = user32_height;
|
||||
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
|
||||
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
|
||||
|
||||
ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
|
||||
ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
|
||||
focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
|
||||
device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
|
||||
|
||||
SetRect(&d3d_rect, 0, 0, d3d_width, d3d_height);
|
||||
GetWindowRect(focus_window, &focus_rect);
|
||||
|
||||
device_desc.device_window = device_window;
|
||||
device_desc.width = d3d_width;
|
||||
device_desc.height = d3d_height;
|
||||
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||
if (!(device = create_device(d3d9, focus_window, &device_desc)))
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
|
||||
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
|
||||
goto done;
|
||||
}
|
||||
|
||||
devmode.dmPelsWidth = user32_width;
|
||||
devmode.dmPelsHeight = user32_height;
|
||||
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
|
||||
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
|
||||
ok(ret, "Failed to get display mode.\n");
|
||||
ok(devmode.dmPelsWidth == 640, "Got unexpect width %u.\n", devmode.dmPelsWidth);
|
||||
ok(devmode.dmPelsHeight == 480, "Got unexpect height %u.\n", devmode.dmPelsHeight);
|
||||
ok(devmode.dmPelsWidth == user32_width && devmode.dmPelsHeight == user32_height,
|
||||
"Expected resolution %ux%u, got %ux%u.\n",
|
||||
user32_width, user32_height, devmode.dmPelsWidth, devmode.dmPelsHeight);
|
||||
|
||||
GetWindowRect(device_window, &r);
|
||||
ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
|
||||
fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
|
||||
ok(EqualRect(&r, &d3d_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
|
||||
d3d_rect.left, d3d_rect.top, d3d_rect.right, d3d_rect.bottom,
|
||||
r.left, r.top, r.right, r.bottom);
|
||||
GetWindowRect(focus_window, &r);
|
||||
ok(EqualRect(&r, &focus_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
|
||||
|
@ -3960,31 +4019,52 @@ static void test_mode_change(void)
|
|||
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
|
||||
hr = IDirect3DSurface9_GetDesc(backbuffer, &desc);
|
||||
ok(SUCCEEDED(hr), "Failed to get backbuffer desc, hr %#x.\n", hr);
|
||||
ok(desc.Width == registry_mode.dmPelsWidth, "Got unexpected backbuffer width %u.\n", desc.Width);
|
||||
ok(desc.Height == registry_mode.dmPelsHeight, "Got unexpected backbuffer height %u.\n", desc.Height);
|
||||
ok(desc.Width == d3d_width, "Got unexpected backbuffer width %u, expected %u.\n",
|
||||
desc.Width, d3d_width);
|
||||
ok(desc.Height == d3d_height, "Got unexpected backbuffer height %u, expected %u.\n",
|
||||
desc.Height, d3d_height);
|
||||
IDirect3DSurface9_Release(backbuffer);
|
||||
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
|
||||
ok(ret, "Failed to get display mode.\n");
|
||||
ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
|
||||
ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
|
||||
todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
|
||||
&& devmode.dmPelsHeight == registry_mode.dmPelsHeight,
|
||||
"Expected resolution %ux%u, got %ux%u.\n",
|
||||
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
|
||||
|
||||
change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
|
||||
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
|
||||
|
||||
/* The mode restore also happens when the device was created at the original screen size. */
|
||||
|
||||
device_desc.device_window = device_window;
|
||||
device_desc.width = registry_mode.dmPelsWidth;
|
||||
device_desc.height = registry_mode.dmPelsHeight;
|
||||
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
|
||||
ok(!!(device = create_device(d3d9, focus_window, &device_desc)), "Failed to create a D3D device.\n");
|
||||
|
||||
devmode.dmPelsWidth = user32_width;
|
||||
devmode.dmPelsHeight = user32_height;
|
||||
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
|
||||
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
|
||||
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
|
||||
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
|
||||
ok(ret, "Failed to get display mode.\n");
|
||||
ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
|
||||
&& devmode.dmPelsHeight == registry_mode.dmPelsHeight,
|
||||
"Expected resolution %ux%u, got %ux%u.\n",
|
||||
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
|
||||
|
||||
done:
|
||||
DestroyWindow(device_window);
|
||||
DestroyWindow(focus_window);
|
||||
IDirect3D9_Release(d3d9);
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
|
||||
ok(ret, "Failed to get display mode.\n");
|
||||
ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
|
||||
ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
|
||||
}
|
||||
|
||||
static void test_device_window_reset(void)
|
||||
|
|
Loading…
Reference in New Issue