Commit 5000eba6 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Set user memory in ddraw_surface_create() instead of ddraw_surface_init().

parent e28800c6
......@@ -4726,7 +4726,6 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *ddraw_surface;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
......@@ -4746,13 +4745,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return DDERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = ddraw_surface_init(ddraw_surface, ddraw, container_parent, surface, parent_ops)))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, ddraw_surface);
return hr;
}
ddraw_surface_init(ddraw_surface, ddraw, container_parent, surface, parent_ops);
*parent = ddraw_surface;
list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
......
......@@ -207,7 +207,7 @@ struct ddraw_texture
HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version) DECLSPEC_HIDDEN;
struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
......
......@@ -5605,6 +5605,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
DDSURFACEDESC2 *desc, *mip_desc;
struct ddraw_texture *texture;
UINT layers, levels, i, j;
unsigned int pitch = 0;
HRESULT hr;
TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p, version %u.\n",
......@@ -5969,6 +5970,8 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
HeapFree(GetProcessHeap(), 0, texture);
return DDERR_INVALIDPARAMS;
}
pitch = desc->u1.lPitch;
}
}
......@@ -6073,6 +6076,14 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
}
}
if ((desc->dwFlags & DDSD_LPSURFACE) && FAILED(hr = wined3d_surface_update_desc(root->wined3d_surface,
wined3d_desc.width, wined3d_desc.height, wined3d_desc.format,
WINED3D_MULTISAMPLE_NONE, 0, desc->lpSurface, pitch)))
{
ERR("Failed to set surface memory, hr %#x.\n", hr);
goto fail;
}
if (desc->dwFlags & DDSD_BACKBUFFERCOUNT)
{
unsigned int count = desc->dwBackBufferCount;
......@@ -6148,13 +6159,12 @@ fail:
return hr;
}
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
{
DDSURFACEDESC2 *desc = &surface->surface_desc;
struct wined3d_resource_desc wined3d_desc;
unsigned int version = texture->version;
HRESULT hr;
surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
surface->IDirectDrawSurface4_iface.lpVtbl = &ddraw_surface4_vtbl;
......@@ -6193,46 +6203,18 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
if (format_is_compressed(&desc->u4.ddpfPixelFormat))
{
if (desc->dwFlags & DDSD_LPSURFACE)
{
if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width,
wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0,
desc->lpSurface, 0)))
{
ERR("Failed to set surface memory, hr %#x.\n", hr);
return hr;
}
desc->dwFlags |= DDSD_LINEARSIZE;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH);
desc->u1.dwLinearSize = ~0u;
}
else
{
desc->dwFlags |= DDSD_LINEARSIZE;
desc->dwFlags &= ~DDSD_PITCH;
desc->u1.dwLinearSize = wined3d_surface_get_pitch(wined3d_surface) * ((desc->dwHeight + 3) / 4);
}
desc->dwFlags |= DDSD_LINEARSIZE;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH);
}
else
{
if (desc->dwFlags & DDSD_LPSURFACE)
{
if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width,
wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0,
desc->lpSurface, desc->u1.lPitch)))
{
ERR("Failed to set surface memory, hr %#x.\n", hr);
return hr;
}
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE);
}
else
{
desc->dwFlags |= DDSD_PITCH;
desc->dwFlags &= ~DDSD_LINEARSIZE;
if (!(desc->dwFlags & DDSD_LPSURFACE))
desc->u1.lPitch = wined3d_surface_get_pitch(wined3d_surface);
}
desc->dwFlags |= DDSD_PITCH;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE);
}
desc->lpSurface = NULL;
......@@ -6241,8 +6223,6 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
*parent_ops = &ddraw_surface_wined3d_parent_ops;
wined3d_private_store_init(&surface->private_store);
return DD_OK;
}
static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment