d3d: Callback infrastructure for implicit render target destruction in IWineD3DSwapChain.

This commit is contained in:
Markus Amsler 2006-12-05 00:29:14 +01:00 committed by Alexandre Julliard
parent 2946f7a267
commit cb8652947a
2 changed files with 38 additions and 36 deletions

View File

@ -88,14 +88,27 @@ static ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) {
refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
if (refCount == 0) {
IUnknown* bufferParent;
IWineD3DSwapChain_Destroy(iface, D3DCB_DefaultDestroySurface);
}
return refCount;
}
static HRESULT WINAPI IWineD3DSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
*ppParent = This->parent;
IUnknown_AddRef(*ppParent);
TRACE("(%p) returning %p\n", This , *ppParent);
return WINED3D_OK;
}
/*IWineD3DSwapChain parts follow: */
static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
/* release the ref to the front and back buffer parents */
if(This->frontBuffer) {
IWineD3DSurface_SetContainer(This->frontBuffer, 0);
IWineD3DSurface_GetParent(This->frontBuffer, &bufferParent);
IUnknown_Release(bufferParent); /* once for the get parent */
if(IUnknown_Release(bufferParent) > 0){
if(D3DCB_DestroyRenderTarget(This->frontBuffer) > 0) {
FIXME("(%p) Something's still holding the front buffer\n",This);
}
}
@ -104,9 +117,7 @@ static ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) {
int i;
for(i = 0; i < This->presentParms.BackBufferCount; i++) {
IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
IWineD3DSurface_GetParent(This->backBuffer[i], &bufferParent);
IUnknown_Release(bufferParent); /* once for the get parent */
if(IUnknown_Release(bufferParent) > 0){
if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
FIXME("(%p) Something's still holding the back buffer\n",This);
}
}
@ -123,19 +134,8 @@ static ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) {
the child to be released, not the other way around!
*/
HeapFree(GetProcessHeap(), 0, This);
}
return refCount;
}
static HRESULT WINAPI IWineD3DSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
*ppParent = This->parent;
IUnknown_AddRef(*ppParent);
TRACE("(%p) returning %p\n", This , *ppParent);
return WINED3D_OK;
}
/*IWineD3DSwapChain parts follow: */
static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
@ -572,6 +572,7 @@ IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
IWineD3DSwapChainImpl_Release,
/* IWineD3DSwapChain */
IWineD3DSwapChainImpl_GetParent,
IWineD3DSwapChainImpl_Destroy,
IWineD3DSwapChainImpl_GetDevice,
IWineD3DSwapChainImpl_Present,
IWineD3DSwapChainImpl_GetFrontBufferData,

View File

@ -1367,6 +1367,7 @@ DECLARE_INTERFACE_(IWineD3DSwapChain,IWineD3DBase)
/*** IWineD3DBase methods ***/
STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
/*** IDirect3DSwapChain9 methods ***/
STDMETHOD_(void, Destroy)(THIS_ D3DCB_DESTROYSURFACEFN pFn) PURE;
STDMETHOD(GetDevice)(THIS_ IWineD3DDevice **ppDevice) PURE;
STDMETHOD(Present)(THIS_ CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) PURE;
STDMETHOD(GetFrontBufferData)(THIS_ IWineD3DSurface *pDestSurface) PURE;
@ -1387,7 +1388,7 @@ DECLARE_INTERFACE_(IWineD3DSwapChain,IWineD3DBase)
/*** IWineD3DBase methods ***/
#define IWineD3DSwapChain_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
/*** IWineD3DSwapChain methods ***/
#define IWineD3DSwapChain_Destroy(p,a) (p)->lpVtbl->Destroy(p,a)
#define IWineD3DSwapChain_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IWineD3DSwapChain_Present(p,a,b,c,d,e) (p)->lpVtbl->Present(p,a,b,c,d,e)
#define IWineD3DSwapChain_GetFrontBufferData(p,a) (p)->lpVtbl->GetFrontBufferData(p,a)