ddraw: Get rid of IDirect3DDeviceImpl.

This commit is contained in:
Henri Verbeet 2012-04-09 20:43:40 +02:00 committed by Alexandre Julliard
parent 96fa113513
commit daedd0077d
9 changed files with 1463 additions and 1873 deletions

View File

@ -4431,7 +4431,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
{
struct ddraw_surface *target = unsafe_impl_from_IDirectDrawSurface7(surface);
struct ddraw *ddraw = impl_from_IDirect3D7(iface);
IDirect3DDeviceImpl *object;
struct d3d_device *object;
HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p.\n", iface, debugstr_guid(riid), surface, device);
@ -4455,7 +4455,7 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
{
struct ddraw_surface *surface_impl = unsafe_impl_from_IDirectDrawSurface4(surface);
struct ddraw *ddraw = impl_from_IDirect3D3(iface);
IDirect3DDeviceImpl *device_impl;
struct d3d_device *device_impl;
HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p, outer_unknown %p.\n",
@ -4483,7 +4483,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid,
{
struct ddraw_surface *surface_impl = unsafe_impl_from_IDirectDrawSurface(surface);
struct ddraw *ddraw = impl_from_IDirect3D2(iface);
IDirect3DDeviceImpl *device_impl;
struct d3d_device *device_impl;
HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p.\n",

View File

@ -40,7 +40,6 @@
extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
/* Typdef the interfaces */
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
@ -90,7 +89,7 @@ struct ddraw
/* D3D things */
HWND d3d_window;
IDirect3DDeviceImpl *d3ddevice;
struct d3d_device *d3ddevice;
int d3dversion;
/* Various HWNDs */
@ -159,7 +158,7 @@ struct ddraw_surface
struct ddraw *ddraw;
struct wined3d_surface *wined3d_surface;
struct wined3d_texture *wined3d_texture;
IDirect3DDeviceImpl *device1;
struct d3d_device *device1;
/* This implementation handles attaching surfaces to other surfaces */
struct ddraw_surface *next_attached;
@ -272,7 +271,7 @@ DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddr
void *ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
struct IDirect3DDeviceImpl
struct d3d_device
{
/* IUnknown */
IDirect3DDevice7 IDirect3DDevice7_iface;
@ -318,7 +317,8 @@ struct IDirect3DDeviceImpl
};
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target,
UINT version, IDirect3DDeviceImpl **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN;
UINT version, struct d3d_device **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN;
enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device *device) DECLSPEC_HIDDEN;
/* The IID */
extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
@ -326,32 +326,31 @@ extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
/* Helper functions */
HRESULT IDirect3DImpl_GetCaps(const struct wined3d *wined3d,
D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
enum wined3d_depth_buffer_type IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *device) DECLSPEC_HIDDEN;
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice(IDirect3DDevice *iface)
static inline struct d3d_device *impl_from_IDirect3DDevice(IDirect3DDevice *iface)
{
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice_iface);
return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice_iface);
}
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
static inline struct d3d_device *impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice2_iface);
return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice2_iface);
}
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
static inline struct d3d_device *impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice3_iface);
return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice3_iface);
}
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
static inline struct d3d_device *impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice7_iface);
return CONTAINING_RECORD(iface, struct d3d_device, IDirect3DDevice7_iface);
}
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) DECLSPEC_HIDDEN;
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN;
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN;
struct d3d_device *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
struct d3d_device *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) DECLSPEC_HIDDEN;
struct d3d_device *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN;
struct d3d_device *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN;
struct ddraw_clipper
{
@ -438,7 +437,7 @@ struct d3d_material
/* IDirect3DMaterial2 fields */
struct ddraw *ddraw;
IDirect3DDeviceImpl *active_device;
struct d3d_device *active_device;
D3DMATERIAL mat;
DWORD Handle;
@ -460,7 +459,7 @@ struct d3d_viewport
struct ddraw *ddraw;
/* If this viewport is active for one device, put the device here */
IDirect3DDeviceImpl *active_device;
struct d3d_device *active_device;
DWORD num_lights;
DWORD map_lights;
@ -495,7 +494,7 @@ struct IDirect3DExecuteBufferImpl
LONG ref;
/* IDirect3DExecuteBuffer fields */
struct ddraw *ddraw;
IDirect3DDeviceImpl *d3ddev;
struct d3d_device *d3ddev;
D3DEXECUTEBUFFERDESC desc;
D3DEXECUTEDATA data;
@ -512,12 +511,12 @@ struct IDirect3DExecuteBufferImpl
};
HRESULT d3d_execute_buffer_init(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, D3DEXECUTEBUFFERDESC *desc) DECLSPEC_HIDDEN;
struct d3d_device *device, D3DEXECUTEBUFFERDESC *desc) DECLSPEC_HIDDEN;
IDirect3DExecuteBufferImpl *unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer *iface) DECLSPEC_HIDDEN;
/* The execute function */
HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, struct d3d_viewport *viewport) DECLSPEC_HIDDEN;
struct d3d_device *device, struct d3d_viewport *viewport) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3DVertexBuffer

