Commit aa8cedb0 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Update the primary surface format when changing the display mode.

parent 312cb811
......@@ -1129,7 +1129,19 @@ static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD width, DW
/* TODO: The possible return values from msdn suggest that the screen mode
* can't be changed if a surface is locked or some drawing is in progress. */
if (SUCCEEDED(hr = wined3d_set_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode)))
{
if (ddraw->primary)
{
DDSURFACEDESC2 *surface_desc = &ddraw->primary->surface_desc;
if (FAILED(hr = wined3d_swapchain_resize_buffers(ddraw->wined3d_swapchain, 0,
surface_desc->dwWidth, surface_desc->dwHeight, mode.format_id, WINED3D_MULTISAMPLE_NONE, 0)))
ERR("Failed to resize buffers, hr %#x.\n", hr);
else
ddrawformat_from_wined3dformat(&ddraw->primary->surface_desc.u4.ddpfPixelFormat, mode.format_id);
}
ddraw->flags |= DDRAW_RESTORE_MODE;
}
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_OK);
......
......@@ -4629,9 +4629,28 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface_IsLost(primary);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
hr = set_display_mode(ddraw, 640, 480);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
|| U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
hr = IDirectDrawSurface_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_Restore(primary);
......@@ -4639,6 +4658,16 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
|| U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
done:
refcount = IDirectDrawSurface_Release(backbuffer);
ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
......
......@@ -5676,9 +5676,28 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface_IsLost(primary);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
hr = set_display_mode(ddraw, 640, 480);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
|| U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
hr = IDirectDrawSurface_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_Restore(primary);
......@@ -5686,6 +5705,16 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
|| U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
done:
refcount = IDirectDrawSurface_Release(backbuffer);
ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
......
......@@ -6947,9 +6947,28 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface4_IsLost(primary);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
hr = set_display_mode(ddraw, 640, 480);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
|| U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
hr = IDirectDrawSurface4_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_Restore(primary);
......@@ -6957,6 +6976,16 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface4_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
|| U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
done:
refcount = IDirectDrawSurface4_Release(backbuffer);
ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
......
......@@ -6870,9 +6870,28 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface7_IsLost(primary);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
hr = set_display_mode(ddraw, 640, 480);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
|| U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
hr = IDirectDrawSurface7_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_Restore(primary);
......@@ -6880,6 +6899,16 @@ static void test_primary_palette(void)
hr = IDirectDrawSurface7_IsLost(primary);
ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
|| U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
"Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
done:
refcount = IDirectDrawSurface7_Release(backbuffer);
ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
......
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