Module: wine Branch: refs/heads/master Commit: b994d057ace77f5171a2bc17091820cacb1fba0a URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b994d057ace77f5171a2bc17...
Author: H. Verbeet hverbeet@gmail.com Date: Tue Feb 7 12:26:10 2006 +0100
wined3d/d3d9: Cleanup GetContainer for volumes.
---
dlls/d3d9/volume.c | 34 +++++++++++++++++++++++++++------- dlls/wined3d/volume.c | 18 ++++++++++++++---- 2 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index d16b2ee..4e53b2a 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -92,18 +92,38 @@ HRESULT WINAPI IDirect3DVolume9Impl_Free
HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) { IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface; + IWineD3DBase *wineD3DContainer = NULL; + IUnknown *wineD3DContainerParent = NULL; HRESULT res; - IUnknown *IWineContainer = NULL;
- TRACE("(%p) Relay\n", This); - res = IWineD3DVolume_GetContainer(This->wineD3DVolume, riid, (void **)&IWineContainer); + TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
- /* If this works, the only valid container is a child of resource (volumetexture) */ - if (res == D3D_OK && NULL != ppContainer) { - IWineD3DResource_GetParent((IWineD3DResource *)IWineContainer, (IUnknown **)ppContainer); - IWineD3DResource_Release((IWineD3DResource *)IWineContainer); + if (!ppContainer) { + ERR("Called without a valid ppContainer.\n"); }
+ /* Get the WineD3D container. */ + res = IWineD3DVolume_GetContainer(This->wineD3DVolume, &IID_IWineD3DBase, (void **)&wineD3DContainer); + if (res != D3D_OK) return res; + + if (!wineD3DContainer) { + ERR("IWineD3DSurface_GetContainer should never return NULL\n"); + } + + /* Get the parent */ + IWineD3DBase_GetParent(wineD3DContainer, &wineD3DContainerParent); + IUnknown_Release(wineD3DContainer); + + if (!wineD3DContainerParent) { + ERR("IWineD3DBase_GetParent should never return NULL\n"); + } + + /* Now, query the interface of the parent for the riid */ + res = IUnknown_QueryInterface(wineD3DContainerParent, riid, ppContainer); + IUnknown_Release(wineD3DContainerParent); + + TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer); + return res; }
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index df9ca85..3108662 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -105,10 +105,20 @@ D3DRESOURCETYPE WINAPI IWineD3DVolumeImp ******************************************* */ HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID riid, void** ppContainer) { IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; - TRACE("(%p) : returning %p\n", This, This->container); - *ppContainer = This->container; - IUnknown_AddRef(This->container); - return D3D_OK; + + TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer); + + if (!ppContainer) { + ERR("Called without a valid ppContainer.\n"); + } + + /* Although surfaces can be standalone, volumes can't */ + if (!This->container) { + ERR("Volume without an container. Should not happen.\n"); + } + + TRACE("Relaying to QueryInterface\n"); + return IUnknown_QueryInterface(This->container, riid, ppContainer); }
HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC* pDesc) {