ddraw: Return DDERR_WRONGMODE when attempting to restore surfaces of a lost device.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2020-07-30 16:42:28 +04:30 committed by Alexandre Julliard
parent 7e56c12c0f
commit 6179ac14cb
5 changed files with 53 additions and 1 deletions

View File

@ -3785,9 +3785,13 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
}
}
if (!ddraw_surface_can_be_lost(surface))
return DD_OK;
ddraw_update_lost_surfaces(surface->ddraw);
surface->is_lost = FALSE;
if (surface->ddraw->device_state == DDRAW_DEVICE_STATE_LOST)
return DDERR_WRONGMODE;
surface->is_lost = FALSE;
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
{
if (surface->complex_array[i])

View File

@ -7381,12 +7381,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);

View File

@ -8334,12 +8334,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);

View File

@ -9731,12 +9731,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);

View File

@ -9489,12 +9489,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);