Commit 05318581 authored by Markus Amsler's avatar Markus Amsler Committed by Alexandre Julliard

d3d8: Handle surface container in d3d8.

parent 73b5fb05
......@@ -253,6 +253,9 @@ struct IDirect3DSurface8Impl
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
/* The surface container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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) {
/* 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);
/* Now, query the interface of the parent for the riid */
if (IUnknownParent != NULL) {
res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer);
/* Tidy up.. */
IUnknown_Release(IUnknownParent);
}
}
if (!This->container) return E_NOINTERFACE;
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("(%p) : returning %p\n", This, *ppContainer);
TRACE("(%p) : returning %p\n", This, *ppContainer);
return res;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment