Module: wine Branch: master Commit: bc6786d0e540d162ad1cc5eb6b4d1ab8b65569f7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=bc6786d0e540d162ad1cc5eb6b...
Author: Michael Stefaniuc mstefani@redhat.de Date: Mon Mar 14 23:29:09 2011 +0100
d3d8: COM cleanup in shader.c.
---
dlls/d3d8/d3d8_private.h | 6 +++--- dlls/d3d8/device.c | 4 ++-- dlls/d3d8/shader.c | 22 ++++++++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 59b851a..b577ea5 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -484,8 +484,8 @@ DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown) */
struct IDirect3DVertexShader8Impl { - const IDirect3DVertexShader8Vtbl *lpVtbl; - LONG ref; + IDirect3DVertexShader8 IDirect3DVertexShader8_iface; + LONG ref;
IDirect3DVertexDeclaration8 *vertex_declaration; IWineD3DVertexShader *wineD3DVertexShader; @@ -500,7 +500,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im * IDirect3DPixelShader implementation structure */ typedef struct IDirect3DPixelShader8Impl { - const IDirect3DPixelShader8Vtbl *lpVtbl; + IDirect3DPixelShader8 IDirect3DPixelShader8_iface; LONG ref;
DWORD handle; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 9383173..bfc3f74 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2146,7 +2146,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8
wined3d_mutex_unlock();
- if (IUnknown_Release((IUnknown *)shader)) + if (IDirect3DVertexShader8_Release(&shader->IDirect3DVertexShader8_iface)) { ERR("Shader %p has references left, this shouldn't happen.\n", shader); } @@ -2471,7 +2471,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
wined3d_mutex_unlock();
- if (IUnknown_Release((IUnknown *)shader)) + if (IDirect3DPixelShader8_Release(&shader->IDirect3DPixelShader8_iface)) { ERR("Shader %p has references left, this shouldn't happen.\n", shader); } diff --git a/dlls/d3d8/shader.c b/dlls/d3d8/shader.c index a59f10b..c0a9a35 100644 --- a/dlls/d3d8/shader.c +++ b/dlls/d3d8/shader.c @@ -22,6 +22,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+static inline IDirect3DVertexShader8Impl *impl_from_IDirect3DVertexShader8(IDirect3DVertexShader8 *iface) +{ + return CONTAINING_RECORD(iface, IDirect3DVertexShader8Impl, IDirect3DVertexShader8_iface); +} + static HRESULT WINAPI d3d8_vertexshader_QueryInterface(IDirect3DVertexShader8 *iface, REFIID riid, void **object) { TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); @@ -42,7 +47,7 @@ static HRESULT WINAPI d3d8_vertexshader_QueryInterface(IDirect3DVertexShader8 *i
static ULONG WINAPI d3d8_vertexshader_AddRef(IDirect3DVertexShader8 *iface) { - IDirect3DVertexShader8Impl *shader = (IDirect3DVertexShader8Impl *)iface; + IDirect3DVertexShader8Impl *shader = impl_from_IDirect3DVertexShader8(iface); ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount); @@ -66,7 +71,7 @@ static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *p
static ULONG WINAPI d3d8_vertexshader_Release(IDirect3DVertexShader8 *iface) { - IDirect3DVertexShader8Impl *shader = (IDirect3DVertexShader8Impl *)iface; + IDirect3DVertexShader8Impl *shader = impl_from_IDirect3DVertexShader8(iface); ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); @@ -157,7 +162,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im }
shader->ref = 1; - shader->lpVtbl = &d3d8_vertexshader_vtbl; + shader->IDirect3DVertexShader8_iface.lpVtbl = &d3d8_vertexshader_vtbl;
hr = d3d8_vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration); if (FAILED(hr)) @@ -187,6 +192,11 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im return D3D_OK; }
+static inline IDirect3DPixelShader8Impl *impl_from_IDirect3DPixelShader8(IDirect3DPixelShader8 *iface) +{ + return CONTAINING_RECORD(iface, IDirect3DPixelShader8Impl, IDirect3DPixelShader8_iface); +} + static HRESULT WINAPI d3d8_pixelshader_QueryInterface(IDirect3DPixelShader8 *iface, REFIID riid, void **object) { TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); @@ -207,7 +217,7 @@ static HRESULT WINAPI d3d8_pixelshader_QueryInterface(IDirect3DPixelShader8 *ifa
static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface) { - IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)iface; + IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface); ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount); @@ -224,7 +234,7 @@ static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface) { - IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)iface; + IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface); ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); @@ -263,7 +273,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl HRESULT hr;
shader->ref = 1; - shader->lpVtbl = &d3d8_pixelshader_vtbl; + shader->IDirect3DPixelShader8_iface.lpVtbl = &d3d8_pixelshader_vtbl; shader->handle = shader_handle;
wined3d_mutex_lock();