diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 8c685e48e12..6e64b8e0dc7 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -192,12 +192,11 @@ struct d3d9_volume IDirect3DVolume9 IDirect3DVolume9_iface; struct d3d9_resource resource; struct wined3d_volume *wined3d_volume; - IUnknown *container; - IUnknown *forwardReference; + struct d3d9_texture *texture; }; -void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume, - const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; +void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d9_swapchain { diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2f5d5adda7e..e6fe63122af 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3496,15 +3496,10 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent * if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY; - volume_init(d3d_volume, volume, parent_ops); + volume_init(d3d_volume, container_parent, volume, parent_ops); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume); - d3d_volume->container = container_parent; - - IDirect3DVolume9_Release(&d3d_volume->IDirect3DVolume9_iface); - d3d_volume->forwardReference = container_parent; - return D3D_OK; } diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 30a977c990f..4b22f20eef7 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -50,73 +50,30 @@ static HRESULT WINAPI d3d9_volume_QueryInterface(IDirect3DVolume9 *iface, REFIID static ULONG WINAPI d3d9_volume_AddRef(IDirect3DVolume9 *iface) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - ULONG refcount; TRACE("iface %p.\n", iface); + TRACE("Forwarding to %p.\n", volume->texture); - if (volume->forwardReference) - { - TRACE("Forwarding to %p.\n", volume->forwardReference); - return IUnknown_AddRef(volume->forwardReference); - } - - refcount = InterlockedIncrement(&volume->resource.refcount); - TRACE("%p increasing refcount to %u.\n", iface, refcount); - - if (refcount == 1) - { - wined3d_mutex_lock(); - wined3d_volume_incref(volume->wined3d_volume); - wined3d_mutex_unlock(); - } - - return refcount; + return IDirect3DBaseTexture9_AddRef(&volume->texture->IDirect3DBaseTexture9_iface); } static ULONG WINAPI d3d9_volume_Release(IDirect3DVolume9 *iface) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - ULONG refcount; TRACE("iface %p.\n", iface); + TRACE("Forwarding to %p.\n", volume->texture); - if (volume->forwardReference) - { - TRACE("Forwarding to %p.\n", volume->forwardReference); - return IUnknown_Release(volume->forwardReference); - } - - refcount = InterlockedDecrement(&volume->resource.refcount); - TRACE("%p decreasing refcount to %u.\n", iface, refcount); - - if (!refcount) - { - wined3d_mutex_lock(); - wined3d_volume_decref(volume->wined3d_volume); - wined3d_mutex_unlock(); - } - - return refcount; + return IDirect3DBaseTexture9_Release(&volume->texture->IDirect3DBaseTexture9_iface); } static HRESULT WINAPI d3d9_volume_GetDevice(IDirect3DVolume9 *iface, IDirect3DDevice9 **device) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - IDirect3DResource9 *resource; - HRESULT hr; TRACE("iface %p, device %p.\n", iface, device); - hr = IUnknown_QueryInterface(volume->forwardReference, &IID_IDirect3DResource9, (void **)&resource); - if (SUCCEEDED(hr)) - { - hr = IDirect3DResource9_GetDevice(resource, device); - IDirect3DResource9_Release(resource); - - TRACE("Returning device %p.\n", *device); - } - - return hr; + return IDirect3DBaseTexture9_GetDevice(&volume->texture->IDirect3DBaseTexture9_iface, device); } static HRESULT WINAPI d3d9_volume_SetPrivateData(IDirect3DVolume9 *iface, REFGUID guid, @@ -150,18 +107,10 @@ static HRESULT WINAPI d3d9_volume_FreePrivateData(IDirect3DVolume9 *iface, REFGU static HRESULT WINAPI d3d9_volume_GetContainer(IDirect3DVolume9 *iface, REFIID riid, void **container) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - HRESULT hr; TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container); - if (!volume->container) - return E_NOINTERFACE; - - hr = IUnknown_QueryInterface(volume->container, riid, container); - - TRACE("Returning %p,\n", *container); - - return hr; + return IDirect3DBaseTexture9_QueryInterface(&volume->texture->IDirect3DBaseTexture9_iface, riid, container); } static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DESC *desc) @@ -252,13 +201,14 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = volume_wined3d_object_destroyed, }; -void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume, - const struct wined3d_parent_ops **parent_ops) +void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) { volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl; d3d9_resource_init(&volume->resource); - wined3d_volume_incref(wined3d_volume); + volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; + volume->texture = texture; *parent_ops = &d3d9_volume_wined3d_parent_ops; }