Mikolaj Zalewski : winex11.drv: Support GdiAlphaBlend with blendfn. AlphaFormat == 0.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Aug 31 07:22:19 CDT 2007


Module: wine
Branch: master
Commit: ee747f3d70597a10af5984783efcb5eccf9e9f11
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ee747f3d70597a10af5984783efcb5eccf9e9f11

Author: Mikolaj Zalewski <mikolajz at google.com>
Date:   Thu Aug 30 10:43:20 2007 -0700

winex11.drv: Support GdiAlphaBlend with blendfn.AlphaFormat == 0.

---

 dlls/winex11.drv/xrender.c |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 449c671..b659e21 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -1524,7 +1524,7 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
     XImage *image;
     GC gc;
     XGCValues gcv;
-    BYTE *dstbits, *data;
+    DWORD *dstbits, *data;
     int y, y2;
     POINT pts[2];
     BOOL top_down = FALSE;
@@ -1580,6 +1580,9 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
         return FALSE;
     }
 
+    if ((blendfn.AlphaFormat & AC_SRC_ALPHA) && blendfn.SourceConstantAlpha != 0xff)
+        FIXME("Ignoring SourceConstantAlpha %d for AC_SRC_ALPHA\n", blendfn.SourceConstantAlpha);
+
     if(dib.dsBm.bmBitsPixel != 32) {
         FIXME("not a 32 bpp dibsection\n");
         return FALSE;
@@ -1588,7 +1591,7 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
 
     if(dib.dsBmih.biHeight < 0) { /* top-down dib */
         top_down = TRUE;
-        dstbits += widthSrc * (heightSrc - 1) * 4;
+        dstbits += widthSrc * (heightSrc - 1);
         y2 = ySrc;
         y = y2 + heightSrc - 1;
     }
@@ -1597,10 +1600,34 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
         y = dib.dsBmih.biHeight - ySrc - 1;
         y2 = y - heightSrc + 1;
     }
-    for(; y >= y2; y--) {
-        memcpy(dstbits, (char *)dib.dsBm.bmBits + y * dib.dsBm.bmWidthBytes + xSrc * 4,
-               widthSrc * 4);
-        dstbits += (top_down ? -1 : 1) * widthSrc * 4;
+
+    if (blendfn.AlphaFormat & AC_SRC_ALPHA)
+    {
+        for(; y >= y2; y--)
+        {
+            memcpy(dstbits, (char *)dib.dsBm.bmBits + y * dib.dsBm.bmWidthBytes + xSrc * 4,
+                   widthSrc * 4);
+            dstbits += (top_down ? -1 : 1) * widthSrc;
+        }
+    }
+    else
+    {
+        DWORD source_alpha = (DWORD)blendfn.SourceConstantAlpha << 24;
+        int x;
+
+        for(; y >= y2; y--)
+        {
+            DWORD *srcbits = (DWORD *)((char *)dib.dsBm.bmBits + y * dib.dsBm.bmWidthBytes) + xSrc;
+            for (x = 0; x < widthSrc; x++)
+            {
+                DWORD argb = *srcbits++;
+                argb = (argb & 0xffffff) | source_alpha;
+                *dstbits++ = argb;
+            }
+            if (top_down)  /* we traversed the row forward so we should go back by two rows */
+                dstbits -= 2 * widthSrc;
+        }
+
     }
 
     wine_tsx11_lock();




More information about the wine-cvs mailing list