ddraw: SetSurfaceDesc accepts DDSD_CAPS with dwCaps=0.

This commit is contained in:
Stefan Dösinger 2013-12-03 13:44:35 +01:00 committed by Alexandre Julliard
parent 1f36605886
commit c15d89c803
4 changed files with 34 additions and 4 deletions

View File

@ -4264,7 +4264,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
WARN("DDSD_LPSURFACE is not set, returning DDERR_INVALIDPARAMS\n");
return DDERR_INVALIDPARAMS;
}
if (DDSD->dwFlags & DDSD_CAPS)
if ((DDSD->dwFlags & DDSD_CAPS) && DDSD->ddsCaps.dwCaps)
{
WARN("DDSD_CAPS is set, returning DDERR_INVALIDCAPS.\n");
return DDERR_INVALIDCAPS;

View File

@ -4476,6 +4476,7 @@ static void test_set_surface_desc(void)
hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.ddsCaps.dwCaps == DDSCAPS_SYSTEMMEMORY, "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
/* Setting the caps is an error. This also means the original description cannot be reapplied. */
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
@ -4485,7 +4486,7 @@ static void test_set_surface_desc(void)
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#x.\n", hr);
/* TODO: The INVALIDCAPS return value suggests that some caps can be set. */
/* dwCaps = 0 is allowed, but ignored. */
ddsd.dwFlags = DDSD_CAPS | DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
@ -4493,6 +4494,13 @@ static void test_set_surface_desc(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
ddsd.ddsCaps.dwCaps = 0;
hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.ddsCaps.dwCaps == DDSCAPS_SYSTEMMEMORY, "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
/* Setting the height is allowed, but it cannot be set to 0, and only if LPSURFACE is set too. */
reset_ddsd(&ddsd);

View File

@ -5077,6 +5077,8 @@ static void test_set_surface_desc(void)
hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.ddsCaps.dwCaps == DDSCAPS_SYSTEMMEMORY, "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
/* Setting the caps is an error. This also means the original description cannot be reapplied. */
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
@ -5086,7 +5088,7 @@ static void test_set_surface_desc(void)
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#x.\n", hr);
/* TODO: The INVALIDCAPS return value suggests that some caps can be set. */
/* dwCaps = 0 is allowed, but ignored. Caps2 can be anything and is ignored too. */
ddsd.dwFlags = DDSD_CAPS | DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
@ -5094,6 +5096,15 @@ static void test_set_surface_desc(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
ddsd.ddsCaps.dwCaps = 0;
ddsd.ddsCaps.dwCaps2 = 0xdeadbeef;
hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.ddsCaps.dwCaps == DDSCAPS_SYSTEMMEMORY, "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
/* Setting the height is allowed, but it cannot be set to 0, and only if LPSURFACE is set too. */
reset_ddsd(&ddsd);

View File

@ -4964,6 +4964,8 @@ static void test_set_surface_desc(void)
hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.ddsCaps.dwCaps == DDSCAPS_SYSTEMMEMORY, "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
/* Setting the caps is an error. This also means the original description cannot be reapplied. */
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
@ -4973,7 +4975,7 @@ static void test_set_surface_desc(void)
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#x.\n", hr);
/* TODO: The INVALIDCAPS return value suggests that some caps can be set. */
/* dwCaps = 0 is allowed, but ignored. Caps2 can be anything and is ignored too. */
ddsd.dwFlags = DDSD_CAPS | DDSD_LPSURFACE;
ddsd.lpSurface = data;
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
@ -4981,6 +4983,15 @@ static void test_set_surface_desc(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
ddsd.ddsCaps.dwCaps = 0;
ddsd.ddsCaps.dwCaps2 = 0xdeadbeef;
hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.ddsCaps.dwCaps == DDSCAPS_SYSTEMMEMORY, "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
/* Setting the height is allowed, but it cannot be set to 0, and only if LPSURFACE is set too. */
reset_ddsd(&ddsd);