From e2457ea7b916b1dca8c4e4a472dcb966a33303f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Thu, 17 Dec 2009 20:07:30 +0100 Subject: [PATCH 03/20] DDraw: Recreate surfaces after switching the implementation --- dlls/ddraw/ddraw.c | 2 +- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/surface.c | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 527f448..57d8b75 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -1700,7 +1700,7 @@ IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf, * new WineD3DSurface, copies the content and releases the old surface * *****************************************************************************/ -static HRESULT +HRESULT IDirectDrawImpl_RecreateAllSurfaces(IDirectDrawImpl *This) { DDSURFACEDESC2 desc; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index d6f4a57..a117536 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -195,6 +195,7 @@ void IDirectDrawImpl_Destroy(IDirectDrawImpl *This) DECLSPEC_HIDDEN; HRESULT WINAPI IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf, DDSURFACEDESC2 *desc, void *Context) DECLSPEC_HIDDEN; IWineD3DVertexDeclaration *IDirectDrawImpl_FindDecl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN; +HRESULT IDirectDrawImpl_RecreateAllSurfaces(IDirectDrawImpl *This); static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface) { diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index bfe83a4..86bcc02 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -290,6 +290,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface) IDirectDrawImpl *ddraw; IUnknown *ifaceToRelease = This->ifaceToRelease; UINT i; + BOOL recreate_surfaces = FALSE; /* Complex attached surfaces are destroyed implicitly when the root is released */ EnterCriticalSection(&ddraw_cs); @@ -355,10 +356,16 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface) /* Reset to the default surface implementation type. This is needed if apps use * non render target surfaces and expect blits to work after destroying the render * target. - * - * TODO: Recreate existing offscreen surfaces */ - ddraw->ImplType = DefaultSurfaceType; + if(DefaultSurfaceType == SURFACE_UNKNOWN) + { + ddraw->ImplType = SURFACE_GDI; + } + else + { + ddraw->ImplType = DefaultSurfaceType; + } + recreate_surfaces = TRUE; /* Write a trace because D3D unloading was the reason for many * crashes during development. @@ -393,6 +400,11 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface) */ IDirectDrawSurfaceImpl_Destroy(This); + if(recreate_surfaces) + { + IDirectDrawImpl_RecreateAllSurfaces(ddraw); + } + /* Reduce the ddraw refcount */ if(ifaceToRelease) IUnknown_Release(ifaceToRelease); LeaveCriticalSection(&ddraw_cs); -- 1.6.4.4