Module: wine Branch: master Commit: 8ec3238b5ee6e937da22c0069f86d7fc233b2839 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8ec3238b5ee6e937da22c0069f...
Author: Michael Stefaniuc mstefani@redhat.de Date: Mon Jan 31 01:40:25 2011 +0100
d3d8: COM cleanup for the IDirect3DSwapChain8 iface.
---
dlls/d3d8/d3d8_private.h | 8 ++++---- dlls/d3d8/device.c | 2 +- dlls/d3d8/swapchain.c | 33 +++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index d8f79f0..11ae25f 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -230,14 +230,14 @@ HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, struct IDirect3DSwapChain8Impl { /* IUnknown fields */ - const IDirect3DSwapChain8Vtbl *lpVtbl; - LONG ref; + IDirect3DSwapChain8 IDirect3DSwapChain8_iface; + LONG ref;
/* IDirect3DSwapChain8 fields */ - IWineD3DSwapChain *wineD3DSwapChain; + IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */ - LPDIRECT3DDEVICE8 parentDevice; + IDirect3DDevice8 *parentDevice; };
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl *device, diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 6f6622a..0cd56e5 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -547,7 +547,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(IDirect3DDe }
TRACE("Created swapchain %p.\n", object); - *swapchain = (IDirect3DSwapChain8 *)object; + *swapchain = &object->IDirect3DSwapChain8_iface;
return D3D_OK; } diff --git a/dlls/d3d8/swapchain.c b/dlls/d3d8/swapchain.c index 4875d3a..d6b7a28 100644 --- a/dlls/d3d8/swapchain.c +++ b/dlls/d3d8/swapchain.c @@ -23,10 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-/* IDirect3DSwapChain IUnknown parts follow: */ -static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface, REFIID riid, LPVOID* ppobj) +static inline IDirect3DSwapChain8Impl *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface) { - IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface; + return CONTAINING_RECORD(iface, IDirect3DSwapChain8Impl, IDirect3DSwapChain8_iface); +} + +static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(IDirect3DSwapChain8 *iface, + REFIID riid, void **ppobj) +{ + IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@@ -42,8 +47,9 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN return E_NOINTERFACE; }
-static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface) { - IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface; +static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(IDirect3DSwapChain8 *iface) +{ + IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref); @@ -51,8 +57,9 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface) { return ref; }
-static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface) { - IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface; +static ULONG WINAPI IDirect3DSwapChain8Impl_Release(IDirect3DSwapChain8 *iface) +{ + IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref); @@ -68,9 +75,11 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface) return ref; }
-/* IDirect3DSwapChain8 parts follow: */ -static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion) { - IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface; +static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(IDirect3DSwapChain8 *iface, + const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, + const RGNDATA *pDirtyRegion) +{ + IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface); HRESULT hr;
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n", @@ -86,7 +95,7 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8 *iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer) { - IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface; + IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface); IWineD3DSurface *mySurface = NULL; HRESULT hr;
@@ -123,7 +132,7 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl HRESULT hr;
swapchain->ref = 1; - swapchain->lpVtbl = &Direct3DSwapChain8_Vtbl; + swapchain->IDirect3DSwapChain8_iface.lpVtbl = &Direct3DSwapChain8_Vtbl;
wined3d_parameters.BackBufferWidth = present_parameters->BackBufferWidth; wined3d_parameters.BackBufferHeight = present_parameters->BackBufferHeight;