Commit 3032b40c authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of the IWineD3DDeviceParent interface.

parent 74844ca3
......@@ -71,10 +71,11 @@ struct d3d10_device
{
const struct ID3D10DeviceVtbl *vtbl;
const struct IUnknownVtbl *inner_unknown_vtbl;
const struct IWineD3DDeviceParentVtbl *device_parent_vtbl;
IWineDXGIDeviceParent IWineDXGIDeviceParent_iface;
IUnknown *outer_unknown;
LONG refcount;
struct wined3d_device_parent device_parent;
struct wined3d_device *wined3d_device;
};
......
......@@ -175,7 +175,7 @@ struct IDirect3DDevice8Impl
{
/* IUnknown fields */
IDirect3DDevice8 IDirect3DDevice8_iface;
IWineD3DDeviceParent IWineD3DDeviceParent_iface;
struct wined3d_device_parent device_parent;
LONG ref;
struct wined3d_device *wined3d_device;
struct d3d8_handle_table handle_table;
......
......@@ -163,7 +163,7 @@ void filter_caps(D3DCAPS9* pCaps) DECLSPEC_HIDDEN;
typedef struct IDirect3DDevice9Impl
{
IDirect3DDevice9Ex IDirect3DDevice9Ex_iface;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
struct wined3d_device_parent device_parent;
LONG ref;
struct wined3d_device *wined3d_device;
/* Avoids recursion with nested ReleaseRef to 0 */
......
......@@ -78,7 +78,7 @@ struct IDirectDrawImpl
IDirect3D3 IDirect3D3_iface;
IDirect3D2 IDirect3D2_iface;
IDirect3D IDirect3D_iface;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
struct wined3d_device_parent device_parent;
/* See comment in IDirectDraw::AddRef */
LONG ref7, ref4, ref2, ref3, ref1, numIfaces;
......
......@@ -158,7 +158,8 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
const DXGI_SURFACE_DESC *desc, UINT surface_count, DXGI_USAGE usage,
const DXGI_SHARED_RESOURCE *shared_resource, IDXGISurface **surface)
{
IWineD3DDeviceParent *device_parent;
struct wined3d_device_parent *device_parent;
IWineDXGIDeviceParent *dxgi_device_parent;
HRESULT hr;
UINT i;
UINT j;
......@@ -166,13 +167,15 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
TRACE("iface %p, desc %p, surface_count %u, usage %#x, shared_resource %p, surface %p\n",
iface, desc, surface_count, usage, shared_resource, surface);
hr = IWineDXGIDevice_QueryInterface(iface, &IID_IWineD3DDeviceParent, (void **)&device_parent);
hr = IWineDXGIDevice_QueryInterface(iface, &IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent);
if (FAILED(hr))
{
ERR("Device should implement IWineD3DDeviceParent\n");
return E_FAIL;
}
device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
FIXME("Implement DXGI<->wined3d usage conversion\n");
memset(surface, 0, surface_count * sizeof(*surface));
......@@ -181,7 +184,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
struct wined3d_surface *wined3d_surface;
IUnknown *parent;
hr = IWineD3DDeviceParent_CreateSurface(device_parent, NULL, desc->Width, desc->Height,
hr = device_parent->ops->create_surface(device_parent, NULL, desc->Width, desc->Height,
wined3dformat_from_dxgi_format(desc->Format), usage, WINED3DPOOL_DEFAULT, 0,
WINED3DCUBEMAP_FACE_POSITIVE_X, &wined3d_surface);
if (FAILED(hr))
......@@ -201,7 +204,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
TRACE("Created IDXGISurface %p (%u/%u)\n", surface[i], i + 1, surface_count);
}
IWineD3DDeviceParent_Release(device_parent);
IWineDXGIDeviceParent_Release(dxgi_device_parent);
return S_OK;
......@@ -210,7 +213,7 @@ fail:
{
IDXGISurface_Release(surface[i]);
}
IWineD3DDeviceParent_Release(device_parent);
IWineDXGIDeviceParent_Release(dxgi_device_parent);
return hr;
}
......@@ -337,7 +340,8 @@ static const struct IWineDXGIDeviceVtbl dxgi_device_vtbl =
HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer,
IDXGIFactory *factory, IDXGIAdapter *adapter)
{
IWineD3DDeviceParent *wined3d_device_parent;
struct wined3d_device_parent *wined3d_device_parent;
IWineDXGIDeviceParent *dxgi_device_parent;
IWineDXGIAdapter *wine_adapter;
UINT adapter_ordinal;
struct wined3d *wined3d;
......@@ -377,18 +381,20 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
adapter_ordinal = IWineDXGIAdapter_get_ordinal(wine_adapter);
IWineDXGIAdapter_Release(wine_adapter);
hr = IUnknown_QueryInterface((IUnknown *)device, &IID_IWineD3DDeviceParent, (void **)&wined3d_device_parent);
hr = IUnknown_QueryInterface((IUnknown *)device, &IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent);
if (FAILED(hr))
{
ERR("DXGI device should implement IWineD3DDeviceParent.\n");
goto fail;
}
wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
FIXME("Ignoring adapter type.\n");
EnterCriticalSection(&dxgi_cs);
hr = wined3d_device_create(wined3d, adapter_ordinal, WINED3DDEVTYPE_HAL, NULL, 0,
wined3d_device_parent, &device->wined3d_device);
IWineD3DDeviceParent_Release(wined3d_device_parent);
IWineDXGIDeviceParent_Release(dxgi_device_parent);
wined3d_decref(wined3d);
LeaveCriticalSection(&dxgi_cs);
if (FAILED(hr))
......
......@@ -1212,7 +1212,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
/* Setup the implicit swapchain. This also initializes a context. */
TRACE("Creating implicit swapchain\n");
hr = IWineD3DDeviceParent_CreateSwapChain(device->device_parent,
hr = device->device_parent->ops->create_swapchain(device->device_parent,
present_parameters, &swapchain);
if (FAILED(hr))
{
......@@ -1356,7 +1356,7 @@ HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
/* Setup the implicit swapchain */
TRACE("Creating implicit swapchain\n");
hr = IWineD3DDeviceParent_CreateSwapChain(device->device_parent,
hr = device->device_parent->ops->create_swapchain(device->device_parent,
present_parameters, &swapchain);
if (FAILED(hr))
{
......@@ -5694,7 +5694,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
TRACE("Creating the depth stencil buffer\n");
hrc = IWineD3DDeviceParent_CreateDepthStencilSurface(device->device_parent,
hrc = device->device_parent->ops->create_depth_stencil(device->device_parent,
present_parameters->BackBufferWidth,
present_parameters->BackBufferHeight,
present_parameters->AutoDepthStencilFormat,
......@@ -6103,7 +6103,7 @@ HRESULT CDECL wined3d_device_get_surface_from_dc(struct wined3d_device *device,
HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
IWineD3DDeviceParent *device_parent)
struct wined3d_device_parent *device_parent)
{
struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct fragment_pipeline *fragment_pipeline;
......
......@@ -4850,7 +4850,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
}
HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type,
HWND focus_window, DWORD flags, IWineD3DDeviceParent *device_parent, struct wined3d_device **device)
HWND focus_window, DWORD flags, struct wined3d_device_parent *device_parent, struct wined3d_device **device)
{
struct wined3d_device *object;
HRESULT hr;
......@@ -4881,7 +4881,7 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, W
TRACE("Created device %p.\n", object);
*device = object;
IWineD3DDeviceParent_WineD3DDeviceCreated(device_parent, *device);
device_parent->ops->wined3d_device_created(device_parent, *device);
return WINED3D_OK;
}
......
......@@ -898,7 +898,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTY
}
TRACE("Creating front buffer.\n");
hr = IWineD3DDeviceParent_CreateRenderTarget(device->device_parent, parent,
hr = device->device_parent->ops->create_rendertarget(device->device_parent, parent,
swapchain->presentParms.BackBufferWidth, swapchain->presentParms.BackBufferHeight,
swapchain->presentParms.BackBufferFormat, swapchain->presentParms.MultiSampleType,
swapchain->presentParms.MultiSampleQuality, TRUE /* Lockable */,
......@@ -1009,7 +1009,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTY
for (i = 0; i < swapchain->presentParms.BackBufferCount; ++i)
{
TRACE("Creating back buffer %u.\n", i);
hr = IWineD3DDeviceParent_CreateRenderTarget(device->device_parent, parent,
hr = device->device_parent->ops->create_rendertarget(device->device_parent, parent,
swapchain->presentParms.BackBufferWidth, swapchain->presentParms.BackBufferHeight,
swapchain->presentParms.BackBufferFormat, swapchain->presentParms.MultiSampleType,
swapchain->presentParms.MultiSampleQuality, TRUE /* Lockable */,
......@@ -1030,7 +1030,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTY
TRACE("Creating depth/stencil buffer.\n");
if (!device->auto_depth_stencil)
{
hr = IWineD3DDeviceParent_CreateDepthStencilSurface(device->device_parent,
hr = device->device_parent->ops->create_depth_stencil(device->device_parent,
swapchain->presentParms.BackBufferWidth, swapchain->presentParms.BackBufferHeight,
swapchain->presentParms.AutoDepthStencilFormat, swapchain->presentParms.MultiSampleType,
swapchain->presentParms.MultiSampleQuality, FALSE /* FIXME: Discard */,
......
......@@ -895,7 +895,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
UINT idx = j * texture->level_count + i;
struct wined3d_surface *surface;
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
hr = device->device_parent->ops->create_surface(device->device_parent, parent, tmp_w, tmp_w,
format_id, usage, pool, i /* Level */, j, &surface);
if (FAILED(hr))
{
......@@ -1051,7 +1051,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
struct wined3d_surface *surface;
/* Use the callback to create the texture surface. */
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h,
hr = device->device_parent->ops->create_surface(device->device_parent, parent, tmp_w, tmp_h,
format->id, usage, pool, i, 0, &surface);
if (FAILED(hr))
{
......@@ -1259,7 +1259,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, U
struct wined3d_volume *volume;
/* Create the volume. */
hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
hr = device->device_parent->ops->create_volume(device->device_parent, parent,
tmp_w, tmp_h, tmp_d, format_id, pool, usage, &volume);
if (FAILED(hr))
{
......
......@@ -1645,7 +1645,7 @@ struct wined3d_device
LONG ref;
/* WineD3D Information */
IWineD3DDeviceParent *device_parent;
struct wined3d_device_parent *device_parent;
struct wined3d *wined3d;
struct wined3d_adapter *adapter;
......@@ -1774,7 +1774,7 @@ void device_context_remove(struct wined3d_device *device, struct wined3d_context
void device_get_draw_rect(struct wined3d_device *device, RECT *rect) DECLSPEC_HIDDEN;
HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN;
struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
void device_preload_textures(struct wined3d_device *device) DECLSPEC_HIDDEN;
LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
......
......@@ -2101,66 +2101,30 @@ struct wined3d_texture;
struct wined3d_vertex_declaration;
struct wined3d_volume;
[
object,
local,
uuid(aeb62dfc-bdcb-4f02-9519-1eeea00c15cd)
]
interface IWineD3DDeviceParent : IUnknown
{
void WineD3DDeviceCreated(
[in] struct wined3d_device *device
);
HRESULT CreateSurface(
[in] void *container_parent,
[in] UINT width,
[in] UINT height,
[in] enum wined3d_format_id format_id,
[in] DWORD usage,
[in] WINED3DPOOL pool,
[in] UINT level,
[in] WINED3DCUBEMAP_FACES face,
[out] struct wined3d_surface **surface
);
HRESULT CreateRenderTarget(
[in] void *container_parent,
[in] UINT width,
[in] UINT height,
[in] enum wined3d_format_id format_id,
[in] WINED3DMULTISAMPLE_TYPE multisample_type,
[in] DWORD multisample_quality,
[in] BOOL lockable,
[out] struct wined3d_surface **surface
);
HRESULT CreateDepthStencilSurface(
[in] UINT width,
[in] UINT height,
[in] enum wined3d_format_id format_id,
[in] WINED3DMULTISAMPLE_TYPE multisample_type,
[in] DWORD multisample_quality,
[in] BOOL discard,
[out] struct wined3d_surface **surface
);
HRESULT CreateVolume(
[in] void *container_parent,
[in] UINT width,
[in] UINT height,
[in] UINT depth,
[in] enum wined3d_format_id format_id,
[in] WINED3DPOOL pool,
[in] DWORD usage,
[out] struct wined3d_volume **volume
);
HRESULT CreateSwapChain(
[in, out] WINED3DPRESENT_PARAMETERS *present_parameters,
[out] struct wined3d_swapchain **swapchain
);
}
struct wined3d_device_parent
{
const struct wined3d_device_parent_ops *ops;
};
struct wined3d_device_parent_ops
{
void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
HRESULT (__cdecl *create_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, WINED3DPOOL pool,
UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface);
HRESULT (__cdecl *create_rendertarget)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, enum wined3d_format_id format_id, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL lockable, struct wined3d_surface **surface);
HRESULT (__cdecl *create_depth_stencil)(struct wined3d_device_parent *device_parent,
UINT width, UINT height, enum wined3d_format_id format_id, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface);
HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, UINT depth, enum wined3d_format_id format_id, WINED3DPOOL pool, DWORD usage,
struct wined3d_volume **volume);
HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain);
};
typedef HRESULT (__stdcall *D3DCB_ENUMRESOURCES)(struct wined3d_resource *resource, void *pData);
void __stdcall wined3d_mutex_lock(void);
......@@ -2242,7 +2206,7 @@ HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct
const RECT *rect, const WINED3DCOLORVALUE *color);
HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx,
WINED3DDEVTYPE device_type, HWND focus_window, DWORD behaviour_flags,
IWineD3DDeviceParent *device_parent, struct wined3d_device **device);
struct wined3d_device_parent *device_parent, struct wined3d_device **device);
ULONG __cdecl wined3d_device_decref(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_delete_patch(struct wined3d_device *device, UINT handle);
HRESULT __cdecl wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count);
......
......@@ -58,3 +58,13 @@ interface IWineDXGIDevice : IDXGIDevice
[out] struct wined3d_swapchain **wined3d_swapchain
);
}
[
object,
local,
uuid(f2b918f3-603f-430a-9ccd-55872b6e85df)
]
interface IWineDXGIDeviceParent : IUnknown
{
struct wined3d_device_parent *get_wined3d_device_parent();
}
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