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

Alexandre Julliard julliard at wine.codeweavers.com
Mon Sep 10 10:17:53 CDT 2007


Module: wine
Branch: master
Commit: c53487b599a50ddcf0311ffe4be456975f984cbb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c53487b599a50ddcf0311ffe4be456975f984cbb

Author: David Hedberg <david.hedberg at gmail.com>
Date:   Mon Sep  3 13:57:24 2007 +0200

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

---

 dlls/ddraw/ddraw.c          |    7 ++++++-
 dlls/ddraw/tests/dsurface.c |   19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 696552d..7c6bf5f 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -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
             {
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index 6c223f4..59fd4ae 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -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)




More information about the wine-cvs mailing list