wined3d: Cleanup Get/SetDepthStencilSurface().

This commit is contained in:
Henri Verbeet 2010-08-04 11:10:25 +02:00 committed by Alexandre Julliard
parent 009cd78fa4
commit 43a86d1e56
1 changed files with 17 additions and 16 deletions

View File

@ -5688,18 +5688,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice* iface, IWineD3DSurface **ppZStencilSurface) { static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface **depth_stencil)
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; {
*ppZStencilSurface = (IWineD3DSurface *)This->depth_stencil; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : zStencilSurface returning %p\n", This, *ppZStencilSurface);
if(*ppZStencilSurface != NULL) { TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
/* Note inc ref on returned surface */
IWineD3DSurface_AddRef(*ppZStencilSurface); *depth_stencil = (IWineD3DSurface *)device->depth_stencil;
return WINED3D_OK; TRACE("Returning depth/stencil surface %p.\n", *depth_stencil);
} else { if (!*depth_stencil) return WINED3DERR_NOTFOUND;
return WINED3DERR_NOTFOUND; IWineD3DSurface_AddRef(*depth_stencil);
}
return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
@ -5765,13 +5765,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface *pNewZStencil) { static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface *depth_stencil)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *tmp; IWineD3DSurfaceImpl *tmp;
TRACE("device %p, depth_stencil %p, old depth_stencil %p.\n", This, pNewZStencil, This->depth_stencil); TRACE("device %p, depth_stencil %p, old depth_stencil %p.\n", This, depth_stencil, This->depth_stencil);
if (This->depth_stencil == (IWineD3DSurfaceImpl *)pNewZStencil) if (This->depth_stencil == (IWineD3DSurfaceImpl *)depth_stencil)
{ {
TRACE("Trying to do a NOP SetRenderTarget operation.\n"); TRACE("Trying to do a NOP SetRenderTarget operation.\n");
return WINED3D_OK; return WINED3D_OK;
@ -5794,11 +5795,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *
} }
tmp = This->depth_stencil; tmp = This->depth_stencil;
This->depth_stencil = (IWineD3DSurfaceImpl *)pNewZStencil; This->depth_stencil = (IWineD3DSurfaceImpl *)depth_stencil;
if (This->depth_stencil) IWineD3DSurface_AddRef((IWineD3DSurface *)This->depth_stencil); if (This->depth_stencil) IWineD3DSurface_AddRef((IWineD3DSurface *)This->depth_stencil);
if (tmp) IWineD3DSurface_Release((IWineD3DSurface *)tmp); if (tmp) IWineD3DSurface_Release((IWineD3DSurface *)tmp);
if ((!tmp && pNewZStencil) || (!pNewZStencil && tmp)) if ((!tmp && depth_stencil) || (!depth_stencil && tmp))
{ {
/* Swapping NULL / non NULL depth stencil affects the depth and tests */ /* Swapping NULL / non NULL depth stencil affects the depth and tests */
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZENABLE)); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZENABLE));