Commit d1d48d31 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: The "forwardReference" field in struct d3d9_surface is always a texture, if set.

parent c8ec6918
...@@ -216,12 +216,12 @@ struct d3d9_surface ...@@ -216,12 +216,12 @@ struct d3d9_surface
struct wined3d_surface *wined3d_surface; struct wined3d_surface *wined3d_surface;
IDirect3DDevice9Ex *parent_device; IDirect3DDevice9Ex *parent_device;
IUnknown *container; IUnknown *container;
IUnknown *forwardReference; struct d3d9_texture *texture;
BOOL getdc_supported; BOOL getdc_supported;
}; };
void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface, void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
struct d3d9_device *device, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN; struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
struct d3d9_vertexbuffer struct d3d9_vertexbuffer
......
...@@ -1026,7 +1026,6 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width ...@@ -1026,7 +1026,6 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
sub_resource = wined3d_texture_get_sub_resource(texture, 0); sub_resource = wined3d_texture_get_sub_resource(texture, 0);
surface_impl = wined3d_resource_get_parent(sub_resource); surface_impl = wined3d_resource_get_parent(sub_resource);
surface_impl->forwardReference = NULL;
surface_impl->parent_device = &device->IDirect3DDevice9Ex_iface; surface_impl->parent_device = &device->IDirect3DDevice9Ex_iface;
*surface = &surface_impl->IDirect3DSurface9_iface; *surface = &surface_impl->IDirect3DSurface9_iface;
IDirect3DSurface9_AddRef(*surface); IDirect3DSurface9_AddRef(*surface);
...@@ -3461,7 +3460,6 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -3461,7 +3460,6 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
void *container_parent, struct wined3d_surface *surface, void **parent, void *container_parent, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops) const struct wined3d_parent_ops **parent_ops)
{ {
struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_surface *d3d_surface; struct d3d9_surface *d3d_surface;
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n", TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
...@@ -3470,17 +3468,10 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -3470,17 +3468,10 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
surface_init(d3d_surface, surface, device, parent_ops); surface_init(d3d_surface, container_parent, surface, parent_ops);
*parent = d3d_surface; *parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface); TRACE("Created surface %p.\n", d3d_surface);
d3d_surface->container = container_parent;
IDirect3DDevice9Ex_Release(d3d_surface->parent_device);
d3d_surface->parent_device = NULL;
IDirect3DSurface9_Release(&d3d_surface->IDirect3DSurface9_iface);
d3d_surface->forwardReference = container_parent;
return D3D_OK; return D3D_OK;
} }
...@@ -3532,7 +3523,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic ...@@ -3532,7 +3523,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
wined3d_texture_decref(texture); wined3d_texture_decref(texture);
d3d_surface = wined3d_surface_get_parent(*surface); d3d_surface = wined3d_surface_get_parent(*surface);
d3d_surface->forwardReference = NULL;
d3d_surface->parent_device = &device->IDirect3DDevice9Ex_iface; d3d_surface->parent_device = &device->IDirect3DDevice9Ex_iface;
return hr; return hr;
......
...@@ -55,10 +55,10 @@ static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface) ...@@ -55,10 +55,10 @@ static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
if (surface->forwardReference) if (surface->texture)
{ {
TRACE("Forwarding to %p.\n", surface->forwardReference); TRACE("Forwarding to %p.\n", surface->texture);
return IUnknown_AddRef(surface->forwardReference); return IDirect3DBaseTexture9_AddRef(&surface->texture->IDirect3DBaseTexture9_iface);
} }
refcount = InterlockedIncrement(&surface->resource.refcount); refcount = InterlockedIncrement(&surface->resource.refcount);
...@@ -83,10 +83,10 @@ static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface) ...@@ -83,10 +83,10 @@ static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
if (surface->forwardReference) if (surface->texture)
{ {
TRACE("Forwarding to %p.\n", surface->forwardReference); TRACE("Forwarding to %p.\n", surface->texture);
return IUnknown_Release(surface->forwardReference); return IDirect3DBaseTexture9_Release(&surface->texture->IDirect3DBaseTexture9_iface);
} }
refcount = InterlockedDecrement(&surface->resource.refcount); refcount = InterlockedDecrement(&surface->resource.refcount);
...@@ -114,22 +114,8 @@ static HRESULT WINAPI d3d9_surface_GetDevice(IDirect3DSurface9 *iface, IDirect3D ...@@ -114,22 +114,8 @@ static HRESULT WINAPI d3d9_surface_GetDevice(IDirect3DSurface9 *iface, IDirect3D
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
if (surface->forwardReference) if (surface->texture)
{ return IDirect3DBaseTexture9_GetDevice(&surface->texture->IDirect3DBaseTexture9_iface, device);
IDirect3DResource9 *resource;
HRESULT hr;
hr = IUnknown_QueryInterface(surface->forwardReference, &IID_IDirect3DResource9, (void **)&resource);
if (SUCCEEDED(hr))
{
hr = IDirect3DResource9_GetDevice(resource, device);
IDirect3DResource9_Release(resource);
TRACE("Returning device %p.\n", *device);
}
return hr;
}
*device = (IDirect3DDevice9 *)surface->parent_device; *device = (IDirect3DDevice9 *)surface->parent_device;
IDirect3DDevice9_AddRef(*device); IDirect3DDevice9_AddRef(*device);
...@@ -355,13 +341,24 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops = ...@@ -355,13 +341,24 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed, surface_wined3d_object_destroyed,
}; };
void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface, void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
struct d3d9_device *device, const struct wined3d_parent_ops **parent_ops) struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
{ {
struct wined3d_resource_desc desc; struct wined3d_resource_desc desc;
IDirect3DBaseTexture9 *texture;
surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl; surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
d3d9_resource_init(&surface->resource); d3d9_resource_init(&surface->resource);
surface->resource.refcount = 0;
surface->wined3d_surface = wined3d_surface;
surface->container = container_parent;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent,
&IID_IDirect3DBaseTexture9, (void **)&texture)))
{
surface->texture = unsafe_impl_from_IDirect3DBaseTexture9(texture);
IDirect3DBaseTexture9_Release(texture);
}
wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &desc); wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &desc);
switch (d3dformat_from_wined3dformat(desc.format)) switch (d3dformat_from_wined3dformat(desc.format))
...@@ -380,11 +377,6 @@ void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_ ...@@ -380,11 +377,6 @@ void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_
break; break;
} }
wined3d_surface_incref(wined3d_surface);
surface->wined3d_surface = wined3d_surface;
surface->parent_device = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(surface->parent_device);
*parent_ops = &d3d9_surface_wined3d_parent_ops; *parent_ops = &d3d9_surface_wined3d_parent_ops;
} }
......
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