From 52dddb8b40de5b165685a85a5b42e1dc3ae9fd31 Mon Sep 17 00:00:00 2001
From: Roderick Colenbrander <thunderbird2k@gmail.com>
Date: Mon, 12 Oct 2009 13:48:22 +0200
Subject: [PATCH] Add X11DRV_XRender_SetDeviceClipping for setting the clipping region of the Picture associated with a physDev.

---
 dlls/winex11.drv/graphics.c |    3 ++
 dlls/winex11.drv/x11drv.h   |    1 +
 dlls/winex11.drv/xrender.c  |   44 ++++++++++++++++++++++++++++--------------
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c
index af1e74c..22214e3 100644
--- a/dlls/winex11.drv/graphics.c
+++ b/dlls/winex11.drv/graphics.c
@@ -166,6 +166,9 @@ void CDECL X11DRV_SetDeviceClipping( X11DRV_PDEVICE *physDev, HRGN vis_rgn, HRGN
     XSetClipRectangles( gdi_display, physDev->gc, physDev->dc_rect.left, physDev->dc_rect.top,
                         (XRectangle *)data->Buffer, data->rdh.nCount, YXBanded );
     wine_tsx11_unlock();
+
+    if(physDev->xrender) X11DRV_XRender_SetDeviceClipping(physDev);
+
     HeapFree( GetProcessHeap(), 0, data );
 }
 
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index eee5849..4c8fbc9 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -281,6 +281,7 @@ extern int using_client_side_fonts;
 extern void X11DRV_XRender_Init(void);
 extern void X11DRV_XRender_Finalize(void);
 extern BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE*, HFONT);
+extern void X11DRV_XRender_SetDeviceClipping(X11DRV_PDEVICE *physDev);
 extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE*);
 extern void X11DRV_XRender_CopyBrush(X11DRV_PDEVICE *physDev, X_PHYSBITMAP *physBitmap, int width, int height);
 extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index ad309c1..48d6d56 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -516,6 +516,7 @@ static Picture get_xrender_picture(X11DRV_PDEVICE *physDev)
     {
         info->pict = alloc_xrender_picture(physDev->drawable, physDev->depth, physDev->color_shifts);
         TRACE("Allocing pict=%lx dc=%p drawable=%08lx\n", info->pict, physDev->hdc, physDev->drawable);
+        X11DRV_XRender_SetDeviceClipping(physDev);
     }
 
     return info->pict;
@@ -874,6 +875,28 @@ BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
     return 0;
 }
 
+ /***********************************************************************
+ *   X11DRV_XRender_SetDeviceClipping
+ */
+void X11DRV_XRender_SetDeviceClipping(X11DRV_PDEVICE *physDev)
+{
+    RGNDATA *data;
+
+    /* Only continue if XRender was already initialized for this physDev */
+    if(!physDev->xrender || !physDev->xrender->pict)
+        return;
+
+    if ((data = X11DRV_GetRegionData( physDev->region, 0 )))
+    {
+        wine_tsx11_lock();
+        pXRenderSetPictureClipRectangles( gdi_display, physDev->xrender->pict,
+                            physDev->dc_rect.left, physDev->dc_rect.top,
+                            (XRectangle *)data->Buffer, data->rdh.nCount );
+        wine_tsx11_unlock();
+        HeapFree( GetProcessHeap(), 0, data );
+    }
+}
+
 /***********************************************************************
  *   X11DRV_XRender_DeleteDC
  */
@@ -1468,7 +1491,6 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
 				const RECT *lprect, LPCWSTR wstr, UINT count,
 				const INT *lpDx )
 {
-    RGNDATA *data;
     XGCValues xgcval;
     gsCacheEntry *entry;
     gsCacheEntryFormat *formatEntry;
@@ -1553,20 +1575,6 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
         DeleteObject( clip_region );
     }
 
-    if(X11DRV_XRender_Installed) {
-        Picture pict = get_xrender_picture(physDev);
-
-	if ((data = X11DRV_GetRegionData( physDev->region, 0 )))
-	{
-	    wine_tsx11_lock();
-	    pXRenderSetPictureClipRectangles( gdi_display, pict,
-					      physDev->dc_rect.left, physDev->dc_rect.top,
-					      (XRectangle *)data->Buffer, data->rdh.nCount );
-	    wine_tsx11_unlock();
-	    HeapFree( GetProcessHeap(), 0, data );
-	}
-    }
-
     EnterCriticalSection(&xrender_cs);
 
     entry = glyphsetCache + physDev->xrender->cache_index;
@@ -2207,6 +2215,12 @@ void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
   return;
 }
 
+void X11DRV_XRender_SetDeviceClipping(X11DRV_PDEVICE *physDev)
+{
+  assert(0);
+  return;
+}
+
 BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
 				const RECT *lprect, LPCWSTR wstr, UINT count,
 				const INT *lpDx )
-- 
1.6.0.4

