wined3d: Just return the texture from wined3d_device_get_texture().

This commit is contained in:
Henri Verbeet 2012-09-26 22:34:02 +02:00 committed by Alexandre Julliard
parent fb2dac9621
commit f9d494294a
6 changed files with 17 additions and 60 deletions

View File

@ -1691,7 +1691,6 @@ static HRESULT WINAPI d3d8_device_GetTexture(IDirect3DDevice8 *iface, DWORD stag
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_texture *wined3d_texture;
struct d3d8_texture *texture_impl;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
@ -1699,21 +1698,11 @@ static HRESULT WINAPI d3d8_device_GetTexture(IDirect3DDevice8 *iface, DWORD stag
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
hr = wined3d_device_get_texture(device->wined3d_device, stage, &wined3d_texture);
if (FAILED(hr))
{
WARN("Failed to get texture for stage %u, hr %#x.\n", stage, hr);
wined3d_mutex_unlock();
*texture = NULL;
return hr;
}
if (wined3d_texture)
if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
{
texture_impl = wined3d_texture_get_parent(wined3d_texture);
*texture = &texture_impl->IDirect3DBaseTexture8_iface;
IDirect3DBaseTexture8_AddRef(*texture);
wined3d_texture_decref(wined3d_texture);
}
else
{

View File

@ -1666,7 +1666,6 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_texture *wined3d_texture = NULL;
struct d3d9_texture *texture_impl;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
@ -1674,23 +1673,19 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
hr = wined3d_device_get_texture(device->wined3d_device, stage, &wined3d_texture);
if (SUCCEEDED(hr) && wined3d_texture)
if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
{
texture_impl = wined3d_texture_get_parent(wined3d_texture);
*texture = &texture_impl->IDirect3DBaseTexture9_iface;
IDirect3DBaseTexture9_AddRef(*texture);
wined3d_texture_decref(wined3d_texture);
}
else
{
if (FAILED(hr))
WARN("Call to get texture (%u) failed (%p).\n", stage, wined3d_texture);
*texture = NULL;
}
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 *texture)

View File

@ -2361,7 +2361,6 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
D3DRENDERSTATETYPE state, DWORD *value)
{
struct d3d_device *device = impl_from_IDirect3DDevice3(iface);
HRESULT hr;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
@ -2375,19 +2374,17 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
*value = 0;
wined3d_mutex_lock();
hr = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
if (SUCCEEDED(hr) && tex)
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
{
/* The parent of the texture is the IDirectDrawSurface7
* interface of the ddraw surface. */
struct ddraw_surface *parent = wined3d_texture_get_parent(tex);
if (parent)
*value = parent->Handle;
wined3d_texture_decref(tex);
}
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
case D3DRENDERSTATE_TEXTUREMAPBLEND:
@ -2423,13 +2420,10 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
else
{
struct wined3d_texture *tex = NULL;
HRESULT hr;
BOOL tex_alpha = FALSE;
DDPIXELFORMAT ddfmt;
hr = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
if(hr == WINED3D_OK && tex)
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
{
struct wined3d_resource *sub_resource;
@ -2442,8 +2436,6 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
wined3d_texture_decref(tex);
}
if (!(colorop == WINED3D_TOP_MODULATE
@ -2720,9 +2712,7 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
BOOL tex_alpha = FALSE;
DDPIXELFORMAT ddfmt;
hr = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
if(hr == WINED3D_OK && tex)
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
{
struct wined3d_resource *sub_resource;
@ -2735,8 +2725,6 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
wined3d_texture_decref(tex);
}
if (tex_alpha)
@ -4312,7 +4300,6 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
struct wined3d_texture *wined3d_texture;
struct ddraw_surface *surface;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
@ -4320,21 +4307,19 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS;
wined3d_mutex_lock();
hr = wined3d_device_get_texture(device->wined3d_device, stage, &wined3d_texture);
if (FAILED(hr) || !wined3d_texture)
if (!(wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
{
*texture = NULL;
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
surface = wined3d_texture_get_parent(wined3d_texture);
*texture = &surface->IDirectDrawSurface7_iface;
IDirectDrawSurface7_AddRef(*texture);
wined3d_texture_decref(wined3d_texture);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d_device7_GetTexture_FPUSetup(IDirect3DDevice7 *iface,
@ -4452,10 +4437,8 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
struct wined3d_texture *tex = NULL;
BOOL tex_alpha = FALSE;
DDPIXELFORMAT ddfmt;
HRESULT result;
result = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
if (result == WINED3D_OK && tex)
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
{
struct wined3d_resource *sub_resource;
@ -4468,8 +4451,6 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
wined3d_texture_decref(tex);
}
/* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */

View File

@ -3556,10 +3556,9 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
return WINED3D_OK;
}
HRESULT CDECL wined3d_device_get_texture(const struct wined3d_device *device,
UINT stage, struct wined3d_texture **texture)
struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_device *device, UINT stage)
{
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
TRACE("device %p, stage %u.\n", device, stage);
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
@ -3567,16 +3566,10 @@ HRESULT CDECL wined3d_device_get_texture(const struct wined3d_device *device,
if (stage >= sizeof(device->stateBlock->state.textures) / sizeof(*device->stateBlock->state.textures))
{
WARN("Ignoring invalid stage %u.\n", stage);
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
return NULL; /* Windows accepts overflowing this array ... we do not. */
}
*texture = device->stateBlock->state.textures[stage];
if (*texture)
wined3d_texture_incref(*texture);
TRACE("Returning %p.\n", *texture);
return WINED3D_OK;
return device->stateBlock->state.textures[stage];
}
HRESULT CDECL wined3d_device_get_back_buffer(const struct wined3d_device *device, UINT swapchain_idx,

View File

@ -85,7 +85,7 @@
@ cdecl wined3d_device_get_surface_from_dc(ptr ptr ptr)
@ cdecl wined3d_device_get_swapchain(ptr long)
@ cdecl wined3d_device_get_swapchain_count(ptr)
@ cdecl wined3d_device_get_texture(ptr long ptr)
@ cdecl wined3d_device_get_texture(ptr long)
@ cdecl wined3d_device_get_texture_stage_state(ptr long long)
@ cdecl wined3d_device_get_transform(ptr long ptr)
@ cdecl wined3d_device_get_vertex_declaration(ptr)

View File

@ -2158,8 +2158,7 @@ HRESULT __cdecl wined3d_device_get_surface_from_dc(const struct wined3d_device *
struct wined3d_swapchain * __cdecl wined3d_device_get_swapchain(const struct wined3d_device *device,
UINT swapchain_idx);
UINT __cdecl wined3d_device_get_swapchain_count(const struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_texture(const struct wined3d_device *device,
UINT stage, struct wined3d_texture **texture);
struct wined3d_texture * __cdecl wined3d_device_get_texture(const struct wined3d_device *device, UINT stage);
DWORD __cdecl wined3d_device_get_texture_stage_state(const struct wined3d_device *device,
UINT stage, enum wined3d_texture_stage_state state);
void __cdecl wined3d_device_get_transform(const struct wined3d_device *device,