ddraw: Fix and test case for situation where DDSD_MIPMAPCOUNT is set and dwMipMapCount is 0.

This commit is contained in:
David Hedberg 2007-09-03 13:57:24 +02:00 committed by Alexandre Julliard
parent 2456473d66
commit c53487b599
2 changed files with 25 additions and 1 deletions

View File

@ -2417,7 +2417,12 @@ IDirectDrawImpl_CreateSurface(IDirectDraw7 *iface,
{
if(desc2.dwFlags & DDSD_MIPMAPCOUNT)
{
/* Mipmap count is given, nothing to do */
/* Mipmap count is given, should not be 0 */
if( desc2.u2.dwMipMapCount == 0 )
{
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
}
else
{

View File

@ -183,6 +183,25 @@ static void MipMapCreationTest(void)
/* Destroy the surface. */
IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Fifth mipmap creation test: try to create a surface with
DDSCAPS_COMPLEX, DDSCAPS_MIPMAP, DDSD_MIPMAPCOUNT,
where dwMipMapCount = 0. This should fail. */
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
U2(ddsd).dwMipMapCount = 0;
ddsd.dwWidth = 128;
ddsd.dwHeight = 32;
rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
ok(rc==DDERR_INVALIDPARAMS,"CreateSurface returned: %x\n",rc);
/* Destroy the surface. */
if( rc == DD_OK )
IDirectDrawSurface_Release(lpDDSMipMapTest);
}
static void SrcColorKey32BlitTest(void)