Commit 7d793715 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: Use the new private store api.

parent e50c4d0f
...@@ -150,6 +150,7 @@ struct ddraw_surface ...@@ -150,6 +150,7 @@ struct ddraw_surface
struct ddraw *ddraw; struct ddraw *ddraw;
struct wined3d_surface *wined3d_surface; struct wined3d_surface *wined3d_surface;
struct wined3d_texture *wined3d_texture; struct wined3d_texture *wined3d_texture;
struct wined3d_private_store private_store;
struct d3d_device *device1; struct d3d_device *device1;
/* This implementation handles attaching surfaces to other surfaces */ /* This implementation handles attaching surfaces to other surfaces */
......
...@@ -2246,25 +2246,18 @@ static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWO ...@@ -2246,25 +2246,18 @@ static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWO
* *
*****************************************************************************/ *****************************************************************************/
static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface, static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface,
REFGUID tag, void *Data, DWORD Size, DWORD Flags) REFGUID tag, void *data, DWORD size, DWORD flags)
{ {
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
struct wined3d_resource *resource;
HRESULT hr; HRESULT hr;
TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n", TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(tag), Data, Size, Flags); iface, debugstr_guid(tag), data, size, flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
resource = wined3d_surface_get_resource(surface->wined3d_surface); hr = wined3d_private_store_set_private_data(&surface->private_store, tag, data, size, flags);
hr = wined3d_resource_set_private_data(resource, tag, Data, Size, Flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr_ddraw_from_wined3d(hr);
switch(hr)
{
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
default: return hr;
}
} }
static HRESULT WINAPI ddraw_surface4_SetPrivateData(IDirectDrawSurface4 *iface, static HRESULT WINAPI ddraw_surface4_SetPrivateData(IDirectDrawSurface4 *iface,
...@@ -2294,23 +2287,45 @@ static HRESULT WINAPI ddraw_surface4_SetPrivateData(IDirectDrawSurface4 *iface, ...@@ -2294,23 +2287,45 @@ static HRESULT WINAPI ddraw_surface4_SetPrivateData(IDirectDrawSurface4 *iface,
* For more details, see IWineD3DSurface::GetPrivateData * For more details, see IWineD3DSurface::GetPrivateData
* *
*****************************************************************************/ *****************************************************************************/
static HRESULT WINAPI ddraw_surface7_GetPrivateData(IDirectDrawSurface7 *iface, REFGUID tag, void *Data, DWORD *Size) static HRESULT WINAPI ddraw_surface7_GetPrivateData(IDirectDrawSurface7 *iface, REFGUID tag, void *data, DWORD *size)
{ {
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
struct wined3d_resource *resource; const struct wined3d_private_data *stored_data;
HRESULT hr; HRESULT hr;
TRACE("iface %p, tag %s, data %p, data_size %p.\n", TRACE("iface %p, tag %s, data %p, data_size %p.\n",
iface, debugstr_guid(tag), Data, Size); iface, debugstr_guid(tag), data, size);
if(!Data)
return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); wined3d_mutex_lock();
resource = wined3d_surface_get_resource(surface->wined3d_surface); stored_data = wined3d_private_store_get_private_data(&surface->private_store, tag);
hr = wined3d_resource_get_private_data(resource, tag, Data, Size); if (!stored_data)
wined3d_mutex_unlock(); {
hr = DDERR_NOTFOUND;
goto done;
}
if (!size)
{
hr = DDERR_INVALIDPARAMS;
goto done;
}
if (*size < stored_data->size)
{
*size = stored_data->size;
hr = DDERR_MOREDATA;
goto done;
}
if (!data)
{
hr = DDERR_INVALIDPARAMS;
goto done;
}
*size = stored_data->size;
memcpy(data, stored_data->content.data, stored_data->size);
hr = DD_OK;
done:
wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -2340,17 +2355,22 @@ static HRESULT WINAPI ddraw_surface4_GetPrivateData(IDirectDrawSurface4 *iface, ...@@ -2340,17 +2355,22 @@ static HRESULT WINAPI ddraw_surface4_GetPrivateData(IDirectDrawSurface4 *iface,
static HRESULT WINAPI ddraw_surface7_FreePrivateData(IDirectDrawSurface7 *iface, REFGUID tag) static HRESULT WINAPI ddraw_surface7_FreePrivateData(IDirectDrawSurface7 *iface, REFGUID tag)
{ {
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
struct wined3d_resource *resource; struct wined3d_private_data *entry;
HRESULT hr;
TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag)); TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag));
wined3d_mutex_lock(); wined3d_mutex_lock();
resource = wined3d_surface_get_resource(surface->wined3d_surface); entry = wined3d_private_store_get_private_data(&surface->private_store, tag);
hr = wined3d_resource_free_private_data(resource, tag); if (!entry)
{
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DDERR_NOTFOUND;
}
return hr; wined3d_private_store_free_private_data(&surface->private_store, entry);
wined3d_mutex_unlock();
return DD_OK;
} }
static HRESULT WINAPI ddraw_surface4_FreePrivateData(IDirectDrawSurface4 *iface, REFGUID tag) static HRESULT WINAPI ddraw_surface4_FreePrivateData(IDirectDrawSurface4 *iface, REFGUID tag)
...@@ -5469,6 +5489,8 @@ static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *paren ...@@ -5469,6 +5489,8 @@ static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *paren
if (surface == surface->ddraw->primary) if (surface == surface->ddraw->primary)
surface->ddraw->primary = NULL; surface->ddraw->primary = NULL;
wined3d_private_store_cleanup(&surface->private_store);
HeapFree(GetProcessHeap(), 0, surface); HeapFree(GetProcessHeap(), 0, surface);
} }
...@@ -6095,5 +6117,7 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s ...@@ -6095,5 +6117,7 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
surface->wined3d_surface = wined3d_surface; surface->wined3d_surface = wined3d_surface;
*parent_ops = &ddraw_surface_wined3d_parent_ops; *parent_ops = &ddraw_surface_wined3d_parent_ops;
wined3d_private_store_init(&surface->private_store);
return DD_OK; return DD_OK;
} }
...@@ -192,14 +192,8 @@ HRESULT CDECL wined3d_resource_get_private_data(const struct wined3d_resource *r ...@@ -192,14 +192,8 @@ HRESULT CDECL wined3d_resource_get_private_data(const struct wined3d_resource *r
if (d->flags & WINED3DSPD_IUNKNOWN) if (d->flags & WINED3DSPD_IUNKNOWN)
{ {
*(IUnknown **)data = d->content.object; *(IUnknown **)data = d->content.object;
if (resource->device->wined3d->dxVersion != 7)
{
/* D3D8 and D3D9 addref the private data, DDraw does not. This
* can't be handled in ddraw because it doesn't know if the
* pointer returned is an IUnknown * or just a blob. */
IUnknown_AddRef(d->content.object); IUnknown_AddRef(d->content.object);
} }
}
else else
{ {
memcpy(data, d->content.data, d->size); memcpy(data, d->content.data, d->size);
......
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