mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
ddraw: Add a test for IDirectDrawSurface::GetDC.
This commit is contained in:
parent
6a548b1e9d
commit
616ea53226
@ -263,7 +263,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface,
|
||||
EnterCriticalSection(&d3d9_cs);
|
||||
hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
|
||||
LeaveCriticalSection(&d3d9_cs);
|
||||
return hr;
|
||||
switch(hr) {
|
||||
case WINEDDERR_NODC: return WINED3DERR_INVALIDCALL;
|
||||
default: return hr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2764,6 +2764,101 @@ static BOOL can_create_primary_surface(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void dctest_surf(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 == DDERR_DCALREADYCREATED, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);
|
||||
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);
|
||||
|
||||
hr = IDirectDrawSurface_ReleaseDC(surf, dc);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr);
|
||||
hr = IDirectDrawSurface_ReleaseDC(surf, dc);
|
||||
ok(hr == DDERR_NODC, "IDirectDrawSurface_ReleaseDC returned 0x%08x, expected DDERR_NODC\n", hr);
|
||||
}
|
||||
|
||||
static void GetDCTest(void)
|
||||
{
|
||||
DDSURFACEDESC ddsd;
|
||||
DDSURFACEDESC2 ddsd2;
|
||||
IDirectDrawSurface *surf;
|
||||
IDirectDrawSurface2 *surf2;
|
||||
IDirectDrawSurface4 *surf4;
|
||||
IDirectDrawSurface7 *surf7;
|
||||
HRESULT hr;
|
||||
IDirectDraw2 *dd2;
|
||||
IDirectDraw4 *dd4;
|
||||
IDirectDraw7 *dd7;
|
||||
|
||||
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_OFFSCREENPLAIN;
|
||||
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_OFFSCREENPLAIN;
|
||||
|
||||
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surf, NULL);
|
||||
ok(hr == DD_OK, "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
|
||||
dctest_surf(surf, 1);
|
||||
IDirectDrawSurface_Release(surf);
|
||||
|
||||
hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
|
||||
ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
|
||||
|
||||
hr = IDirectDraw2_CreateSurface(dd2, &ddsd, &surf, NULL);
|
||||
ok(hr == DD_OK, "IDirectDraw2_CreateSurface failed: 0x%08x\n", hr);
|
||||
dctest_surf(surf, 1);
|
||||
|
||||
hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface2, (void **) &surf2);
|
||||
ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed: 0x%08x\n", hr);
|
||||
dctest_surf((IDirectDrawSurface *) surf2, 1);
|
||||
|
||||
IDirectDrawSurface2_Release(surf2);
|
||||
IDirectDrawSurface_Release(surf);
|
||||
IDirectDraw2_Release(dd2);
|
||||
|
||||
hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
|
||||
ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
|
||||
|
||||
surf = NULL;
|
||||
hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);
|
||||
ok(hr == DD_OK, "IDirectDraw4_CreateSurface failed: 0x%08x\n", hr);
|
||||
dctest_surf((IDirectDrawSurface *) surf4, 2);
|
||||
|
||||
IDirectDrawSurface4_Release(surf4);
|
||||
IDirectDraw4_Release(dd4);
|
||||
|
||||
hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
|
||||
ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
|
||||
surf = NULL;
|
||||
hr = IDirectDraw7_CreateSurface(dd7, &ddsd2, &surf7, NULL);
|
||||
ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed: 0x%08x\n", hr);
|
||||
dctest_surf((IDirectDrawSurface *) surf7, 2);
|
||||
|
||||
IDirectDrawSurface7_Release(surf7);
|
||||
IDirectDraw7_Release(dd7);
|
||||
}
|
||||
|
||||
START_TEST(dsurface)
|
||||
{
|
||||
HRESULT ret;
|
||||
@ -2806,5 +2901,6 @@ START_TEST(dsurface)
|
||||
StructSizeTest();
|
||||
PaletteTest();
|
||||
SurfaceCapsTest();
|
||||
GetDCTest();
|
||||
ReleaseDirectDraw();
|
||||
}
|
||||
|
@ -1527,11 +1527,11 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC
|
||||
TRACE("(%p)->(%p)\n",This,hDC);
|
||||
|
||||
if (!(This->Flags & SFLAG_DCINUSE))
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
return WINEDDERR_NODC;
|
||||
|
||||
if (This->hDC !=hDC) {
|
||||
WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
return WINEDDERR_NODC;
|
||||
}
|
||||
|
||||
if((This->Flags & SFLAG_PBO) && This->resource.allocatedMemory) {
|
||||
|
@ -442,11 +442,11 @@ static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC
|
||||
TRACE("(%p)->(%p)\n",This,hDC);
|
||||
|
||||
if (!(This->Flags & SFLAG_DCINUSE))
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
return WINEDDERR_NODC;
|
||||
|
||||
if (This->hDC !=hDC) {
|
||||
WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
return WINEDDERR_NODC;
|
||||
}
|
||||
|
||||
/* we locked first, so unlock now */
|
||||
|
Loading…
Reference in New Issue
Block a user