Module: wine Branch: master Commit: 2e5628df3fba1c3991b9f3bbf3bf88a19238e827 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2e5628df3fba1c3991b9f3bbf3...
Author: Stefan Dösinger stefandoesinger@gmx.at Date: Sat Oct 14 21:57:09 2006 +0200
ddraw: Make the surface list a standard wine list.
---
dlls/ddraw/ddraw.c | 27 +++++++++++---------------- dlls/ddraw/ddraw_private.h | 11 +++++------ dlls/ddraw/main.c | 2 ++ dlls/ddraw/surface.c | 10 +--------- 4 files changed, 19 insertions(+), 31 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index fc80517..11de3ef 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -1904,12 +1904,7 @@ IDirectDrawImpl_CreateNewSurface(IDirect
/* Increase the surface counter, and attach the surface */ InterlockedIncrement(&This->surfaces); - if(This->surface_list) - { - This->surface_list->prev = *ppSurf; - } - (*ppSurf)->next = This->surface_list; - This->surface_list = *ppSurf; + list_add_head(&This->surface_list, &(*ppSurf)->surface_list_entry);
/* Here we could store all created surfaces in the DirectDrawImpl structure, * But this could also be delegated to WineDDraw, as it keeps track of all its @@ -2375,23 +2370,20 @@ IDirectDrawImpl_CreateSurface(IDirectDra if( (This->ImplType == SURFACE_OPENGL) && !(This->d3d_initialized) && desc2.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE) ) { - IDirectDrawSurfaceImpl *target = This->surface_list; + IDirectDrawSurfaceImpl *target = object, *surface; + struct list *entry;
/* Search for the primary to use as render target */ - while(target) + LIST_FOR_EACH(entry, &This->surface_list) { - if(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) + surface = LIST_ENTRY(entry, IDirectDrawSurfaceImpl, surface_list_entry); + if(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) { /* found */ + target = surface; TRACE("Using primary %p as render target\n", target); break; } - target = target->next; - } - /* If it's not found, use the just created DDSCAPS_3DDEVICE surface */ - if(!target) - { - target = object; }
TRACE("(%p) Attaching a D3DDevice, rendertarget = %p\n", This, target); @@ -2601,6 +2593,7 @@ IDirectDrawImpl_EnumSurfaces(IDirectDraw IDirectDrawSurfaceImpl *surf; BOOL all, nomatch; DDSURFACEDESC2 desc; + struct list *entry, *entry2;
all = Flags & DDENUMSURFACES_ALL; nomatch = Flags & DDENUMSURFACES_NOMATCH; @@ -2610,8 +2603,10 @@ IDirectDrawImpl_EnumSurfaces(IDirectDraw if(!Callback) return DDERR_INVALIDPARAMS;
- for(surf = This->surface_list; surf; surf = surf->next) + /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */ + LIST_FOR_EACH_SAFE(entry, entry2, &This->surface_list) { + surf = LIST_ENTRY(entry, IDirectDrawSurfaceImpl, surface_list_entry); if (all || (nomatch != IDirectDrawImpl_DDSD_Match(DDSD, &surf->surface_desc))) { desc = surf->surface_desc; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index f70da21..7181997 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -130,10 +130,6 @@ struct IDirectDrawImpl /* The surface type to request */ WINED3DSURFTYPE ImplType;
- /* The surface list - can't relay this to WineD3D - * because of IParent - */ - IDirectDrawSurfaceImpl *surface_list;
/* Our private window class */ char classname[32]; @@ -145,6 +141,10 @@ struct IDirectDrawImpl
/* For the dll unload cleanup code */ struct list ddraw_list_entry; + /* The surface list - can't relay this to WineD3D + * because of IParent + */ + struct list surface_list; LONG surfaces; };
@@ -233,8 +233,7 @@ struct IDirectDrawSurfaceImpl IDirectDrawClipperImpl *clipper;
/* For the ddraw surface list */ - IDirectDrawSurfaceImpl *next; - IDirectDrawSurfaceImpl *prev; + struct list surface_list_entry;
DWORD Handle; }; diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 8865fe5..eec98f1 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -315,6 +315,8 @@ #undef BLIT_CAPS #undef CKEY_CAPS #undef FX_CAPS
+ list_init(&This->surface_list); + EnterCriticalSection(&ddraw_list_cs); list_add_head(&global_ddraw_list, &This->ddraw_list_entry); LeaveCriticalSection(&ddraw_list_cs); diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 0ce28da..d7940bd 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -238,15 +238,7 @@ static void IDirectDrawSurfaceImpl_Destr
/* Reduce the ddraw surface count */ InterlockedDecrement(&This->ddraw->surfaces); - if(This->prev) - This->prev->next = This->next; - else - { - assert(This->ddraw->surface_list == This); - This->ddraw->surface_list = This->next; - } - if(This->next) - This->next->prev = This->prev; + list_remove(&This->surface_list_entry);
HeapFree(GetProcessHeap(), 0, This); }