From a69c86d3f517f659ba47495f77deac2df671fb03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Thu, 18 Dec 2008 16:43:06 +0100 Subject: [PATCH] ddrawex: Add a test for the permanent DC function. --- dlls/d3d8/surface.c | 6 ++++- dlls/d3d9/surface.c | 6 ++++- dlls/ddrawex/tests/surface.c | 62 +++++++++++++++++++++++++++++++++++++++++++- dlls/wined3d/surface.c | 2 +- dlls/wined3d/surface_gdi.c | 2 +- include/wine/wined3d.idl | 1 + 6 files changed, 74 insertions(+), 5 deletions(-) diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 6ecd7af8c8f..0d06da26938 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -206,7 +206,11 @@ static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) EnterCriticalSection(&d3d8_cs); hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface); LeaveCriticalSection(&d3d8_cs); - return hr; + switch(hr) + { + case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL; + default: return hr; + } } const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl = diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 394d52786af..a626049df53 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -241,7 +241,11 @@ static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) EnterCriticalSection(&d3d9_cs); hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface); LeaveCriticalSection(&d3d9_cs); - return hr; + switch(hr) + { + case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL; + default: return hr; + } } static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) { diff --git a/dlls/ddrawex/tests/surface.c b/dlls/ddrawex/tests/surface.c index 1edb9d54d31..dd9ebfb0c9f 100644 --- a/dlls/ddrawex/tests/surface.c +++ b/dlls/ddrawex/tests/surface.c @@ -60,7 +60,7 @@ static void dctest_surf(IDirectDrawSurface *surf, int ddsdver) { ok(dc2 == (HDC) 0x1234, "The failed GetDC call changed the dc: %p\n", dc2); hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL); - ok(hr == DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned 0x%08x, expected DDERR_ALREADYLOCKED\n", hr); + ok(hr == DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned 0x%08x, expected DDERR_SURFACEBUSY\n", hr); hr = IDirectDrawSurface_ReleaseDC(surf, dc); ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr); @@ -170,6 +170,65 @@ static void CapsTest(void) IDirectDraw_Release(dd1); } +static void dctest_sysvidmem(IDirectDrawSurface *surf, int ddsdver) { + HRESULT hr; + HDC dc, dc2 = (HDC) 0x1234; + DDSURFACEDESC ddsd; + DDSURFACEDESC2 ddsd2; + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + memset(&ddsd2, 0, sizeof(ddsd2)); + ddsd2.dwSize = sizeof(ddsd2); + + hr = IDirectDrawSurface_GetDC(surf, &dc); + ok(hr == DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr); + + hr = IDirectDrawSurface_GetDC(surf, &dc2); + ok(hr == DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr); + ok(dc == dc2, "Got two different DCs\n"); + + hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL); + ok(hr == DD_OK, "IDirectDrawSurface_Lock returned 0x%08x, expected DD_OK\n", hr); + + hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL); + ok(hr == DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned 0x%08x, expected DDERR_SURFACEBUSY\n", hr); + + hr = IDirectDrawSurface_Unlock(surf, NULL); + ok(hr == DD_OK, "IDirectDrawSurface_Unlock returned 0x%08x, expected DD_OK\n", hr); + hr = IDirectDrawSurface_Unlock(surf, NULL); + ok(hr == DDERR_NOTLOCKED, "IDirectDrawSurface_Unlock returned 0x%08x, expected DDERR_NOTLOCKED\n", hr); + + hr = IDirectDrawSurface_ReleaseDC(surf, dc); + ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr); + hr = IDirectDrawSurface_ReleaseDC(surf, dc); + ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr); + /* That works any number of times... */ + hr = IDirectDrawSurface_ReleaseDC(surf, dc); + ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr); +} + +static void SysVidMemTest(void) +{ + DDSURFACEDESC ddsd; + DDSURFACEDESC2 ddsd2; + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwWidth = 64; + ddsd.dwHeight = 64; + ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY; + memset(&ddsd2, 0, sizeof(ddsd2)); + ddsd2.dwSize = sizeof(ddsd2); + ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd2.dwWidth = 64; + ddsd2.dwHeight = 64; + ddsd2.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY; + + GetDCTest_main(&ddsd, &ddsd2, dctest_sysvidmem); +} + START_TEST(surface) { IClassFactory *classfactory = NULL; @@ -193,6 +252,7 @@ START_TEST(surface) GetDCTest(); CapsTest(); + SysVidMemTest(); if(factory) { ref = IDirectDrawFactory_Release(factory); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 17936968897..771291f0651 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1320,7 +1320,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) { if (!(This->Flags & SFLAG_LOCKED)) { WARN("trying to Unlock an unlocked surf@%p\n", This); - return WINED3DERR_INVALIDCALL; + return WINEDDERR_NOTLOCKED; } if (This->Flags & SFLAG_PBO) { diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c index 7e53cd33649..4a8f6faf7cc 100644 --- a/dlls/wined3d/surface_gdi.c +++ b/dlls/wined3d/surface_gdi.c @@ -168,7 +168,7 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface) if (!(This->Flags & SFLAG_LOCKED)) { WARN("trying to Unlock an unlocked surf@%p\n", This); - return WINED3DERR_INVALIDCALL; + return WINEDDERR_NOTLOCKED; } /* Can be useful for debugging */ diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index b43a8e75b6d..21e55c112de 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -74,6 +74,7 @@ cpp_quote("#define WINED3DERR_INVALIDCALL MAKE_WINED3DHRESU cpp_quote("#define WINED3DERR_DRIVERINVALIDCALL MAKE_WINED3DHRESULT(2157)") cpp_quote("#define WINED3DERR_WASSTILLDRAWING MAKE_WINED3DHRESULT(540)") cpp_quote("#define WINEDDERR_NOTAOVERLAYSURFACE MAKE_WINED3DHRESULT(580)") +cpp_quote("#define WINEDDERR_NOTLOCKED MAKE_WINED3DHRESULT(584)") cpp_quote("#define WINEDDERR_NODC MAKE_WINED3DHRESULT(586)") cpp_quote("#define WINEDDERR_DCALREADYCREATED MAKE_WINED3DHRESULT(620)") cpp_quote("#define WINEDDERR_NOTFLIPPABLE MAKE_WINED3DHRESULT(582)") -- 2.11.4.GIT