From: David Adam <david.adam.cnrs(a)gmail.com>
Signed-off-by: David Adam <david.adam.cnrs(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 49 ++++++++++++++++++++++++++++++++++-------------
dlls/ddraw/tests/ddraw2.c | 49 ++++++++++++++++++++++++++++++++++-------------
dlls/ddraw/tests/ddraw4.c | 49 ++++++++++++++++++++++++++++++++++-------------
dlls/ddraw/tests/ddraw7.c | 49 ++++++++++++++++++++++++++++++++++-------------
4 files changed, 144 insertions(+), 52 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index cb6bffef7f9..99df15aea5b 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -5396,10 +5396,10 @@ static void test_create_surface_pitch(void)
static void test_mipmap(void)
{
- IDirectDrawSurface *surface, *surface2;
+ IDirectDrawSurface *surface, *surface_base, *surface_mip;
+ unsigned int i, mipmap_count;
DDSURFACEDESC surface_desc;
IDirectDraw *ddraw;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -5468,24 +5468,47 @@ static void test_mipmap(void)
ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
"Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1)
+ surface_base = surface;
+ IDirectDrawSurface2_AddRef(surface_base);
+ mipmap_count = U2(surface_desc).dwMipMapCount;
+ while (mipmap_count > 1)
{
- hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface_GetAttachedSurface(surface_base, &caps, &surface_mip);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(surface_base, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(U2(surface_desc).dwMipMapCount == mipmap_count,
+ "Test %u, %u: Got unexpected mipmap count %u.\n",
+ i, mipmap_count, U2(surface_desc).dwMipMapCount);
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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface_Lock(surface_base, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(surface_desc.dwMipMapCount == mipmap_count,
+ "Test %u, %u: unexpected change of mipmap count %u.\n",
+ i, mipmap_count, surface_desc.dwMipMapCount);
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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
- IDirectDrawSurface_Unlock(surface2, NULL);
- IDirectDrawSurface_Unlock(surface, NULL);
-
- IDirectDrawSurface_Release(surface2);
+ hr = IDirectDrawSurface_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine ok(surface_desc.dwMipMapCount == mipmap_count - 1,
+ "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+ IDirectDrawSurface_Unlock(surface_mip, NULL);
+ IDirectDrawSurface_Unlock(surface_base, NULL);
+
+ IDirectDrawSurface_Release(surface_base);
+ surface_base = surface_mip;
+ --mipmap_count;
}
+ IDirectDrawSurface_Release(surface_base);
IDirectDrawSurface_Release(surface);
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 8a19327071d..2c2008a2f02 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -6422,10 +6422,10 @@ static void test_create_surface_pitch(void)
static void test_mipmap(void)
{
IDirectDrawSurface *surface1;
- IDirectDrawSurface2 *surface, *surface2;
+ IDirectDrawSurface2 *surface, *surface_base, *surface_mip;
+ unsigned int i, mipmap_count;
DDSURFACEDESC surface_desc;
IDirectDraw2 *ddraw;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -6498,24 +6498,47 @@ static void test_mipmap(void)
ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
"Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1)
+ surface_base = surface;
+ IDirectDrawSurface2_AddRef(surface_base);
+ mipmap_count = U2(surface_desc).dwMipMapCount;
+ while (mipmap_count > 1)
{
- hr = IDirectDrawSurface2_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface2_GetAttachedSurface(surface_base, &caps, &surface_mip);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, 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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface2_GetSurfaceDesc(surface_base, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(U2(surface_desc).dwMipMapCount == mipmap_count,
+ "Test %u, %u: Got unexpected mipmap count %u.\n",
+ i, mipmap_count, U2(surface_desc).dwMipMapCount);
+
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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
- IDirectDrawSurface2_Unlock(surface2, NULL);
- IDirectDrawSurface2_Unlock(surface, NULL);
-
- IDirectDrawSurface2_Release(surface2);
+ hr = IDirectDrawSurface2_Lock(surface_base, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(surface_desc.dwMipMapCount == mipmap_count,
+ "Test %u, %u: unexpected change of mipmap count %u.\n",
+ i, mipmap_count, surface_desc.dwMipMapCount);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface2_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine ok(surface_desc.dwMipMapCount == mipmap_count - 1,
+ "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+ IDirectDrawSurface2_Unlock(surface_mip, NULL);
+ IDirectDrawSurface2_Unlock(surface_base, NULL);
+
+ IDirectDrawSurface2_Release(surface_base);
+ surface_base = surface_mip;
+ --mipmap_count;
}
+ IDirectDrawSurface2_Release(surface_base);
IDirectDrawSurface2_Release(surface);
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index b304863a38b..f94f62ef799 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -7954,10 +7954,10 @@ static void test_create_surface_pitch(void)
static void test_mipmap(void)
{
- IDirectDrawSurface4 *surface, *surface2;
+ IDirectDrawSurface4 *surface, *surface_base, *surface_mip;
+ unsigned int i, mipmap_count;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -8026,24 +8026,47 @@ static void test_mipmap(void)
ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
"Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1)
+ surface_base = surface;
+ IDirectDrawSurface4_AddRef(surface_base);
+ mipmap_count = U2(surface_desc).dwMipMapCount;
+ while (mipmap_count > 1)
{
- hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface4_GetAttachedSurface(surface_base, &caps, &surface_mip);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, 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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(surface_base, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(U2(surface_desc).dwMipMapCount == mipmap_count,
+ "Test %u, %u: Got unexpected mipmap count %u.\n",
+ i, mipmap_count, U2(surface_desc).dwMipMapCount);
+
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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
- IDirectDrawSurface4_Unlock(surface2, NULL);
- IDirectDrawSurface4_Unlock(surface, NULL);
-
- IDirectDrawSurface4_Release(surface2);
+ hr = IDirectDrawSurface4_Lock(surface_base, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(surface_desc.dwMipMapCount == mipmap_count,
+ "Test %u, %u: unexpected change of mipmap count %u.\n",
+ i, mipmap_count, surface_desc.dwMipMapCount);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine ok(surface_desc.dwMipMapCount == mipmap_count - 1,
+ "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+ IDirectDrawSurface4_Unlock(surface_mip, NULL);
+ IDirectDrawSurface4_Unlock(surface_base, NULL);
+
+ IDirectDrawSurface4_Release(surface_base);
+ surface_base = surface_mip;
+ --mipmap_count;
}
+ IDirectDrawSurface4_Release(surface_base);
IDirectDrawSurface4_Release(surface);
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 1cc8f8fe319..061c691c961 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -7788,10 +7788,10 @@ static void test_create_surface_pitch(void)
static void test_mipmap(void)
{
- IDirectDrawSurface7 *surface, *surface2;
+ IDirectDrawSurface7 *surface, *surface_base, *surface_mip;
+ unsigned int i, mipmap_count;
DDSURFACEDESC2 surface_desc;
IDirectDraw7 *ddraw;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -7861,24 +7861,47 @@ static void test_mipmap(void)
ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
"Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1)
+ surface_base = surface;
+ IDirectDrawSurface7_AddRef(surface_base);
+ mipmap_count = U2(surface_desc).dwMipMapCount;
+ while (mipmap_count > 1)
{
- hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface7_GetAttachedSurface(surface_base, &caps, &surface_mip);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, 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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(surface_base, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(U2(surface_desc).dwMipMapCount == mipmap_count,
+ "Test %u, %u: Got unexpected mipmap count %u.\n",
+ i, mipmap_count, U2(surface_desc).dwMipMapCount);
+
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), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
- IDirectDrawSurface7_Unlock(surface2, NULL);
- IDirectDrawSurface7_Unlock(surface, NULL);
-
- IDirectDrawSurface7_Release(surface2);
+ hr = IDirectDrawSurface7_Lock(surface_base, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine_if(mipmap_count != tests[i].mipmap_count_out)
+ ok(surface_desc.dwMipMapCount == mipmap_count,
+ "Test %u, %u: unexpected change of mipmap count %u.\n",
+ i, mipmap_count, surface_desc.dwMipMapCount);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+ todo_wine ok(surface_desc.dwMipMapCount == mipmap_count - 1,
+ "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+ IDirectDrawSurface7_Unlock(surface_mip, NULL);
+ IDirectDrawSurface7_Unlock(surface_base, NULL);
+
+ IDirectDrawSurface7_Release(surface_base);
+ surface_base = surface_mip;
+ --mipmap_count;
}
+ IDirectDrawSurface7_Release(surface_base);
IDirectDrawSurface7_Release(surface);
}
--
2.11.0