Commit a69c86d3 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddrawex: Add a test for the permanent DC function.

parent 58480f16
......@@ -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 =
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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 */
......
......@@ -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)")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment