From c722f2d31ec61fe372e466957605b222ee6f9a7d Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 13 Jun 2012 18:23:35 +0200 Subject: [PATCH] ddraw: Merge ddraw_surface_destroy() into ddraw_surface_cleanup(). --- dlls/ddraw/surface.c | 51 +++++++++---------------------------- dlls/ddraw/tests/dsurface.c | 2 +- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index d1309ee035e..3f9f78f5cc6 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -444,37 +444,6 @@ static ULONG WINAPI d3d_texture1_AddRef(IDirect3DTexture *iface) return IUnknown_AddRef(surface->texture_outer); } -/***************************************************************************** - * ddraw_surface_destroy - * - * A helper function for IDirectDrawSurface7::Release - * - * Frees the surface, regardless of its refcount. - * See IDirectDrawSurface7::Release for more information - * - * Params: - * This: Surface to free - * - *****************************************************************************/ -static void ddraw_surface_destroy(struct ddraw_surface *This) -{ - TRACE("surface %p.\n", This); - - /* Check the iface count and give a warning */ - if(This->iface_count > 1) - { - /* This can happen when a complex surface is destroyed, - * because the 2nd surface was addref()ed when the app - * called GetAttachedSurface - */ - WARN("(%p): Destroying surface with refcounts 7: %d 4: %d 3: %d 2: %d 1: %d\n", - This, This->ref7, This->ref4, This->ref3, This->ref2, This->ref1); - } - - if (This->wined3d_surface) - wined3d_surface_decref(This->wined3d_surface); -} - static void ddraw_surface_cleanup(struct ddraw_surface *surface) { struct ddraw_surface *surf; @@ -498,20 +467,24 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface) surf = surface->complex_array[i]; surface->complex_array[i] = NULL; - while (surf) - { - struct ddraw_surface *destroy = surf; - surf = surf->complex_array[0]; /* Iterate through the "tree" */ - ddraw_surface_destroy(destroy); /* Destroy it */ - } + ddraw_surface_cleanup(surf); } if (surface->device1) IUnknown_Release(&surface->device1->IUnknown_inner); ifaceToRelease = surface->ifaceToRelease; - /* Destroy the root surface. */ - ddraw_surface_destroy(surface); + if (surface->iface_count > 1) + { + /* This can happen when a complex surface is destroyed, because the + * 2nd surface was addref()ed when the app called + * GetAttachedSurface(). */ + WARN("Destroying surface %p with refcounts 7: %u 4: %u 3: %u 2: %u 1: %u.\n", + surface, surface->ref7, surface->ref4, surface->ref3, surface->ref2, surface->ref1); + } + + if (surface->wined3d_surface) + wined3d_surface_decref(surface->wined3d_surface); /* Reduce the ddraw refcount */ if (ifaceToRelease) diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c index ecc54f116b4..e3cd0856a61 100644 --- a/dlls/ddraw/tests/dsurface.c +++ b/dlls/ddraw/tests/dsurface.c @@ -1958,7 +1958,7 @@ static void CubeMapTest(void) IDirectDrawSurface7_Release(cubemap); ref = getRefcount((IUnknown *) palette); - todo_wine ok(ref == 1, "Refcount is %u, expected 1\n", ref); + ok(ref == 1, "Refcount is %u, expected 1\n", ref); IDirectDrawPalette_Release(palette);