Commit 3ec19590 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Remove COM from the swapchain implementation.

parent 178061d3
......@@ -1465,7 +1465,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
IWineDXGIDevice *wine_device;
HRESULT hr;
......
......@@ -229,12 +229,8 @@ struct IDirect3DSwapChain8Impl
/* IUnknown fields */
IDirect3DSwapChain8 IDirect3DSwapChain8_iface;
LONG ref;
/* IDirect3DSwapChain8 fields */
IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */
IDirect3DDevice8 *parentDevice;
struct wined3d_swapchain *wined3d_swapchain;
IDirect3DDevice8 *parentDevice;
};
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl *device,
......
......@@ -2900,7 +2900,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
IDirect3DDevice8Impl *This = impl_from_IWineD3DDeviceParent(iface);
D3DPRESENT_PARAMETERS local_parameters;
......@@ -2933,8 +2933,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
return hr;
}
*swapchain = ((IDirect3DSwapChain8Impl *)d3d_swapchain)->wineD3DSwapChain;
IWineD3DSwapChain_AddRef(*swapchain);
*swapchain = ((IDirect3DSwapChain8Impl *)d3d_swapchain)->wined3d_swapchain;
wined3d_swapchain_incref(*swapchain);
IDirect3DSwapChain8_Release(d3d_swapchain);
/* Copy back the presentation parameters */
......
......@@ -59,7 +59,7 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(IDirect3DSwapChain8 *iface)
if (This->parentDevice)
IDirect3DDevice8_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DSwapChain_AddRef(This->wineD3DSwapChain);
wined3d_swapchain_incref(This->wined3d_swapchain);
wined3d_mutex_unlock();
}
......@@ -78,7 +78,7 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_Release(IDirect3DSwapChain8 *iface)
IDirect3DDevice8 *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DSwapChain_Release(This->wineD3DSwapChain);
wined3d_swapchain_decref(This->wined3d_swapchain);
wined3d_mutex_unlock();
if (parentDevice)
......@@ -98,7 +98,8 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(IDirect3DSwapChain8 *iface
iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
hr = wined3d_swapchain_present(This->wined3d_swapchain, pSourceRect,
pDestRect, hDestWindowOverride, pDirtyRegion, 0);
wined3d_mutex_unlock();
return hr;
......@@ -115,8 +116,8 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8
iface, iBackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer,
(WINED3DBACKBUFFER_TYPE)Type, &mySurface);
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
iBackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &mySurface);
if (SUCCEEDED(hr) && mySurface)
{
*ppBackBuffer = IWineD3DSurface_GetParent(mySurface);
......@@ -175,7 +176,7 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
SURFACE_OPENGL, swapchain, &d3d8_swapchain_wined3d_parent_ops,
&swapchain->wineD3DSwapChain);
&swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
......
......@@ -216,12 +216,8 @@ typedef struct IDirect3DSwapChain9Impl
/* IUnknown fields */
const IDirect3DSwapChain9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSwapChain9 fields */
IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
struct wined3d_swapchain *wined3d_swapchain;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DSwapChain9Impl;
HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl *device,
......
......@@ -481,7 +481,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwa
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface,
UINT swapchain_idx, IDirect3DSwapChain9 **swapchain)
{
IWineD3DSwapChain *wined3d_swapchain = NULL;
struct wined3d_swapchain *wined3d_swapchain = NULL;
HRESULT hr;
TRACE("iface %p, swapchain_idx %u, swapchain %p.\n", iface, swapchain_idx, swapchain);
......@@ -491,9 +491,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(IDirec
swapchain_idx, &wined3d_swapchain);
if (SUCCEEDED(hr) && wined3d_swapchain)
{
*swapchain = IWineD3DSwapChain_GetParent(wined3d_swapchain);
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
IDirect3DSwapChain9_AddRef(*swapchain);
IWineD3DSwapChain_Release(wined3d_swapchain);
wined3d_swapchain_decref(wined3d_swapchain);
}
else
{
......@@ -3159,7 +3159,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
D3DPRESENT_PARAMETERS local_parameters;
......@@ -3193,8 +3193,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
return hr;
}
*swapchain = ((IDirect3DSwapChain9Impl *)d3d_swapchain)->wineD3DSwapChain;
IWineD3DSwapChain_AddRef(*swapchain);
*swapchain = ((IDirect3DSwapChain9Impl *)d3d_swapchain)->wined3d_swapchain;
wined3d_swapchain_incref(*swapchain);
IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
/* Copy back the presentation parameters */
......
......@@ -56,7 +56,7 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface) {
IDirect3DDevice9Ex_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DSwapChain_AddRef(This->wineD3DSwapChain);
wined3d_swapchain_incref(This->wined3d_swapchain);
wined3d_mutex_unlock();
}
......@@ -73,7 +73,7 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface)
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DSwapChain_Release(This->wineD3DSwapChain);
wined3d_swapchain_decref(This->wined3d_swapchain);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
......@@ -91,7 +91,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DSwapChain9Impl_Present(LPDIRECT
iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
hr = wined3d_swapchain_present(This->wined3d_swapchain, pSourceRect,
pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
wined3d_mutex_unlock();
return hr;
......@@ -104,7 +105,8 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPC
TRACE("iface %p, surface %p.\n", iface, pDestSurface);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
hr = wined3d_swapchain_get_front_buffer_data(This->wined3d_swapchain,
((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
wined3d_mutex_unlock();
return hr;
......@@ -121,8 +123,8 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(IDirect3DSwapChain9
iface, iBackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer,
(WINED3DBACKBUFFER_TYPE)Type, &mySurface);
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
iBackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &mySurface);
if (SUCCEEDED(hr) && mySurface)
{
*ppBackBuffer = IWineD3DSurface_GetParent(mySurface);
......@@ -142,7 +144,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAI
TRACE("iface %p, raster_status %p.\n", iface, pRasterStatus);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
hr = wined3d_swapchain_get_raster_status(This->wined3d_swapchain, (WINED3DRASTER_STATUS *)pRasterStatus);
wined3d_mutex_unlock();
return hr;
......@@ -155,7 +157,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN
TRACE("iface %p, mode %p.\n", iface, pMode);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
hr = wined3d_swapchain_get_display_mode(This->wined3d_swapchain, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
......@@ -185,7 +187,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWA
TRACE("iface %p, parameters %p.\n", iface, pPresentationParameters);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, &winePresentParameters);
hr = wined3d_swapchain_get_present_parameters(This->wined3d_swapchain, &winePresentParameters);
wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
......@@ -259,7 +261,7 @@ HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
SURFACE_OPENGL, swapchain, &d3d9_swapchain_wined3d_parent_ops,
&swapchain->wineD3DSwapChain);
&swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
......
......@@ -2520,7 +2520,7 @@ HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDE
IDirectDrawImpl *This = surfImpl->ddraw;
struct wined3d_clipper *clipper = NULL;
IWineD3DSurface *wineD3DSurface;
IWineD3DSwapChain *swapchain;
struct wined3d_swapchain *swapchain;
void *parent;
HRESULT hr;
......@@ -2533,8 +2533,8 @@ HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDE
if(surfImpl->ImplType == This->ImplType) return DDENUMRET_OK; /* Continue */
/* Get the objects */
swapchain = surfImpl->wineD3DSwapChain;
surfImpl->wineD3DSwapChain = NULL;
swapchain = surfImpl->wined3d_swapchain;
surfImpl->wined3d_swapchain = NULL;
wineD3DSurface = surfImpl->WineD3DSurface;
/* get the clipper */
......@@ -2934,7 +2934,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
if (FAILED(hr))
{
WARN("Failed to initialize GDI ddraw implementation, hr %#x.\n", hr);
primary->wineD3DSwapChain = NULL;
primary->wined3d_swapchain = NULL;
}
return hr;
......@@ -5888,7 +5888,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
IDirectDrawSurfaceImpl *iterator;
......@@ -5905,11 +5905,11 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
return hr;
}
This->d3d_target->wineD3DSwapChain = *swapchain;
This->d3d_target->wined3d_swapchain = *swapchain;
iterator = This->d3d_target->complex_array[0];
while (iterator)
{
iterator->wineD3DSwapChain = *swapchain;
iterator->wined3d_swapchain = *swapchain;
iterator = iterator->complex_array[0];
}
......
......@@ -181,7 +181,7 @@ struct IDirectDrawSurfaceImpl
IDirectDrawImpl *ddraw;
IWineD3DSurface *WineD3DSurface;
struct wined3d_texture *wined3d_texture;
IWineD3DSwapChain *wineD3DSwapChain;
struct wined3d_swapchain *wined3d_swapchain;
/* This implementation handles attaching surfaces to other surfaces */
IDirectDrawSurfaceImpl *next_attached;
......
......@@ -356,7 +356,7 @@ static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
wined3d_texture_decref(This->wined3d_texture);
/* If it's the RenderTarget, destroy the d3ddevice */
else if(This->wineD3DSwapChain)
else if (This->wined3d_swapchain)
{
if((ddraw->d3d_initialized) && (This == ddraw->d3d_target)) {
TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
......@@ -389,14 +389,14 @@ static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
/* Unset the pointers */
}
This->wineD3DSwapChain = NULL; /* Uninit3D releases the swapchain */
This->wined3d_swapchain = NULL; /* Uninit3D releases the swapchain */
ddraw->d3d_initialized = FALSE;
ddraw->d3d_target = NULL;
}
else
{
IWineD3DDevice_UninitGDI(ddraw->wineD3DDevice);
This->wineD3DSwapChain = NULL;
This->wined3d_swapchain = NULL;
}
/* Reset to the default surface implementation type. This is needed if apps use
......@@ -2569,19 +2569,17 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface, IDir
hr = IWineD3DSurface_SetClipper(This->WineD3DSurface, This->clipper ? This->clipper->wineD3DClipper : NULL);
if(This->wineD3DSwapChain) {
if (This->wined3d_swapchain)
{
clipWindow = NULL;
if(Clipper) {
IDirectDrawClipper_GetHWnd(Clipper, &clipWindow);
}
if(clipWindow) {
IWineD3DSwapChain_SetDestWindowOverride(This->wineD3DSwapChain,
clipWindow);
} else {
IWineD3DSwapChain_SetDestWindowOverride(This->wineD3DSwapChain,
This->ddraw->d3d_window);
}
if (clipWindow)
wined3d_swapchain_set_window(This->wined3d_swapchain, clipWindow);
else
wined3d_swapchain_set_window(This->wined3d_swapchain, This->ddraw->d3d_window);
}
LeaveCriticalSection(&ddraw_cs);
......
......@@ -282,7 +282,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
}
static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **wined3d_swapchain)
WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **wined3d_swapchain)
{
struct dxgi_swapchain *object;
HRESULT hr;
......
......@@ -126,7 +126,7 @@ struct dxgi_swapchain
{
const struct IDXGISwapChainVtbl *vtbl;
LONG refcount;
IWineD3DSwapChain *wined3d_swapchain;
struct wined3d_swapchain *wined3d_swapchain;
};
HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device,
......
......@@ -162,7 +162,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain)
{
WINED3DPRESENT_PARAMETERS present_parameters;
IWineD3DSwapChain *wined3d_swapchain;
struct wined3d_swapchain *wined3d_swapchain;
IWineD3DDevice *wined3d_device;
IWineDXGIDevice *dxgi_device;
UINT count;
......@@ -235,8 +235,8 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
return hr;
}
*swapchain = IWineD3DSwapChain_GetParent(wined3d_swapchain);
IUnknown_Release(wined3d_swapchain);
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
wined3d_swapchain_decref(wined3d_swapchain);
/* FIXME? The swapchain is created with refcount 1 by the wined3d device,
* but the wined3d device can't hold a real reference. */
......
......@@ -54,7 +54,7 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface)
TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1)
IWineD3DSwapChain_AddRef(This->wined3d_swapchain);
wined3d_swapchain_incref(This->wined3d_swapchain);
return refcount;
}
......@@ -73,19 +73,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
FIXME("Only a single swapchain is supported\n");
hr = IWineD3DSwapChain_GetDevice(This->wined3d_swapchain, &wined3d_device);
wined3d_device = wined3d_swapchain_get_device(This->wined3d_swapchain);
hr = IWineD3DDevice_Uninit3D(wined3d_device);
if (FAILED(hr))
{
ERR("Failed to get the wined3d device, hr %#x\n", hr);
}
else
{
hr = IWineD3DDevice_Uninit3D(wined3d_device);
IWineD3DDevice_Release(wined3d_device);
if (FAILED(hr))
{
ERR("Uninit3D failed, hr %#x\n", hr);
}
ERR("Uninit3D failed, hr %#x\n", hr);
}
}
......@@ -145,7 +137,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, U
if (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval);
if (flags) FIXME("Unimplemented flags %#x\n", flags);
return IWineD3DSwapChain_Present(This->wined3d_swapchain, NULL, NULL, NULL, NULL, 0);
return wined3d_swapchain_present(This->wined3d_swapchain, NULL, NULL, NULL, NULL, 0);
}
static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
......@@ -161,7 +153,8 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
EnterCriticalSection(&dxgi_cs);
hr = IWineD3DSwapChain_GetBackBuffer(This->wined3d_swapchain, buffer_idx, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
buffer_idx, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
if (FAILED(hr))
{
LeaveCriticalSection(&dxgi_cs);
......
......@@ -1326,7 +1326,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface,
if (iSwapChain < This->swapchain_count)
{
*pSwapChain = (IWineD3DSwapChain *)This->swapchains[iSwapChain];
IWineD3DSwapChain_AddRef(*pSwapChain);
wined3d_swapchain_incref(*pSwapChain);
TRACE("(%p) returning %p\n", This, *pSwapChain);
return WINED3D_OK;
} else {
......@@ -2065,9 +2065,7 @@ err_out:
}
This->palette_count = 0;
if (swapchain)
{
IWineD3DSwapChain_Release( (IWineD3DSwapChain *) swapchain);
}
wined3d_swapchain_decref(swapchain);
if (This->stateBlock)
{
wined3d_stateblock_decref(This->stateBlock);
......@@ -2113,7 +2111,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_InitGDI(IWineD3DDevice *iface,
return WINED3D_OK;
err_out:
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
wined3d_swapchain_decref(swapchain);
return hr;
}
......@@ -2265,10 +2263,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface)
for (i = 0; i < This->swapchain_count; ++i)
{
TRACE("Releasing the implicit swapchain %u.\n", i);
if (IWineD3DSwapChain_Release((IWineD3DSwapChain *)This->swapchains[i]))
{
FIXME("(%p) Something's still holding the implicit swapchain\n", This);
}
if (wined3d_swapchain_decref(This->swapchains[i]))
FIXME("Something's still holding the implicit swapchain.\n");
}
HeapFree(GetProcessHeap(), 0, This->swapchains);
......@@ -2297,10 +2293,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface)
for (i = 0; i < This->swapchain_count; ++i)
{
TRACE("Releasing the implicit swapchain %u.\n", i);
if (IWineD3DSwapChain_Release((IWineD3DSwapChain *)This->swapchains[i]))
{
FIXME("(%p) Something's still holding the implicit swapchain\n", This);
}
if (wined3d_swapchain_decref(This->swapchains[i]))
FIXME("Something's still holding the implicit swapchain.\n");
}
HeapFree(GetProcessHeap(), 0, This->swapchains);
......@@ -4635,8 +4629,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UI
return hr;
}
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, backbuffer_idx, backbuffer_type, backbuffer);
IWineD3DSwapChain_Release(swapchain);
hr = wined3d_swapchain_get_back_buffer(swapchain, backbuffer_idx, backbuffer_type, backbuffer);
wined3d_swapchain_decref(swapchain);
if (FAILED(hr))
{
WARN("Failed to get backbuffer %u, hr %#x.\n", backbuffer_idx, hr);
......@@ -4662,13 +4656,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface, U
if(iSwapChain > 0) {
hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapChain);
if (hr == WINED3D_OK) {
hr = IWineD3DSwapChain_GetDisplayMode(swapChain, pMode);
IWineD3DSwapChain_Release(swapChain);
} else {
if (SUCCEEDED(hr))
{
hr = wined3d_swapchain_get_display_mode(swapChain, pMode);
wined3d_swapchain_decref(swapChain);
}
else
{
FIXME("(%p) Error getting display mode\n", This);
}
} else {
}
else
{
/* Don't read the real display mode,
but return the stored mode instead. X11 can't change the color
depth, and some apps are pretty angry if they SetDisplayMode from
......@@ -4790,8 +4789,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface, const RE
for (i = 0; i < device->swapchain_count; ++i)
{
IWineD3DSwapChain_Present((IWineD3DSwapChain *)device->swapchains[i],
src_rect, dst_rect, dst_window_override, dirty_region, 0);
wined3d_swapchain_present(device->swapchains[i], src_rect,
dst_rect, dst_window_override, dirty_region, 0);
}
return WINED3D_OK;
......@@ -5238,8 +5237,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *ifac
hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
if (FAILED(hr)) return hr;
hr = IWineD3DSwapChain_GetFrontBufferData(swapchain, dst_surface);
IWineD3DSwapChain_Release(swapchain);
hr = wined3d_swapchain_get_front_buffer_data(swapchain, dst_surface);
wined3d_swapchain_decref(swapchain);
return hr;
}
......@@ -5471,8 +5470,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface,
return hr;
}
hr = IWineD3DSwapChain_GetRasterStatus(swapchain, raster_status);
IWineD3DSwapChain_Release(swapchain);
hr = wined3d_swapchain_get_raster_status(swapchain, raster_status);
wined3d_swapchain_decref(swapchain);
if (FAILED(hr))
{
WARN("Failed to get raster status, hr %#x.\n", hr);
......@@ -6400,7 +6399,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
WARN("Rejecting Reset() call because the requested display mode is not supported\n");
WARN("Requested mode: %d, %d\n", pPresentationParameters->BackBufferWidth,
pPresentationParameters->BackBufferHeight);
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
wined3d_swapchain_decref(swapchain);
return WINED3DERR_INVALIDCALL;
}
......@@ -6460,10 +6459,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
pPresentationParameters->MultiSampleQuality,
FALSE,
(IWineD3DSurface **)&This->auto_depth_stencil);
if (FAILED(hrc)) {
ERR("Failed to create the depth stencil buffer\n");
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
if (FAILED(hrc))
{
ERR("Failed to create the depth stencil buffer.\n");
wined3d_swapchain_decref(swapchain);
return WINED3DERR_INVALIDCALL;
}
}
......@@ -6514,7 +6513,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
hr = updateSurfaceDesc(swapchain->front_buffer, pPresentationParameters);
if(FAILED(hr))
{
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
wined3d_swapchain_decref(swapchain);
return hr;
}
......@@ -6523,7 +6522,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
hr = updateSurfaceDesc(swapchain->back_buffers[i], pPresentationParameters);
if(FAILED(hr))
{
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
wined3d_swapchain_decref(swapchain);
return hr;
}
}
......@@ -6532,7 +6531,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
hr = updateSurfaceDesc(This->auto_depth_stencil, pPresentationParameters);
if(FAILED(hr))
{
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
wined3d_swapchain_decref(swapchain);
return hr;
}
}
......@@ -6555,7 +6554,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(iface, focus_window)))
{
ERR("Failed to acquire focus window, hr %#x.\n", hr);
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
wined3d_swapchain_decref(swapchain);
return hr;
}
......@@ -6634,7 +6633,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
}
hr = create_primary_opengl_context(This, swapchain);
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
wined3d_swapchain_decref(swapchain);
/* All done. There is no need to reload resources or shaders, this will happen automatically on the
* first use
......@@ -6667,10 +6666,10 @@ static void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice *iface,
TRACE("Relaying to swapchain\n");
if (IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain) == WINED3D_OK)
if (SUCCEEDED(IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain)))
{
IWineD3DSwapChain_SetGammaRamp(swapchain, flags, pRamp);
IWineD3DSwapChain_Release(swapchain);
wined3d_swapchain_set_gamma_ramp(swapchain, flags, pRamp);
wined3d_swapchain_decref(swapchain);
}
}
......@@ -6679,9 +6678,10 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i
TRACE("Relaying to swapchain\n");
if (IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain) == WINED3D_OK) {
IWineD3DSwapChain_GetGammaRamp(swapchain, pRamp);
IWineD3DSwapChain_Release(swapchain);
if (SUCCEEDED(IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain)))
{
wined3d_swapchain_get_gamma_ramp(swapchain, pRamp);
wined3d_swapchain_decref(swapchain);
}
}
......
......@@ -1287,7 +1287,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
hr = IWineD3DDevice_GetSwapChain((IWineD3DDevice *)device, 0, &swapchain);
if (SUCCEEDED(hr) && swapchain)
{
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
hr = wined3d_swapchain_get_back_buffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
if (SUCCEEDED(hr) && backbuffer)
{
struct wined3d_resource_desc desc;
......@@ -1310,7 +1310,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
state->viewport.MinZ = 0.0f;
state->viewport.MaxZ = 1.0f;
IWineD3DSwapChain_Release(swapchain);
wined3d_swapchain_decref(swapchain);
}
TRACE("Done.\n");
......
......@@ -2897,9 +2897,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS
else
swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_FOUR;
/* Flipping a OpenGL surface -> Use WineD3DDevice::Present */
return IWineD3DSwapChain_Present((IWineD3DSwapChain *)swapchain,
NULL, NULL, swapchain->win_handle, NULL, 0);
/* Flipping a OpenGL surface -> present. */
return wined3d_swapchain_present(swapchain, NULL, NULL, swapchain->win_handle, NULL, 0);
}
/* Does a direct frame buffer -> texture copy. Stretching is done
......@@ -3795,9 +3794,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
dstSwapchain->presentParms.SwapEffect = WINED3DSWAPEFFECT_COPY;
dstSwapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_IMMEDIATE;
TRACE("Full screen back buffer -> front buffer blt, performing a flip instead\n");
IWineD3DSwapChain_Present((IWineD3DSwapChain *)dstSwapchain,
NULL, NULL, dstSwapchain->win_handle, NULL, 0);
TRACE("Full screen back buffer -> front buffer blt, performing a flip instead.\n");
wined3d_swapchain_present(dstSwapchain, NULL, NULL, dstSwapchain->win_handle, NULL, 0);
dstSwapchain->presentParms.SwapEffect = orig_swap;
......
......@@ -223,8 +223,7 @@ static HRESULT WINAPI IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS
}
swapchain = surface->container.u.swapchain;
hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *)swapchain,
NULL, NULL, swapchain->win_handle, NULL, 0);
hr = wined3d_swapchain_present(swapchain, NULL, NULL, swapchain->win_handle, NULL, 0);
return hr;
}
......
......@@ -77,6 +77,20 @@
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_swapchain_decref(ptr)
@ cdecl wined3d_swapchain_get_back_buffer(ptr long long ptr)
@ cdecl wined3d_swapchain_get_device(ptr)
@ cdecl wined3d_swapchain_get_display_mode(ptr ptr)
@ cdecl wined3d_swapchain_get_front_buffer_data(ptr ptr)
@ cdecl wined3d_swapchain_get_gamma_ramp(ptr ptr)
@ cdecl wined3d_swapchain_get_parent(ptr)
@ cdecl wined3d_swapchain_get_present_parameters(ptr ptr)
@ cdecl wined3d_swapchain_get_raster_status(ptr ptr)
@ cdecl wined3d_swapchain_incref(ptr)
@ cdecl wined3d_swapchain_present(ptr ptr ptr ptr ptr long)
@ cdecl wined3d_swapchain_set_gamma_ramp(ptr long ptr)
@ cdecl wined3d_swapchain_set_window(ptr ptr)
@ cdecl wined3d_texture_add_dirty_region(ptr long ptr)
@ cdecl wined3d_texture_decref(ptr)
@ cdecl wined3d_texture_free_private_data(ptr ptr)
......
......@@ -54,7 +54,8 @@
typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
typedef struct wined3d_swapchain IWineD3DSwapChainImpl;
typedef struct wined3d_swapchain IWineD3DSwapChain;
/* Texture format fixups */
......@@ -2015,7 +2016,7 @@ struct wined3d_subresource_container
enum wined3d_container_type type;
union
{
struct IWineD3DSwapChainImpl *swapchain;
struct wined3d_swapchain *swapchain;
struct wined3d_texture *texture;
void *base;
} u;
......@@ -2519,44 +2520,40 @@ void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
struct wined3d_swapchain_ops
{
HRESULT (*swapchain_present)(struct IWineD3DSwapChainImpl *swapchain, const RECT *src_rect,
HRESULT (*swapchain_present)(struct wined3d_swapchain *swapchain, const RECT *src_rect,
const RECT *dst_rect, const RGNDATA *dirty_region, DWORD flags);
};
struct IWineD3DSwapChainImpl
struct wined3d_swapchain
{
/*IUnknown part*/
const IWineD3DSwapChainVtbl *lpVtbl;
LONG ref; /* Note: Ref counting not required */
LONG ref;
void *parent;
const struct wined3d_parent_ops *parent_ops;
const struct wined3d_swapchain_ops *swapchain_ops;
IWineD3DDeviceImpl *device;
/* IWineD3DSwapChain fields */
IWineD3DSurfaceImpl **back_buffers;
IWineD3DSurfaceImpl *front_buffer;
WINED3DPRESENT_PARAMETERS presentParms;
DWORD orig_width, orig_height;
DWORD orig_width, orig_height;
enum wined3d_format_id orig_fmt;
WINED3DGAMMARAMP orig_gamma;
BOOL render_to_fbo;
WINED3DGAMMARAMP orig_gamma;
BOOL render_to_fbo;
const struct wined3d_format *ds_format;
LONG prev_time, frames; /* Performance tracking */
unsigned int vSyncCounter;
struct wined3d_context **context;
unsigned int num_contexts;
unsigned int num_contexts;
HWND win_handle;
HWND win_handle;
HWND device_window;
};
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc) DECLSPEC_HIDDEN;
struct wined3d_context *swapchain_get_context(struct IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters,
void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
......
......@@ -2088,7 +2088,6 @@ struct wined3d_parent_ops
interface IWineD3DSurface;
interface IWineD3DVolume;
interface IWineD3DSwapChain;
interface IWineD3DDevice;
struct wined3d;
struct wined3d_buffer;
......@@ -2099,6 +2098,7 @@ struct wined3d_resource;
struct wined3d_rendertarget_view;
struct wined3d_shader;
struct wined3d_stateblock;
struct wined3d_swapchain;
struct wined3d_texture;
struct wined3d_vertex_declaration;
......@@ -2159,7 +2159,7 @@ interface IWineD3DDeviceParent : IUnknown
HRESULT CreateSwapChain(
[in, out] WINED3DPRESENT_PARAMETERS *present_parameters,
[out] IWineD3DSwapChain **swapchain
[out] struct wined3d_swapchain **swapchain
);
}
typedef HRESULT (__stdcall *D3DCB_ENUMRESOURCES)(struct wined3d_resource *resource, void *pData);
......@@ -2328,52 +2328,6 @@ interface IWineD3DVolume : IWineD3DResource
[
object,
local,
uuid(34d01b10-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DSwapChain : IWineD3DBase
{
HRESULT GetDevice(
[out] IWineD3DDevice **device
);
HRESULT Present(
[in] const RECT *src_rect,
[in] const RECT *dst_rect,
[in] HWND dst_window_override,
[in] const RGNDATA *dirty_region,
[in] DWORD flags
);
HRESULT SetDestWindowOverride(
[in] HWND window
);
HRESULT GetFrontBufferData(
[in] IWineD3DSurface *dst_surface
);
HRESULT GetBackBuffer(
[in] UINT backbuffer_idx,
[in] WINED3DBACKBUFFER_TYPE backbuffer_type,
[out] IWineD3DSurface **backbuffer
);
HRESULT GetRasterStatus(
[out] WINED3DRASTER_STATUS *raster_status
);
HRESULT GetDisplayMode(
[out] WINED3DDISPLAYMODE *mode
);
HRESULT GetPresentParameters(
[out] WINED3DPRESENT_PARAMETERS *present_parameters
);
HRESULT SetGammaRamp(
[in] DWORD flags,
[in] const WINED3DGAMMARAMP *ramp
);
HRESULT GetGammaRamp(
[out] WINED3DGAMMARAMP *ramp
);
}
[
object,
local,
uuid(6d10a2ce-09d0-4a53-a427-11388f9f8ca5)
]
interface IWineD3DDevice : IUnknown
......@@ -2479,7 +2433,7 @@ interface IWineD3DDevice : IUnknown
[in] WINED3DSURFTYPE surface_type,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DSwapChain **swapchain
[out] struct wined3d_swapchain **swapchain
);
HRESULT CreateVertexDeclaration(
[in] const WINED3DVERTEXELEMENT *elements,
......@@ -2568,7 +2522,7 @@ interface IWineD3DDevice : IUnknown
);
HRESULT GetSwapChain(
[in] UINT swapchain_idx,
[out] IWineD3DSwapChain **swapchain
[out] struct wined3d_swapchain **swapchain
);
HRESULT Reset(
[in] WINED3DPRESENT_PARAMETERS *present_parameters
......@@ -3078,6 +3032,29 @@ HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_swapchain_decref(struct wined3d_swapchain *swapchain);
HRESULT __cdecl wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain,
UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, IWineD3DSurface **backbuffer);
IWineD3DDevice * __cdecl wined3d_swapchain_get_device(const struct wined3d_swapchain *swapchain);
HRESULT __cdecl wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain,
WINED3DDISPLAYMODE *mode);
HRESULT __cdecl wined3d_swapchain_get_front_buffer_data(const struct wined3d_swapchain *swapchain,
IWineD3DSurface *dst_surface);
HRESULT __cdecl wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain,
WINED3DGAMMARAMP *ramp);
void * __cdecl wined3d_swapchain_get_parent(const struct wined3d_swapchain *swapchain);
HRESULT __cdecl wined3d_swapchain_get_present_parameters(const struct wined3d_swapchain *swapchain,
WINED3DPRESENT_PARAMETERS *present_parameters);
HRESULT __cdecl wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain,
WINED3DRASTER_STATUS *raster_status);
ULONG __cdecl wined3d_swapchain_incref(struct wined3d_swapchain *swapchain);
HRESULT __cdecl wined3d_swapchain_present(struct wined3d_swapchain *swapchain,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
const RGNDATA *dirty_region, DWORD flags);
HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain,
DWORD flags, const WINED3DGAMMARAMP *ramp);
HRESULT __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window);
HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
UINT layer, const WINED3DBOX *dirty_region);
ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
......
......@@ -55,6 +55,6 @@ interface IWineDXGIDevice : IDXGIDevice
);
HRESULT create_swapchain(
[in] struct _WINED3DPRESENT_PARAMETERS *present_parameters,
[out] struct IWineD3DSwapChain **wined3d_swapchain
[out] struct wined3d_swapchain **wined3d_swapchain
);
}
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