wined3d: Move "parent_ops" to IWineD3DResourceClass.

This commit is contained in:
Henri Verbeet 2009-09-17 23:03:33 +02:00 committed by Alexandre Julliard
parent 93b0600829
commit dbc4dfc495
9 changed files with 25 additions and 37 deletions

View File

@ -5,6 +5,7 @@
* Copyright 2002-2004 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -29,11 +30,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
WINED3DPOOL pool, IUnknown *parent)
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
{
HRESULT hr;
hr = resource_init((IWineD3DResource *)texture, resource_type, device, size, usage, format_desc, pool, parent);
hr = resource_init((IWineD3DResource *)texture, resource_type, device,
size, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, returning %#x\n", hr);

View File

@ -635,7 +635,7 @@ static ULONG STDMETHODCALLTYPE buffer_Release(IWineD3DBuffer *iface)
{
buffer_UnLoad(iface);
resource_cleanup((IWineD3DResource *)iface);
This->parent_ops->wined3d_object_destroyed(This->resource.parent);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
@ -1076,13 +1076,12 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
buffer->vtbl = &wined3d_buffer_vtbl;
hr = resource_init((IWineD3DResource *)buffer, WINED3DRTYPE_BUFFER,
device, size, usage, format_desc, pool, parent);
device, size, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, hr %#x\n", hr);
return hr;
}
buffer->parent_ops = parent_ops;
buffer->buffer_type_hint = bind_hint;
TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage,

View File

@ -177,7 +177,7 @@ static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface)
if (!ref)
{
cubetexture_cleanup(This);
This->parent_ops->wined3d_object_destroyed(This->resource.parent);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@ -486,16 +486,14 @@ HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UIN
texture->lpVtbl = &IWineD3DCubeTexture_Vtbl;
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
WINED3DRTYPE_CUBETEXTURE, device, 0, usage, format_desc, pool, parent);
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_CUBETEXTURE,
device, 0, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x\n", hr);
return hr;
}
texture->parent_ops = parent_ops;
/* Find the nearest pow2 match. */
pow2_edge_length = 1;
while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;

View File

@ -5,6 +5,7 @@
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -28,7 +29,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
WINED3DPOOL pool, IUnknown *parent)
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
{
struct IWineD3DResourceClass *resource = &((IWineD3DResourceImpl *)iface)->resource;
@ -41,6 +42,7 @@ HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type
resource->usage = usage;
resource->size = size;
resource->priority = 0;
resource->parent_ops = parent_ops;
list_init(&resource->privateData);
if (size)

View File

@ -160,15 +160,13 @@ HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type,
}
hr = resource_init((IWineD3DResource *)surface, WINED3DRTYPE_SURFACE,
device, resource_size, usage, format_desc, pool, parent);
device, resource_size, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
return hr;
}
surface->parent_ops = parent_ops;
/* "Standalone" surface. */
IWineD3DSurface_SetContainer((IWineD3DSurface *)surface, NULL);
@ -730,7 +728,7 @@ static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
if (!ref)
{
surface_cleanup(This);
This->parent_ops->wined3d_object_destroyed(This->resource.parent);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
TRACE("(%p) Released.\n", This);
HeapFree(GetProcessHeap(), 0, This);

View File

@ -164,7 +164,7 @@ static ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
if (!ref)
{
texture_cleanup(This);
This->parent_ops->wined3d_object_destroyed(This->resource.parent);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@ -501,16 +501,14 @@ HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT
texture->lpVtbl = &IWineD3DTexture_Vtbl;
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
WINED3DRTYPE_TEXTURE, device, 0, usage, format_desc, pool, parent);
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_TEXTURE,
device, 0, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
return hr;
}
texture->parent_ops = parent_ops;
/* Precalculated scaling for 'faked' non power of two texture coords.
* Second also don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
* is used in combination with texture uploads (RTL_READTEX). The reason is that EXT_PALETTED_TEXTURE

View File

@ -123,7 +123,7 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
resource_cleanup((IWineD3DResource *)iface);
This->parent_ops->wined3d_object_destroyed(This->resource.parent);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@ -392,14 +392,13 @@ HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT
volume->lpVtbl = &IWineD3DVolume_Vtbl;
hr = resource_init((IWineD3DResource *)volume, WINED3DRTYPE_VOLUME, device,
width * height * depth * format_desc->byte_count, usage, format_desc, pool, parent);
width * height * depth * format_desc->byte_count, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
return hr;
}
volume->parent_ops = parent_ops;
volume->currentDesc.Width = width;
volume->currentDesc.Height = height;
volume->currentDesc.Depth = depth;

View File

@ -136,7 +136,7 @@ static ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *ifa
if (!ref)
{
volumetexture_cleanup(This);
This->parent_ops->wined3d_object_destroyed(This->resource.parent);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@ -406,16 +406,14 @@ HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT
texture->lpVtbl = &IWineD3DVolumeTexture_Vtbl;
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
WINED3DRTYPE_VOLUMETEXTURE, device, 0, usage, format_desc, pool, parent);
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_VOLUMETEXTURE,
device, 0, usage, format_desc, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
return hr;
}
texture->parent_ops = parent_ops;
/* Is NP2 support for volumes needed? */
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;

