From 053185814694b7163b19d9941a133cbb87b3dc61 Mon Sep 17 00:00:00 2001 From: Markus Amsler Date: Mon, 18 Dec 2006 00:17:38 +0100 Subject: [PATCH] d3d8: Handle surface container in d3d8. --- dlls/d3d8/d3d8_private.h | 3 +++ dlls/d3d8/device.c | 1 + dlls/d3d8/directx.c | 2 ++ dlls/d3d8/surface.c | 37 +++---------------------------------- dlls/d3d8/tests/device.c | 4 ++-- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index fd07053811c..be27401a412 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -253,6 +253,9 @@ struct IDirect3DSurface8Impl /* Parent reference */ LPDIRECT3DDEVICE8 parentDevice; + /* The surface container */ + IUnknown *container; + /* If set forward refcounting to this object */ IUnknown *forwardReference; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 78c469ba104..3faf8079fb0 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1624,6 +1624,7 @@ HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT if (SUCCEEDED(res)) { *ppSurface = d3dSurface->wineD3DSurface; + d3dSurface->container = pSuperior; IUnknown_Release(d3dSurface->parentDevice); d3dSurface->parentDevice = NULL; d3dSurface->forwardReference = pSuperior; diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index 410107ea2e9..c3d06798dce 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -200,6 +200,7 @@ HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, if (SUCCEEDED(res)) { *ppSurface = d3dSurface->wineD3DSurface; + d3dSurface->container = device; d3dSurface->isImplicit = TRUE; /* Implicit surfaces are created with an refcount of 0 */ IUnknown_Release((IUnknown *)d3dSurface); @@ -299,6 +300,7 @@ HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSup (D3DFORMAT)Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface); if (SUCCEEDED(res)) { *ppSurface = d3dSurface->wineD3DSurface; + d3dSurface->container = device; d3dSurface->isImplicit = TRUE; /* Implicit surfaces are created with an refcount of 0 */ IUnknown_Release((IUnknown *)d3dSurface); diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index d834460862d..93ea2f5f14e 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -113,45 +113,14 @@ static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 i static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) { IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface; HRESULT res; - IUnknown *IWineContainer = NULL; TRACE("(%p) Relay\n", This); - /* The container returned from IWineD3DSurface_GetContainer is either an IWineD3DDevice, - one of the subclasses of IWineD3DBaseTexture or an IWineD3DSwapChain */ - /* Get the IUnknown container. */ - res = IWineD3DSurface_GetContainer(This->wineD3DSurface, &IID_IUnknown, (void **)&IWineContainer); - if (res == D3D_OK && IWineContainer != NULL) { + if (!This->container) return E_NOINTERFACE; - /* Now find out what kind of container it is (so that we can get its parent)*/ - IUnknown *IUnknownParent = NULL; - IUnknown *myContainer = NULL; - if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DDevice, (void **)&myContainer)) { - IWineD3DDevice_GetParent((IWineD3DDevice *)IWineContainer, &IUnknownParent); - IUnknown_Release(myContainer); - } else - if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DBaseTexture, (void **)&myContainer)) { - IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent); - IUnknown_Release(myContainer); - } else - if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DSwapChain, (void **)&myContainer)) { - IWineD3DSwapChain_GetParent((IWineD3DSwapChain *)IWineContainer, &IUnknownParent); - IUnknown_Release(myContainer); - } else { - FIXME("Container is of unknown interface\n"); - } - /* Tidy up.. */ - IUnknown_Release((IWineD3DDevice *)IWineContainer); + res = IUnknown_QueryInterface(This->container, riid, ppContainer); - /* Now, query the interface of the parent for the riid */ - if (IUnknownParent != NULL) { - res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer); - /* Tidy up.. */ - IUnknown_Release(IUnknownParent); - } - } - - TRACE("(%p) : returning %p\n", This, *ppContainer); + TRACE("(%p) : returning %p\n", This, *ppContainer); return res; } diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 1ad56b72308..2d3b376927e 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -332,7 +332,7 @@ static void test_refcount(void) CHECK_CALL( hr, "GetRenderTarget", pDevice, ++refcount); if(pRenderTarget) { - todo_wine CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice); + CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice); CHECK_REFCOUNT( pRenderTarget, 1); CHECK_ADDREF_REFCOUNT(pRenderTarget, 2); @@ -496,7 +496,7 @@ static void test_refcount(void) CHECK_REFCOUNT( pSwapChain, 1); if(pBackBuffer) { - todo_wine CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice); + CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice); CHECK_REFCOUNT( pBackBuffer, 1); CHECK_RELEASE_REFCOUNT( pBackBuffer, 0); CHECK_REFCOUNT( pDevice, --refcount);