[PATCH 7/8] ddraw: Require exclusive mode only for primary surface flips.
Henri Verbeet
hverbeet at codeweavers.com
Thu Apr 21 10:05:09 CDT 2016
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/ddraw/surface.c | 3 ++-
dlls/ddraw/tests/ddraw1.c | 18 ++++++++++++++++--
dlls/ddraw/tests/ddraw2.c | 18 ++++++++++++++++--
dlls/ddraw/tests/ddraw4.c | 18 ++++++++++++++++--
dlls/ddraw/tests/ddraw7.c | 18 ++++++++++++++++--
5 files changed, 66 insertions(+), 9 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index a1bbced..c7e7256 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -1235,7 +1235,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7
wined3d_mutex_lock();
- if (!(dst_impl->ddraw->cooperative_level & DDSCL_EXCLUSIVE))
+ if ((dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ && !(dst_impl->ddraw->cooperative_level & DDSCL_EXCLUSIVE))
{
WARN("Not in exclusive mode.\n");
wined3d_mutex_unlock();
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index a9ba1b1..88d4f0c 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -4197,8 +4197,6 @@ static void test_flip(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
- hr = set_display_mode(ddraw, 640, 480);
- ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
@@ -4233,6 +4231,22 @@ static void test_flip(void)
if (FAILED(hr))
continue;
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface_IsLost(frontbuffer);
+ ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
+ if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
+ ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ else
+ ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface_IsLost(frontbuffer);
+ todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = restore_surfaces(ddraw);
+ ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(frontbuffer, &surface_desc);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index a56df21..4ee81b8 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -4830,8 +4830,6 @@ static void test_flip(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
- hr = set_display_mode(ddraw, 640, 480);
- ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
@@ -4866,6 +4864,22 @@ static void test_flip(void)
if (FAILED(hr))
continue;
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface_IsLost(frontbuffer);
+ ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
+ if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
+ ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ else
+ ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface_IsLost(frontbuffer);
+ todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = restore_surfaces(ddraw);
+ ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(frontbuffer, &surface_desc);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 8615e1c..271ae00 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -6150,8 +6150,6 @@ static void test_flip(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
- hr = set_display_mode(ddraw, 640, 480);
- ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
@@ -6239,6 +6237,22 @@ static void test_flip(void)
test_data[i].name, surface, frontbuffer);
IDirectDrawSurface4_Release(surface);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface4_IsLost(frontbuffer);
+ ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
+ if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
+ ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ else
+ ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface4_IsLost(frontbuffer);
+ todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
+ ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 1444800..7ea1d6e 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -6018,8 +6018,6 @@ static void test_flip(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
- hr = set_display_mode(ddraw, 640, 480);
- ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
@@ -6109,6 +6107,22 @@ static void test_flip(void)
test_data[i].name, surface, frontbuffer);
IDirectDrawSurface7_Release(surface);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface7_IsLost(frontbuffer);
+ ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
+ if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
+ ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ else
+ ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDrawSurface7_IsLost(frontbuffer);
+ todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+ hr = IDirectDraw7_RestoreAllSurfaces(ddraw);
+ ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
--
2.1.4
More information about the wine-patches
mailing list