Module: wine Branch: master Commit: ae4e8244230f6d298eadb71b9af8bda64991927b URL: http://source.winehq.org/git/wine.git/?a=commit;h=ae4e8244230f6d298eadb71b9a...
Author: Stefan Dösinger stefan@codeweavers.com Date: Fri Jan 9 12:32:24 2009 +0100
ddraw[ex]: Show a caps handling difference.
---
dlls/ddraw/ddraw.c | 11 +++++++++++ dlls/ddraw/tests/dsurface.c | 10 ++++++++++ dlls/ddrawex/tests/surface.c | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 286e4b3..5a24ddb 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -2432,6 +2432,7 @@ IDirectDrawImpl_CreateSurface(IDirectDraw7 *iface, LONG extra_surfaces = 0; DDSURFACEDESC2 desc2; WINED3DDISPLAYMODE Mode; + const DWORD sysvidmem = DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
TRACE("(%p)->(%p,%p,%p)\n", This, DDSD, Surf, UnkOuter);
@@ -2490,6 +2491,16 @@ IDirectDrawImpl_CreateSurface(IDirectDraw7 *iface, LeaveCriticalSection(&ddraw_cs); return DDERR_INVALIDCAPS; } + + if((DDSD->ddsCaps.dwCaps & sysvidmem) == sysvidmem) + { + /* This is a special switch in ddrawex.dll, but not allowed in ddraw.dll */ + WARN("Application tries to put the surface in both system and video memory\n"); + LeaveCriticalSection(&ddraw_cs); + *Surf = NULL; + return DDERR_INVALIDCAPS; + } + /* Check cube maps but only if the size includes them */ if (DDSD->dwSize >= sizeof(DDSURFACEDESC2)) { diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c index 68a51cd..a12b968 100644 --- a/dlls/ddraw/tests/dsurface.c +++ b/dlls/ddraw/tests/dsurface.c @@ -2746,6 +2746,16 @@ static void SurfaceCapsTest(void)
IDirectDraw7_Release(dd7); } + + memset(&create, 0, sizeof(create)); + create.dwSize = sizeof(create); + create.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + create.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY; + create.dwWidth = 64; + create.dwHeight = 64; + hr = IDirectDraw_CreateSurface(lpDD, &create, &surface1, NULL); + ok(hr == DDERR_INVALIDCAPS, "Creating a SYSMEM | VIDMEM surface returned 0x%08x, expected DDERR_INVALIDCAPS\n", hr); + if(surface1) IDirectDrawSurface_Release(surface1); }
static BOOL can_create_primary_surface(void) diff --git a/dlls/ddrawex/tests/surface.c b/dlls/ddrawex/tests/surface.c index 84743fe..b2065bc 100644 --- a/dlls/ddrawex/tests/surface.c +++ b/dlls/ddrawex/tests/surface.c @@ -147,6 +147,26 @@ static void GetDCTest(void) IDirectDraw_Release(dd1); }
+static void CapsTest(void) +{ + DDSURFACEDESC ddsd; + IDirectDraw *dd1 = createDD(); + IDirectDrawSurface *surf; + HRESULT hr; + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY; + ddsd.dwWidth = 64; + ddsd.dwHeight = 64; + hr = IDirectDraw_CreateSurface(dd1, &ddsd, &surf, NULL); + todo_wine ok(hr == DD_OK, "Creating a SYSMEM | VIDMEM surface returned 0x%08x, expected DD_OK\n", hr); + if(surf) IDirectDrawSurface_Release(surf); + + IDirectDraw_Release(dd1); +} + START_TEST(surface) { IClassFactory *classfactory = NULL; @@ -169,6 +189,7 @@ START_TEST(surface) ok(hr == S_OK, "Failed to create a IDirectDrawFactory\n");
GetDCTest(); + CapsTest();
if(factory) { ref = IDirectDrawFactory_Release(factory);