[PATCH 5/5] ddraw: Update the primary surface format when changing the display mode.
Henri Verbeet
hverbeet at codeweavers.com
Wed Feb 1 05:02:58 CST 2017
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/ddraw/ddraw.c | 12 ++++++++++++
dlls/ddraw/tests/ddraw1.c | 29 +++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw2.c | 29 +++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 29 +++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 29 +++++++++++++++++++++++++++++
5 files changed, 128 insertions(+)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 16abbe1..a0865c0 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -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);
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index c57fa67..2832095 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -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);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 853a0d4..db09e5d 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -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);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 93987e9..0693dbc 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -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);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index c29a50d..0f44d3c 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -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);
--
2.1.4
More information about the wine-patches
mailing list