[PATCH] d3d: Do not restore the display mode in ddraw=0A=

Stefan Doesinger stefan at codeweavers.com
Sat Nov 1 22:35:23 CDT 2008


=0A=
If the primary surface is destroyed in DirectDraw, the display=0A=
mode is not reset. The application has to do that manually using=0A=
RestoreDisplayMode, or the mode is restored when the ddraw=0A=
interface is destroyed. This patch stops wined3d from interfering=0A=
with the application's display mode when the primary surface is=0A=
destroyed.=0A=
=0A=
I cannot handle this with a RestoreDisplayMode swapchain method=0A=
because we want to restore the display mode after unloading=0A=
opengl. But in d3d8/d3d9 unloading opengl is done with the=0A=
release call(or rather, Uninit3D), which also destroys the=0A=
swapchain, we can't do that. Instead I am using a swapchain=0A=
parameter for this.=0A=
---=0A=
 dlls/d3d8/device.c           |    2 ++=0A=
 dlls/d3d8/directx.c          |    1 +=0A=
 dlls/d3d9/device.c           |    1 +=0A=
 dlls/d3d9/directx.c          |    1 +=0A=
 dlls/wined3d/swapchain.c     |    2 +-=0A=
 dlls/wined3d/swapchain_gdi.c |    2 +-=0A=
 include/wine/wined3d_types.h |    1 +=0A=
 7 files changed, 8 insertions(+), 2 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c=0A=
index 04f56b8..e8df4f0 100644=0A=
--- a/dlls/d3d8/device.c=0A=
+++ b/dlls/d3d8/device.c=0A=
@@ -305,6 +305,7 @@ static HRESULT WINAPI =
IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DD=0A=
     localParameters.Flags                                       =3D =
pPresentationParameters->Flags;=0A=
     localParameters.FullScreen_RefreshRateInHz                  =3D =
pPresentationParameters->FullScreen_RefreshRateInHz;=0A=
     localParameters.PresentationInterval                        =3D =
pPresentationParameters->FullScreen_PresentationInterval;=0A=
+    localParameters.AutoRestoreDisplayMode                      =3D =
TRUE;=0A=
 =0A=
     EnterCriticalSection(&d3d8_cs);=0A=
     hrc =3D IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, =
&localParameters, &object->wineD3DSwapChain, (IUnknown*)object, =
D3D8CB_CreateRenderTarget, D3D8CB_CreateDepthStencilSurface, =
SURFACE_OPENGL);=0A=
@@ -358,6 +359,7 @@ static HRESULT WINAPI =
IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRE=0A=
     localParameters.Flags                                       =3D =
pPresentationParameters->Flags;=0A=
     localParameters.FullScreen_RefreshRateInHz                  =3D =
pPresentationParameters->FullScreen_RefreshRateInHz;=0A=
     localParameters.PresentationInterval                        =3D =
pPresentationParameters->FullScreen_PresentationInterval;=0A=
+    localParameters.AutoRestoreDisplayMode                      =3D =
TRUE;=0A=
 =0A=
     EnterCriticalSection(&d3d8_cs);=0A=
     hr =3D IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);=0A=
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c=0A=
index afcb0fe..3efbab0 100644=0A=
--- a/dlls/d3d8/directx.c=0A=
+++ b/dlls/d3d8/directx.c=0A=
@@ -444,6 +444,7 @@ static HRESULT WINAPI =
IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte=0A=
     localParameters.Flags                                       =3D =
pPresentationParameters->Flags;=0A=
     localParameters.FullScreen_RefreshRateInHz                  =3D =
pPresentationParameters->FullScreen_RefreshRateInHz;=0A=
     localParameters.PresentationInterval                        =3D =
pPresentationParameters->FullScreen_PresentationInterval;=0A=
+    localParameters.AutoRestoreDisplayMode                      =3D =
TRUE;=0A=
 =0A=
     if(BehaviourFlags & D3DCREATE_MULTITHREADED) {=0A=
         IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);=0A=
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c=0A=
index 8aab230..426c8ab 100644=0A=
--- a/dlls/d3d9/device.c=0A=
+++ b/dlls/d3d9/device.c=0A=
@@ -376,6 +376,7 @@ static HRESULT  WINAPI  =
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3=0A=
     localParameters.Flags                               =3D =
