wined3d: Get rid of IWineD3DBaseTexture::GetSubResourceDesc().

This commit is contained in:
Henri Verbeet 2011-03-09 19:16:17 +01:00 committed by Alexandre Julliard
parent 8809ebdf79
commit 4fd03150f6
14 changed files with 85 additions and 131 deletions

View File

@ -253,18 +253,20 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(IDirect3DCubeTexture
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(IDirect3DCubeTexture8 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
struct wined3d_resource_desc wined3d_desc;
HRESULT hr;
IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetSubResourceDesc(This->wineD3DCubeTexture, level, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = IWineD3DCubeTexture_GetSubResource(texture->wineD3DCubeTexture, level)))
hr = D3DERR_INVALIDCALL;
else
{
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
@ -274,6 +276,7 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(IDirect3DCubeTextur
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}

View File

@ -250,18 +250,20 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(IDirect3DTexture8 *iface
static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(IDirect3DTexture8 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
struct wined3d_resource_desc wined3d_desc;
HRESULT hr;
IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetSubResourceDesc(This->wineD3DTexture, level, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = IWineD3DTexture_GetSubResource(texture->wineD3DTexture, level)))
hr = D3DERR_INVALIDCALL;
else
{
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
@ -271,6 +273,7 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(IDirect3DTexture8 *ifac
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}

View File

@ -227,18 +227,20 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETE
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(IDirect3DVolumeTexture8 *iface,
UINT level, D3DVOLUME_DESC *desc)
{
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
struct wined3d_resource_desc wined3d_desc;
HRESULT hr;
IDirect3DVolumeTexture8Impl *texture = (IDirect3DVolumeTexture8Impl *)iface;
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetSubResourceDesc(This->wineD3DVolumeTexture, level, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wineD3DVolumeTexture, level)))
hr = D3DERR_INVALIDCALL;
else
{
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
@ -248,6 +250,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(IDirect3DVolumeTe
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
}
wined3d_mutex_unlock();
return hr;
}

View File

@ -269,18 +269,20 @@ static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBE
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(IDirect3DCubeTexture9 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
struct wined3d_resource_desc wined3d_desc;
HRESULT hr;
IDirect3DCubeTexture9Impl *texture = (IDirect3DCubeTexture9Impl *)iface;
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetSubResourceDesc(This->wineD3DCubeTexture, level, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = IWineD3DCubeTexture_GetSubResource(texture->wineD3DCubeTexture, level)))
hr = D3DERR_INVALIDCALL;
else
{
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
@ -290,6 +292,7 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(IDirect3DCubeTextur
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}

View File

@ -265,18 +265,20 @@ static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9
static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(IDirect3DTexture9 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
struct wined3d_resource_desc wined3d_desc;
HRESULT hr;
IDirect3DTexture9Impl *texture = (IDirect3DTexture9Impl *)iface;
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetSubResourceDesc(This->wineD3DTexture, level, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = IWineD3DTexture_GetSubResource(texture->wineD3DTexture, level)))
hr = D3DERR_INVALIDCALL;
else
{
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
@ -286,6 +288,7 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(IDirect3DTexture9 *ifac
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}

View File

@ -290,20 +290,20 @@ static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVO
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(IDirect3DVolumeTexture9 *iface,
UINT level, D3DVOLUME_DESC *desc)
{
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
struct wined3d_resource_desc wined3d_desc;
HRESULT hr;
IDirect3DVolumeTexture9Impl *texture = (IDirect3DVolumeTexture9Impl *)iface;
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetSubResourceDesc(This->wineD3DVolumeTexture, level, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wineD3DVolumeTexture, level)))
hr = D3DERR_INVALIDCALL;
else
{
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
@ -312,6 +312,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(IDirect3DVolumeTe
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
}
wined3d_mutex_unlock();
return hr;
}

View File

@ -2497,18 +2497,19 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
HRESULT hr;
BOOL tex_alpha = FALSE;
IWineD3DBaseTexture *tex = NULL;
struct wined3d_resource_desc desc;
DDPIXELFORMAT ddfmt;
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
0,
&tex);
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
if(hr == WINED3D_OK && tex)
{
hr = IWineD3DBaseTexture_GetSubResourceDesc(tex, 0, &desc);
if (SUCCEEDED(hr))
struct wined3d_resource *sub_resource;
if ((sub_resource = IWineD3DBaseTexture_GetSubResource(tex, 0)))
{
struct wined3d_resource_desc desc;
wined3d_resource_get_desc(sub_resource, &desc);
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
@ -2805,19 +2806,19 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
{
BOOL tex_alpha = FALSE;
IWineD3DBaseTexture *tex = NULL;
struct wined3d_resource_desc desc;
DDPIXELFORMAT ddfmt;
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
0,
&tex);
hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
if(hr == WINED3D_OK && tex)
{
memset(&desc, 0, sizeof(desc));
hr = IWineD3DBaseTexture_GetSubResourceDesc(tex, 0, &desc);
if (SUCCEEDED(hr))
struct wined3d_resource *sub_resource;
if ((sub_resource = IWineD3DBaseTexture_GetSubResource(tex, 0)))
{
struct wined3d_resource_desc desc;
wined3d_resource_get_desc(sub_resource, &desc);
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
@ -4575,22 +4576,22 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
{
/* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states.
See IDirect3DDeviceImpl_3_SetRenderState for details. */
struct wined3d_resource_desc desc;
BOOL tex_alpha = FALSE;
IWineD3DBaseTexture *tex = NULL;
DDPIXELFORMAT ddfmt;
HRESULT result;
result = IWineD3DDevice_GetTexture(This->wineD3DDevice,
0,
&tex);
result = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
if(result == WINED3D_OK && tex)
{
memset(&desc, 0, sizeof(desc));
result = IWineD3DBaseTexture_GetSubResourceDesc(tex, 0, &desc);
if (SUCCEEDED(result))
struct wined3d_resource *sub_resource;
if ((sub_resource = IWineD3DBaseTexture_GetSubResource(tex, 0)))
{
struct wined3d_resource_desc desc;
wined3d_resource_get_desc(sub_resource, &desc);
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;

View File

@ -326,25 +326,6 @@ static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface)
return FALSE;
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetSubResourceDesc(IWineD3DCubeTexture *iface,
UINT sub_resource_idx, struct wined3d_resource_desc *desc)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc);
if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
wined3d_resource_get_desc(sub_resource, desc);
return WINED3D_OK;
}
static struct wined3d_resource * WINAPI IWineD3DCubeTextureImpl_GetSubResource(IWineD3DCubeTexture *iface,
UINT sub_resource_idx)
{
@ -437,7 +418,6 @@ static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
IWineD3DCubeTextureImpl_GetAutoGenFilterType,
IWineD3DCubeTextureImpl_GenerateMipSubLevels,
IWineD3DCubeTextureImpl_IsCondNP2,
IWineD3DCubeTextureImpl_GetSubResourceDesc,
IWineD3DCubeTextureImpl_GetSubResource,
/* IWineD3DCubeTexture */
IWineD3DCubeTextureImpl_Map,

View File

@ -283,7 +283,7 @@ void * CDECL wined3d_resource_get_parent(const struct wined3d_resource *resource
return resource->parent;
}
void wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc)
void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc)
{
desc->resource_type = resource->resourceType;
desc->format = resource->format->id;

View File

@ -351,25 +351,6 @@ static BOOL WINAPI IWineD3DTextureImpl_IsCondNP2(IWineD3DTexture *iface) {
return This->cond_np2;
}
static HRESULT WINAPI IWineD3DTextureImpl_GetSubResourceDesc(IWineD3DTexture *iface,
UINT sub_resource_idx, struct wined3d_resource_desc *desc)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc);
if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
wined3d_resource_get_desc(sub_resource, desc);
return WINED3D_OK;
}
static struct wined3d_resource * WINAPI IWineD3DTextureImpl_GetSubResource(IWineD3DTexture *iface,
UINT sub_resource_idx)
{
@ -456,7 +437,6 @@ static const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
IWineD3DTextureImpl_GetAutoGenFilterType,
IWineD3DTextureImpl_GenerateMipSubLevels,
IWineD3DTextureImpl_IsCondNP2,
IWineD3DTextureImpl_GetSubResourceDesc,
IWineD3DTextureImpl_GetSubResource,
/* IWineD3DTexture */
IWineD3DTextureImpl_Map,

View File

@ -263,25 +263,6 @@ static BOOL WINAPI IWineD3DVolumeTextureImpl_IsCondNP2(IWineD3DVolumeTexture *if
return FALSE;
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetSubResourceDesc(IWineD3DVolumeTexture *iface,
UINT sub_resource_idx, struct wined3d_resource_desc *desc)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc);
if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
wined3d_resource_get_desc(sub_resource, desc);
return WINED3D_OK;
}
static struct wined3d_resource * WINAPI IWineD3DVolumeTextureImpl_GetSubResource(IWineD3DVolumeTexture *iface,
UINT sub_resource_idx)
{
@ -369,7 +350,6 @@ static const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
IWineD3DVolumeTextureImpl_GetAutoGenFilterType,
IWineD3DVolumeTextureImpl_GenerateMipSubLevels,
IWineD3DVolumeTextureImpl_IsCondNP2,
IWineD3DVolumeTextureImpl_GetSubResourceDesc,
IWineD3DVolumeTextureImpl_GetSubResource,
/* volume texture */
IWineD3DVolumeTextureImpl_Map,

View File

@ -59,6 +59,7 @@
@ cdecl wined3d_query_incref(ptr)
@ cdecl wined3d_query_issue(ptr long)
@ cdecl wined3d_resource_get_desc(ptr ptr)
@ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_stateblock_apply(ptr)

View File

@ -1824,8 +1824,6 @@ struct wined3d_resource
void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_free_private_data(struct wined3d_resource *resource, REFGUID guid) DECLSPEC_HIDDEN;
void wined3d_resource_get_desc(const struct wined3d_resource *resource,
struct wined3d_resource_desc *desc) DECLSPEC_HIDDEN;
DWORD resource_get_priority(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid,
void *data, DWORD *data_size) DECLSPEC_HIDDEN;

View File

@ -2362,10 +2362,6 @@ interface IWineD3DBaseTexture : IWineD3DResource
);
BOOL IsCondNP2(
);
HRESULT GetSubResourceDesc(
[in] UINT sub_resource_idx,
[out] struct wined3d_resource_desc *desc
);
struct wined3d_resource *GetSubResource(
[in] UINT sub_resource_idx
);
@ -3215,6 +3211,8 @@ WINED3DQUERYTYPE __cdecl wined3d_query_get_type(const struct wined3d_query *quer
ULONG __cdecl wined3d_query_incref(struct wined3d_query *query);
HRESULT __cdecl wined3d_query_issue(struct wined3d_query *query, DWORD flags);
void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
struct wined3d_resource_desc *desc);
void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);