[PATCH 2/4] wined3d: Pass an IWineD3DResourceImpl pointer to resource_cleanup().
Henri Verbeet
hverbeet at codeweavers.com
Thu Jan 6 02:39:00 CST 2011
---
dlls/wined3d/basetexture.c | 4 ++--
dlls/wined3d/buffer.c | 6 +++---
dlls/wined3d/resource.c | 31 ++++++++++++++++---------------
dlls/wined3d/surface.c | 2 +-
dlls/wined3d/surface_gdi.c | 2 +-
dlls/wined3d/volume.c | 2 +-
dlls/wined3d/wined3d_private.h | 2 +-
7 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c
index d6678b7..6d0f951 100644
--- a/dlls/wined3d/basetexture.c
+++ b/dlls/wined3d/basetexture.c
@@ -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)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index bfed37c..b5aeee4 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -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;
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 0c8aa98..7b8066e 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -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)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a4f37cc..8eedb90 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -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)
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index b1c0b32..013ff2c 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -54,7 +54,7 @@ void surface_gdi_cleanup(IWineD3DSurfaceImpl *This)
HeapFree(GetProcessHeap(), 0, This->palette9);
- resource_cleanup((IWineD3DResource *)This);
+ resource_cleanup((IWineD3DResourceImpl *)This);
}
/*****************************************************************************
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 8ccc482..dbc2116 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -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);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9d4009c..41456f9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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,
--
1.7.2.2
More information about the wine-patches
mailing list