Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/ddraw/tests/ddraw1.c | 48 +++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw2.c | 48 +++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw4.c | 50 ++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw7.c | 52 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 194 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 652e52a..a8e842e 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -7309,7 +7309,7 @@ static void test_palette_alpha(void)
static void test_lost_device(void) { - IDirectDrawSurface *surface, *back_buffer; + IDirectDrawSurface *surface, *surface2, *back_buffer; IDirectDrawSurface *sysmem_surface; DDSURFACEDESC surface_desc; HWND window1, window2; @@ -7336,6 +7336,21 @@ static void test_lost_device(void) hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &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; + 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, &surface2, 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; @@ -7349,6 +7364,8 @@ static void test_lost_device(void) 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(surface2); + 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);
@@ -7358,6 +7375,8 @@ 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_IsLost(surface2); + 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);
@@ -7367,6 +7386,8 @@ 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_IsLost(surface2); + 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);
@@ -7376,6 +7397,8 @@ static void test_lost_device(void) 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(surface2); + 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);
@@ -7386,6 +7409,8 @@ static void test_lost_device(void) hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE || broken(ddraw_is_warp(ddraw) && hr == DDERR_SURFACELOST), "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7406,6 +7431,8 @@ static void test_lost_device(void) ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + todo_wine ok(hr == DDERR_SURFACELOST || broken(hr == DD_OK) /* WinXP */, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
@@ -7413,6 +7440,8 @@ static void test_lost_device(void) ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + todo_wine ok(hr == DDERR_SURFACELOST || broken(hr == DD_OK) /* WinXP */, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(sysmem_surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
@@ -7420,6 +7449,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7427,6 +7458,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7445,6 +7478,8 @@ static void test_lost_device(void) 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(surface2); + 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);
@@ -7454,6 +7489,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7463,6 +7500,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7472,6 +7511,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7481,6 +7522,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -7490,6 +7533,8 @@ 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_IsLost(surface2); + 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);
@@ -7507,6 +7552,7 @@ static void test_lost_device(void) IDirectDrawSurface_Release(back_buffer);
IDirectDrawSurface_Release(sysmem_surface); + IDirectDrawSurface_Release(surface2); IDirectDrawSurface_Release(surface); refcount = IDirectDraw_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index edaf868..1c0ccd9 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -8262,7 +8262,7 @@ static void test_palette_alpha(void)
static void test_lost_device(void) { - IDirectDrawSurface *surface, *back_buffer; + IDirectDrawSurface *surface, *surface2, *back_buffer; IDirectDrawSurface *sysmem_surface; DDSURFACEDESC surface_desc; HWND window1, window2; @@ -8289,6 +8289,21 @@ static void test_lost_device(void) hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &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; + 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, &surface2, 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; @@ -8302,6 +8317,8 @@ static void test_lost_device(void) 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(surface2); + 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);
@@ -8311,6 +8328,8 @@ 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_IsLost(surface2); + 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);
@@ -8320,6 +8339,8 @@ 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_IsLost(surface2); + 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);
@@ -8329,6 +8350,8 @@ static void test_lost_device(void) 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(surface2); + 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);
@@ -8338,6 +8361,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8358,6 +8383,8 @@ static void test_lost_device(void) ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8365,6 +8392,8 @@ static void test_lost_device(void) ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8372,6 +8401,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8379,6 +8410,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8397,6 +8430,8 @@ static void test_lost_device(void) 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(surface2); + 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);
@@ -8406,6 +8441,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8415,6 +8452,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8424,6 +8463,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8433,6 +8474,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(surface2); + 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);
@@ -8442,6 +8485,8 @@ 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_IsLost(surface2); + 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);
@@ -8459,6 +8504,7 @@ static void test_lost_device(void) IDirectDrawSurface_Release(back_buffer);
IDirectDrawSurface_Release(sysmem_surface); + IDirectDrawSurface_Release(surface2); IDirectDrawSurface_Release(surface); refcount = IDirectDraw2_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index d1abde0..97318bd 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9655,7 +9655,7 @@ static void test_vb_writeonly(void)
static void test_lost_device(void) { - IDirectDrawSurface4 *surface, *back_buffer; + IDirectDrawSurface4 *surface, *surface2, *back_buffer; IDirectDrawSurface4 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; @@ -9682,6 +9682,21 @@ static void test_lost_device(void) hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &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; + 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, &surface2, 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; @@ -9697,6 +9712,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9708,6 +9725,8 @@ 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_IsLost(surface2); + 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);
@@ -9719,6 +9738,8 @@ 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_IsLost(surface2); + 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);
@@ -9730,6 +9751,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9741,6 +9764,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9758,6 +9783,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9767,6 +9794,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9776,6 +9805,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9785,6 +9816,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9794,6 +9827,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9814,6 +9849,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9825,6 +9862,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9836,6 +9875,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9847,6 +9888,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9858,6 +9901,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9867,6 +9912,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(surface2); + 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);
@@ -9887,6 +9934,7 @@ static void test_lost_device(void) IDirectDrawSurface4_Release(back_buffer);
IDirectDrawSurface4_Release(sysmem_surface); + IDirectDrawSurface4_Release(surface2); IDirectDrawSurface4_Release(surface); refcount = IDirectDraw4_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 13eadfd..bd64134 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -9413,7 +9413,7 @@ static void test_vb_writeonly(void)
static void test_lost_device(void) { - IDirectDrawSurface7 *surface, *back_buffer; + IDirectDrawSurface7 *surface, *surface2, *back_buffer; IDirectDrawSurface7 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; @@ -9440,6 +9440,21 @@ static void test_lost_device(void) hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &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; + 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, &surface2, 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; @@ -9455,6 +9470,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9466,6 +9483,8 @@ 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_IsLost(surface2); + 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);
@@ -9477,6 +9496,8 @@ 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_IsLost(surface2); + 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);
@@ -9488,6 +9509,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9499,6 +9522,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9511,6 +9536,8 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9518,6 +9545,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9527,6 +9556,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9536,6 +9567,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9545,6 +9578,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9554,6 +9589,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9574,6 +9611,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9585,6 +9624,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9596,6 +9637,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9607,6 +9650,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9618,6 +9663,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(surface2); + 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);
@@ -9629,6 +9676,8 @@ 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_IsLost(surface2); + 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);
@@ -9647,6 +9696,7 @@ static void test_lost_device(void) IDirectDrawSurface7_Release(back_buffer);
IDirectDrawSurface7_Release(sysmem_surface); + IDirectDrawSurface7_Release(surface2); IDirectDrawSurface7_Release(surface); refcount = IDirectDraw7_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount);
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 a8e842e..ce00a8b 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -7375,10 +7375,22 @@ 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(surface2); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(surface2); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface2); 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);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 1c0ccd9..35c50fb 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -8328,10 +8328,22 @@ 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(surface2); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_Restore(surface2); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface2); 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);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 97318bd..5164139 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9725,10 +9725,22 @@ 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(surface2); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_Restore(surface2); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface2); 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);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index bd64134..9ebcd92 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -9483,10 +9483,22 @@ 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(surface2); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_Restore(surface2); + ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface2); 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);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n");
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=76173
Your paranoid android.
=== w8adm (32 bit report) ===
ddraw: ddraw1.c:1947: Test failed: Got unexpected color 0x000000ff.
=== w1064v1809 (32 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_2scr (32 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_ar (32 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_he (32 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_ja (32 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_zh_CN (32 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809 (64 bit report) ===
ddraw: ddraw1.c:7425: Test failed: Got unexpected hr 0x887601c2.
=== w864 (64 bit report) ===
ddraw: ddraw2.c:3122: Test failed: Failed to create surface, hr 0x887601c2. 0c4c:ddraw2: unhandled exception c0000005 at 0000000000473FB9
=== w1064v1809_2scr (32 bit report) ===
ddraw: ddraw7.c:4026: Test failed: Lit quad without normals has color 0x00ffff00, expected 0x00000000. ddraw7.c:4039: Test failed: Lit quad with normals has color 0x00ffff00, expected 0x00000000. ddraw7.c:4084: Test failed: Lit quad with light has color 0x00ffffff. ddraw7.c:4084: Test failed: Lit quad with singular world matrix has color 0x00ffffff. ddraw7.c:4084: Test failed: Lit quad with transformation matrix has color 0x00ffffff. ddraw7.c:4084: Test failed: Lit quad with non-affine matrix has color 0x00ffff00.
=== debiant (32 bit report) ===
ddraw: ddraw1: Timeout
=== debiant (build log) ===
The task timed out
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
I haven't been able to add a reliable test for this, mostly because WM_QUERYNEWPALETTE is rarely sent on Windows. In fact, for some reason even changing the display mode to 8bpp still didn't send it. But it was sent if the application was forced into "Run in 256 colors" (Windows XP) while having a 32bpp desktop display mode, which sounds like a compatibility shim hack to me.
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..f2182d5 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 (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=76174
Your paranoid android.
=== debiant (32 bit report) ===
ddraw: ddraw1: Timeout
=== debiant (build log) ===
The task timed out
Am 27.07.2020 um 19:05 schrieb Gabriel Ivăncescu gabrielopcode@gmail.com:
- surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
- surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
This will either create a video or system memory surface depending on the whims of the driver. Since we already explicitly test offscreen sysmem surfaces, shouldn't this one request video memory explicitly and skip some tests if creation fails? That might make your broken(hr == DD_OK) /* WinXP */ go away.
On 27/07/2020 19:30, Stefan Dösinger wrote:
Am 27.07.2020 um 19:05 schrieb Gabriel Ivăncescu <gabrielopcode@gmail.com mailto:gabrielopcode@gmail.com>:
- surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
DDSD_PIXELFORMAT;
- surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
This will either create a video or system memory surface depending on the whims of the driver. Since we already explicitly test offscreen sysmem surfaces, shouldn't this one request video memory explicitly and skip some tests if creation fails? That might make your broken(hr == DD_OK) /* WinXP */ go away.
You're right, sorry, I'm not very familiar with ddraw. I tried with DDSCAPS_VIDEOMEMORY (and even DDSCAPS_LOCALVIDMEM, though it shouldn't be necessary), unfortunately it's still broken on Windows XP so that broken check has to stay.
On Mon, 27 Jul 2020 at 22:06, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
On 27/07/2020 19:30, Stefan Dösinger wrote:
This will either create a video or system memory surface depending on the whims of the driver. Since we already explicitly test offscreen sysmem surfaces, shouldn't this one request video memory explicitly and skip some tests if creation fails? That might make your broken(hr == DD_OK) /* WinXP */ go away.
You're right, sorry, I'm not very familiar with ddraw. I tried with DDSCAPS_VIDEOMEMORY (and even DDSCAPS_LOCALVIDMEM, though it shouldn't be necessary), unfortunately it's still broken on Windows XP so that broken check has to stay.
Why do you consider the Windows XP result broken? DD_OK is what I would expect for DDSCL_NORMAL.
On 28/07/2020 13:37, Henri Verbeet wrote:
On Mon, 27 Jul 2020 at 22:06, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
On 27/07/2020 19:30, Stefan Dösinger wrote:
This will either create a video or system memory surface depending on the whims of the driver. Since we already explicitly test offscreen sysmem surfaces, shouldn't this one request video memory explicitly and skip some tests if creation fails? That might make your broken(hr == DD_OK) /* WinXP */ go away.
You're right, sorry, I'm not very familiar with ddraw. I tried with DDSCAPS_VIDEOMEMORY (and even DDSCAPS_LOCALVIDMEM, though it shouldn't be necessary), unfortunately it's still broken on Windows XP so that broken check has to stay.
Why do you consider the Windows XP result broken? DD_OK is what I would expect for DDSCL_NORMAL.
Well, I thought it's broken because it only applies to ddraw1 and on Win XP (not on Windows 7). The other ddraw have the same behavior as other Windows OSes and fail, too. So it seemed like the odd one out.
On Tue, 28 Jul 2020 at 16:35, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
On 28/07/2020 13:37, Henri Verbeet wrote:
On Mon, 27 Jul 2020 at 22:06, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
On 27/07/2020 19:30, Stefan Dösinger wrote:
This will either create a video or system memory surface depending on the whims of the driver. Since we already explicitly test offscreen sysmem surfaces, shouldn't this one request video memory explicitly and skip some tests if creation fails? That might make your broken(hr == DD_OK) /* WinXP */ go away.
You're right, sorry, I'm not very familiar with ddraw. I tried with DDSCAPS_VIDEOMEMORY (and even DDSCAPS_LOCALVIDMEM, though it shouldn't be necessary), unfortunately it's still broken on Windows XP so that broken check has to stay.
Why do you consider the Windows XP result broken? DD_OK is what I would expect for DDSCL_NORMAL.
Well, I thought it's broken because it only applies to ddraw1 and on Win XP (not on Windows 7). The other ddraw have the same behavior as other Windows OSes and fail, too. So it seemed like the odd one out.
I see. The other ddraw versions are probably missing a Restore() call though. I.e., my understanding of the expected behaviour is the following:
- In DDSCL_EXCLUSIVE mode, changing the foreground window makes the device lost. - In DDSCL_NORMAL mode, this does not happen.
A more subtle implication of that is that switching from exclusive fullscreen to the normal cooperative level loses surfaces, due to the order of the fullscreen/windowed change relative to the exclusive/normal change. This is currently a todo_wine. On the other hand, inserting a change to the normal fullscreen cooperative level in between avoids losing surfaces.
After the change from exclusive fullscreen to normal, we recreate the primary to make it non-flippable. This avoids a call to RestoreAllSurfaces()/restore_surfaces(), but only because before this patch the primary is the only surface that can get lost. Restoring surfaces after recreating the primary should get rid of many of the todo_wine/DDERR_SURFACELOST introduced in this patch.
The part that is unusual for ddraw1 compared to the other versions is that surfaces do not appear to get lost during the change from exclusive fullscreen to normal. This may be due to slight ordering differences compared to the other versions (see also above). Seemingly that's not entirely consistent between Windows versions or drivers though, as the existing broken() seems to hint at. But once we're in the normal cooperative level, we wouldn't expect window changes to lose surfaces. In any case, I'd expect restoring surfaces after recreating the primary to make the ddraw1 behaviour consistent again with the other ddraw versions, and across Windows versions.
Last, and for what it's worth, the behaviour of older Windows versions like Windows XP and Windows 98 is generally much more in line with what ddraw applications expect. It's not unusual for older ddraw applications in particular to simply not work on e.g. Windows 10 unless specific compatibility settings (or in some cases patches) are used.
On 28/07/2020 16:26, Henri Verbeet wrote:
On Tue, 28 Jul 2020 at 16:35, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
On 28/07/2020 13:37, Henri Verbeet wrote:
On Mon, 27 Jul 2020 at 22:06, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
On 27/07/2020 19:30, Stefan Dösinger wrote:
This will either create a video or system memory surface depending on the whims of the driver. Since we already explicitly test offscreen sysmem surfaces, shouldn't this one request video memory explicitly and skip some tests if creation fails? That might make your broken(hr == DD_OK) /* WinXP */ go away.
You're right, sorry, I'm not very familiar with ddraw. I tried with DDSCAPS_VIDEOMEMORY (and even DDSCAPS_LOCALVIDMEM, though it shouldn't be necessary), unfortunately it's still broken on Windows XP so that broken check has to stay.
Why do you consider the Windows XP result broken? DD_OK is what I would expect for DDSCL_NORMAL.
Well, I thought it's broken because it only applies to ddraw1 and on Win XP (not on Windows 7). The other ddraw have the same behavior as other Windows OSes and fail, too. So it seemed like the odd one out.
I see. The other ddraw versions are probably missing a Restore() call though. I.e., my understanding of the expected behaviour is the following:
- In DDSCL_EXCLUSIVE mode, changing the foreground window makes
the device lost. - In DDSCL_NORMAL mode, this does not happen.
A more subtle implication of that is that switching from exclusive fullscreen to the normal cooperative level loses surfaces, due to the order of the fullscreen/windowed change relative to the exclusive/normal change. This is currently a todo_wine. On the other hand, inserting a change to the normal fullscreen cooperative level in between avoids losing surfaces.
After the change from exclusive fullscreen to normal, we recreate the primary to make it non-flippable. This avoids a call to RestoreAllSurfaces()/restore_surfaces(), but only because before this patch the primary is the only surface that can get lost. Restoring surfaces after recreating the primary should get rid of many of the todo_wine/DDERR_SURFACELOST introduced in this patch.
The part that is unusual for ddraw1 compared to the other versions is that surfaces do not appear to get lost during the change from exclusive fullscreen to normal. This may be due to slight ordering differences compared to the other versions (see also above). Seemingly that's not entirely consistent between Windows versions or drivers though, as the existing broken() seems to hint at. But once we're in the normal cooperative level, we wouldn't expect window changes to lose surfaces. In any case, I'd expect restoring surfaces after recreating the primary to make the ddraw1 behaviour consistent again with the other ddraw versions, and across Windows versions.
Last, and for what it's worth, the behaviour of older Windows versions like Windows XP and Windows 98 is generally much more in line with what ddraw applications expect. It's not unusual for older ddraw applications in particular to simply not work on e.g. Windows 10 unless specific compatibility settings (or in some cases patches) are used.
That makes sense, thanks for the explanation. Restoring it did indeed solve it, I'll send updated patches shortly.
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=76172
Your paranoid android.
=== w1064v1809 (32 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_2scr (32 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_ar (32 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_he (32 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_ja (32 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809_zh_CN (32 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== w1064v1809 (64 bit report) ===
ddraw: ddraw1.c:7413: Test failed: Got unexpected hr 0x887601c2.
=== debiant (build log) ===
The task timed out