[resend 3/5] ddraw7/tests: test SetColorKey on cubemap surfaces

Riccardo Bortolato rikyz619 at gmail.com
Wed Nov 4 12:51:06 CST 2015


From: Stefan Dösinger <stefan at codeweavers.com>

Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
---
 dlls/ddraw/tests/ddraw7.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index fe02396..35e0cc0 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -1613,12 +1613,14 @@ static void test_ck_default(void)
 static void test_ck_complex(void)
 {
     IDirectDrawSurface7 *surface, *mipmap, *tmp;
+    D3DDEVICEDESC7 device_desc;
     DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, {0}};
     DDSURFACEDESC2 surface_desc;
     IDirect3DDevice7 *device;
     DDCOLORKEY color_key;
     IDirectDraw7 *ddraw;
     IDirect3D7 *d3d;
+    BOOL cubemap_supported;
     unsigned int i;
     ULONG refcount;
     HWND window;
@@ -1632,6 +1634,9 @@ static void test_ck_complex(void)
         DestroyWindow(window);
         return;
     }
+    hr = IDirect3DDevice7_GetCaps(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    cubemap_supported = !!(device_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP);
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
     ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
@@ -1728,6 +1733,61 @@ static void test_ck_complex(void)
 
     refcount = IDirectDrawSurface7_Release(surface);
     ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+
+    if (!cubemap_supported)
+        goto cleanup;
+
+    memset(&surface_desc, 0, sizeof(surface_desc));
+    surface_desc.dwSize = sizeof(surface_desc);
+    surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+    surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
+    surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_ALLFACES;
+    surface_desc.dwWidth = 128;
+    surface_desc.dwHeight = 128;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+    hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    color_key.dwColorSpaceLowValue = 0x0000ff00;
+    color_key.dwColorSpaceHighValue = 0x0000ff00;
+    hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+
+    caps.dwCaps2 = DDSCAPS2_CUBEMAP_NEGATIVEZ;
+    hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &mipmap);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+
+    hr = IDirectDrawSurface7_GetColorKey(mipmap, DDCKEY_SRCBLT, &color_key);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    color_key.dwColorSpaceLowValue = 0x0000ff00;
+    color_key.dwColorSpaceHighValue = 0x0000ff00;
+    hr = IDirectDrawSurface7_SetColorKey(mipmap, DDCKEY_SRCBLT, &color_key);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+
+    IDirectDrawSurface_AddRef(mipmap);
+    for (i = 0; i < 7; ++i)
+    {
+        hr = IDirectDrawSurface7_GetAttachedSurface(mipmap, &caps, &tmp);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        hr = IDirectDrawSurface7_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
+        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+
+        color_key.dwColorSpaceLowValue = 0x000000ff;
+        color_key.dwColorSpaceHighValue = 0x000000ff;
+        hr = IDirectDrawSurface7_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
+        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x, i %u.\n", hr, i);
+
+        IDirectDrawSurface_Release(mipmap);
+        mipmap = tmp;
+    }
+
+    IDirectDrawSurface7_Release(mipmap);
+
+    refcount = IDirectDrawSurface7_Release(surface);
+    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+
+cleanup:
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
     ok(!refcount, "Got unexpected refcount %u.\n", refcount);
-- 
1.9.1




More information about the wine-patches mailing list