forked from Mirrors/wine-wine
d3d8: Get rid of IDirect3DSwapChain8Impl.
parent
1993727ee7
commit
584053d0ee
|
@ -101,7 +101,6 @@
|
||||||
void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN;
|
void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
|
typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
|
||||||
typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
|
|
||||||
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
|
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
|
||||||
|
|
||||||
struct d3d8
|
struct d3d8
|
||||||
|
@ -189,23 +188,15 @@ struct IDirect3DVolume8Impl
|
||||||
HRESULT volume_init(IDirect3DVolume8Impl *volume, struct d3d8_device *device, UINT width, UINT height,
|
HRESULT volume_init(IDirect3DVolume8Impl *volume, struct d3d8_device *device, UINT width, UINT height,
|
||||||
UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) DECLSPEC_HIDDEN;
|
UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* ------------------- */
|
struct d3d8_swapchain
|
||||||
/* IDirect3DSwapChain8 */
|
|
||||||
/* ------------------- */
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* IDirect3DSwapChain8 implementation structure
|
|
||||||
*/
|
|
||||||
struct IDirect3DSwapChain8Impl
|
|
||||||
{
|
{
|
||||||
/* IUnknown fields */
|
|
||||||
IDirect3DSwapChain8 IDirect3DSwapChain8_iface;
|
IDirect3DSwapChain8 IDirect3DSwapChain8_iface;
|
||||||
LONG ref;
|
LONG refcount;
|
||||||
struct wined3d_swapchain *wined3d_swapchain;
|
struct wined3d_swapchain *wined3d_swapchain;
|
||||||
IDirect3DDevice8 *parentDevice;
|
IDirect3DDevice8 *parent_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, struct d3d8_device *device,
|
HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device,
|
||||||
D3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
|
D3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* ----------------- */
|
/* ----------------- */
|
||||||
|
|
|
@ -498,7 +498,7 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
|
||||||
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain8 **swapchain)
|
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain8 **swapchain)
|
||||||
{
|
{
|
||||||
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
|
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
|
||||||
IDirect3DSwapChain8Impl *object;
|
struct d3d8_swapchain *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
|
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
|
||||||
|
@ -2974,7 +2974,7 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*swapchain = ((IDirect3DSwapChain8Impl *)d3d_swapchain)->wined3d_swapchain;
|
*swapchain = ((struct d3d8_swapchain *)d3d_swapchain)->wined3d_swapchain;
|
||||||
wined3d_swapchain_incref(*swapchain);
|
wined3d_swapchain_incref(*swapchain);
|
||||||
IDirect3DSwapChain8_Release(d3d_swapchain);
|
IDirect3DSwapChain8_Release(d3d_swapchain);
|
||||||
|
|
||||||
|
|
|
@ -23,107 +23,106 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
||||||
|
|
||||||
static inline IDirect3DSwapChain8Impl *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
|
static inline struct d3d8_swapchain *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
|
||||||
{
|
{
|
||||||
return CONTAINING_RECORD(iface, IDirect3DSwapChain8Impl, IDirect3DSwapChain8_iface);
|
return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(IDirect3DSwapChain8 *iface,
|
static HRESULT WINAPI d3d8_swapchain_QueryInterface(IDirect3DSwapChain8 *iface, REFIID riid, void **out)
|
||||||
REFIID riid, void **ppobj)
|
|
||||||
{
|
{
|
||||||
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||||
|
|
||||||
if (IsEqualGUID(riid, &IID_IDirect3DSwapChain8)
|
if (IsEqualGUID(riid, &IID_IDirect3DSwapChain8)
|
||||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||||
{
|
{
|
||||||
IUnknown_AddRef(iface);
|
IUnknown_AddRef(iface);
|
||||||
*ppobj = iface;
|
*out = iface;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
||||||
|
|
||||||
*ppobj = NULL;
|
*out = NULL;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(IDirect3DSwapChain8 *iface)
|
static ULONG WINAPI d3d8_swapchain_AddRef(IDirect3DSwapChain8 *iface)
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
|
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
|
||||||
ULONG ref = InterlockedIncrement(&This->ref);
|
ULONG ref = InterlockedIncrement(&swapchain->refcount);
|
||||||
|
|
||||||
TRACE("%p increasing refcount to %u.\n", iface, ref);
|
TRACE("%p increasing refcount to %u.\n", iface, ref);
|
||||||
|
|
||||||
if (ref == 1)
|
if (ref == 1)
|
||||||
{
|
{
|
||||||
if (This->parentDevice)
|
if (swapchain->parent_device)
|
||||||
IDirect3DDevice8_AddRef(This->parentDevice);
|
IDirect3DDevice8_AddRef(swapchain->parent_device);
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
wined3d_swapchain_incref(This->wined3d_swapchain);
|
wined3d_swapchain_incref(swapchain->wined3d_swapchain);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirect3DSwapChain8Impl_Release(IDirect3DSwapChain8 *iface)
|
static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
|
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
|
||||||
ULONG ref = InterlockedDecrement(&This->ref);
|
ULONG ref = InterlockedDecrement(&swapchain->refcount);
|
||||||
|
|
||||||
TRACE("%p decreasing refcount to %u.\n", iface, ref);
|
TRACE("%p decreasing refcount to %u.\n", iface, ref);
|
||||||
|
|
||||||
if (!ref)
|
if (!ref)
|
||||||
{
|
{
|
||||||
IDirect3DDevice8 *parentDevice = This->parentDevice;
|
IDirect3DDevice8 *parent_device = swapchain->parent_device;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
wined3d_swapchain_decref(This->wined3d_swapchain);
|
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
if (parentDevice)
|
if (parent_device)
|
||||||
IDirect3DDevice8_Release(parentDevice);
|
IDirect3DDevice8_Release(parent_device);
|
||||||
}
|
}
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(IDirect3DSwapChain8 *iface,
|
static HRESULT WINAPI d3d8_swapchain_Present(IDirect3DSwapChain8 *iface,
|
||||||
const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride,
|
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
|
||||||
const RGNDATA *pDirtyRegion)
|
const RGNDATA *dirty_region)
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
|
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
|
TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
|
||||||
iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region);
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_swapchain_present(This->wined3d_swapchain, pSourceRect,
|
hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, src_rect,
|
||||||
pDestRect, hDestWindowOverride, pDirtyRegion, 0);
|
dst_rect, dst_window_override, dirty_region, 0);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8 *iface,
|
static HRESULT WINAPI d3d8_swapchain_GetBackBuffer(IDirect3DSwapChain8 *iface,
|
||||||
UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer)
|
UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
|
struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
|
||||||
struct wined3d_surface *wined3d_surface = NULL;
|
struct wined3d_surface *wined3d_surface = NULL;
|
||||||
IDirect3DSurface8Impl *surface_impl;
|
IDirect3DSurface8Impl *surface_impl;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
|
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
|
||||||
iface, iBackBuffer, Type, ppBackBuffer);
|
iface, backbuffer_idx, backbuffer_type, backbuffer);
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
|
hr = wined3d_swapchain_get_back_buffer(swapchain->wined3d_swapchain,
|
||||||
iBackBuffer, (enum wined3d_backbuffer_type)Type, &wined3d_surface);
|
backbuffer_idx, (enum wined3d_backbuffer_type)backbuffer_type, &wined3d_surface);
|
||||||
if (SUCCEEDED(hr) && wined3d_surface)
|
if (SUCCEEDED(hr) && wined3d_surface)
|
||||||
{
|
{
|
||||||
surface_impl = wined3d_surface_get_parent(wined3d_surface);
|
surface_impl = wined3d_surface_get_parent(wined3d_surface);
|
||||||
*ppBackBuffer = &surface_impl->IDirect3DSurface8_iface;
|
*backbuffer = &surface_impl->IDirect3DSurface8_iface;
|
||||||
IDirect3DSurface8_AddRef(*ppBackBuffer);
|
IDirect3DSurface8_AddRef(*backbuffer);
|
||||||
wined3d_surface_decref(wined3d_surface);
|
wined3d_surface_decref(wined3d_surface);
|
||||||
}
|
}
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
@ -131,13 +130,13 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
|
static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl =
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain8Impl_QueryInterface,
|
d3d8_swapchain_QueryInterface,
|
||||||
IDirect3DSwapChain8Impl_AddRef,
|
d3d8_swapchain_AddRef,
|
||||||
IDirect3DSwapChain8Impl_Release,
|
d3d8_swapchain_Release,
|
||||||
IDirect3DSwapChain8Impl_Present,
|
d3d8_swapchain_Present,
|
||||||
IDirect3DSwapChain8Impl_GetBackBuffer
|
d3d8_swapchain_GetBackBuffer
|
||||||
};
|
};
|
||||||
|
|
||||||
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
|
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
|
||||||
|
@ -150,14 +149,14 @@ static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
|
||||||
d3d8_swapchain_wined3d_object_released,
|
d3d8_swapchain_wined3d_object_released,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, struct d3d8_device *device,
|
HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device,
|
||||||
D3DPRESENT_PARAMETERS *present_parameters)
|
D3DPRESENT_PARAMETERS *present_parameters)
|
||||||
{
|
{
|
||||||
struct wined3d_swapchain_desc desc;
|
struct wined3d_swapchain_desc desc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
swapchain->ref = 1;
|
swapchain->refcount = 1;
|
||||||
swapchain->IDirect3DSwapChain8_iface.lpVtbl = &Direct3DSwapChain8_Vtbl;
|
swapchain->IDirect3DSwapChain8_iface.lpVtbl = &d3d8_swapchain_vtbl;
|
||||||
|
|
||||||
desc.backbuffer_width = present_parameters->BackBufferWidth;
|
desc.backbuffer_width = present_parameters->BackBufferWidth;
|
||||||
desc.backbuffer_height = present_parameters->BackBufferHeight;
|
desc.backbuffer_height = present_parameters->BackBufferHeight;
|
||||||
|
@ -201,8 +200,8 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, struct d3d8_device *d
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
swapchain->parentDevice = &device->IDirect3DDevice8_iface;
|
swapchain->parent_device = &device->IDirect3DDevice8_iface;
|
||||||
IDirect3DDevice8_AddRef(swapchain->parentDevice);
|
IDirect3DDevice8_AddRef(swapchain->parent_device);
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue