Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/ddraw/tests/ddraw1.c | 99 +++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw2.c | 99 +++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw4.c | 104 +++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw7.c | 104 +++++++++++++++++++++++++++++++++++++- 4 files changed, 402 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 652e52a..a6b978e 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -7309,8 +7309,8 @@ static void test_palette_alpha(void)
static void test_lost_device(void) { + IDirectDrawSurface *sysmem_surface, *vidmem_surface; IDirectDrawSurface *surface, *back_buffer; - IDirectDrawSurface *sysmem_surface; DDSURFACEDESC surface_desc; HWND window1, window2; IDirectDraw *ddraw; @@ -7345,12 +7345,36 @@ static void test_lost_device(void) hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + surface_desc.dwWidth = 640; + surface_desc.dwHeight = 480; + surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat); + surface_desc.ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 32; + U2(surface_desc.ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff; + hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &vidmem_surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create video memory surface, skipping related tests.\n"); + vidmem_surface = NULL; + } + hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -7360,6 +7384,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -7369,6 +7398,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7378,6 +7412,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7388,6 +7427,11 @@ static void test_lost_device(void) "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK || broken(ddraw_is_warp(ddraw) && hr == DDERR_SURFACELOST), "Got unexpected hr %#x.\n", hr); + }
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -7398,6 +7442,8 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = restore_surfaces(ddraw); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7408,6 +7454,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -7415,6 +7466,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7422,6 +7478,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7429,6 +7490,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
IDirectDrawSurface_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -7447,6 +7513,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7456,6 +7527,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7465,6 +7541,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7474,6 +7555,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7483,6 +7569,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7492,6 +7583,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_FLIP; @@ -7506,6 +7602,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface_Release(back_buffer);
+ if (vidmem_surface) IDirectDrawSurface_Release(vidmem_surface); IDirectDrawSurface_Release(sysmem_surface); IDirectDrawSurface_Release(surface); refcount = IDirectDraw_Release(ddraw); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index edaf868..41b9ed1 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -8262,8 +8262,8 @@ static void test_palette_alpha(void)
static void test_lost_device(void) { + IDirectDrawSurface *sysmem_surface, *vidmem_surface; IDirectDrawSurface *surface, *back_buffer; - IDirectDrawSurface *sysmem_surface; DDSURFACEDESC surface_desc; HWND window1, window2; IDirectDraw2 *ddraw; @@ -8298,12 +8298,36 @@ static void test_lost_device(void) hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + surface_desc.dwWidth = 640; + surface_desc.dwHeight = 480; + surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat); + surface_desc.ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 32; + U2(surface_desc.ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff; + hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &vidmem_surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create video memory surface, skipping related tests.\n"); + vidmem_surface = NULL; + } + hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -8313,6 +8337,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -8322,6 +8351,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8331,6 +8365,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8340,6 +8379,11 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -8350,6 +8394,8 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = restore_surfaces(ddraw); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8360,6 +8406,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -8367,6 +8418,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8374,6 +8430,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8381,6 +8442,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
IDirectDrawSurface_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -8399,6 +8465,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8408,6 +8479,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8417,6 +8493,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8426,6 +8507,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8435,6 +8521,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8444,6 +8535,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_FLIP; @@ -8458,6 +8554,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface_Release(back_buffer);
+ if (vidmem_surface) IDirectDrawSurface_Release(vidmem_surface); IDirectDrawSurface_Release(sysmem_surface); IDirectDrawSurface_Release(surface); refcount = IDirectDraw2_Release(ddraw); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index d1abde0..10f39ae 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9655,8 +9655,8 @@ static void test_vb_writeonly(void)
static void test_lost_device(void) { + IDirectDrawSurface4 *sysmem_surface, *vidmem_surface; IDirectDrawSurface4 *surface, *back_buffer; - IDirectDrawSurface4 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; IDirectDraw4 *ddraw; @@ -9691,6 +9691,25 @@ static void test_lost_device(void) hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + surface_desc.dwWidth = 640; + surface_desc.dwHeight = 480; + U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat); + U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 32; + U2(U4(surface_desc).ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff; + hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &vidmem_surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create video memory surface, skipping related tests.\n"); + vidmem_surface = NULL; + } + hr = IDirectDraw4_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); @@ -9699,6 +9718,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9710,6 +9734,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9721,6 +9750,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9732,6 +9766,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9743,6 +9782,11 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -9753,6 +9797,8 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDraw4_RestoreAllSurfaces(ddraw); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9760,6 +9806,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9769,6 +9820,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9778,6 +9834,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9787,6 +9848,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9796,6 +9862,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
IDirectDrawSurface4_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -9816,6 +9887,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9827,6 +9903,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9838,6 +9919,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9849,6 +9935,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9860,6 +9951,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9869,6 +9965,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); @@ -9886,6 +9987,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface4_Release(back_buffer);
+ if (vidmem_surface) IDirectDrawSurface4_Release(vidmem_surface); IDirectDrawSurface4_Release(sysmem_surface); IDirectDrawSurface4_Release(surface); refcount = IDirectDraw4_Release(ddraw); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 13eadfd..9d579fa 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -9413,8 +9413,8 @@ static void test_vb_writeonly(void)
static void test_lost_device(void) { + IDirectDrawSurface7 *sysmem_surface, *vidmem_surface; IDirectDrawSurface7 *surface, *back_buffer; - IDirectDrawSurface7 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; IDirectDraw7 *ddraw; @@ -9449,6 +9449,25 @@ static void test_lost_device(void) hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + surface_desc.dwWidth = 640; + surface_desc.dwHeight = 480; + U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat); + U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 32; + U2(U4(surface_desc).ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff; + hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &vidmem_surface, NULL); + if (FAILED(hr)) + { + skip("Failed to create video memory surface, skipping related tests.\n"); + vidmem_surface = NULL; + } + hr = IDirectDraw7_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); @@ -9457,6 +9476,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9468,6 +9492,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9479,6 +9508,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9490,6 +9524,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9501,6 +9540,11 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -9513,6 +9557,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDraw7_RestoreAllSurfaces(ddraw); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9520,6 +9566,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9529,6 +9580,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9538,6 +9594,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9547,6 +9608,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9556,6 +9622,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
IDirectDrawSurface7_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -9576,6 +9647,11 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9587,6 +9663,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9598,6 +9679,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9609,6 +9695,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9620,6 +9711,11 @@ static void test_lost_device(void) ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + }
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9631,6 +9727,11 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + if (vidmem_surface) + { + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + }
memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_FLIP; @@ -9646,6 +9747,7 @@ static void test_lost_device(void)
IDirectDrawSurface7_Release(back_buffer);
+ if (vidmem_surface) IDirectDrawSurface7_Release(vidmem_surface); IDirectDrawSurface7_Release(sysmem_surface); IDirectDrawSurface7_Release(surface); refcount = IDirectDraw7_Release(ddraw);
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/ddraw/surface.c | 3 +++ dlls/ddraw/tests/ddraw1.c | 12 ++++++++++++ dlls/ddraw/tests/ddraw2.c | 12 ++++++++++++ dlls/ddraw/tests/ddraw4.c | 12 ++++++++++++ dlls/ddraw/tests/ddraw7.c | 12 ++++++++++++ 5 files changed, 51 insertions(+)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 7b7f16e..8805014 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -3785,6 +3785,9 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface) } }
+ if (surface->ddraw->device_state == DDRAW_DEVICE_STATE_LOST && ddraw_surface_can_be_lost(surface)) + return DDERR_WRONGMODE; + ddraw_update_lost_surfaces(surface->ddraw); surface->is_lost = FALSE;
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index a6b978e..7717012 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -7382,12 +7382,24 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); if (vidmem_surface) { hr = IDirectDrawSurface_IsLost(vidmem_surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(vidmem_surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); }
ret = SetForegroundWindow(window1); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 41b9ed1..eca48d9 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -8335,12 +8335,24 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); if (vidmem_surface) { hr = IDirectDrawSurface_IsLost(vidmem_surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(vidmem_surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); }
ret = SetForegroundWindow(window1); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 10f39ae..1e151d7 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9732,12 +9732,24 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_Restore(surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_Restore(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); if (vidmem_surface) { hr = IDirectDrawSurface4_IsLost(vidmem_surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_Restore(vidmem_surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); }
ret = SetForegroundWindow(window1); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 9d579fa..bc3d022 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -9490,12 +9490,24 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_Restore(surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_Restore(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); if (vidmem_surface) { hr = IDirectDrawSurface7_IsLost(vidmem_surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_Restore(vidmem_surface); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(vidmem_surface); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); }
ret = SetForegroundWindow(window1);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76228
Your paranoid android.
=== w1064v1809_2scr (32 bit report) ===
ddraw: ddraw4.c:2789: Test failed: Failed to set foreground window. ddraw4.c:2797: Test failed: Failed to set foreground window. ddraw4.c:2819: Test failed: Expected window extended style 0x108, got 0x100. ddraw4.c:2822: Test failed: Failed to set foreground window. ddraw4.c:2825: Test failed: Expected window style 0x34cf0000, got 0x14cf0000. ddraw4.c:2828: Test failed: Expected window extended style 0x108, got 0x100. ddraw4.c:3164: Test failed: Failed to set foreground window. ddraw4.c:3165: Test failed: Expected message 0x6, but didn't receive it. ddraw4.c:3172: Test failed: Got unexpected screen size 2560x1600. ddraw4.c:598: Test failed: Got unexpected wparam 0 for message 1c, expected 1. ddraw4.c:3181: Test failed: Expected (0,0)-(1152,864), got (-32000,-32000)-(-31840,-31972). ddraw4.c:3185: Test failed: Got unexpected screen size 1024x768. ddraw4.c:3198: Test failed: Expected message 0x46, but didn't receive it. ddraw4.c:3226: Test failed: Expected message 0x46, but didn't receive it. ddraw4.c:3228: Test failed: Expected screen size 1024x768, got 0x0. ddraw4.c:3234: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3264: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3271: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3297: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3320: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3342: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3368: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3388: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3424: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3434: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3460: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3483: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3505: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3531: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3551: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3588: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3614: Test failed: Expected (0,0)-(1024,768), got (-8,-8)-(1032,736). ddraw4.c:3684: Test failed: Expected (0,0)-(1152,864), got (-8,-8)-(1160,832). ddraw4.c:3709: Test failed: Expected (0,0)-(1152,864), got (-8,-8)-(1160,832).
=== w1064v1809_2scr (32 bit report) ===
ddraw: ddraw7.c:15402: Test failed: Expected width 1920, got 2000. ddraw7.c:15403: Test failed: Expected height 1440, got 2000. ddraw7.c:15403: Test failed: Expected height 1536, got 2048. ddraw7.c:15402: Test failed: Expected width 2048, got 2560. ddraw7.c:15403: Test failed: Expected height 2048, got 1440. ddraw7.c:15545: Test failed: Expected 22 surfaces, got 21.
=== debiant (build log) ===
The task timed out
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/ddraw/surface.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 8805014..c2d794b 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -3786,7 +3786,18 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface) }
if (surface->ddraw->device_state == DDRAW_DEVICE_STATE_LOST && ddraw_surface_can_be_lost(surface)) - return DDERR_WRONGMODE; + { + HWND window = surface->ddraw->focuswindow ? surface->ddraw->focuswindow : surface->ddraw->dest_window; + + /* Railroad Tycoon 2 tries to restore the surface from within + a WM_QUERYNEWPALETTE message and expects it to succeed. We + haven't received the WM_ACTIVATEAPP message by that point, + so the device state is still LOST, even though we are in + the foreground. */ + if (!window || GetForegroundWindow() != window) return DDERR_WRONGMODE; + + surface->ddraw->device_state = DDRAW_DEVICE_STATE_NOT_RESTORED; + }
ddraw_update_lost_surfaces(surface->ddraw); surface->is_lost = FALSE;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76229
Your paranoid android.
=== debiant (build log) ===
The task timed out
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76227
Your paranoid android.
=== w1064v1809_2scr (32 bit report) ===
ddraw: ddraw2.c:13474: Test failed: Expected 18 surfaces, got 4.
=== w1064v1809_he (32 bit report) ===
ddraw: ddraw7.c:4026: Test failed: Lit quad without normals has color 0x00ff0000, expected 0x00000000. ddraw7.c:4039: Test failed: Lit quad with normals has color 0x00ff0000, expected 0x00000000. ddraw7.c:4084: Test failed: Lit quad with light has color 0x00ff0000. ddraw7.c:4084: Test failed: Lit quad with singular world matrix has color 0x00ff0000. ddraw7.c:4084: Test failed: Lit quad with transformation matrix has color 0x00ff0000. ddraw7.c:4084: Test failed: Lit quad with non-affine matrix has color 0x00ff0000.
=== debiant (build log) ===
The task timed out