[PATCH] DDrawex: Add a test for the permanent DC function=0A=

Stefan Doesinger stefan at codeweavers.com
Thu Dec 18 16:43:06 CST 2008


=0A=
---=0A=
 dlls/d3d8/surface.c          |    6 +++-=0A=
 dlls/d3d9/surface.c          |    6 +++-=0A=
 dlls/ddrawex/tests/surface.c |   62 =
+++++++++++++++++++++++++++++++++++++++++-=0A=
 dlls/wined3d/surface.c       |    2 +-=0A=
 dlls/wined3d/surface_gdi.c   |    2 +-=0A=
 include/wine/wined3d.idl     |    1 +=0A=
 6 files changed, 74 insertions(+), 5 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c=0A=
index 6ecd7af..0d06da2 100644=0A=
--- a/dlls/d3d8/surface.c=0A=
+++ b/dlls/d3d8/surface.c=0A=
@@ -206,7 +206,11 @@ static HRESULT WINAPI =
IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface)=0A=
     EnterCriticalSection(&d3d8_cs);=0A=
     hr =3D IWineD3DSurface_UnlockRect(This->wineD3DSurface);=0A=
     LeaveCriticalSection(&d3d8_cs);=0A=
-    return hr;=0A=
+    switch(hr)=0A=
+    {=0A=
+        case WINEDDERR_NOTLOCKED:       return D3DERR_INVALIDCALL;=0A=
+        default:                        return hr;=0A=
+    }=0A=
 }=0A=
 =0A=
 const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =3D=0A=
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c=0A=
index 394d527..a626049 100644=0A=
--- a/dlls/d3d9/surface.c=0A=
+++ b/dlls/d3d9/surface.c=0A=
@@ -241,7 +241,11 @@ static HRESULT WINAPI =
IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface)=0A=
     EnterCriticalSection(&d3d9_cs);=0A=
     hr =3D IWineD3DSurface_UnlockRect(This->wineD3DSurface);=0A=
     LeaveCriticalSection(&d3d9_cs);=0A=
-    return hr;=0A=
+    switch(hr)=0A=
+    {=0A=
+        case WINEDDERR_NOTLOCKED:       return D3DERR_INVALIDCALL;=0A=
+        default:                        return hr;=0A=
+    }=0A=
 }=0A=
 =0A=
 static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 =
