[1/4] user32/cursoricon.c: Multiple Fixes/Improvements for DrawIconEx

Wilfried Pasquazzo wilfried.pasquazzo at gmail.com
Fri Sep 25 12:12:57 CDT 2009


Hi there,

here are 4 improvements for DrawIconEx in "dlls/user32/cursoricon.c".
The testsuite passes after applying each patch, as long as they are applied
in correct order:

1.) Fix for Bug http://bugs.winehq.org/show_bug.cgi?id=20145
Only changed hierarchy of if statements to get monochrome 1 bpp icons into
the "correct"
branch which doesn't compute alpha blending.

2.) Extremely small change to make a "wine todo" test pass
Changed rendering flag for BitBlt
Remove "wine todo" from corresponding test

3.) Another small change to make the remaining two "wine todo" tests of
DrawIconEx pass
Changed rendering flag to depend on DI_MASK flag
Remove "wine todo" from both corresponding tests

4.) Replacing the DrawIcon implementation with now equivalent call to
DrawIconEx
(as suggested by
http://msdn.microsoft.com/en-us/library/ms648065(VS.85).aspx ),
therefore eliminating lots of duplicated code.

Best regards,


Wilfried Pasquazzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090925/7223838a/attachment-0001.htm>
-------------- next part --------------
From 532daa333a38ac805be262e38c28b4030dde9622 Mon Sep 17 00:00:00 2001
From: Wilfried Pasquazzo <wilfried.pasquazzo at gmail.com>
Date: Thu, 24 Sep 2009 17:09:30 +0000
Subject: Fixed handling of 1 bpp monochrome icons

---
 dlls/user32/cursoricon.c |   59 +++++++++++++++++++++++----------------------
 1 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 23de6a5..586f265 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -2371,23 +2371,23 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
 
         if (flags & DI_IMAGE)
         {
-            BITMAPINFOHEADER bmih;
-            unsigned char *dibBits;
-
-            memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
-            bmih.biSize = sizeof(BITMAPINFOHEADER);
-            bmih.biWidth = ptr->nWidth;
-            bmih.biHeight = -ptr->nHeight;
-            bmih.biPlanes = ptr->bPlanes;
-            bmih.biBitCount = ptr->bBitsPerPixel;
-            bmih.biCompression = BI_RGB;
-
-            hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
-                                        (void*)&dibBits, NULL, 0);
-
-            if (hXorBits && dibBits)
+            if (has_alpha)
             {
-                if(has_alpha)
+                BITMAPINFOHEADER bmih;
+                unsigned char *dibBits;
+
+                memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
+                bmih.biSize = sizeof(BITMAPINFOHEADER);
+                bmih.biWidth = ptr->nWidth;
+                bmih.biHeight = -ptr->nHeight;
+                bmih.biPlanes = ptr->bPlanes;
+                bmih.biBitCount = ptr->bBitsPerPixel;
+                bmih.biCompression = BI_RGB;
+
+                hXorBits = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
+                                            (void*)&dibBits, NULL, 0);
+                
+                if(hXorBits && dibBits)
                 {
                     BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
 
@@ -2403,20 +2403,21 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
                                         0, 0, ptr->nWidth, ptr->nHeight, pixelblend);
 
                     SelectObject( hMemDC, hBitTemp );
-                }
-                else
-                {
-                    memcpy(dibBits, xorBitmapBits, xorLength);
-                    hBitTemp = SelectObject( hMemDC, hXorBits );
-                    if (DoOffscreen)
-                        StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
-                                    hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
-                    else
-                        StretchBlt (hdc, x0, y0, cxWidth, cyWidth,
-                                    hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
-                    SelectObject( hMemDC, hBitTemp );
-                }
+                    DeleteObject( hXorBits );
+		}
+            }
+            else
+            {
+                hXorBits = CreateBitmap( ptr->nWidth, ptr->nHeight, ptr->bPlanes, ptr->bBitsPerPixel, xorBitmapBits);
 
+                hBitTemp = SelectObject( hMemDC, hXorBits );
+                if (DoOffscreen)
+                    StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
+                                hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
+                else
+                    StretchBlt (hdc, x0, y0, cxWidth, cyWidth,
+                                hMemDC, 0, 0, ptr->nWidth, ptr->nHeight, SRCPAINT);
+                SelectObject( hMemDC, hBitTemp );
                 DeleteObject( hXorBits );
             }
         }
-- 
1.6.3.3


More information about the wine-patches mailing list