Fix Using DDraw to Access the Desktop

Christian Costa titan.costa at wanadoo.fr
Thu Aug 4 08:46:10 CDT 2005


Hi Rob (and Lionel),

While debugging a game where there is the same problem, I did exactly 
the same fix.
However, although this works, it is horribly slow. Do you have the same 
issue?
Maybe this is the reason this was commented out.
I wonder if SYNC_UPDATE and OWN_WINDOW stuff has been written to 
workaround this.
There is not comment about that and the code is from transgaming and 
rather old so I don't know.
Lionel do you remember something about that?

Robert Shearman wrote:

> Hi,
>
> Previously, using ddraw to write to a small area of the desktop (or 
> even none at all) would cause the screen to go black because the 
> contents of the screen wasn't copied to the surface before the surface 
> was copied back to the screen. This patch fixes that.
>
> Changelog:
> Copy the current contents of the DC to the surface on locking so that 
> when it is used to write to the desktop then the previous contents 
> plus the updates are correctly written out.
>
>------------------------------------------------------------------------
>
>Index: dlls/ddraw/surface_user.c
>===================================================================
>RCS file: /home/wine/wine/dlls/ddraw/surface_user.c,v
>retrieving revision 1.1
>diff -u -p -r1.1 surface_user.c
>--- dlls/ddraw/surface_user.c	5 Jun 2005 17:50:49 -0000	1.1
>+++ dlls/ddraw/surface_user.c	25 Jul 2005 14:45:32 -0000
>@@ -47,6 +47,7 @@ static void User_destroy_own_window(IDir
> static DWORD CALLBACK User_update_thread(LPVOID);
> #endif
> static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc);
>+static void User_copy_from_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc);
> 
> static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt);
> 
>@@ -224,10 +225,8 @@ static void User_DirectDrawSurface_wait_
> void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
> 					LPCRECT pRect, DWORD dwFlags)
> {
>-#if 0
>     if (!(dwFlags & DDLOCK_WRITEONLY))
> 	User_copy_from_screen(This, pRect);
>-#endif
>     if (dwFlags & DDLOCK_WAIT) User_DirectDrawSurface_wait_update(This);
> 
>     if (pRect) {
>@@ -594,7 +593,6 @@ static void User_copy_to_screen(IDirectD
>     }
> }
> 
>-#if 0
> static void User_copy_from_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
> {
>     if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
>@@ -603,6 +601,13 @@ static void User_copy_from_screen(IDirec
> 	HWND hDisplayWnd = get_display_window(This, &offset);
> 	HDC hDisplayDC = GetDC(hDisplayWnd);
> 	RECT drawrect;
>+	HDC hSurfaceDC;
>+
>+	if (FAILED(This->get_dc(This, &hSurfaceDC)))
>+	{
>+	    ReleaseDC(hDisplayWnd, hDisplayDC);
>+	    return;
>+	}
> 
> 	drawrect.left	= 0;
> 	drawrect.right	= This->surface_desc.dwWidth;
>@@ -611,7 +616,7 @@ static void User_copy_from_screen(IDirec
> 	if (rc)
> 	    IntersectRect(&drawrect,&drawrect,rc);
> 
>-	BitBlt(This->hDC,
>+	BitBlt(hSurfaceDC,
> 	    drawrect.left, drawrect.top,
> 	    drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
> 	    hDisplayDC,
>@@ -621,7 +626,6 @@ static void User_copy_from_screen(IDirec
> 	ReleaseDC(hDisplayWnd, hDisplayDC);
>     }
> }
>-#endif
> 
> static const IDirectDrawSurface7Vtbl User_IDirectDrawSurface7_VTable =
> {
>  
>






More information about the wine-devel mailing list