iface, HDC* phdc) {=0A=
diff --git a/dlls/ddrawex/tests/surface.c b/dlls/ddrawex/tests/surface.c=0A=
index 1c0acdd..e636d67 100644=0A=
--- a/dlls/ddrawex/tests/surface.c=0A=
+++ b/dlls/ddrawex/tests/surface.c=0A=
@@ -60,7 +60,7 @@ static void dctest_surf(IDirectDrawSurface *surf, int =
ddsdver) {=0A=
     ok(dc2 =3D=3D (HDC) 0x1234, "The failed GetDC call changed the dc: =
%p\n", dc2);=0A=
 =0A=
     hr =3D IDirectDrawSurface_Lock(surf, NULL, ddsdver =3D=3D 1 ? &ddsd =
: ((DDSURFACEDESC *) &ddsd2), 0, NULL);=0A=
-    ok(hr =3D=3D DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned =
0x%08x, expected DDERR_ALREADYLOCKED\n", hr);=0A=
+    ok(hr =3D=3D DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned =
0x%08x, expected DDERR_SURFACEBUSY\n", hr);=0A=
 =0A=
     hr =3D IDirectDrawSurface_ReleaseDC(surf, dc);=0A=
     ok(hr =3D=3D DD_OK, "IDirectDrawSurface_ReleaseDC failed: =
0x%08x\n", hr);=0A=
@@ -170,6 +170,65 @@ static void CapsTest(void)=0A=
     IDirectDraw_Release(dd1);=0A=
 }=0A=
 =0A=
+static void dctest_sysvidmem(IDirectDrawSurface *surf, int ddsdver) {=0A=
+    HRESULT hr;=0A=
+    HDC dc, dc2 =3D (HDC) 0x1234;=0A=
+    DDSURFACEDESC ddsd;=0A=
+    DDSURFACEDESC2 ddsd2;=0A=
+=0A=
+    memset(&ddsd, 0, sizeof(ddsd));=0A=
+    ddsd.dwSize =3D sizeof(ddsd);=0A=
+    memset(&ddsd2, 0, sizeof(ddsd2));=0A=
+    ddsd2.dwSize =3D sizeof(ddsd2);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_GetDC(surf, &dc);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", =
hr);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_GetDC(surf, &dc2);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", =
hr);=0A=
+    ok(dc =3D=3D dc2, "Got two different DCs\n");=0A=
+=0A=
+    hr =3D IDirectDrawSurface_Lock(surf, NULL, ddsdver =3D=3D 1 ? &ddsd =
: ((DDSURFACEDESC *) &ddsd2), 0, NULL);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_Lock returned 0x%08x, =
expected DD_OK\n", hr);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_Lock(surf, NULL, ddsdver =3D=3D 1 ? &ddsd =
: ((DDSURFACEDESC *) &ddsd2), 0, NULL);=0A=
+    ok(hr =3D=3D DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned =
0x%08x, expected DDERR_SURFACEBUSY\n", hr);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_Unlock(surf, NULL);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_Unlock returned 0x%08x, =
expected DD_OK\n", hr);=0A=
+    hr =3D IDirectDrawSurface_Unlock(surf, NULL);=0A=
+    ok(hr =3D=3D DDERR_NOTLOCKED, "IDirectDrawSurface_Unlock returned =
0x%08x, expected DDERR_NOTLOCKED\n", hr);=0A=
+=0A=
+    hr =3D IDirectDrawSurface_ReleaseDC(surf, dc);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_ReleaseDC failed: =
0x%08x\n", hr);=0A=
+    hr =3D IDirectDrawSurface_ReleaseDC(surf, dc);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_ReleaseDC failed: =
0x%08x\n", hr);=0A=
+    /* That works any number of times... */=0A=
+    hr =3D IDirectDrawSurface_ReleaseDC(surf, dc);=0A=
+    ok(hr =3D=3D DD_OK, "IDirectDrawSurface_ReleaseDC failed: =
0x%08x\n", hr);=0A=
+}=0A=
+=0A=
+static void SysVidMemTest(void)=0A=
+{=0A=
+    DDSURFACEDESC ddsd;=0A=
+    DDSURFACEDESC2 ddsd2;=0A=
+=0A=
+    memset(&ddsd, 0, sizeof(ddsd));=0A=
+    ddsd.dwSize =3D sizeof(ddsd);=0A=
+    ddsd.dwFlags =3D DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;=0A=
+    ddsd.dwWidth =3D 64;=0A=
+    ddsd.dwHeight =3D 64;=0A=
+    ddsd.ddsCaps.dwCaps =3D DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY;=0A=
+    memset(&ddsd2, 0, sizeof(ddsd2));=0A=
+    ddsd2.dwSize =3D sizeof(ddsd2);=0A=
+    ddsd2.dwFlags =3D DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;=0A=
+    ddsd2.dwWidth =3D 64;=0A=
+    ddsd2.dwHeight =3D 64;=0A=
+    ddsd2.ddsCaps.dwCaps =3D DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY;=0A=
+=0A=
+    GetDCTest_main(&ddsd, &ddsd2, dctest_sysvidmem);=0A=
+}=0A=
+=0A=
 START_TEST(surface)=0A=
 {=0A=
     IClassFactory *classfactory =3D NULL;=0A=
@@ -193,6 +252,7 @@ START_TEST(surface)=0A=
 =0A=
     GetDCTest();=0A=
     CapsTest();=0A=
+    SysVidMemTest();=0A=
 =0A=
     if(factory) {=0A=
         ref =3D IDirectDrawFactory_Release(factory);=0A=
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c=0A=
index 2837740..971bb9d 100644=0A=
--- a/dlls/wined3d/surface.c=0A=
+++ b/dlls/wined3d/surface.c=0A=
@@ -1320,7 +1320,7 @@ static HRESULT WINAPI =
IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {=0A=
 =0A=
     if (!(This->Flags & SFLAG_LOCKED)) {=0A=
         WARN("trying to Unlock an unlocked surf@%p\n", This);=0A=
-        return WINED3DERR_INVALIDCALL;=0A=
+        return WINEDDERR_NOTLOCKED;=0A=
     }=0A=
 =0A=
     if (This->Flags & SFLAG_PBO) {=0A=
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c=0A=
index 07a13b5..d3d4456 100644=0A=
--- a/dlls/wined3d/surface_gdi.c=0A=
+++ b/dlls/wined3d/surface_gdi.c=0A=
@@ -168,7 +168,7 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface =
*iface)=0A=
     if (!(This->Flags & SFLAG_LOCKED))=0A=
     {=0A=
         WARN("trying to Unlock an unlocked surf@%p\n", This);=0A=
-        return WINED3DERR_INVALIDCALL;=0A=
+        return WINEDDERR_NOTLOCKED;=0A=
     }=0A=
 =0A=
     /* Can be useful for debugging */=0A=
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl=0A=
index b43a8e7..21e55c1 100644=0A=
--- a/include/wine/wined3d.idl=0A=
+++ b/include/wine/wined3d.idl=0A=
@@ -74,6 +74,7 @@ cpp_quote("#define WINED3DERR_INVALIDCALL              =
        MAKE_WINED3DHRESU=0A=
 cpp_quote("#define WINED3DERR_DRIVERINVALIDCALL                =
MAKE_WINED3DHRESULT(2157)")=0A=
 cpp_quote("#define WINED3DERR_WASSTILLDRAWING                  =
MAKE_WINED3DHRESULT(540)")=0A=
 cpp_quote("#define WINEDDERR_NOTAOVERLAYSURFACE                =
MAKE_WINED3DHRESULT(580)")=0A=
+cpp_quote("#define WINEDDERR_NOTLOCKED                         =
MAKE_WINED3DHRESULT(584)")=0A=
 cpp_quote("#define WINEDDERR_NODC                              =
MAKE_WINED3DHRESULT(586)")=0A=
 cpp_quote("#define WINEDDERR_DCALREADYCREATED                  =
MAKE_WINED3DHRESULT(620)")=0A=
 cpp_quote("#define WINEDDERR_NOTFLIPPABLE                      =
MAKE_WINED3DHRESULT(582)")=0A=
-- =0A=
1.6.0.6=0A=
=0A=

------=_NextPart_000_0023_01C97257.7D3757F0--




More information about the wine-patches mailing list