ddraw: Pass the ddraw texture to ddraw_surface_init().

This commit is contained in:
Henri Verbeet 2013-11-14 10:47:17 +01:00 committed by Alexandre Julliard
parent 10411fb2a1
commit 80055e1fcd
3 changed files with 15 additions and 18 deletions

View File

@ -2722,13 +2722,13 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
return DD_OK; return DD_OK;
} }
static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *desc, static HRESULT ddraw_create_surface(struct ddraw *ddraw, struct ddraw_texture *texture,
const struct wined3d_resource_desc *wined3d_desc, DWORD flags, struct ddraw_surface **surface, UINT version) const struct wined3d_resource_desc *wined3d_desc, DWORD flags, struct ddraw_surface **surface)
{ {
HRESULT hr; HRESULT hr;
TRACE("ddraw %p, desc %p, wined3d_desc %p, flags %#x, surface %p.\n", TRACE("ddraw %p, texture %p, wined3d_desc %p, flags %#x, surface %p.\n",
ddraw, desc, wined3d_desc, flags, surface); ddraw, texture, wined3d_desc, flags, surface);
/* Create the Surface object */ /* Create the Surface object */
*surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**surface)); *surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**surface));
@ -2738,7 +2738,7 @@ static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
return DDERR_OUTOFVIDEOMEMORY; return DDERR_OUTOFVIDEOMEMORY;
} }
if (FAILED(hr = ddraw_surface_init(*surface, ddraw, desc, wined3d_desc, flags, version))) if (FAILED(hr = ddraw_surface_init(*surface, ddraw, texture, wined3d_desc, flags)))
{ {
WARN("Failed to initialize surface, hr %#x.\n", hr); WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, *surface); HeapFree(GetProcessHeap(), 0, *surface);
@ -5105,8 +5105,6 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
{ {
struct ddraw *ddraw = ddraw_from_device_parent(device_parent); struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *ddraw_surface; struct ddraw_surface *ddraw_surface;
struct ddraw_texture *texture;
DDSURFACEDESC2 desc;
HRESULT hr; HRESULT hr;
TRACE("device_parent %p, container_parent %p, wined3d_desc %p, sub_resource_idx %u, flags %#x, surface %p.\n", TRACE("device_parent %p, container_parent %p, wined3d_desc %p, sub_resource_idx %u, flags %#x, surface %p.\n",
@ -5119,13 +5117,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
wined3d_desc->multisample_quality, WINED3D_SURFACE_MAPPABLE, NULL, wined3d_desc->multisample_quality, WINED3D_SURFACE_MAPPABLE, NULL,
&ddraw_null_wined3d_parent_ops, surface); &ddraw_null_wined3d_parent_ops, surface);
texture = container_parent;
desc = texture->surface_desc;
desc.dwWidth = wined3d_desc->width;
desc.dwHeight = wined3d_desc->height;
/* FIXME: Validate that format, usage, pool, etc. really make sense. */ /* FIXME: Validate that format, usage, pool, etc. really make sense. */
if (FAILED(hr = ddraw_create_surface(ddraw, &desc, wined3d_desc, flags, &ddraw_surface, texture->version))) if (FAILED(hr = ddraw_create_surface(ddraw, container_parent, wined3d_desc, flags, &ddraw_surface)))
return hr; return hr;
*surface = ddraw_surface->wined3d_surface; *surface = ddraw_surface->wined3d_surface;

View File

@ -195,8 +195,8 @@ struct ddraw_texture
HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc, HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
unsigned int version, struct ddraw_surface **surface) DECLSPEC_HIDDEN; unsigned int version, struct ddraw_surface **surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, const DDSURFACEDESC2 *desc, HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
const struct wined3d_resource_desc *wined3d_desc, DWORD flags, UINT version) DECLSPEC_HIDDEN; const struct wined3d_resource_desc *wined3d_desc, DWORD flags) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN; ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface) static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface)

View File

@ -5793,9 +5793,11 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
return DD_OK; return DD_OK;
} }
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, const DDSURFACEDESC2 *desc, HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
const struct wined3d_resource_desc *wined3d_desc, DWORD flags, UINT version) const struct wined3d_resource_desc *wined3d_desc, DWORD flags)
{ {
DDSURFACEDESC2 *desc = &surface->surface_desc;
unsigned int version = texture->version;
HRESULT hr; HRESULT hr;
surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl; surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
@ -5826,7 +5828,9 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, c
surface->texture_outer = (IUnknown *)&surface->IDirectDrawSurface_iface; surface->texture_outer = (IUnknown *)&surface->IDirectDrawSurface_iface;
} }
surface->surface_desc = *desc; *desc = texture->surface_desc;
desc->dwWidth = wined3d_desc->width;
desc->dwHeight = wined3d_desc->height;
surface->first_attached = surface; surface->first_attached = surface;
if (FAILED(hr = wined3d_surface_create(ddraw->wined3d_device, wined3d_desc->width, wined3d_desc->height, if (FAILED(hr = wined3d_surface_create(ddraw->wined3d_device, wined3d_desc->width, wined3d_desc->height,