Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/surface.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 85c1ef4966..9d937414ae 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -33,6 +33,11 @@ static inline struct ddraw_surface *impl_from_IDirectDrawGammaControl(IDirectDra return CONTAINING_RECORD(iface, struct ddraw_surface, IDirectDrawGammaControl_iface); }
+static BOOL ddraw_surface_is_lost(const struct ddraw_surface *surface) +{ + return surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->is_lost; +} + /* This is slow, of course. Also, in case of locks, we can't prevent other * applications from drawing to the screen while we've locked the frontbuffer. * We'd like to do this in wined3d instead, but for that to work wined3d needs @@ -766,7 +771,7 @@ static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *ifa
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, surface);
- if (IDirectDrawSurface7_IsLost(&head_surface->IDirectDrawSurface7_iface) != DD_OK) + if (ddraw_surface_is_lost(head_surface)) { WARN("Surface %p is lost.\n", head_surface);
@@ -1291,7 +1296,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 if (src == iface || !(dst_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_OVERLAY))) return DDERR_NOTFLIPPABLE;
- if (IDirectDrawSurface7_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(dst_impl)) return DDERR_SURFACELOST;
wined3d_mutex_lock(); @@ -3681,10 +3686,7 @@ static HRESULT WINAPI ddraw_surface7_IsLost(IDirectDrawSurface7 *iface)
TRACE("iface %p.\n", iface);
- if (surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->is_lost) - return DDERR_SURFACELOST; - - return DD_OK; + return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK; }
static HRESULT WINAPI ddraw_surface4_IsLost(IDirectDrawSurface4 *iface) @@ -3693,7 +3695,7 @@ static HRESULT WINAPI ddraw_surface4_IsLost(IDirectDrawSurface4 *iface)
TRACE("iface %p.\n", iface);
- return ddraw_surface7_IsLost(&surface->IDirectDrawSurface7_iface); + return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK; }
static HRESULT WINAPI ddraw_surface3_IsLost(IDirectDrawSurface3 *iface) @@ -3702,7 +3704,7 @@ static HRESULT WINAPI ddraw_surface3_IsLost(IDirectDrawSurface3 *iface)
TRACE("iface %p.\n", iface);
- return ddraw_surface7_IsLost(&surface->IDirectDrawSurface7_iface); + return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK; }
static HRESULT WINAPI ddraw_surface2_IsLost(IDirectDrawSurface2 *iface) @@ -3711,7 +3713,7 @@ static HRESULT WINAPI ddraw_surface2_IsLost(IDirectDrawSurface2 *iface)
TRACE("iface %p.\n", iface);
- return ddraw_surface7_IsLost(&surface->IDirectDrawSurface7_iface); + return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK; }
static HRESULT WINAPI ddraw_surface1_IsLost(IDirectDrawSurface *iface) @@ -3720,7 +3722,7 @@ static HRESULT WINAPI ddraw_surface1_IsLost(IDirectDrawSurface *iface)
TRACE("iface %p.\n", iface);
- return ddraw_surface7_IsLost(&surface->IDirectDrawSurface7_iface); + return ddraw_surface_is_lost(surface) ? DDERR_SURFACELOST : DD_OK; }
/***************************************************************************** @@ -4774,7 +4776,7 @@ static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDir
if (!palette) return DDERR_INVALIDPARAMS; - if (IDirectDrawSurface7_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(surface)) { WARN("Surface lost, returning DDERR_SURFACELOST.\n"); return DDERR_SURFACELOST; @@ -4970,7 +4972,7 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
if (surface->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL) return DDERR_NOTONMIPMAPSUBLEVEL; - if (IDirectDrawSurface7_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(surface)) { WARN("Surface lost, returning DDERR_SURFACELOST.\n"); return DDERR_SURFACELOST; @@ -4985,7 +4987,7 @@ static HRESULT WINAPI ddraw_surface4_SetPalette(IDirectDrawSurface4 *iface, IDir
TRACE("iface %p, palette %p.\n", iface, palette);
- if (IDirectDrawSurface4_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(surface)) { WARN("Surface lost, returning DDERR_SURFACELOST.\n"); return DDERR_SURFACELOST; @@ -5000,7 +5002,7 @@ static HRESULT WINAPI ddraw_surface3_SetPalette(IDirectDrawSurface3 *iface, IDir
TRACE("iface %p, palette %p.\n", iface, palette);
- if (IDirectDrawSurface3_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(surface)) { WARN("Surface lost, returning DDERR_SURFACELOST.\n"); return DDERR_SURFACELOST; @@ -5015,7 +5017,7 @@ static HRESULT WINAPI ddraw_surface2_SetPalette(IDirectDrawSurface2 *iface, IDir
TRACE("iface %p, palette %p.\n", iface, palette);
- if (IDirectDrawSurface2_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(surface)) { WARN("Surface lost, returning DDERR_SURFACELOST.\n"); return DDERR_SURFACELOST; @@ -5030,7 +5032,7 @@ static HRESULT WINAPI ddraw_surface1_SetPalette(IDirectDrawSurface *iface, IDire
TRACE("iface %p, palette %p.\n", iface, palette);
- if (IDirectDrawSurface_IsLost(iface) == DDERR_SURFACELOST) + if (ddraw_surface_is_lost(surface)) { WARN("Surface lost, returning DDERR_SURFACELOST.\n"); return DDERR_SURFACELOST;
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/surface.c | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 9d937414ae..b6a7ebb734 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1128,17 +1128,13 @@ static HRESULT WINAPI ddraw_surface4_Lock(IDirectDrawSurface4 *iface, RECT *rect return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h); }
-static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect, +static HRESULT ddraw_surface_lock_ddsd(struct ddraw_surface *surface, RECT *rect, DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface); unsigned int surface_desc_size; DDSURFACEDESC2 surface_desc2; HRESULT hr;
- TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n", - iface, wine_dbgstr_rect(rect), surface_desc, flags, h); - if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
@@ -1150,48 +1146,37 @@ static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect return hr; }
+static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect, + DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h) +{ + struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface); + + TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n", + iface, wine_dbgstr_rect(rect), surface_desc, flags, h); + + return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h); +} + static HRESULT WINAPI ddraw_surface2_Lock(IDirectDrawSurface2 *iface, RECT *rect, DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h) { struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface); - unsigned int surface_desc_size; - DDSURFACEDESC2 surface_desc2; - HRESULT hr;
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n", iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
- if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size)) - return DDERR_INVALIDPARAMS; - - surface_desc2.dwSize = surface_desc->dwSize; - surface_desc2.dwFlags = 0; - hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h); - DDSD2_to_DDSD(&surface_desc2, surface_desc); - surface_desc->dwSize = surface_desc2.dwSize; - return hr; + return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h); }
static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect, DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h) { struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface); - unsigned int surface_desc_size; - DDSURFACEDESC2 surface_desc2; - HRESULT hr;
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n", iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
- if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size)) - return DDERR_INVALIDPARAMS; - - surface_desc2.dwSize = surface_desc->dwSize; - surface_desc2.dwFlags = 0; - hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h); - DDSD2_to_DDSD(&surface_desc2, surface_desc); - surface_desc->dwSize = surface_desc2.dwSize; - return hr; + return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h); }
/*****************************************************************************
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/surface.c | 18 ++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 13 +++++++++++++ 2 files changed, 31 insertions(+)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index b6a7ebb734..9850a1e8c9 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1110,6 +1110,12 @@ static HRESULT WINAPI ddraw_surface7_Lock(IDirectDrawSurface7 *iface, if (!surface_validate_lock_desc(surface, (DDSURFACEDESC *)surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
+ if (ddraw_surface_is_lost(surface)) + { + WARN("Surface is lost.\n"); + return DDERR_SURFACELOST; + } + return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h); }
@@ -1125,6 +1131,12 @@ static HRESULT WINAPI ddraw_surface4_Lock(IDirectDrawSurface4 *iface, RECT *rect if (!surface_validate_lock_desc(surface, (DDSURFACEDESC *)surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
+ if (ddraw_surface_is_lost(surface)) + { + WARN("Surface is lost.\n"); + return DDERR_SURFACELOST; + } + return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h); }
@@ -1138,6 +1150,12 @@ static HRESULT ddraw_surface_lock_ddsd(struct ddraw_surface *surface, RECT *rect if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size)) return DDERR_INVALIDPARAMS;
+ if (ddraw_surface_is_lost(surface)) + { + WARN("Surface is lost.\n"); + return DDERR_SURFACELOST; + } + surface_desc2.dwSize = surface_desc->dwSize; surface_desc2.dwFlags = 0; hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 5c0c5bb7c3..abe5249cc0 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -1056,6 +1056,7 @@ static void test_coop_level_d3d_state(void) IDirectDrawSurface7 *rt, *surface; IDirect3DDevice7 *device; IDirectDraw7 *ddraw; + DDSURFACEDESC2 lock; IDirect3D7 *d3d; D3DCOLOR color; DDSCAPS2 caps; @@ -1116,6 +1117,13 @@ static void test_coop_level_d3d_state(void) hr = IDirectDrawSurface7_IsLost(rt); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+ memset(&lock, 0, sizeof(lock)); + lock.dwSize = sizeof(lock); + lock.lpSurface = (void *)0xdeadbeef; + hr = IDirectDrawSurface7_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface); + memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_ZBUFFER; hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface); @@ -1127,6 +1135,11 @@ static void test_coop_level_d3d_state(void) hr = IDirectDraw7_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_Unlock(rt, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + caps.dwCaps = DDSCAPS_ZBUFFER; hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw4.c | 40 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 1e6cf4c446..fc3a415433 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -1111,6 +1111,7 @@ static void test_coop_level_d3d_state(void) IDirect3DViewport3 *viewport; IDirect3DDevice3 *device; IDirectDraw4 *ddraw; + DDSURFACEDESC2 lock; IDirect3D3 *d3d; D3DCOLOR color; DWORD value; @@ -1146,43 +1147,56 @@ static void test_coop_level_d3d_state(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderTarget(device, &rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!!value, "Got unexpected z-enable state %#x.\n", value); hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!value, "Got unexpected alpha blend enable state %#x.\n", value); hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); - ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); color = get_surface_color(rt, 320, 240); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice3_GetDirect3D(device, &d3d); - ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw); - ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirect3D3_Release(d3d); hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(rt); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + + memset(&lock, 0, sizeof(lock)); + lock.dwSize = sizeof(lock); + lock.lpSurface = (void *)0xdeadbeef; + hr = IDirectDrawSurface4_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface); + hr = IDirectDraw4_RestoreAllSurfaces(ddraw); - ok(SUCCEEDED(hr), "Failed to restore surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDrawSurface4_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_Unlock(rt, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderTarget(device, &surface); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(surface == rt, "Got unexpected surface %p.\n", surface); hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!!value, "Got unexpected z-enable state %#x.\n", value); hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!!value, "Got unexpected alpha blend enable state %#x.\n", value); hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); color = get_surface_color(rt, 320, 240); ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw2.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index b472b3d588..5bb5b1baad 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -924,6 +924,7 @@ static void test_coop_level_d3d_state(void) IDirect3DDevice2 *device; D3DMATERIAL material; IDirectDraw2 *ddraw; + DDSURFACEDESC lock; D3DCOLOR color; DWORD value; HWND window; @@ -958,26 +959,39 @@ static void test_coop_level_d3d_state(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_GetRenderTarget(device, &rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!!value, "Got unexpected z-enable state %#x.\n", value); hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!value, "Got unexpected alpha blend enable state %#x.\n", value); hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); - ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); color = get_surface_color(rt, 320, 240); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(rt); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + + memset(&lock, 0, sizeof(lock)); + lock.dwSize = sizeof(lock); + lock.lpSurface = (void *)0xdeadbeef; + hr = IDirectDrawSurface2_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface); + hr = restore_surfaces(ddraw); - ok(SUCCEEDED(hr), "Failed to restore surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDrawSurface2_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface2_Unlock(rt, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&material, 0, sizeof(material)); material.dwSize = sizeof(material); @@ -986,19 +1000,19 @@ static void test_coop_level_d3d_state(void) U3(U(material).diffuse).b = 0.0f; U4(U(material).diffuse).a = 1.0f; hr = IDirect3DMaterial2_SetMaterial(background, &material); - ok(SUCCEEDED(hr), "Failed to set material data, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_GetRenderTarget(device, &surface); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(surface == rt, "Got unexpected surface %p.\n", surface); hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!!value, "Got unexpected z-enable state %#x.\n", value); hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value); - ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(!!value, "Got unexpected alpha blend enable state %#x.\n", value); hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); color = get_surface_color(rt, 320, 240); ok(compare_color(color, 0x0000ff00, 1) || broken(compare_color(color, 0x00000000, 1)), "Got unexpected color 0x%08x.\n", color);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/ddraw1.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 5bfca43008..ff100c64aa 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -1085,6 +1085,7 @@ static void test_coop_level_d3d_state(void) IDirect3DViewport *viewport; IDirect3DDevice *device; D3DMATERIAL material; + DDSURFACEDESC lock; IDirectDraw *ddraw; D3DCOLOR color; HWND window; @@ -1106,18 +1107,31 @@ static void test_coop_level_d3d_state(void) viewport_set_background(device, viewport, background);
hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); color = get_surface_color(rt, 320, 240); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(rt); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + + memset(&lock, 0, sizeof(lock)); + lock.dwSize = sizeof(lock); + lock.lpSurface = (void *)0xdeadbeef; + hr = IDirectDrawSurface_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface); + hr = restore_surfaces(ddraw); - ok(SUCCEEDED(hr), "Failed to restore surfaces, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirectDrawSurface_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface2_Unlock(rt, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&material, 0, sizeof(material)); material.dwSize = sizeof(material); @@ -1126,13 +1140,13 @@ static void test_coop_level_d3d_state(void) U3(U(material).diffuse).b = 0.0f; U4(U(material).diffuse).a = 1.0f; hr = IDirect3DMaterial_SetMaterial(background, &material); - ok(SUCCEEDED(hr), "Failed to set material data, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&surface); - ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(surface == rt, "Got unexpected surface %p.\n", surface); hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET); - ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); color = get_surface_color(rt, 320, 240); ok(compare_color(color, 0x0000ff00, 1) || broken(compare_color(color, 0x00000000, 1)), "Got unexpected color 0x%08x.\n", color);
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=68201
Your paranoid android.
=== w864 (32 bit report) ===
ddraw: ddraw1.c:11168: Test failed: Got unexpected color 0x00ffffff.
=== w1064v1809_zh_CN (32 bit report) ===
ddraw: ddraw1.c:11148: Test failed: Got unexpected color 0x00ffffff. ddraw1.c:11168: Test failed: Got unexpected color 0x00ffffff.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com