Zhiyi Zhang : uxtheme: Use TransparentBlt() for bitmaps with all alpha values being 0xff.

Alexandre Julliard julliard at winehq.org
Fri Feb 25 07:30:24 CST 2022


Module: wine
Branch: oldstable
Commit: 7398ed2977ec495fcd074e4c98d434b05304f19d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7398ed2977ec495fcd074e4c98d434b05304f19d

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Aug 25 14:24:31 2021 +0800

uxtheme: Use TransparentBlt() for bitmaps with all alpha values being 0xff.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51553
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 96b7a8a317a859dd6f9bf9a0e03d303e7d3503b3)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/uxtheme/msstyles.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c
index cd7677e5783..3624bb2d4a6 100644
--- a/dlls/uxtheme/msstyles.c
+++ b/dlls/uxtheme/msstyles.c
@@ -1074,11 +1074,18 @@ static BOOL prepare_alpha (HBITMAP bmp, BOOL* hasAlpha)
     if (!bmp || GetObjectW( bmp, sizeof(dib), &dib ) != sizeof(dib))
         return FALSE;
 
-    if(dib.dsBm.bmBitsPixel != 32)
+    if (dib.dsBm.bmBitsPixel != 32 || dib.dsBmih.biCompression != BI_RGB)
         /* nothing to do */
         return TRUE;
 
-    *hasAlpha = TRUE;
+    /* If all alpha values are 0xff, don't use alpha blending */
+    for (n = 0, p = dib.dsBm.bmBits; n < dib.dsBmih.biWidth * dib.dsBmih.biHeight; n++, p += 4)
+        if ((*hasAlpha = (p[3] != 0xff)))
+            break;
+
+    if (!*hasAlpha)
+        return TRUE;
+
     p = dib.dsBm.bmBits;
     n = dib.dsBmih.biHeight * dib.dsBmih.biWidth;
     /* AlphaBlend() wants premultiplied alpha, so do that now */




More information about the wine-cvs mailing list