d3d8: Handle surface container in d3d8.
This commit is contained in:
parent
73b5fb059f
commit
0531858146
|
@ -253,6 +253,9 @@ struct IDirect3DSurface8Impl
|
||||||
/* Parent reference */
|
/* Parent reference */
|
||||||
LPDIRECT3DDEVICE8 parentDevice;
|
LPDIRECT3DDEVICE8 parentDevice;
|
||||||
|
|
||||||
|
/* The surface container */
|
||||||
|
IUnknown *container;
|
||||||
|
|
||||||
/* If set forward refcounting to this object */
|
/* If set forward refcounting to this object */
|
||||||
IUnknown *forwardReference;
|
IUnknown *forwardReference;
|
||||||
|
|
||||||
|
|
|
@ -1624,6 +1624,7 @@ HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT
|
||||||
|
|
||||||
if (SUCCEEDED(res)) {
|
if (SUCCEEDED(res)) {
|
||||||
*ppSurface = d3dSurface->wineD3DSurface;
|
*ppSurface = d3dSurface->wineD3DSurface;
|
||||||
|
d3dSurface->container = pSuperior;
|
||||||
IUnknown_Release(d3dSurface->parentDevice);
|
IUnknown_Release(d3dSurface->parentDevice);
|
||||||
d3dSurface->parentDevice = NULL;
|
d3dSurface->parentDevice = NULL;
|
||||||
d3dSurface->forwardReference = pSuperior;
|
d3dSurface->forwardReference = pSuperior;
|
||||||
|
|
|
@ -200,6 +200,7 @@ HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior,
|
||||||
|
|
||||||
if (SUCCEEDED(res)) {
|
if (SUCCEEDED(res)) {
|
||||||
*ppSurface = d3dSurface->wineD3DSurface;
|
*ppSurface = d3dSurface->wineD3DSurface;
|
||||||
|
d3dSurface->container = device;
|
||||||
d3dSurface->isImplicit = TRUE;
|
d3dSurface->isImplicit = TRUE;
|
||||||
/* Implicit surfaces are created with an refcount of 0 */
|
/* Implicit surfaces are created with an refcount of 0 */
|
||||||
IUnknown_Release((IUnknown *)d3dSurface);
|
IUnknown_Release((IUnknown *)d3dSurface);
|
||||||
|
@ -299,6 +300,7 @@ HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSup
|
||||||
(D3DFORMAT)Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface);
|
(D3DFORMAT)Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface);
|
||||||
if (SUCCEEDED(res)) {
|
if (SUCCEEDED(res)) {
|
||||||
*ppSurface = d3dSurface->wineD3DSurface;
|
*ppSurface = d3dSurface->wineD3DSurface;
|
||||||
|
d3dSurface->container = device;
|
||||||
d3dSurface->isImplicit = TRUE;
|
d3dSurface->isImplicit = TRUE;
|
||||||
/* Implicit surfaces are created with an refcount of 0 */
|
/* Implicit surfaces are created with an refcount of 0 */
|
||||||
IUnknown_Release((IUnknown *)d3dSurface);
|
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) {
|
static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) {
|
||||||
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
|
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
IUnknown *IWineContainer = NULL;
|
|
||||||
|
|
||||||
TRACE("(%p) Relay\n", This);
|
TRACE("(%p) Relay\n", This);
|
||||||
|
|
||||||
/* The container returned from IWineD3DSurface_GetContainer is either an IWineD3DDevice,
|
if (!This->container) return E_NOINTERFACE;
|
||||||
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)*/
|
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
|
||||||
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 */
|
TRACE("(%p) : returning %p\n", This, *ppContainer);
|
||||||
if (IUnknownParent != NULL) {
|
|
||||||
res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer);
|
|
||||||
/* Tidy up.. */
|
|
||||||
IUnknown_Release(IUnknownParent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("(%p) : returning %p\n", This, *ppContainer);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,7 +332,7 @@ static void test_refcount(void)
|
||||||
CHECK_CALL( hr, "GetRenderTarget", pDevice, ++refcount);
|
CHECK_CALL( hr, "GetRenderTarget", pDevice, ++refcount);
|
||||||
if(pRenderTarget)
|
if(pRenderTarget)
|
||||||
{
|
{
|
||||||
todo_wine CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice);
|
CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice);
|
||||||
CHECK_REFCOUNT( pRenderTarget, 1);
|
CHECK_REFCOUNT( pRenderTarget, 1);
|
||||||
|
|
||||||
CHECK_ADDREF_REFCOUNT(pRenderTarget, 2);
|
CHECK_ADDREF_REFCOUNT(pRenderTarget, 2);
|
||||||
|
@ -496,7 +496,7 @@ static void test_refcount(void)
|
||||||
CHECK_REFCOUNT( pSwapChain, 1);
|
CHECK_REFCOUNT( pSwapChain, 1);
|
||||||
if(pBackBuffer)
|
if(pBackBuffer)
|
||||||
{
|
{
|
||||||
todo_wine CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice);
|
CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice);
|
||||||
CHECK_REFCOUNT( pBackBuffer, 1);
|
CHECK_REFCOUNT( pBackBuffer, 1);
|
||||||
CHECK_RELEASE_REFCOUNT( pBackBuffer, 0);
|
CHECK_RELEASE_REFCOUNT( pBackBuffer, 0);
|
||||||
CHECK_REFCOUNT( pDevice, --refcount);
|
CHECK_REFCOUNT( pDevice, --refcount);
|
||||||
|
|
Loading…
Reference in New Issue