File diff suppressed because it is too large Load Diff

View File

@ -69,7 +69,7 @@ static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC *lpDesc) {
*
*****************************************************************************/
HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice, struct d3d_viewport *viewport)
struct d3d_device *device, struct d3d_viewport *viewport)
{
/* DWORD bs = This->desc.dwBufferSize; */
DWORD vs = This->data.dwVertexOffset;
@ -79,7 +79,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
char *instr = (char *)This->desc.lpData + is;
if (viewport->active_device != lpDevice)
if (viewport->active_device != device)
{
WARN("Viewport %p active device is %p.\n",
viewport, viewport->active_device);
@ -156,8 +156,8 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
/* IDirect3DDevices have color keying always enabled -
* enable it before drawing. This overwrites any ALPHA*
* render state. */
wined3d_device_set_render_state(lpDevice->wined3d_device, WINED3D_RS_COLORKEYENABLE, 1);
IDirect3DDevice7_DrawIndexedPrimitive(&lpDevice->IDirect3DDevice7_iface,
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_COLORKEYENABLE, 1);
IDirect3DDevice7_DrawIndexedPrimitive(&device->IDirect3DDevice7_iface,
D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, tl_vx, 0, This->indices, count * 3, 0);
} break;
@ -175,9 +175,9 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
D3DMATRIXMULTIPLY *ci = (D3DMATRIXMULTIPLY *)instr;
D3DMATRIX *a, *b, *c;
a = ddraw_get_object(&lpDevice->handle_table, ci->hDestMatrix - 1, DDRAW_HANDLE_MATRIX);
b = ddraw_get_object(&lpDevice->handle_table, ci->hSrcMatrix1 - 1, DDRAW_HANDLE_MATRIX);
c = ddraw_get_object(&lpDevice->handle_table, ci->hSrcMatrix2 - 1, DDRAW_HANDLE_MATRIX);
a = ddraw_get_object(&device->handle_table, ci->hDestMatrix - 1, DDRAW_HANDLE_MATRIX);
b = ddraw_get_object(&device->handle_table, ci->hSrcMatrix1 - 1, DDRAW_HANDLE_MATRIX);
c = ddraw_get_object(&device->handle_table, ci->hSrcMatrix2 - 1, DDRAW_HANDLE_MATRIX);
if (!a || !b || !c)
{
@ -203,7 +203,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
D3DSTATE *ci = (D3DSTATE *)instr;
D3DMATRIX *m;
m = ddraw_get_object(&lpDevice->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATRIX);
m = ddraw_get_object(&device->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATRIX);
if (!m)
{
ERR("Invalid matrix handle %#x.\n", ci->u2.dwArg[0]);
@ -211,12 +211,12 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
else
{
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_WORLD)
lpDevice->world = ci->u2.dwArg[0];
device->world = ci->u2.dwArg[0];
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_VIEW)
lpDevice->view = ci->u2.dwArg[0];
device->view = ci->u2.dwArg[0];
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_PROJECTION)
lpDevice->proj = ci->u2.dwArg[0];
IDirect3DDevice7_SetTransform(&lpDevice->IDirect3DDevice7_iface,
device->proj = ci->u2.dwArg[0];
IDirect3DDevice7_SetTransform(&device->IDirect3DDevice7_iface,
ci->u1.dtstTransformStateType, m);
}
@ -239,7 +239,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
{
struct d3d_material *m;
m = ddraw_get_object(&lpDevice->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATERIAL);
m = ddraw_get_object(&device->handle_table, ci->u2.dwArg[0] - 1, DDRAW_HANDLE_MATERIAL);
if (!m)
ERR("Invalid material handle %#x.\n", ci->u2.dwArg[0]);
else
@ -283,7 +283,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
break;
}
IDirect3DDevice7_SetRenderState(&lpDevice->IDirect3DDevice7_iface, rs, ci->u2.dwArg[0]);
IDirect3DDevice7_SetRenderState(&device->IDirect3DDevice7_iface, rs, ci->u2.dwArg[0]);
}
instr += size;
@ -292,7 +292,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
case D3DOP_STATERENDER: {
int i;
IDirect3DDevice2 *d3d_device2 = &lpDevice->IDirect3DDevice2_iface;
IDirect3DDevice2 *d3d_device2 = &device->IDirect3DDevice2_iface;
TRACE("STATERENDER (%d)\n", count);
for (i = 0; i < count; i++) {
@ -315,11 +315,11 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
/* Get the transform and world matrix */
/* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
wined3d_device_get_transform(lpDevice->wined3d_device,
wined3d_device_get_transform(device->wined3d_device,
D3DTRANSFORMSTATE_VIEW, (struct wined3d_matrix *)&view_mat);
wined3d_device_get_transform(lpDevice->wined3d_device,
wined3d_device_get_transform(device->wined3d_device,
D3DTRANSFORMSTATE_PROJECTION, (struct wined3d_matrix *)&proj_mat);
wined3d_device_get_transform(lpDevice->wined3d_device,
wined3d_device_get_transform(device->wined3d_device,
WINED3D_TS_WORLD_MATRIX(0), (struct wined3d_matrix *)&world_mat);
for (i = 0; i < count; i++) {
@ -837,7 +837,7 @@ static const struct IDirect3DExecuteBufferVtbl d3d_execute_buffer_vtbl =
};
HRESULT d3d_execute_buffer_init(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, D3DEXECUTEBUFFERDESC *desc)
struct d3d_device *device, D3DEXECUTEBUFFERDESC *desc)
{
execute_buffer->IDirect3DExecuteBuffer_iface.lpVtbl = &d3d_execute_buffer_vtbl;
execute_buffer->ref = 1;

View File

@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
*****************************************************************************/
static void light_update(struct d3d_light *light)
{
IDirect3DDeviceImpl *device;
struct d3d_device *device;
TRACE("light %p.\n", light);
@ -52,7 +52,7 @@ static void light_update(struct d3d_light *light)
*****************************************************************************/
void light_activate(struct d3d_light *light)
{
IDirect3DDeviceImpl *device;
struct d3d_device *device;
TRACE("light %p.\n", light);
@ -76,7 +76,7 @@ void light_activate(struct d3d_light *light)
*****************************************************************************/
void light_deactivate(struct d3d_light *light)
{
IDirect3DDeviceImpl *device;
struct d3d_device *device;
TRACE("light %p.\n", light);

View File

@ -297,7 +297,7 @@ static HRESULT WINAPI d3d_material3_GetHandle(IDirect3DMaterial3 *iface,
IDirect3DDevice3 *device, D3DMATERIALHANDLE *handle)
{
struct d3d_material *material = impl_from_IDirect3DMaterial3(iface);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
@ -326,7 +326,7 @@ static HRESULT WINAPI d3d_material2_GetHandle(IDirect3DMaterial2 *iface,
IDirect3DDevice2 *device, D3DMATERIALHANDLE *handle)
{
struct d3d_material *material = impl_from_IDirect3DMaterial2(iface);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice2(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice2(device);
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
@ -338,7 +338,7 @@ static HRESULT WINAPI d3d_material1_GetHandle(IDirect3DMaterial *iface,
IDirect3DDevice *device, D3DMATERIALHANDLE *handle)
{
struct d3d_material *material = impl_from_IDirect3DMaterial(iface);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice(device);
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);

View File

@ -1619,10 +1619,8 @@ static HRESULT ddraw_surface_attach_surface(struct ddraw_surface *This, struct d
This->next_attached = Surf;
/* Check if the WineD3D depth stencil needs updating */
if(This->ddraw->d3ddevice)
{
IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
}
if (This->ddraw->d3ddevice)
d3d_device_update_depth_stencil(This->ddraw->d3ddevice);
wined3d_mutex_unlock();
@ -1823,7 +1821,7 @@ static HRESULT ddraw_surface_delete_attached_surface(struct ddraw_surface *surfa
/* Check if the wined3d depth stencil needs updating. */
if (surface->ddraw->d3ddevice)
IDirect3DDeviceImpl_UpdateDepthStencil(surface->ddraw->d3ddevice);
d3d_device_update_depth_stencil(surface->ddraw->d3ddevice);
wined3d_mutex_unlock();
/* Set attached_iface to NULL before releasing it, the surface may go
@ -4968,7 +4966,7 @@ static HRESULT WINAPI d3d_texture2_GetHandle(IDirect3DTexture2 *iface,
IDirect3DDevice2 *device, D3DTEXTUREHANDLE *handle)
{
struct ddraw_surface *surface = impl_from_IDirect3DTexture2(iface);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice2(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice2(device);
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
@ -4999,7 +4997,7 @@ static HRESULT WINAPI d3d_texture1_GetHandle(IDirect3DTexture *iface,
IDirect3DDevice *device, D3DTEXTUREHANDLE *handle)
{
struct ddraw_surface *surface = impl_from_IDirect3DTexture(iface);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice(device);
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);

View File

@ -309,7 +309,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB
{
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer7(iface);
IDirect3DVertexBufferImpl *Src = unsafe_impl_from_IDirect3DVertexBuffer7(SrcBuffer);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice7(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice7(device);
BOOL oldClip, doClip;
HRESULT hr;
@ -360,7 +360,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVerte
{
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
IDirect3DVertexBufferImpl *Src = unsafe_impl_from_IDirect3DVertexBuffer(SrcBuffer);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n",
iface, VertexOp, DestIndex, Count, SrcBuffer, SrcIndex, device, Flags);
@ -459,7 +459,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer
IDirect3DDevice3 *device, DWORD Flags)
{
IDirect3DVertexBufferImpl *This = impl_from_IDirect3DVertexBuffer(iface);
IDirect3DDeviceImpl *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice3(device);
TRACE("iface %p, device %p, flags %#x.\n", iface, device, Flags);

View File

@ -30,7 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
* Helper functions
*****************************************************************************/
static void update_clip_space(IDirect3DDeviceImpl *device,
static void update_clip_space(struct d3d_device *device,
struct wined3d_vec3 *scale, struct wined3d_vec3 *offset)
{
D3DMATRIX clip_space =