Commit 134137cd authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Pass an IWineD3DResourceImpl pointer to resource_cleanup().

parent 7080922e
......@@ -48,7 +48,7 @@ HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, const struct wined3d_
if (!texture->baseTexture.sub_resources)
{
ERR("Failed to allocate sub-resource array.\n");
resource_cleanup((IWineD3DResource *)texture);
resource_cleanup((IWineD3DResourceImpl *)texture);
return E_OUTOFMEMORY;
}
......@@ -79,7 +79,7 @@ void basetexture_cleanup(IWineD3DBaseTextureImpl *texture)
{
basetexture_unload(texture);
HeapFree(GetProcessHeap(), 0, texture->baseTexture.sub_resources);
resource_cleanup((IWineD3DResource *)texture);
resource_cleanup((IWineD3DResourceImpl *)texture);
}
IWineD3DResourceImpl *basetexture_get_sub_resource(IWineD3DBaseTextureImpl *texture, UINT sub_resource_idx)
......
......@@ -742,7 +742,7 @@ static ULONG STDMETHODCALLTYPE buffer_Release(IWineD3DBuffer *iface)
if (!refcount)
{
buffer_UnLoad(iface);
resource_cleanup((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResourceImpl *)iface);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This->maps);
HeapFree(GetProcessHeap(), 0, This);
......@@ -1521,7 +1521,7 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
{
ERR("Failed to map buffer, hr %#x\n", hr);
buffer_UnLoad((IWineD3DBuffer *)buffer);
resource_cleanup((IWineD3DResource *)buffer);
resource_cleanup((IWineD3DResourceImpl *)buffer);
return hr;
}
......@@ -1535,7 +1535,7 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
{
ERR("Out of memory\n");
buffer_UnLoad((IWineD3DBuffer *)buffer);
resource_cleanup((IWineD3DResource *)buffer);
resource_cleanup((IWineD3DResourceImpl *)buffer);
return E_OUTOFMEMORY;
}
buffer->maps_size = 1;
......
......@@ -93,33 +93,34 @@ HRESULT resource_init(struct IWineD3DResourceImpl *resource, WINED3DRESOURCETYPE
return WINED3D_OK;
}
void resource_cleanup(IWineD3DResource *iface)
void resource_cleanup(struct IWineD3DResourceImpl *resource)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
struct private_data *data;
struct list *e1, *e2;
HRESULT hr;
TRACE("(%p) Cleaning up resource\n", This);
if (This->resource.pool == WINED3DPOOL_DEFAULT) {
TRACE("Decrementing device memory pool by %u\n", This->resource.size);
WineD3DAdapterChangeGLRam(This->resource.device, -This->resource.size);
TRACE("Cleaning up resource %p.\n", resource);
if (resource->resource.pool == WINED3DPOOL_DEFAULT)
{
TRACE("Decrementing device memory pool by %u.\n", resource->resource.size);
WineD3DAdapterChangeGLRam(resource->resource.device, -resource->resource.size);
}
LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData)
LIST_FOR_EACH_SAFE(e1, e2, &resource->resource.privateData)
{
data = LIST_ENTRY(e1, struct private_data, entry);
hr = resource_free_private_data(iface, &data->tag);
if(hr != WINED3D_OK) {
ERR("Failed to free private data when destroying resource %p, hr = %08x\n", This, hr);
}
hr = resource_free_private_data((IWineD3DResource *)resource, &data->tag);
if (FAILED(hr))
ERR("Failed to free private data when destroying resource %p, hr = %#x.\n", resource, hr);
}
HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
This->resource.allocatedMemory = 0;
This->resource.heapMemory = 0;
HeapFree(GetProcessHeap(), 0, resource->resource.heapMemory);
resource->resource.allocatedMemory = 0;
resource->resource.heapMemory = 0;
if (This->resource.device) device_resource_released(This->resource.device, iface);
if (resource->resource.device)
device_resource_released(resource->resource.device, (IWineD3DResource *)resource);
}
void resource_unload(IWineD3DResourceImpl *resource)
......
......@@ -89,7 +89,7 @@ static void surface_cleanup(IWineD3DSurfaceImpl *This)
HeapFree(GetProcessHeap(), 0, This->palette9);
resource_cleanup((IWineD3DResource *)This);
resource_cleanup((IWineD3DResourceImpl *)This);
}
void surface_set_container(IWineD3DSurfaceImpl *surface, enum wined3d_container_type type, IWineD3DBase *container)
......
......@@ -54,7 +54,7 @@ void surface_gdi_cleanup(IWineD3DSurfaceImpl *This)
HeapFree(GetProcessHeap(), 0, This->palette9);
resource_cleanup((IWineD3DResource *)This);
resource_cleanup((IWineD3DResourceImpl *)This);
}
/*****************************************************************************
......
......@@ -133,7 +133,7 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
if (!ref)
{
resource_cleanup((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResourceImpl *)iface);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
......
......@@ -1828,7 +1828,7 @@ typedef struct IWineD3DResourceImpl
IWineD3DResourceClass resource;
} IWineD3DResourceImpl;
void resource_cleanup(IWineD3DResource *iface) DECLSPEC_HIDDEN;
void resource_cleanup(struct IWineD3DResourceImpl *resource) DECLSPEC_HIDDEN;
HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid) DECLSPEC_HIDDEN;
DWORD resource_get_priority(IWineD3DResource *iface) DECLSPEC_HIDDEN;
HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
......
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