Markus Amsler : d3d:
Callback infrastructure for implicit surface destruction in
IWineD3DCubeTexture .
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Dec 6 05:49:07 CST 2006
Module: wine
Branch: master
Commit: 2946f7a26747728f0060d8346e94c2f2d445b5ed
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2946f7a26747728f0060d8346e94c2f2d445b5ed
Author: Markus Amsler <markus.amsler at oribi.org>
Date: Tue Dec 5 00:29:08 2006 +0100
d3d: Callback infrastructure for implicit surface destruction in IWineD3DCubeTexture.
---
dlls/wined3d/cubetexture.c | 44 +++++++++++++++++++-------------------
include/wine/wined3d_interface.h | 2 +
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/cubetexture.c b/dlls/wined3d/cubetexture.c
index a55fdb1..f3df9f4 100644
--- a/dlls/wined3d/cubetexture.c
+++ b/dlls/wined3d/cubetexture.c
@@ -67,28 +67,7 @@ static ULONG WINAPI IWineD3DCubeTextureI
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
- int i,j;
- TRACE("(%p) : Cleaning up\n",This);
- for (i = 0; i < This->baseTexture.levels; i++) {
- for (j = 0; j < 6; j++) {
- if (This->surfaces[j][i] != NULL) {
- /* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
- IUnknown* surfaceParent;
- /* Clean out the texture name we gave to the surface so that the surface doesn't try and release it */
- IWineD3DSurface_SetGlTextureDesc(This->surfaces[j][i], 0, 0);
- /* Cleanup the container */
- IWineD3DSurface_SetContainer(This->surfaces[j][i], 0);
- /* Now, release the parent, which will take care of cleaning up the surface for us */
- TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]);
- IWineD3DSurface_GetParent(This->surfaces[j][i], &surfaceParent);
- IUnknown_Release(surfaceParent);
- IUnknown_Release(surfaceParent);
- }
- }
- }
- IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
- /* finally delete the object */
- HeapFree(GetProcessHeap(), 0, This);
+ IWineD3DCubeTexture_Destroy(iface, D3DCB_DefaultDestroySurface);
}
return ref;
}
@@ -256,6 +235,26 @@ static void WINAPI IWineD3DCubeTextureIm
/* *******************************************
IWineD3DCubeTexture IWineD3DCubeTexture parts follow
******************************************* */
+static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
+ IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
+ int i,j;
+ TRACE("(%p) : Cleaning up\n",This);
+ for (i = 0; i < This->baseTexture.levels; i++) {
+ for (j = 0; j < 6; j++) {
+ if (This->surfaces[j][i] != NULL) {
+ /* Clean out the texture name we gave to the surface so that the surface doesn't try and release it */
+ IWineD3DSurface_SetGlTextureDesc(This->surfaces[j][i], 0, 0);
+ /* Cleanup the container */
+ IWineD3DSurface_SetContainer(This->surfaces[j][i], 0);
+ D3DCB_DestroySurface(This->surfaces[j][i]);
+ }
+ }
+ }
+ IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
+ /* finally delete the object */
+ HeapFree(GetProcessHeap(), 0, This);
+}
+
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
@@ -363,6 +362,7 @@ const IWineD3DCubeTextureVtbl IWineD3DCu
IWineD3DCubeTextureImpl_GetTextureDimensions,
IWineD3DCubeTextureImpl_ApplyStateChanges,
/* IWineD3DCubeTexture */
+ IWineD3DCubeTextureImpl_Destroy,
IWineD3DCubeTextureImpl_GetLevelDesc,
IWineD3DCubeTextureImpl_GetCubeMapSurface,
IWineD3DCubeTextureImpl_LockRect,
diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
index 1e0e08e..cb59eba 100644
--- a/include/wine/wined3d_interface.h
+++ b/include/wine/wined3d_interface.h
@@ -942,6 +942,7 @@ DECLARE_INTERFACE_(IWineD3DCubeTexture,I
STDMETHOD_(UINT, GetTextureDimensions)(THIS) PURE;
STDMETHOD_(void, ApplyStateChanges)(THIS_ DWORD const textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) PURE;
/*** IWineD3DCubeTexture methods ***/
+ STDMETHOD_(void, Destroy)(THIS_ D3DCB_DESTROYSURFACEFN pFn) PURE;
STDMETHOD(GetLevelDesc)(THIS_ UINT Level,WINED3DSURFACE_DESC* pDesc) PURE;
STDMETHOD(GetCubeMapSurface)(THIS_ WINED3DCUBEMAP_FACES FaceType, UINT Level, struct IWineD3DSurface** ppCubeMapSurface) PURE;
STDMETHOD(LockRect)(THIS_ WINED3DCUBEMAP_FACES FaceType, UINT Level, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) PURE;
@@ -980,6 +981,7 @@ DECLARE_INTERFACE_(IWineD3DCubeTexture,I
#define IWineD3DCubeTexture_GetTextureDimensions(p) (p)->lpVtbl->GetTextureDimensions(p)
#define IWineD3DCubeTexture_ApplyStateChanges(p,a,b) (p)->lpVtbl->ApplyStateChanges(p,a,b)
/*** IWineD3DCubeTexture methods ***/
+#define IWineD3DCubeTexture_Destroy(p,a) (p)->lpVtbl->Destroy(p,a)
#define IWineD3DCubeTexture_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b)
#define IWineD3DCubeTexture_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c)
#define IWineD3DCubeTexture_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e)
More information about the wine-cvs
mailing list