mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
ddraw-EnumSurfaces: Update patchset.
This commit is contained in:
parent
38db7901d7
commit
c3db854717
@ -0,0 +1,235 @@
|
||||
From 4c6b3da41feef98226bbfe14c2b0e88acf39807e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Tue, 25 Aug 2015 11:15:59 +0200
|
||||
Subject: ddraw/tests: Add more tests for IDirectDraw7::EnumSurfaces.
|
||||
|
||||
---
|
||||
dlls/ddraw/ddraw.c | 3 +
|
||||
dlls/ddraw/tests/d3d.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 172 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
|
||||
index b3caba2..4b7a207 100644
|
||||
--- a/dlls/ddraw/ddraw.c
|
||||
+++ b/dlls/ddraw/ddraw.c
|
||||
@@ -3135,6 +3135,9 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
|
||||
if (!Callback)
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
+ if (!all && !DDSD)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
wined3d_mutex_lock();
|
||||
|
||||
/* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
|
||||
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
|
||||
index ec4197a..e9c616e 100644
|
||||
--- a/dlls/ddraw/tests/d3d.c
|
||||
+++ b/dlls/ddraw/tests/d3d.c
|
||||
@@ -57,6 +57,12 @@ typedef struct {
|
||||
int total;
|
||||
} D3D7ECancelTest;
|
||||
|
||||
+typedef struct
|
||||
+{
|
||||
+ int found;
|
||||
+ int surfaces;
|
||||
+} EnumSurfaceTest;
|
||||
+
|
||||
#define MAX_ENUMERATION_COUNT 10
|
||||
typedef struct
|
||||
{
|
||||
@@ -85,17 +91,21 @@ static ULONG getRefcount(IUnknown *iface)
|
||||
|
||||
static HRESULT WINAPI SurfaceCounter(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context)
|
||||
{
|
||||
- UINT *num = context;
|
||||
- (*num)++;
|
||||
- IDirectDrawSurface_Release(surface);
|
||||
+ EnumSurfaceTest *count = context;
|
||||
+ count->found++;
|
||||
+ if (surface)
|
||||
+ {
|
||||
+ count->surfaces++;
|
||||
+ IDirectDrawSurface_Release(surface);
|
||||
+ }
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
static BOOL CreateDirect3D(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
- DDSURFACEDESC2 ddsd;
|
||||
- UINT num;
|
||||
+ DDSURFACEDESC2 ddsd, ddsd2;
|
||||
+ EnumSurfaceTest count;
|
||||
|
||||
rc = pDirectDrawCreateEx(NULL, (void**)&lpDD,
|
||||
&IID_IDirectDraw7, NULL);
|
||||
@@ -122,9 +132,160 @@ static BOOL CreateDirect3D(void)
|
||||
if (FAILED(rc))
|
||||
return FALSE;
|
||||
|
||||
- num = 0;
|
||||
- IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, NULL, &num, SurfaceCounter);
|
||||
- ok(num == 1, "Has %d surfaces, expected 1\n", num);
|
||||
+ memset(&ddsd2, 0, sizeof(ddsd2));
|
||||
+ ddsd2.dwSize = sizeof(ddsd2);
|
||||
+ ddsd2.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
|
||||
+ ddsd2.dwWidth = 256;
|
||||
+ ddsd2.dwHeight = 256;
|
||||
+
|
||||
+ /* without search type flags */
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, 0, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, 0, &ddsd, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL, NULL, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_MATCH, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_NOMATCH, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ /* search type DDENUMSURFACES_DOESEXIST */
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST, &ddsd2, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
|
||||
+ NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
|
||||
+ &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
|
||||
+ &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
|
||||
+ &ddsd2, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
|
||||
+ &ddsd2, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL |
|
||||
+ DDENUMSURFACES_MATCH, NULL, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL |
|
||||
+ DDENUMSURFACES_NOMATCH, NULL, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH |
|
||||
+ DDENUMSURFACES_NOMATCH, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ /* search type DDENUMSURFACES_CANBECREATED */
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED, &ddsd, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
|
||||
+ &ddsd, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH,
|
||||
+ &ddsd, &count, SurfaceCounter);
|
||||
+ todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
|
||||
+ NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
|
||||
+ &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ /* combination of DDENUMSURFACES_DOESEXIST and DDENUMSURFACES_CANBECREATED */
|
||||
+ count.found = count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_CANBECREATED |
|
||||
+ DDENUMSURFACES_MATCH, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ todo_wine ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
--
|
||||
2.5.0
|
||||
|
@ -1,6 +1,6 @@
|
||||
From 2958e8aaaf0ea5dd63199b884edb94b4c11f2903 Mon Sep 17 00:00:00 2001
|
||||
From 42dd44a1aa50a947d7184e1eeeb5b1b31ed69125 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 9 Apr 2015 05:46:09 +0200
|
||||
Date: Tue, 25 Aug 2015 11:16:07 +0200
|
||||
Subject: ddraw: Fix arguments to IDirectDraw7::EnumSurfaces in DllMain.
|
||||
|
||||
---
|
||||
@ -8,10 +8,10 @@ Subject: ddraw: Fix arguments to IDirectDraw7::EnumSurfaces in DllMain.
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c
|
||||
index 2f5d113..aa50f35 100644
|
||||
index 8631827..3dae424 100644
|
||||
--- a/dlls/ddraw/main.c
|
||||
+++ b/dlls/ddraw/main.c
|
||||
@@ -936,8 +936,8 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
||||
@@ -937,8 +937,8 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
||||
desc.dwSize = sizeof(desc);
|
||||
for(i = 0; i <= 1; i++)
|
||||
{
|
||||
@ -23,5 +23,5 @@ index 2f5d113..aa50f35 100644
|
||||
ERR("(%p) EnumSurfaces failed, prepare for trouble\n", ddraw);
|
||||
}
|
||||
--
|
||||
2.3.5
|
||||
2.5.0
|
||||
|
@ -1,360 +0,0 @@
|
||||
From e01ecc956620d02c29ed92b56372087868a4149e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Sat, 4 Apr 2015 05:49:09 +0200
|
||||
Subject: ddraw: Implement DDENUMSURFACES_CANBECREATED in
|
||||
IDirectDraw7::EnumSurfaces and fix some bugs.
|
||||
|
||||
---
|
||||
dlls/ddraw/ddraw.c | 97 +++++++++++++++++++------
|
||||
dlls/ddraw/tests/d3d.c | 190 ++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 256 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
|
||||
index 31ec6bf..b860834 100644
|
||||
--- a/dlls/ddraw/ddraw.c
|
||||
+++ b/dlls/ddraw/ddraw.c
|
||||
@@ -3119,46 +3119,97 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
|
||||
{
|
||||
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
||||
struct ddraw_surface *surf;
|
||||
- BOOL all, nomatch;
|
||||
- DDSURFACEDESC2 desc;
|
||||
- struct list *entry, *entry2;
|
||||
+ DWORD match_flags = Flags & (DDENUMSURFACES_ALL | DDENUMSURFACES_NOMATCH | DDENUMSURFACES_MATCH);
|
||||
|
||||
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
||||
iface, Flags, DDSD, Context, Callback);
|
||||
|
||||
- all = Flags & DDENUMSURFACES_ALL;
|
||||
- nomatch = Flags & DDENUMSURFACES_NOMATCH;
|
||||
-
|
||||
if (!Callback)
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
- wined3d_mutex_lock();
|
||||
-
|
||||
- /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
|
||||
- LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
|
||||
+ if (Flags & DDENUMSURFACES_CANBECREATED)
|
||||
{
|
||||
- surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
|
||||
+ IDirectDrawSurface7 *surface;
|
||||
+ DDSURFACEDESC2 testdesc;
|
||||
+
|
||||
+ if (match_flags != DDENUMSURFACES_MATCH)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
+ if (!DDSD)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
+ memcpy(&testdesc, DDSD, sizeof(testdesc));
|
||||
+
|
||||
+ if (!(testdesc.dwFlags & DDSD_WIDTH))
|
||||
+ {
|
||||
+ testdesc.dwFlags |= DDSD_WIDTH;
|
||||
+ testdesc.dwWidth = 512;
|
||||
+ }
|
||||
|
||||
- if (!surf->iface_count)
|
||||
+ if (!(testdesc.dwFlags & DDSD_HEIGHT))
|
||||
{
|
||||
- WARN("Not enumerating surface %p because it doesn't have any references.\n", surf);
|
||||
- continue;
|
||||
+ testdesc.dwFlags |= DDSD_HEIGHT;
|
||||
+ testdesc.dwHeight = 512;
|
||||
}
|
||||
|
||||
- if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc)))
|
||||
+ if (IDirectDraw7_CreateSurface(iface, &testdesc, &surface, NULL) == DD_OK)
|
||||
+ {
|
||||
+ surf = unsafe_impl_from_IDirectDrawSurface7(surface);
|
||||
+ Callback(NULL, &surf->surface_desc, Context);
|
||||
+ IDirectDrawSurface7_Release(surface);
|
||||
+ }
|
||||
+ else
|
||||
+ FIXME("Failed to create surface!\n");
|
||||
+ }
|
||||
+ else if (Flags & DDENUMSURFACES_DOESEXIST)
|
||||
+ {
|
||||
+ DDSURFACEDESC2 desc;
|
||||
+ struct list *entry, *entry2;
|
||||
+ BOOL nomatch, all;
|
||||
+
|
||||
+ /* a combination of match flags is not allowed */
|
||||
+ if (match_flags != 0 &&
|
||||
+ match_flags != DDENUMSURFACES_ALL &&
|
||||
+ match_flags != DDENUMSURFACES_MATCH &&
|
||||
+ match_flags != DDENUMSURFACES_NOMATCH)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
+ all = (Flags & DDENUMSURFACES_ALL) != 0;
|
||||
+ nomatch = (Flags & DDENUMSURFACES_NOMATCH) != 0;
|
||||
+
|
||||
+ if (!all && !DDSD)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
+ wined3d_mutex_lock();
|
||||
+
|
||||
+ /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
|
||||
+ LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
|
||||
{
|
||||
- TRACE("Enumerating surface %p.\n", surf);
|
||||
- desc = surf->surface_desc;
|
||||
- IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
||||
- if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK)
|
||||
+ surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
|
||||
+
|
||||
+ if (!surf->iface_count)
|
||||
{
|
||||
- wined3d_mutex_unlock();
|
||||
- return DD_OK;
|
||||
+ WARN("Not enumerating surface %p because it doesn't have any references.\n", surf);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc)))
|
||||
+ {
|
||||
+ TRACE("Enumerating surface %p.\n", surf);
|
||||
+ desc = surf->surface_desc;
|
||||
+ IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
||||
+ if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK)
|
||||
+ {
|
||||
+ wined3d_mutex_unlock();
|
||||
+ return DD_OK;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
- }
|
||||
|
||||
- wined3d_mutex_unlock();
|
||||
+ wined3d_mutex_unlock();
|
||||
+ }
|
||||
+ else
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
|
||||
index ec4197a..457ebbc 100644
|
||||
--- a/dlls/ddraw/tests/d3d.c
|
||||
+++ b/dlls/ddraw/tests/d3d.c
|
||||
@@ -57,6 +57,11 @@ typedef struct {
|
||||
int total;
|
||||
} D3D7ECancelTest;
|
||||
|
||||
+typedef struct {
|
||||
+ UINT found;
|
||||
+ UINT surfaces;
|
||||
+} EnumSurfaceTest;
|
||||
+
|
||||
#define MAX_ENUMERATION_COUNT 10
|
||||
typedef struct
|
||||
{
|
||||
@@ -85,17 +90,21 @@ static ULONG getRefcount(IUnknown *iface)
|
||||
|
||||
static HRESULT WINAPI SurfaceCounter(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context)
|
||||
{
|
||||
- UINT *num = context;
|
||||
- (*num)++;
|
||||
- IDirectDrawSurface_Release(surface);
|
||||
+ EnumSurfaceTest *count = context;
|
||||
+ count->found++;
|
||||
+ if (surface)
|
||||
+ {
|
||||
+ count->surfaces++;
|
||||
+ IDirectDrawSurface_Release(surface);
|
||||
+ }
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
static BOOL CreateDirect3D(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
- DDSURFACEDESC2 ddsd;
|
||||
- UINT num;
|
||||
+ DDSURFACEDESC2 ddsd, ddsd2;
|
||||
+ EnumSurfaceTest count;
|
||||
|
||||
rc = pDirectDrawCreateEx(NULL, (void**)&lpDD,
|
||||
&IID_IDirectDraw7, NULL);
|
||||
@@ -122,9 +131,174 @@ static BOOL CreateDirect3D(void)
|
||||
if (FAILED(rc))
|
||||
return FALSE;
|
||||
|
||||
- num = 0;
|
||||
- IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, NULL, &num, SurfaceCounter);
|
||||
- ok(num == 1, "Has %d surfaces, expected 1\n", num);
|
||||
+ memset(&ddsd2, 0, sizeof(ddsd2));
|
||||
+ ddsd2.dwSize = sizeof(ddsd2);
|
||||
+ ddsd2.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
|
||||
+ ddsd2.dwWidth = 256;
|
||||
+ ddsd2.dwHeight = 256;
|
||||
+
|
||||
+ /* without search type flags */
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, 0, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, 0, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_MATCH, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_NOMATCH, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ /* search type DDENUMSURFACES_DOESEXIST */
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST, &ddsd2, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH, &ddsd2, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 1, "Has %d surfaces, expected 1\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH, &ddsd2, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL | DDENUMSURFACES_MATCH,
|
||||
+ NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL | DDENUMSURFACES_NOMATCH,
|
||||
+ NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH | DDENUMSURFACES_NOMATCH,
|
||||
+ NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ /* search type DDENUMSURFACES_CANBECREATED */
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, NULL, &count, SurfaceCounter);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH, &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+
|
||||
+ /* combination of DDENUMSURFACES_DOESEXIST and DDENUMSURFACES_CANBECREATED */
|
||||
+
|
||||
+ count.found = 0;
|
||||
+ count.surfaces = 0;
|
||||
+ rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
|
||||
+ &ddsd, &count, SurfaceCounter);
|
||||
+ ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
--
|
||||
2.1.0
|
||||
|
@ -0,0 +1,248 @@
|
||||
From 5dcbd836e663da908a9a39b5791da65d64a00eb8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Tue, 25 Aug 2015 11:17:07 +0200
|
||||
Subject: ddraw: Implement DDENUMSURFACES_CANBECREATED flag in
|
||||
ddraw7_EnumSurfaces.
|
||||
|
||||
Also fixes various test failures related to DDENUMSURFACES_DOESEXIST.
|
||||
|
||||
The "Unexpected destination texture level pixels" testfailure on the w8 VM is not related to this patch.
|
||||
---
|
||||
dlls/ddraw/ddraw.c | 98 +++++++++++++++++++++++++++++++++++++-------------
|
||||
dlls/ddraw/tests/d3d.c | 42 +++++++++++-----------
|
||||
2 files changed, 94 insertions(+), 46 deletions(-)
|
||||
|
||||
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
|
||||
index 4b7a207..19ed213 100644
|
||||
--- a/dlls/ddraw/ddraw.c
|
||||
+++ b/dlls/ddraw/ddraw.c
|
||||
@@ -3122,49 +3122,97 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
|
||||
{
|
||||
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
||||
struct ddraw_surface *surf;
|
||||
- BOOL all, nomatch;
|
||||
- DDSURFACEDESC2 desc;
|
||||
- struct list *entry, *entry2;
|
||||
+ DWORD match_flags = Flags & (DDENUMSURFACES_ALL | DDENUMSURFACES_NOMATCH | DDENUMSURFACES_MATCH);
|
||||
|
||||
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
|
||||
iface, Flags, DDSD, Context, Callback);
|
||||
|
||||
- all = Flags & DDENUMSURFACES_ALL;
|
||||
- nomatch = Flags & DDENUMSURFACES_NOMATCH;
|
||||
-
|
||||
if (!Callback)
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
- if (!all && !DDSD)
|
||||
- return DDERR_INVALIDPARAMS;
|
||||
+ if (Flags & DDENUMSURFACES_CANBECREATED)
|
||||
+ {
|
||||
+ IDirectDrawSurface7 *surface;
|
||||
+ DDSURFACEDESC2 testdesc;
|
||||
+ HRESULT hr;
|
||||
|
||||
- wined3d_mutex_lock();
|
||||
+ if (match_flags != DDENUMSURFACES_MATCH)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
|
||||
- /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
|
||||
- LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
|
||||
- {
|
||||
- surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
|
||||
+ if (!DDSD)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
+ memcpy(&testdesc, DDSD, sizeof(testdesc));
|
||||
+ if (!(testdesc.dwFlags & DDSD_WIDTH))
|
||||
+ {
|
||||
+ testdesc.dwFlags |= DDSD_WIDTH;
|
||||
+ testdesc.dwWidth = 512;
|
||||
+ }
|
||||
+ if (!(testdesc.dwFlags & DDSD_HEIGHT))
|
||||
+ {
|
||||
+ testdesc.dwFlags |= DDSD_HEIGHT;
|
||||
+ testdesc.dwHeight = 512;
|
||||
+ }
|
||||
|
||||
- if (!surf->iface_count)
|
||||
+ hr = IDirectDraw7_CreateSurface(iface, &testdesc, &surface, NULL);
|
||||
+ if (SUCCEEDED(hr))
|
||||
{
|
||||
- WARN("Not enumerating surface %p because it doesn't have any references.\n", surf);
|
||||
- continue;
|
||||
+ surf = unsafe_impl_from_IDirectDrawSurface7(surface);
|
||||
+ Callback(NULL, &surf->surface_desc, Context);
|
||||
+ IDirectDrawSurface7_Release(surface);
|
||||
}
|
||||
+ else
|
||||
+ ERR("Failed to create surface, hr %#x.\n", hr);
|
||||
+ }
|
||||
+ else if (Flags & DDENUMSURFACES_DOESEXIST)
|
||||
+ {
|
||||
+ BOOL all, nomatch;
|
||||
+ DDSURFACEDESC2 desc;
|
||||
+ struct list *entry, *entry2;
|
||||
+
|
||||
+ /* a combination of match flags is not allowed */
|
||||
+ if (match_flags != 0 &&
|
||||
+ match_flags != DDENUMSURFACES_ALL &&
|
||||
+ match_flags != DDENUMSURFACES_MATCH &&
|
||||
+ match_flags != DDENUMSURFACES_NOMATCH)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
+
|
||||
+ all = (Flags & DDENUMSURFACES_ALL) != 0;
|
||||
+ nomatch = (Flags & DDENUMSURFACES_NOMATCH) != 0;
|
||||
+
|
||||
+ if (!all && !DDSD)
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
|
||||
- if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc)))
|
||||
+ wined3d_mutex_lock();
|
||||
+
|
||||
+ /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
|
||||
+ LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list)
|
||||
{
|
||||
- TRACE("Enumerating surface %p.\n", surf);
|
||||
- desc = surf->surface_desc;
|
||||
- IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
||||
- if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK)
|
||||
+ surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry);
|
||||
+
|
||||
+ if (!surf->iface_count)
|
||||
{
|
||||
- wined3d_mutex_unlock();
|
||||
- return DD_OK;
|
||||
+ WARN("Not enumerating surface %p because it doesn't have any references.\n", surf);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc)))
|
||||
+ {
|
||||
+ TRACE("Enumerating surface %p.\n", surf);
|
||||
+ desc = surf->surface_desc;
|
||||
+ IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
||||
+ if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK)
|
||||
+ {
|
||||
+ wined3d_mutex_unlock();
|
||||
+ return DD_OK;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
- }
|
||||
|
||||
- wined3d_mutex_unlock();
|
||||
+ wined3d_mutex_unlock();
|
||||
+ }
|
||||
+ else
|
||||
+ return DDERR_INVALIDPARAMS;
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
|
||||
index e9c616e..930460f 100644
|
||||
--- a/dlls/ddraw/tests/d3d.c
|
||||
+++ b/dlls/ddraw/tests/d3d.c
|
||||
@@ -147,15 +147,15 @@ static BOOL CreateDirect3D(void)
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, 0, &ddsd, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL, NULL, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
- todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_MATCH, NULL, &count, SurfaceCounter);
|
||||
@@ -220,22 +220,22 @@ static BOOL CreateDirect3D(void)
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
|
||||
&ddsd2, &count, SurfaceCounter);
|
||||
ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
- todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL |
|
||||
DDENUMSURFACES_MATCH, NULL, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
- todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL |
|
||||
DDENUMSURFACES_NOMATCH, NULL, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
- todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH |
|
||||
@@ -247,23 +247,23 @@ static BOOL CreateDirect3D(void)
|
||||
/* search type DDENUMSURFACES_CANBECREATED */
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED, &ddsd, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
|
||||
&ddsd, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
- todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH,
|
||||
&ddsd, &count, SurfaceCounter);
|
||||
- todo_wine ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
- todo_wine ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
+ ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||
+ ok(count.found == 0, "Has %d surface descriptions, expected 0\n", count.found);
|
||||
+ ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
count.found = count.surfaces = 0;
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
|
||||
@@ -276,7 +276,7 @@ static BOOL CreateDirect3D(void)
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
|
||||
&ddsd, &count, SurfaceCounter);
|
||||
ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
/* combination of DDENUMSURFACES_DOESEXIST and DDENUMSURFACES_CANBECREATED */
|
||||
@@ -284,7 +284,7 @@ static BOOL CreateDirect3D(void)
|
||||
rc = IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_CANBECREATED |
|
||||
DDENUMSURFACES_MATCH, &ddsd, &count, SurfaceCounter);
|
||||
ok(rc == DD_OK, "Expected DD_OK, got %x\n", rc);
|
||||
- todo_wine ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
+ ok(count.found == 1, "Has %d surface descriptions, expected 1\n", count.found);
|
||||
ok(count.surfaces == 0, "Has %d surfaces, expected 0\n", count.surfaces);
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
--
|
||||
2.5.0
|
||||
|
@ -2660,11 +2660,13 @@ fi
|
||||
# | * dlls/ddraw/ddraw.c, dlls/ddraw/main.c, dlls/ddraw/tests/d3d.c
|
||||
# |
|
||||
if test "$enable_ddraw_EnumSurfaces" -eq 1; then
|
||||
patch_apply ddraw-EnumSurfaces/0001-ddraw-Fix-arguments-to-IDirectDraw7-EnumSurfaces-in-.patch
|
||||
patch_apply ddraw-EnumSurfaces/0002-ddraw-Implement-DDENUMSURFACES_CANBECREATED-in-IDire.patch
|
||||
patch_apply ddraw-EnumSurfaces/0001-ddraw-tests-Add-more-tests-for-IDirectDraw7-EnumSurf.patch
|
||||
patch_apply ddraw-EnumSurfaces/0002-ddraw-Fix-arguments-to-IDirectDraw7-EnumSurfaces-in-.patch
|
||||
patch_apply ddraw-EnumSurfaces/0003-ddraw-Implement-DDENUMSURFACES_CANBECREATED-flag-in-.patch
|
||||
(
|
||||
echo '+ { "Michael Müller", "ddraw/tests: Add more tests for IDirectDraw7::EnumSurfaces.", 1 },';
|
||||
echo '+ { "Michael Müller", "ddraw: Fix arguments to IDirectDraw7::EnumSurfaces in DllMain.", 1 },';
|
||||
echo '+ { "Michael Müller", "ddraw: Implement DDENUMSURFACES_CANBECREATED in IDirectDraw7::EnumSurfaces and fix some bugs.", 1 },';
|
||||
echo '+ { "Michael Müller", "ddraw: Implement DDENUMSURFACES_CANBECREATED flag in ddraw7_EnumSurfaces.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user