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

ddraw: COM cleanup for IDirect3DDevice3 interface.

parent bd530d3a
...@@ -4339,6 +4339,8 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid, ...@@ -4339,6 +4339,8 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
{ {
IDirectDrawImpl *This = impl_from_IDirect3D3(iface); IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
IDirectDrawSurfaceImpl *surface_impl = unsafe_impl_from_IDirectDrawSurface4(surface); IDirectDrawSurfaceImpl *surface_impl = unsafe_impl_from_IDirectDrawSurface4(surface);
IDirect3DDevice7 *device7;
IDirect3DDeviceImpl *device_impl;
HRESULT hr; HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p, outer_unknown %p.\n", TRACE("iface %p, riid %s, surface %p, device %p, outer_unknown %p.\n",
...@@ -4347,9 +4349,12 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid, ...@@ -4347,9 +4349,12 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
if (outer_unknown) return CLASS_E_NOAGGREGATION; if (outer_unknown) return CLASS_E_NOAGGREGATION;
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 = (IDirect3DDevice3 *)&((IDirect3DDeviceImpl *)*device)->IDirect3DDevice3_vtbl; {
device_impl = (IDirect3DDeviceImpl *)device7;
*device = &device_impl->IDirect3DDevice3_iface;
}
return hr; return hr;
} }
......
...@@ -278,7 +278,7 @@ struct IDirect3DDeviceImpl ...@@ -278,7 +278,7 @@ struct IDirect3DDeviceImpl
{ {
/* IUnknown */ /* IUnknown */
const IDirect3DDevice7Vtbl *lpVtbl; const IDirect3DDevice7Vtbl *lpVtbl;
const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl; IDirect3DDevice3 IDirect3DDevice3_iface;
IDirect3DDevice2 IDirect3DDevice2_iface; IDirect3DDevice2 IDirect3DDevice2_iface;
IDirect3DDevice IDirect3DDevice_iface; IDirect3DDevice IDirect3DDevice_iface;
LONG ref; LONG ref;
...@@ -337,7 +337,7 @@ static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice2(IDirect3DDevice2 * ...@@ -337,7 +337,7 @@ static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice2(IDirect3DDevice2 *
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice3_vtbl); return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice3_iface);
} }
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN; IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
......
...@@ -332,7 +332,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_2_GetHandle(IDirect3DMaterial2 *ifac ...@@ -332,7 +332,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_2_GetHandle(IDirect3DMaterial2 *ifac
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle); TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
return IDirect3DMaterial3_GetHandle(&This->IDirect3DMaterial3_iface, device_impl ? return IDirect3DMaterial3_GetHandle(&This->IDirect3DMaterial3_iface, device_impl ?
(IDirect3DDevice3 *)&device_impl->IDirect3DDevice3_vtbl : NULL, handle); &device_impl->IDirect3DDevice3_iface : NULL, handle);
} }
static HRESULT WINAPI IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial *iface, static HRESULT WINAPI IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial *iface,
...@@ -344,7 +344,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial *iface ...@@ -344,7 +344,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial *iface
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle); TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
return IDirect3DMaterial3_GetHandle(&This->IDirect3DMaterial3_iface, device_impl ? return IDirect3DMaterial3_GetHandle(&This->IDirect3DMaterial3_iface, device_impl ?
(IDirect3DDevice3 *)&device_impl->IDirect3DDevice3_vtbl : NULL, handle); &device_impl->IDirect3DDevice3_iface : NULL, handle);
} }
static HRESULT WINAPI IDirect3DMaterialImpl_2_QueryInterface(IDirect3DMaterial2 *iface, REFIID riid, static HRESULT WINAPI IDirect3DMaterialImpl_2_QueryInterface(IDirect3DMaterial2 *iface, REFIID riid,
......
...@@ -316,7 +316,7 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface, ...@@ -316,7 +316,7 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
This->viewports.vp1.dvMaxZ = 1.0; This->viewports.vp1.dvMaxZ = 1.0;
if (This->active_device) { if (This->active_device) {
IDirect3DDevice3 *d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if (current_viewport) if (current_viewport)
{ {
...@@ -672,7 +672,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, ...@@ -672,7 +672,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
ERR(" Trying to clear a viewport not attached to a device !\n"); ERR(" Trying to clear a viewport not attached to a device !\n");
return D3DERR_VIEWPORTHASNODEVICE; return D3DERR_VIEWPORTHASNODEVICE;
} }
d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
if (dwFlags & D3DCLEAR_TARGET) { if (dwFlags & D3DCLEAR_TARGET) {
...@@ -970,7 +970,7 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface, ...@@ -970,7 +970,7 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
memcpy(&(This->viewports.vp2), lpData, lpData->dwSize); memcpy(&(This->viewports.vp2), lpData, lpData->dwSize);
if (This->active_device) { if (This->active_device) {
IDirect3DDevice3 *d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; IDirect3DDevice3 *d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if (current_viewport) if (current_viewport)
{ {
...@@ -1070,7 +1070,7 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface, ...@@ -1070,7 +1070,7 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return D3DERR_VIEWPORTHASNODEVICE; return D3DERR_VIEWPORTHASNODEVICE;
} }
d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
/* Need to temporarily activate viewport to clear it. Previously active /* Need to temporarily activate viewport to clear it. Previously active
* one will be restored afterwards. */ * one will be restored afterwards. */
viewport_activate(This, TRUE); viewport_activate(This, TRUE);
......
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