pPresentationParameters->Flags;=0A=
     localParameters.FullScreen_RefreshRateInHz          =3D =
pPresentationParameters->FullScreen_RefreshRateInHz;=0A=
     localParameters.PresentationInterval                =3D =
pPresentationParameters->PresentationInterval;=0A=
+    localParameters.AutoRestoreDisplayMode              =3D TRUE;=0A=
 =0A=
     EnterCriticalSection(&d3d9_cs);=0A=
     hr =3D IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);=0A=
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c=0A=
index b605f44..b44c632 100644=0A=
--- a/dlls/d3d9/directx.c=0A=
+++ b/dlls/d3d9/directx.c=0A=
@@ -515,6 +515,7 @@ static HRESULT WINAPI =
IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap=0A=
     localParameters.Flags                               =3D =
pPresentationParameters->Flags;=0A=
     localParameters.FullScreen_RefreshRateInHz          =3D =
pPresentationParameters->FullScreen_RefreshRateInHz;=0A=
     localParameters.PresentationInterval                =3D =
pPresentationParameters->PresentationInterval;=0A=
+    localParameters.AutoRestoreDisplayMode              =3D TRUE;=0A=
 =0A=
     if(BehaviourFlags & D3DCREATE_MULTITHREADED) {=0A=
         IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);=0A=
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c=0A=
index 74e1cf6..6f4393a 100644=0A=
--- a/dlls/wined3d/swapchain.c=0A=
+++ b/dlls/wined3d/swapchain.c=0A=
@@ -72,7 +72,7 @@ static void WINAPI =
IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB=0A=
      * this will be the original desktop resolution. In case of d3d7 =
this will be a NOP because ddraw sets the resolution=0A=
      * before starting up Direct3D, thus orig_width and orig_height =
will be equal to the modes in the presentation params=0A=
      */=0A=
-    if(This->presentParms.Windowed =3D=3D FALSE) {=0A=
+    if(This->presentParms.Windowed =3D=3D FALSE && =
This->presentParms.AutoRestoreDisplayMode) {=0A=
         mode.Width =3D This->orig_width;=0A=
         mode.Height =3D This->orig_height;=0A=
         mode.RefreshRate =3D 0;=0A=
diff --git a/dlls/wined3d/swapchain_gdi.c b/dlls/wined3d/swapchain_gdi.c=0A=
index f0ec4f2..f634e50 100644=0A=
--- a/dlls/wined3d/swapchain_gdi.c=0A=
+++ b/dlls/wined3d/swapchain_gdi.c=0A=
@@ -59,7 +59,7 @@ static void WINAPI =
IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB=0A=
      * this will be the original desktop resolution. In case of d3d7 =
this will be a NOP because ddraw sets the resolution=0A=
      * before starting up Direct3D, thus orig_width and orig_height =
will be equal to the modes in the presentation params=0A=
      */=0A=
-    if(This->presentParms.Windowed =3D=3D FALSE) {=0A=
+    if(This->presentParms.Windowed =3D=3D FALSE && =
This->presentParms.AutoRestoreDisplayMode) {=0A=
         mode.Width =3D This->orig_width;=0A=
         mode.Height =3D This->orig_height;=0A=
         mode.RefreshRate =3D 0;=0A=
diff --git a/include/wine/wined3d_types.h b/include/wine/wined3d_types.h=0A=
index 4ccbcab..28e5525 100644=0A=
--- a/include/wine/wined3d_types.h=0A=
+++ b/include/wine/wined3d_types.h=0A=
@@ -886,6 +886,7 @@ typedef struct _WINED3DPRESENT_PARAMETERS {=0A=
     DWORD                   Flags;=0A=
     UINT                    FullScreen_RefreshRateInHz;=0A=
     UINT                    PresentationInterval;=0A=
+    BOOL                    AutoRestoreDisplayMode;=0A=
 } WINED3DPRESENT_PARAMETERS;=0A=
 =0A=
 #define WINED3DPRESENTFLAG_LOCKABLE_BACKBUFFER  0x00000001=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_0015_01C93C7C.23DE6B00--




More information about the wine-patches mailing list