ddraw: Separate IDirectDrawSurface3 reference count.

This commit is contained in:
Ričardas Barkauskas 2011-06-20 23:51:01 +03:00 committed by Alexandre Julliard
parent 167ffc7b4b
commit f0634f7a4b
4 changed files with 31 additions and 11 deletions

View file

@ -161,7 +161,7 @@ struct IDirectDrawSurfaceImpl
const IDirect3DTexture2Vtbl *IDirect3DTexture2_vtbl;
const IDirect3DTextureVtbl *IDirect3DTexture_vtbl;
LONG ref, ref2, iface_count;
LONG ref, ref3, ref2, iface_count;
IUnknown *ifaceToRelease;
int version;

View file

@ -752,12 +752,14 @@ DestroyCallback(IDirectDrawSurface7 *surf,
void *context)
{
IDirectDrawSurfaceImpl *Impl = impl_from_IDirectDrawSurface7(surf);
ULONG ref, ref2;
ULONG ref, ref3, ref2;
ref = IDirectDrawSurface7_Release(surf); /* For the EnumSurfaces */
IDirectDrawSurface3_AddRef(&Impl->IDirectDrawSurface3_iface);
ref3 = IDirectDrawSurface3_Release(&Impl->IDirectDrawSurface3_iface);
IDirectDrawSurface2_AddRef(&Impl->IDirectDrawSurface2_iface);
ref2 = IDirectDrawSurface2_Release(&Impl->IDirectDrawSurface2_iface);
WARN("Surface %p has an reference counts of %d 2: %d\n", Impl, ref, ref2);
WARN("Surface %p has an reference counts of %d 3: %d 2: %d\n", Impl, ref, ref3, ref2);
/* Skip surfaces which are attached somewhere or which are
* part of a complex compound. They will get released when destroying
@ -768,6 +770,7 @@ DestroyCallback(IDirectDrawSurface7 *surf,
/* Destroy the surface */
while (ref) ref = IDirectDrawSurface7_Release(surf);
while (ref3) ref3 = IDirectDrawSurface3_Release(&Impl->IDirectDrawSurface3_iface);
while (ref2) ref2 = IDirectDrawSurface2_Release(&Impl->IDirectDrawSurface2_iface);
return DDENUMRET_OK;

View file

@ -90,7 +90,7 @@ static HRESULT WINAPI ddraw_surface7_QueryInterface(IDirectDrawSurface7 *iface,
}
else if (IsEqualGUID(riid, &IID_IDirectDrawSurface3))
{
IUnknown_AddRef(iface);
IDirectDrawSurface3_AddRef(&This->IDirectDrawSurface3_iface);
*obj = &This->IDirectDrawSurface3_iface;
TRACE("(%p) returning IDirectDrawSurface3 interface at %p\n", This, *obj);
return S_OK;
@ -266,9 +266,16 @@ static ULONG WINAPI ddraw_surface4_AddRef(IDirectDrawSurface4 *iface)
static ULONG WINAPI ddraw_surface3_AddRef(IDirectDrawSurface3 *iface)
{
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
TRACE("iface %p.\n", iface);
ULONG refcount = InterlockedIncrement(&This->ref3);
return ddraw_surface7_AddRef(&This->IDirectDrawSurface7_iface);
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
if (refcount == 1)
{
ddraw_surface_add_iface(This);
}
return refcount;
}
static ULONG WINAPI ddraw_surface2_AddRef(IDirectDrawSurface2 *iface)
@ -342,7 +349,8 @@ void ddraw_surface_destroy(IDirectDrawSurfaceImpl *This)
* because the 2nd surface was addref()ed when the app
* called GetAttachedSurface
*/
WARN("(%p): Destroying surface with refcounts %d 2: %d\n", This, This->ref, This->ref2);
WARN("(%p): Destroying surface with refcounts %d 3: %d 2: %d\n", This, This->ref,
This->ref3, This->ref2);
}
if (This->wined3d_surface)
@ -521,9 +529,16 @@ static ULONG WINAPI ddraw_surface4_Release(IDirectDrawSurface4 *iface)
static ULONG WINAPI ddraw_surface3_Release(IDirectDrawSurface3 *iface)
{
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
TRACE("iface %p.\n", iface);
ULONG refcount = InterlockedDecrement(&This->ref3);
return ddraw_surface7_Release(&This->IDirectDrawSurface7_iface);
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
if (refcount == 0)
{
ddraw_surface_release_iface(This);
}
return refcount;
}
static ULONG WINAPI ddraw_surface2_Release(IDirectDrawSurface2 *iface)
@ -740,6 +755,8 @@ static HRESULT WINAPI ddraw_surface3_GetAttachedSurface(IDirectDrawSurface3 *ifa
}
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
*attachment = &attachment_impl->IDirectDrawSurface3_iface;
ddraw_surface3_AddRef(*attachment);
ddraw_surface7_Release(attachment7);
return hr;
}

View file

@ -1092,7 +1092,7 @@ static void IFaceRefCount(void)
IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface3, (void **) &surf3);
ref = getRefcount((IUnknown *) surf3);
todo_wine ok(ref == 1, "Refcount is %u, expected 1\n", ref);
ok(ref == 1, "Refcount is %u, expected 1\n", ref);
IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface4, (void **) &surf4);
ref = getRefcount((IUnknown *) surf4);
@ -1148,7 +1148,7 @@ static void IFaceRefCount(void)
ok(ref == 0, "Refcount is %u, expected 0\n", ref);
ref = IDirectDrawSurface3_Release(surf3);
todo_wine ok(ref == 0, "Refcount is %u, expected 0\n", ref);
ok(ref == 0, "Refcount is %u, expected 0\n", ref);
ref = IDirectDrawSurface4_Release(surf4);
todo_wine ok(ref == 0, "Refcount is %u, expected 0\n", ref);