From 17ca7b7c916651a194bec0541764dd1134b3eac7 Mon Sep 17 00:00:00 2001
From: Roderick Colenbrander <thunderbird2k@gmail.com>
Date: Mon, 2 Nov 2009 14:22:22 +0100
Subject: [PATCH] Fix a regression which caused incorrect colors when the depth is the same but the bit ordering different.

---
 dlls/winex11.drv/bitblt.c  |    4 ++--
 dlls/winex11.drv/x11drv.h  |    1 +
 dlls/winex11.drv/xrender.c |   20 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c
index 435e2c2..f0861b0 100644
--- a/dlls/winex11.drv/bitblt.c
+++ b/dlls/winex11.drv/bitblt.c
@@ -1446,7 +1446,7 @@ BOOL CDECL X11DRV_StretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst, IN
     /* try client-side DIB copy */
     if (!fStretch && rop == SRCCOPY &&
         sSrc == DIB_Status_AppMod && sDst == DIB_Status_AppMod &&
-        physDevSrc->depth == physDevDst->depth)
+        X11DRV_XRender_CompareDepth(physDevSrc, physDevDst))
     {
         if (client_side_dib_copy( physDevSrc, visRectSrc.left, visRectSrc.top,
                                   physDevDst, visRectDst.left, visRectDst.top, width, height ))
@@ -1519,7 +1519,7 @@ BOOL CDECL X11DRV_StretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst, IN
         }
         else if (OP_SRCDST(*opcode) == OP_ARGS(SRC,DST))
         {
-            if (physDevSrc->depth == physDevDst->depth)
+            if (X11DRV_XRender_CompareDepth(physDevSrc, physDevDst))
             {
                 wine_tsx11_lock();
                 XSetFunction( gdi_display, physDevDst->gc, OP_ROP(*opcode) );
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 11f8e0d..3eb0a2a 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -287,6 +287,7 @@ extern void X11DRV_XRender_CopyBrush(X11DRV_PDEVICE *physDev, X_PHYSBITMAP *phys
 extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
 				      const RECT *lprect, LPCWSTR wstr,
 				      UINT count, const INT *lpDx);
+extern BOOL X11DRV_XRender_CompareDepth(X11DRV_PDEVICE *physDevA, X11DRV_PDEVICE *physDevB);
 extern BOOL X11DRV_XRender_SetPhysBitmapDepth(X_PHYSBITMAP *physBitmap, const DIBSECTION *dib);
 BOOL X11DRV_XRender_GetSrcAreaStretch(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDevDst,
                                       Pixmap pixmap, GC gc,
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 005296b..318d9bb 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -931,6 +931,21 @@ void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
     return;
 }
 
+BOOL X11DRV_XRender_CompareDepth(X11DRV_PDEVICE *physDevA, X11DRV_PDEVICE *physDevB)
+{
+    struct xrender_info *infoA, *infoB;
+    if(!X11DRV_XRender_Installed)
+        return (physDevA->depth == physDevB->depth);
+    
+    infoA = get_xrender_info(physDevA);
+    infoB = get_xrender_info(physDevB);
+    
+    if(infoA && infoB && infoA->format->format == infoB->format->format)
+        return TRUE;
+    
+    return FALSE;
+}
+
 BOOL X11DRV_XRender_SetPhysBitmapDepth(X_PHYSBITMAP *physBitmap, const DIBSECTION *dib)
 {
     const WineXRenderFormat *fmt;
@@ -2237,6 +2252,11 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
   return FALSE;
 }
 
+BOOL X11DRV_XRender_CompareDepth(X11DRV_PDEVICE *physDevA, X11DRV_PDEVICE *physDevB)
+{
+    return (physDevA->depth == physDevB->depth);
+}
+
 void X11DRV_XRender_CopyBrush(X11DRV_PDEVICE *physDev, X_PHYSBITMAP *physBitmap, int width, int height)
 {
     wine_tsx11_lock();
-- 
1.6.3.3

