[PATCH 5/5] ddraw/tests: Add mipmap locking tests.
Stefan Dösinger
stefan at codeweavers.com
Fri Apr 4 04:51:05 CDT 2014
---
dlls/ddraw/tests/ddraw1.c | 62 +++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw2.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 62 +++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 62 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 253 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 52f60af..857882a 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -4503,6 +4503,67 @@ static void test_create_surface_pitch(void)
DestroyWindow(window);
}
+static void test_mipmap_lock(void)
+{
+ IDirectDrawSurface *surface, *surface2;
+ DDSURFACEDESC surface_desc;
+ IDirectDraw *ddraw;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+ DDSCAPS caps = {DDSCAPS_COMPLEX};
+ DDCAPS hal_caps;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&hal_caps, 0, sizeof(hal_caps));
+ hal_caps.dwSize = sizeof(hal_caps);
+ hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
+ ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+ if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
+ {
+ skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ IDirectDraw_Release(ddraw);
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
+ surface_desc.dwWidth = 4;
+ surface_desc.dwHeight = 4;
+ U2(surface_desc).dwMipMapCount = 2;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
+ | DDSCAPS_SYSTEMMEMORY;
+ hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ IDirectDrawSurface_Unlock(surface2, NULL);
+ IDirectDrawSurface_Unlock(surface, NULL);
+
+ IDirectDrawSurface_Release(surface2);
+ IDirectDrawSurface_Release(surface);
+ refcount = IDirectDraw_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
@@ -4547,4 +4608,5 @@ START_TEST(ddraw1)
test_surface_attachment();
test_pixel_format();
test_create_surface_pitch();
+ test_mipmap_lock();
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 53c5a37..36845fe 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -5606,6 +5606,72 @@ static void test_create_surface_pitch(void)
DestroyWindow(window);
}
+static void test_mipmap_lock(void)
+{
+ IDirectDrawSurface *surface1;
+ IDirectDrawSurface2 *surface, *surface2;
+ DDSURFACEDESC surface_desc;
+ IDirectDraw2 *ddraw;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+ DDSCAPS caps = {DDSCAPS_COMPLEX};
+ DDCAPS hal_caps;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&hal_caps, 0, sizeof(hal_caps));
+ hal_caps.dwSize = sizeof(hal_caps);
+ hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, NULL);
+ ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+ if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
+ {
+ skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ IDirectDraw2_Release(ddraw);
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
+ surface_desc.dwWidth = 4;
+ surface_desc.dwHeight = 4;
+ U2(surface_desc).dwMipMapCount = 2;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
+ | DDSCAPS_SYSTEMMEMORY;
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
+ ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#x.\n", hr);
+ IDirectDrawSurface_Release(surface1);
+ hr = IDirectDrawSurface2_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface2_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface2_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ IDirectDrawSurface2_Unlock(surface2, NULL);
+ IDirectDrawSurface2_Unlock(surface, NULL);
+
+ IDirectDrawSurface2_Release(surface2);
+ IDirectDrawSurface2_Release(surface);
+ refcount = IDirectDraw2_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
@@ -5656,4 +5722,5 @@ START_TEST(ddraw2)
test_surface_attachment();
test_pixel_format();
test_create_surface_pitch();
+ test_mipmap_lock();
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index e8fe3a1..bd2cf17 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -6465,6 +6465,67 @@ static void test_create_surface_pitch(void)
DestroyWindow(window);
}
+static void test_mipmap_lock(void)
+{
+ IDirectDrawSurface4 *surface, *surface2;
+ DDSURFACEDESC2 surface_desc;
+ IDirectDraw4 *ddraw;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+ DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, 0};
+ DDCAPS hal_caps;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&hal_caps, 0, sizeof(hal_caps));
+ hal_caps.dwSize = sizeof(hal_caps);
+ hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
+ ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+ if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
+ {
+ skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ IDirectDraw4_Release(ddraw);
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
+ surface_desc.dwWidth = 4;
+ surface_desc.dwHeight = 4;
+ U2(surface_desc).dwMipMapCount = 2;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
+ | DDSCAPS_SYSTEMMEMORY;
+ hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ IDirectDrawSurface4_Unlock(surface2, NULL);
+ IDirectDrawSurface4_Unlock(surface, NULL);
+
+ IDirectDrawSurface4_Release(surface2);
+ IDirectDrawSurface4_Release(surface);
+ refcount = IDirectDraw4_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
@@ -6521,4 +6582,5 @@ START_TEST(ddraw4)
test_private_data();
test_pixel_format();
test_create_surface_pitch();
+ test_mipmap_lock();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 7242fc1..8aab791 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -6320,6 +6320,67 @@ static void test_create_surface_pitch(void)
DestroyWindow(window);
}
+static void test_mipmap_lock(void)
+{
+ IDirectDrawSurface7 *surface, *surface2;
+ DDSURFACEDESC2 surface_desc;
+ IDirectDraw7 *ddraw;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+ DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, 0};
+ DDCAPS hal_caps;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ memset(&hal_caps, 0, sizeof(hal_caps));
+ hal_caps.dwSize = sizeof(hal_caps);
+ hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
+ ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+ if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
+ {
+ skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ IDirectDraw7_Release(ddraw);
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
+ surface_desc.dwWidth = 4;
+ surface_desc.dwHeight = 4;
+ U2(surface_desc).dwMipMapCount = 2;
+ surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
+ | DDSCAPS_SYSTEMMEMORY;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+ IDirectDrawSurface7_Unlock(surface2, NULL);
+ IDirectDrawSurface7_Unlock(surface, NULL);
+
+ IDirectDrawSurface7_Release(surface2);
+ IDirectDrawSurface7_Release(surface);
+ refcount = IDirectDraw7_Release(ddraw);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -6383,4 +6444,5 @@ START_TEST(ddraw7)
test_private_data();
test_pixel_format();
test_create_surface_pitch();
+ test_mipmap_lock();
}
--
1.8.3.2
More information about the wine-patches
mailing list