static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface) { IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; WINED3DDISPLAYMODE mode; TRACE("Destroying swapchain %p\n", iface); IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma); /* release the ref to the front and back buffer parents */ if (This->front_buffer) { surface_set_container(This->front_buffer, WINED3D_CONTAINER_NONE, NULL); if (IWineD3DSurface_Release((IWineD3DSurface *)This->front_buffer) > 0) { WARN("(%p) Something's still holding the front buffer\n",This); } } if (This->back_buffers) { UINT i; for (i = 0; i < This->presentParms.BackBufferCount; ++i) { surface_set_container(This->back_buffers[i], WINED3D_CONTAINER_NONE, NULL); if (IWineD3DSurface_Release((IWineD3DSurface *)This->back_buffers[i])) { WARN("(%p) Something's still holding the back buffer\n",This); } } HeapFree(GetProcessHeap(), 0, This->back_buffers); } /* Restore the screen resolution if we rendered in fullscreen * This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9 * this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution * before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params */ if (!This->presentParms.Windowed && This->presentParms.AutoRestoreDisplayMode) { mode.Width = This->orig_width; mode.Height = This->orig_height; mode.RefreshRate = 0; mode.Format = This->orig_fmt; IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode); } HeapFree(GetProcessHeap(), 0, This->context); HeapFree(GetProcessHeap(), 0, This); }
/*IWineD3DSwapChain parts follow: */ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface) { IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; WINED3DDISPLAYMODE mode; unsigned int i; TRACE("Destroying swapchain %p\n", iface); IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma); /* Release the swapchain's draw buffers. Make sure This->backBuffer[0] is * the last buffer to be destroyed, FindContext() depends on that. */ if (This->frontBuffer) { IWineD3DSurface_SetContainer(This->frontBuffer, 0); if (IWineD3DSurface_Release(This->frontBuffer)) { WARN("(%p) Something's still holding the front buffer (%p).\n", This, This->frontBuffer); } This->frontBuffer = NULL; } if (This->backBuffer) { i = This->presentParms.BackBufferCount; while (i--) { IWineD3DSurface_SetContainer(This->backBuffer[i], 0); if (IWineD3DSurface_Release(This->backBuffer[i])) WARN("(%p) Something's still holding back buffer %u (%p).\n", This, i, This->backBuffer[i]); } HeapFree(GetProcessHeap(), 0, This->backBuffer); This->backBuffer = NULL; } #ifndef VBOX_WINE_WITH_SINGLE_CONTEXT for (i = 0; i < This->num_contexts; ++i) { context_destroy(This->device, This->context[i]); } #endif #ifdef VBOX_WITH_WDDM if (This->presentRt) { IWineD3DSurfaceImpl *old = (IWineD3DSurfaceImpl*)This->presentRt; old->presentSwapchain = NULL; IWineD3DSurface_Release(This->presentRt); This->presentRt = NULL; } #endif IWineD3DDevice_RemoveSwapChain((IWineD3DDevice*)This->device, (IWineD3DSwapChain*)This); if (!This->device->NumberOfSwapChains) { /* Restore the screen resolution if we rendered in fullscreen * This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9 * this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution * before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params */ if(This->presentParms.Windowed == FALSE && This->presentParms.AutoRestoreDisplayMode) { mode.Width = This->orig_width; mode.Height = This->orig_height; mode.RefreshRate = 0; mode.Format = This->orig_fmt; IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode); } } #ifdef VBOX_WITH_WDDM if(This->win_handle) { VBoxExtWndDestroy(This->win_handle, This->hDC); swapchain_invalidate(This); } else { WARN("null win info"); } #else HeapFree(GetProcessHeap(), 0, This->context); #endif HeapFree(GetProcessHeap(), 0, This); }