ddraw: Introduce a ddraw_texture structure as parent for textures.
This commit is contained in:
parent
b83a0b9d3e
commit
80dbeb9699
|
@ -5152,8 +5152,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
|
|||
DWORD flags, struct wined3d_surface **surface)
|
||||
{
|
||||
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
|
||||
struct ddraw_surface *tex_root = container_parent;
|
||||
DDSURFACEDESC2 desc = tex_root->surface_desc;
|
||||
struct ddraw_texture *texture = container_parent;
|
||||
DDSURFACEDESC2 desc = texture->surface_desc;
|
||||
struct ddraw_surface *ddraw_surface;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -5163,7 +5163,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
|
|||
/* The ddraw root surface is created before the wined3d texture. */
|
||||
if (!sub_resource_idx)
|
||||
{
|
||||
ddraw_surface = tex_root;
|
||||
ddraw_surface = texture->root;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -5171,7 +5171,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
|
|||
desc.dwHeight = wined3d_desc->height;
|
||||
|
||||
/* FIXME: Validate that format, usage, pool, etc. really make sense. */
|
||||
if (FAILED(hr = ddraw_create_surface(ddraw, &desc, flags, &ddraw_surface, tex_root->version)))
|
||||
if (FAILED(hr = ddraw_create_surface(ddraw, &desc, flags, &ddraw_surface, texture->version)))
|
||||
return hr;
|
||||
|
||||
done:
|
||||
|
|
|
@ -185,6 +185,14 @@ struct ddraw_surface
|
|||
DWORD Handle;
|
||||
};
|
||||
|
||||
struct ddraw_texture
|
||||
{
|
||||
unsigned int version;
|
||||
DDSURFACEDESC2 surface_desc;
|
||||
|
||||
struct ddraw_surface *root;
|
||||
};
|
||||
|
||||
HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface, DWORD surface_flags) DECLSPEC_HIDDEN;
|
||||
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
|
||||
DDSURFACEDESC2 *desc, DWORD flags, UINT version) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -2454,9 +2454,9 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
|
|||
{
|
||||
/* The parent of the texture is the IDirectDrawSurface7
|
||||
* interface of the ddraw surface. */
|
||||
struct ddraw_surface *parent = wined3d_texture_get_parent(tex);
|
||||
struct ddraw_texture *parent = wined3d_texture_get_parent(tex);
|
||||
if (parent)
|
||||
*value = parent->Handle;
|
||||
*value = parent->root->Handle;
|
||||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -4586,7 +4586,7 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
|
|||
{
|
||||
struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
|
||||
struct wined3d_texture *wined3d_texture;
|
||||
struct ddraw_surface *surface;
|
||||
struct ddraw_texture *ddraw_texture;
|
||||
|
||||
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
||||
|
||||
|
@ -4601,8 +4601,8 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
surface = wined3d_texture_get_parent(wined3d_texture);
|
||||
*texture = &surface->IDirectDrawSurface7_iface;
|
||||
ddraw_texture = wined3d_texture_get_parent(wined3d_texture);
|
||||
*texture = &ddraw_texture->root->IDirectDrawSurface7_iface;
|
||||
IDirectDrawSurface7_AddRef(*texture);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
|
|
@ -5575,11 +5575,12 @@ static const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops =
|
|||
|
||||
static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *parent)
|
||||
{
|
||||
struct ddraw_surface *surface = parent;
|
||||
struct ddraw_texture *texture = parent;
|
||||
|
||||
TRACE("surface %p.\n", surface);
|
||||
TRACE("texture %p.\n", texture);
|
||||
|
||||
ddraw_surface_cleanup(surface);
|
||||
ddraw_surface_cleanup(texture->root);
|
||||
HeapFree(GetProcessHeap(), 0, parent);
|
||||
}
|
||||
|
||||
static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops =
|
||||
|
@ -5593,11 +5594,19 @@ HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface, DWORD surfac
|
|||
struct wined3d_resource_desc wined3d_desc;
|
||||
struct ddraw_surface *mip, **attach;
|
||||
struct wined3d_resource *resource;
|
||||
struct ddraw_texture *texture;
|
||||
UINT layers, levels, i, j;
|
||||
DDSURFACEDESC2 *mip_desc;
|
||||
enum wined3d_pool pool;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(texture = HeapAlloc(GetProcessHeap(), 0, sizeof(*texture))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
texture->version = surface->version;
|
||||
texture->surface_desc = *desc;
|
||||
texture->root = surface;
|
||||
|
||||
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
||||
levels = desc->u2.dwMipMapCount;
|
||||
else
|
||||
|
@ -5640,13 +5649,13 @@ HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface, DWORD surfac
|
|||
{
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
|
||||
hr = wined3d_texture_create_cube(surface->ddraw->wined3d_device, &wined3d_desc, levels,
|
||||
surface_flags, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
|
||||
surface_flags, texture, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
hr = wined3d_texture_create_2d(surface->ddraw->wined3d_device, &wined3d_desc, levels,
|
||||
surface_flags, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
|
||||
surface_flags, texture, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
|
@ -5662,6 +5671,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface, DWORD surfac
|
|||
FIXME("Unexpected wined3d error %#x.\n", hr);
|
||||
break;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, texture);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue