Commit d32df839 authored by Ričardas Barkauskas's avatar Ričardas Barkauskas Committed by Alexandre Julliard

ddraw: COM cleanup for IDirect3DDevice2 interface.

parent 1c045cbb
...@@ -4359,15 +4359,20 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid, ...@@ -4359,15 +4359,20 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid,
{ {
IDirectDrawImpl *This = impl_from_IDirect3D2(iface); IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
IDirectDrawSurfaceImpl *surface_impl = unsafe_impl_from_IDirectDrawSurface(surface); IDirectDrawSurfaceImpl *surface_impl = unsafe_impl_from_IDirectDrawSurface(surface);
IDirect3DDevice7 *device7;
IDirect3DDeviceImpl *device_impl;
HRESULT hr; HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p.\n", TRACE("iface %p, riid %s, surface %p, device %p.\n",
iface, debugstr_guid(riid), surface, device); iface, debugstr_guid(riid), surface, device);
hr = d3d7_CreateDevice(&This->IDirect3D7_iface, riid, hr = d3d7_CreateDevice(&This->IDirect3D7_iface, riid,
surface_impl ? &surface_impl->IDirectDrawSurface7_iface : NULL, surface_impl ? &surface_impl->IDirectDrawSurface7_iface : NULL, device ? &device7 : NULL);
(IDirect3DDevice7 **)device); if (SUCCEEDED(hr))
if (*device) *device = (IDirect3DDevice2 *)&((IDirect3DDeviceImpl *)*device)->IDirect3DDevice2_vtbl; {
device_impl = (IDirect3DDeviceImpl *)device7;
*device = &device_impl->IDirect3DDevice2_iface;
}
return hr; return hr;
} }
......
...@@ -279,7 +279,7 @@ struct IDirect3DDeviceImpl ...@@ -279,7 +279,7 @@ struct IDirect3DDeviceImpl
/* IUnknown */ /* IUnknown */
const IDirect3DDevice7Vtbl *lpVtbl; const IDirect3DDevice7Vtbl *lpVtbl;
const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl; const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl;
const IDirect3DDevice2Vtbl *IDirect3DDevice2_vtbl; IDirect3DDevice2 IDirect3DDevice2_iface;
IDirect3DDevice IDirect3DDevice_iface; IDirect3DDevice IDirect3DDevice_iface;
LONG ref; LONG ref;
...@@ -332,7 +332,7 @@ static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice(IDirect3DDevice *if ...@@ -332,7 +332,7 @@ static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice(IDirect3DDevice *if
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice2_vtbl); return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice2_iface);
} }
static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface) static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
......
...@@ -167,7 +167,7 @@ IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7 *iface, ...@@ -167,7 +167,7 @@ IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7 *iface,
TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj); TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
} }
else if ( IsEqualGUID( &IID_IDirect3DDevice2 , refiid ) ) { else if ( IsEqualGUID( &IID_IDirect3DDevice2 , refiid ) ) {
*obj = &This->IDirect3DDevice2_vtbl; *obj = &This->IDirect3DDevice2_iface;
TRACE("(%p) Returning IDirect3DDevice2 interface at %p\n", This, *obj); TRACE("(%p) Returning IDirect3DDevice2 interface at %p\n", This, *obj);
} }
else if ( IsEqualGUID( &IID_IDirect3DDevice3 , refiid ) ) { else if ( IsEqualGUID( &IID_IDirect3DDevice3 , refiid ) ) {
...@@ -581,7 +581,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice * ...@@ -581,7 +581,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice *
TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, D3DTex1, D3DTex2); TRACE("iface %p, tex1 %p, tex2 %p.\n", iface, D3DTex1, D3DTex2);
return IDirect3DDevice2_SwapTextureHandles((IDirect3DDevice2 *)&This->IDirect3DDevice2_vtbl, t1, t2); return IDirect3DDevice2_SwapTextureHandles(&This->IDirect3DDevice2_iface, t1, t2);
} }
/***************************************************************************** /*****************************************************************************
...@@ -1274,7 +1274,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice * ...@@ -1274,7 +1274,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice *
TRACE("iface %p, callback %p, context %p.\n", iface, Callback, Arg); TRACE("iface %p, callback %p, context %p.\n", iface, Callback, Arg);
return IDirect3DDevice2_EnumTextureFormats((IDirect3DDevice2 *)&This->IDirect3DDevice2_vtbl, Callback, Arg); return IDirect3DDevice2_EnumTextureFormats(&This->IDirect3DDevice2_iface, Callback, Arg);
} }
/***************************************************************************** /*****************************************************************************
...@@ -6750,7 +6750,7 @@ IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) ...@@ -6750,7 +6750,7 @@ IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
{ {
if (!iface) return NULL; if (!iface) return NULL;
assert(iface->lpVtbl == &d3d_device2_vtbl); assert(iface->lpVtbl == &d3d_device2_vtbl);
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice2_vtbl); return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice2_iface);
} }
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface)
...@@ -6803,7 +6803,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi ...@@ -6803,7 +6803,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
device->lpVtbl = &d3d_device7_fpu_setup_vtbl; device->lpVtbl = &d3d_device7_fpu_setup_vtbl;
device->IDirect3DDevice3_vtbl = &d3d_device3_vtbl; device->IDirect3DDevice3_vtbl = &d3d_device3_vtbl;
device->IDirect3DDevice2_vtbl = &d3d_device2_vtbl; device->IDirect3DDevice2_iface.lpVtbl = &d3d_device2_vtbl;
device->IDirect3DDevice_iface.lpVtbl = &d3d_device1_vtbl; device->IDirect3DDevice_iface.lpVtbl = &d3d_device1_vtbl;
device->ref = 1; device->ref = 1;
device->ddraw = ddraw; device->ddraw = ddraw;
......
...@@ -292,7 +292,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This, ...@@ -292,7 +292,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
case D3DOP_STATERENDER: { case D3DOP_STATERENDER: {
int i; int i;
IDirect3DDevice2 *d3d_device2 = (IDirect3DDevice2 *)&lpDevice->IDirect3DDevice2_vtbl; IDirect3DDevice2 *d3d_device2 = &lpDevice->IDirect3DDevice2_iface;
TRACE("STATERENDER (%d)\n", count); TRACE("STATERENDER (%d)\n", count);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
......
...@@ -4557,7 +4557,7 @@ static HRESULT WINAPI d3d_texture1_GetHandle(IDirect3DTexture *iface, ...@@ -4557,7 +4557,7 @@ static HRESULT WINAPI d3d_texture1_GetHandle(IDirect3DTexture *iface,
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle); TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
return d3d_texture2_GetHandle(&This->IDirect3DTexture2_iface, return d3d_texture2_GetHandle(&This->IDirect3DTexture2_iface,
device_impl ? (IDirect3DDevice2 *)&device_impl->IDirect3DDevice2_vtbl : NULL, handle); device_impl ? &device_impl->IDirect3DDevice2_iface : NULL, handle);
} }
/***************************************************************************** /*****************************************************************************
......
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