ddraw: Fix IDirectDraw4Impl_GetSurfaceFromDC().

Perhaps interesting to note is that this returns an IDirectDrawSurface instead
of an IDirectDrawSurface4.
This commit is contained in:
Henri Verbeet 2010-03-16 19:02:22 +01:00 committed by Alexandre Julliard
parent 4e48ae2629
commit 89fef0e669
2 changed files with 41 additions and 1 deletions

View File

@ -1048,7 +1048,15 @@ static HRESULT WINAPI
IDirectDraw4Impl_GetSurfaceFromDC(LPDIRECTDRAW4 This, HDC hDC,
LPDIRECTDRAWSURFACE4 *pSurf)
{
return IDirectDraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw4(This), hDC, (LPDIRECTDRAWSURFACE7 *)pSurf);
IDirectDrawSurface7 *surf7;
HRESULT hr;
if (!pSurf) return E_INVALIDARG;
hr = IDirectDraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw4(This), hDC, &surf7);
*pSurf = surf7 ? (IDirectDrawSurface4 *)&((IDirectDrawSurfaceImpl *)surf7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
static HRESULT WINAPI

View File

@ -3008,6 +3008,7 @@ static void GetDCTest(void)
IDirectDrawSurface2 *surf2;
IDirectDrawSurface4 *surf4;
IDirectDrawSurface7 *surf7;
IDirectDrawSurface *tmp;
IDirectDrawSurface7 *tmp7;
HRESULT hr;
IDirectDraw2 *dd2;
@ -3056,6 +3057,37 @@ static void GetDCTest(void)
ok(hr == DD_OK, "IDirectDraw4_CreateSurface failed: 0x%08x\n", hr);
dctest_surf((IDirectDrawSurface *) surf4, 2);
hr = IDirectDrawSurface4_QueryInterface(surf4, &IID_IDirectDrawSurface, (void **)&surf);
ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
hr = IDirectDrawSurface4_GetDC(surf4, &dc);
ok(SUCCEEDED(hr), "GetDC failed, hr %#x.\n", hr);
hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, NULL);
ok(hr == E_INVALIDARG, "Expected hr E_INVALIDARG, got %#x.\n", hr);
hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, (IDirectDrawSurface4 **)&tmp);
ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
ok(tmp == surf, "Expected surface %p, got %p.\n\n", surf, tmp);
hr = IDirectDrawSurface4_ReleaseDC(surf4, dc);
ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#x.\n", hr);
dc = CreateCompatibleDC(NULL);
ok(!!dc, "CreateCompatibleDC failed.\n");
tmp = (IDirectDrawSurface *)0xdeadbeef;
hr = IDirectDraw4_GetSurfaceFromDC(dd4, dc, (IDirectDrawSurface4 **)&tmp);
ok(hr == DDERR_NOTFOUND, "GetSurfaceFromDC failed, hr %#x.\n", hr);
ok(!tmp, "Expected surface NULL, got %p.\n", tmp);
ok(DeleteDC(dc), "DeleteDC failed.\n");
tmp = (IDirectDrawSurface *)0xdeadbeef;
hr = IDirectDraw4_GetSurfaceFromDC(dd4, NULL, (IDirectDrawSurface4 **)&tmp);
ok(hr == DDERR_NOTFOUND, "GetSurfaceFromDC failed, hr %#x.\n", hr);
ok(!tmp, "Expected surface NULL, got %p.\n", tmp);
IDirectDrawSurface4_Release(surf4);
IDirectDraw4_Release(dd4);