d3d9: COM cleanup for the IDirect3D9Ex iface.

This commit is contained in:
Michael Stefaniuc 2011-04-10 22:20:18 +02:00 committed by Alexandre Julliard
parent c52c15ef99
commit a159569115
3 changed files with 64 additions and 40 deletions

View File

@ -36,7 +36,7 @@ void WINAPI DebugSetMute(void) {
IDirect3D9* WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT SDKVersion) {
IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
object->lpVtbl = &Direct3D9_Vtbl;
object->IDirect3D9Ex_iface.lpVtbl = &Direct3D9_Vtbl;
object->ref = 1;
wined3d_mutex_lock();
@ -66,7 +66,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex
object = (IDirect3D9Impl *) ret;
object->extended = TRUE; /* Enables QI for extended interfaces */
*direct3d9ex = (IDirect3D9Ex *) object;
*direct3d9ex = &object->IDirect3D9Ex_iface;
return D3D_OK;
}

View File

@ -146,7 +146,7 @@ extern const IDirect3D9ExVtbl Direct3D9_Vtbl DECLSPEC_HIDDEN;
typedef struct IDirect3D9Impl
{
/* IUnknown fields */
const IDirect3D9ExVtbl *lpVtbl;
IDirect3D9Ex IDirect3D9Ex_iface;
LONG ref;
struct wined3d *WineD3D;

View File

@ -24,10 +24,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3D9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID riid, LPVOID* ppobj)
static inline IDirect3D9Impl *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return CONTAINING_RECORD(iface, IDirect3D9Impl, IDirect3D9Ex_iface);
}
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(IDirect3D9Ex *iface, REFIID riid, void **ppobj)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -55,8 +59,9 @@ static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static ULONG WINAPI IDirect3D9Impl_AddRef(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -64,8 +69,9 @@ static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
return ref;
}
static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static ULONG WINAPI IDirect3D9Impl_Release(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -82,8 +88,10 @@ static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
}
/* IDirect3D9 Interface follow: */
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX iface, void* pInitializeFunction) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(IDirect3D9Ex *iface,
void *pInitializeFunction)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
@ -95,8 +103,9 @@ static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX ifac
return hr;
}
static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static UINT WINAPI IDirect3D9Impl_GetAdapterCount(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
@ -108,8 +117,10 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT Adapter,
DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
@ -138,8 +149,10 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, U
return hr;
}
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(IDirect3D9Ex *iface, UINT Adapter,
D3DFORMAT Format)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, format %#x.\n", iface, Adapter, Format);
@ -156,8 +169,10 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(IDirect3D9Ex *iface, UINT Adapter,
D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
@ -178,8 +193,10 @@ static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(IDirect3D9Ex *iface, UINT Adapter,
D3DDISPLAYMODE *pMode)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, mode %p.\n", iface, Adapter, pMode);
@ -196,7 +213,7 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface,
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
@ -210,10 +227,11 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT A
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType,
D3DFORMAT CheckFormat)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
WINED3DRESOURCETYPE WineD3DRType;
@ -252,10 +270,10 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType,
DWORD *pQualityLevels)
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed,
D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
@ -270,9 +288,10 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *if
}
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat,
D3DFORMAT DepthStencilFormat)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
@ -287,8 +306,10 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface,
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
@ -362,8 +383,10 @@ void filter_caps(D3DCAPS9* pCaps)
pCaps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS, pCaps->NumSimultaneousRTs);
}
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
@ -394,8 +417,9 @@ static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Ada
return hrc;
}
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UINT Adapter) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(IDirect3D9Ex *iface, UINT Adapter)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HMONITOR ret;
TRACE("iface %p, adapter %u.\n", iface, Adapter);
@ -411,7 +435,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
IDirect3DDevice9 **device)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
IDirect3DDevice9Impl *object;
HRESULT hr;
@ -469,7 +493,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3
UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
{
IDirect3D9Impl *d3d9 = (IDirect3D9Impl *)iface;
IDirect3D9Impl *d3d9 = impl_from_IDirect3D9Ex(iface);
IDirect3DDevice9Impl *object;
HRESULT hr;
@ -499,7 +523,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3
static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;