Commit 1fc1fe3c authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Use standard wine lists for the resource list.

parent 7a97d4e2
......@@ -179,9 +179,9 @@ static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
/* NOTE: You must release the parent if the object was created via a callback
** ***************************/
if (This->resources != NULL ) {
if (!list_empty(&This->resources)) {
FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This);
dumpResources(This->resources);
dumpResources(&This->resources);
}
if(This->contexts) ERR("Context array not freed!\n");
......@@ -6622,18 +6622,18 @@ static BOOL WINAPI IWineD3DDeviceImpl_ShowCursor(IWineD3DDevice* iface, BOO
static HRESULT WINAPI IWineD3DDeviceImpl_TestCooperativeLevel(IWineD3DDevice* iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DResourceImpl *resource;
TRACE("(%p) : state (%u)\n", This, This->state);
/* TODO: Implement wrapping of the WndProc so that mimimize and maxamise can be monitored and the states adjusted. */
switch (This->state) {
case WINED3D_OK:
return WINED3D_OK;
case WINED3DERR_DEVICELOST:
{
ResourceList *resourceList = This->resources;
while (NULL != resourceList) {
if (((IWineD3DResourceImpl *)resourceList->resource)->resource.pool == WINED3DPOOL_DEFAULT /* TODO: IWineD3DResource_GetPool(resourceList->resource)*/)
return WINED3DERR_DEVICENOTRESET;
resourceList = resourceList->next;
LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry) {
if (resource->resource.pool == WINED3DPOOL_DEFAULT)
return WINED3DERR_DEVICENOTRESET;
}
return WINED3DERR_DEVICELOST;
}
......@@ -6876,51 +6876,17 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i
*****************************************************/
static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
ResourceList* resourceList;
TRACE("(%p) : resource %p\n", This, resource);
/* add a new texture to the frot of the linked list */
resourceList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ResourceList));
resourceList->resource = resource;
/* Get the old head */
resourceList->next = This->resources;
This->resources = resourceList;
TRACE("Added resource %p with element %p pointing to %p\n", resource, resourceList, resourceList->next);
return;
TRACE("(%p) : Adding Resource %p\n", This, resource);
list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
}
static void WINAPI IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
ResourceList* resourceList = NULL;
ResourceList* previousResourceList = NULL;
TRACE("(%p) : resource %p\n", This, resource);
resourceList = This->resources;
TRACE("(%p) : Removing resource %p\n", This, resource);
while (resourceList != NULL) {
if(resourceList->resource == resource) break;
previousResourceList = resourceList;
resourceList = resourceList->next;
}
if (resourceList == NULL) {
FIXME("Attempted to remove resource %p that hasn't been stored\n", resource);
return;
} else {
TRACE("Found resource %p with element %p pointing to %p (previous %p)\n", resourceList->resource, resourceList, resourceList->next, previousResourceList);
}
/* make sure we don't leave a hole in the list */
if (previousResourceList != NULL) {
previousResourceList->next = resourceList->next;
} else {
This->resources = resourceList->next;
}
return;
list_remove(&((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
}
......
......@@ -2695,6 +2695,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
object->adapter = numAdapters ? &Adapters[Adapter] : NULL;
IWineD3D_AddRef(object->wineD3D);
object->parent = parent;
list_init(&object->resources);
if(This->dxVersion == 7) {
object->surface_alignment = 8;
......
......@@ -107,7 +107,7 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW
static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt)
{
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
ResourceList *res;
IWineD3DResourceImpl *res;
TRACE("(%p)->(%08x,%d,%d,%p)\n",This,Flags,Start,Count,PalEnt);
......@@ -134,11 +134,11 @@ static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DW
/* If the palette is attached to the render target, update all render targets */
for(res = This->wineD3DDevice->resources; res != NULL; res=res->next) {
if(IWineD3DResource_GetType(res->resource) == WINED3DRTYPE_SURFACE) {
IWineD3DSurfaceImpl *impl = (IWineD3DSurfaceImpl *) res->resource;
LIST_FOR_EACH_ENTRY(res, &This->wineD3DDevice->resources, IWineD3DResourceImpl, resource.resource_list_entry) {
if(IWineD3DResource_GetType((IWineD3DResource *) res) == WINED3DRTYPE_SURFACE) {
IWineD3DSurfaceImpl *impl = (IWineD3DSurfaceImpl *) res;
if(impl->palette == This)
IWineD3DSurface_RealizePalette( (IWineD3DSurface *) res->resource);
IWineD3DSurface_RealizePalette((IWineD3DSurface *) res);
}
}
......
......@@ -248,12 +248,11 @@ HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown
return WINED3D_OK;
}
void dumpResources(ResourceList *resources) {
ResourceList *iterator = resources;
void dumpResources(struct list *list) {
IWineD3DResourceImpl *resource;
while(iterator) {
FIXME("Leftover resource %p with type %d,%s\n", iterator->resource, IWineD3DResource_GetType(iterator->resource), debug_d3dresourcetype(IWineD3DResource_GetType(iterator->resource)));
iterator = iterator->next;
LIST_FOR_EACH_ENTRY(resource, list, IWineD3DResourceImpl, resource.resource_list_entry) {
FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource)));
}
}
......
......@@ -625,13 +625,8 @@ extern BOOL pbuffer_support;
/* allocate one pbuffer per surface */
extern BOOL pbuffer_per_surface;
typedef struct ResourceList {
IWineD3DResource *resource;
struct ResourceList *next;
} ResourceList;
/* A helper function that dumps a resource list */
void dumpResources(ResourceList *resources);
void dumpResources(struct list *list);
/*****************************************************************************
* IWineD3DDevice implementation structure
......@@ -681,7 +676,7 @@ struct IWineD3DDeviceImpl
IWineD3DSwapChain **swapchains;
UINT NumberOfSwapChains;
ResourceList *resources; /* a linked list to track resources created by the device */
struct list resources; /* a linked list to track resources created by the device */
/* Render Target Support */
IWineD3DSurface **render_targets;
......@@ -821,6 +816,7 @@ typedef struct IWineD3DResourceClass
BYTE *allocatedMemory; /* Pointer to the real data location */
BYTE *heapMemory; /* Pointer to the HeapAlloced block of memory */
struct list privateData;
struct list resource_list_entry;
} IWineD3DResourceClass;
......
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