Commit 227efbbf authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store a pointer to an array of IWineD3DSwapChainImpl pointers in the device.

parent 6f95f05a
......@@ -1877,7 +1877,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
}
else
{
IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[0];
IWineD3DSwapChainImpl *swapchain = This->swapchains[0];
if (swapchain->back_buffers) target = swapchain->back_buffers[0];
else target = swapchain->front_buffer;
}
......@@ -1904,7 +1904,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
if (current_context && current_context->swapchain->device == This)
context = current_context;
else
context = swapchain_get_context((IWineD3DSwapChainImpl *)This->swapchains[0]);
context = swapchain_get_context(This->swapchains[0]);
}
context_validate(context);
......
......@@ -1305,8 +1305,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, U
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : swapchain %d\n", This, iSwapChain);
if(iSwapChain < This->NumberOfSwapChains) {
*pSwapChain = This->swapchains[iSwapChain];
if (iSwapChain < This->NumberOfSwapChains)
{
*pSwapChain = (IWineD3DSwapChain *)This->swapchains[iSwapChain];
IWineD3DSwapChain_AddRef(*pSwapChain);
TRACE("(%p) returning %p\n", This, *pSwapChain);
return WINED3D_OK;
......@@ -1939,12 +1940,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
}
This->NumberOfSwapChains = 1;
This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
if(!This->swapchains) {
This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(*This->swapchains));
if (!This->swapchains)
{
ERR("Out of memory!\n");
goto err_out;
}
This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
This->swapchains[0] = swapchain;
if (swapchain->back_buffers && swapchain->back_buffers[0])
{
......@@ -2079,12 +2081,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_InitGDI(IWineD3DDevice *iface,
}
This->NumberOfSwapChains = 1;
This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
if(!This->swapchains) {
This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(*This->swapchains));
if (!This->swapchains)
{
ERR("Out of memory!\n");
goto err_out;
}
This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
This->swapchains[0] = swapchain;
return WINED3D_OK;
err_out:
......@@ -2227,9 +2230,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
context_release(context);
for(i=0; i < This->NumberOfSwapChains; i++) {
TRACE("Releasing the implicit swapchain %d\n", i);
if (D3DCB_DestroySwapChain(This->swapchains[i]) > 0) {
for (i = 0; i < This->NumberOfSwapChains; ++i)
{
TRACE("Releasing the implicit swapchain %u.\n", i);
if (D3DCB_DestroySwapChain((IWineD3DSwapChain *)This->swapchains[i]) > 0)
{
FIXME("(%p) Something's still holding the implicit swapchain\n", This);
}
}
......@@ -2255,9 +2260,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface, D3DCB_
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
unsigned int i;
for(i=0; i < This->NumberOfSwapChains; i++) {
TRACE("Releasing the implicit swapchain %d\n", i);
if (D3DCB_DestroySwapChain(This->swapchains[i]) > 0) {
for (i = 0; i < This->NumberOfSwapChains; ++i)
{
TRACE("Releasing the implicit swapchain %u.\n", i);
if (D3DCB_DestroySwapChain((IWineD3DSwapChain *)This->swapchains[i]) > 0)
{
FIXME("(%p) Something's still holding the implicit swapchain\n", This);
}
}
......@@ -5820,7 +5827,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *
if (This->depth_stencil)
{
if (((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
if (This->swapchains[0]->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
|| This->depth_stencil->flags & SFLAG_DISCARD)
{
surface_modify_ds_location(This->depth_stencil, SFLAG_DS_DISCARDED,
......
......@@ -2014,7 +2014,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHD
} else {
IWineD3DSurfaceImpl *dds_primary;
IWineD3DSwapChainImpl *swapchain;
swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[0];
swapchain = This->resource.device->swapchains[0];
dds_primary = swapchain->front_buffer;
if (dds_primary && dds_primary->palette)
pal = dds_primary->palette->palents;
......
......@@ -266,7 +266,7 @@ static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHD
} else {
IWineD3DSurfaceImpl *dds_primary;
IWineD3DSwapChainImpl *swapchain;
swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[0];
swapchain = This->resource.device->swapchains[0];
dds_primary = swapchain->front_buffer;
if (dds_primary && dds_primary->palette)
pal = dds_primary->palette->palents;
......
......@@ -1707,7 +1707,7 @@ struct IWineD3DDeviceImpl
WINED3DDEVTYPE devType;
HWND focus_window;
IWineD3DSwapChain **swapchains;
IWineD3DSwapChainImpl **swapchains;
UINT NumberOfSwapChains;
struct list resources; /* a linked list to track resources created by the device */
......
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