View File

@ -1699,7 +1699,7 @@ typedef struct IWineD3DResourceClass
BYTE *heapMemory; /* Pointer to the HeapAlloced block of memory */
struct list privateData;
struct list resource_list_entry;
const struct wined3d_parent_ops *parent_ops;
} IWineD3DResourceClass;
typedef struct IWineD3DResourceImpl
@ -1718,7 +1718,7 @@ HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
void *data, DWORD *data_size) DECLSPEC_HIDDEN;
HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
WINED3DPOOL pool, IUnknown *parent) DECLSPEC_HIDDEN;
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface) DECLSPEC_HIDDEN;
DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority) DECLSPEC_HIDDEN;
HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
@ -1801,7 +1801,7 @@ DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
WINED3DPOOL pool, IUnknown *parent) DECLSPEC_HIDDEN;
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty) DECLSPEC_HIDDEN;
@ -1819,7 +1819,6 @@ typedef struct IWineD3DTextureImpl
IWineD3DBaseTextureClass baseTexture;
/* IWineD3DTexture */
const struct wined3d_parent_ops *parent_ops;
IWineD3DSurface *surfaces[MAX_MIP_LEVELS];
UINT target;
BOOL cond_np2;
@ -1841,7 +1840,6 @@ typedef struct IWineD3DCubeTextureImpl
IWineD3DBaseTextureClass baseTexture;
/* IWineD3DCubeTexture */
const struct wined3d_parent_ops *parent_ops;
IWineD3DSurface *surfaces[6][MAX_MIP_LEVELS];
} IWineD3DCubeTextureImpl;
@ -1866,7 +1864,6 @@ typedef struct IWineD3DVolumeImpl
IWineD3DResourceClass resource;
/* WineD3DVolume Information */
const struct wined3d_parent_ops *parent_ops;
WINED3DVOLUMET_DESC currentDesc;
IWineD3DBase *container;
BOOL lockable;
@ -1892,7 +1889,6 @@ typedef struct IWineD3DVolumeTextureImpl
IWineD3DBaseTextureClass baseTexture;
/* IWineD3DVolumeTexture */
const struct wined3d_parent_ops *parent_ops;
IWineD3DVolume *volumes[MAX_MIP_LEVELS];
} IWineD3DVolumeTextureImpl;
@ -1958,7 +1954,6 @@ struct IWineD3DSurfaceImpl
IWineD3DResourceClass resource;
/* IWineD3DSurface fields */
const struct wined3d_parent_ops *parent_ops;
IWineD3DBase *container;
WINED3DSURFACET_DESC currentDesc;
IWineD3DPaletteImpl *palette; /* D3D7 style palette handling */
@ -2416,7 +2411,6 @@ struct wined3d_buffer
const struct IWineD3DBufferVtbl *vtbl;
IWineD3DResourceClass resource;
const struct wined3d_parent_ops *parent_ops;
struct wined3d_buffer_desc desc;
GLuint buffer_object;