d3d9: Simplify GetDevice().

This commit is contained in:
Henri Verbeet 2009-12-04 11:50:47 +01:00 committed by Alexandre Julliard
parent 3cedef2ffe
commit ff92e6eb6a
12 changed files with 96 additions and 153 deletions

View File

@ -85,23 +85,18 @@ static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 ifa
}
/* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(IDirect3DCubeTexture9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {

View File

@ -80,23 +80,18 @@ static ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 ifa
}
/* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(IDirect3DIndexBuffer9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {

View File

@ -79,19 +79,17 @@ static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 ifa
}
/* IDirect3DPixelShader9 Interface follow: */
static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
{
IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
TRACE("iface %p, device %p.\n", iface, ppDevice);
TRACE("iface %p, device %p.\n", iface, device);
wined3d_mutex_lock();
IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
wined3d_mutex_unlock();
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return D3D_OK;
}

View File

@ -70,24 +70,18 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
}
/* IDirect3DQuery9 Interface follow: */
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDirect3DDevice9** ppDevice) {
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDirect3DDevice9 **device)
{
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
IWineD3DDevice* pDevice;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
TRACE("iface %p, device %p.\n", iface, device);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
if(hr != D3D_OK){
*ppDevice = NULL;
}else{
hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(pDevice);
}
wined3d_mutex_unlock();
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
return hr;
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {

View File

@ -70,23 +70,18 @@ static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface
}
/* IDirect3DStateBlock9 Interface follow: */
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DStateBlock, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) {

View File

@ -102,23 +102,18 @@ static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
}
/* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDevice(This->wineD3DSurface, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(IDirect3DSurface9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {

View File

@ -154,22 +154,18 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN
return hr;
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice) {
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(IDirect3DSwapChain9 *iface, IDirect3DDevice9 **device)
{
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
HRESULT hrc = D3D_OK;
IWineD3DDevice *device = NULL;
TRACE("iface %p, device %p.\n", iface, ppDevice);
TRACE("iface %p, device %p.\n", iface, device);
wined3d_mutex_lock();
hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device);
if (hrc == D3D_OK && NULL != device) {
IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(device);
}
wined3d_mutex_unlock();
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
return hrc;
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {

View File

@ -82,23 +82,18 @@ static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
}
/* IDirect3DTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(IDirect3DTexture9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {

View File

@ -81,23 +81,18 @@ static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 i
}
/* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(IDirect3DVertexBuffer9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {

View File

@ -263,22 +263,19 @@ static ULONG WINAPI IDirect3DVertexDeclaration9Impl_Release(LPDIRECT3DVERTEXDECL
}
/* IDirect3DVertexDeclaration9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEXDECLARATION9 iface, IDirect3DDevice9** ppDevice) {
static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(IDirect3DVertexDeclaration9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
HRESULT hr = D3D_OK;
TRACE("iface %p, device %p.\n", iface, ppDevice);
TRACE("iface %p, device %p.\n", iface, device);
wined3d_mutex_lock();
hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
if (hr == D3D_OK && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
}
wined3d_mutex_unlock();
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
return hr;
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDeclaration(LPDIRECT3DVERTEXDECLARATION9 iface, D3DVERTEXELEMENT9* pDecl, UINT* pNumElements) {

View File

@ -79,25 +79,18 @@ static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 i
}
/* IDirect3DVertexShader9 Interface follow: */
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(IDirect3DVertexShader9 *iface, IDirect3DDevice9 **device)
{
IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
TRACE("iface %p, device %p.\n", iface, device);
wined3d_mutex_lock();
hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
if (WINED3D_OK == hr && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
} else {
*ppDevice = NULL;
}
wined3d_mutex_unlock();
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return hr;
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {

View File

@ -81,23 +81,18 @@ static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9
}
/* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, ppDevice);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
if (SUCCEEDED(hr))
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(IDirect3DVolumeTexture9 *iface, IDirect3DDevice9 **device)
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
wined3d_mutex_unlock();
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
return hr;
TRACE("iface %p, device %p.\n", iface, device);
*device = (IDirect3DDevice9 *)This->parentDevice;
IDirect3DDevice9_AddRef(*device);
TRACE("Returning device %p.\n", *device);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {