From f5f3426c878238545393ce4e95be2c75217f55ea Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 29 May 2010 10:47:28 +0200 Subject: [PATCH] user32: Fallback to normal icon drawing if AlphaBlend fails. --- dlls/user32/cursoricon.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index e4973e3baa2..b54d9fd0067 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -2030,11 +2030,11 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon, r.right = cxWidth; r.bottom = cxWidth; - if (!(hdc_dest = CreateCompatibleDC(hdc))) goto done; + if (!(hdc_dest = CreateCompatibleDC(hdc))) goto failed; if (!(hB_off = CreateCompatibleBitmap(hdc, cxWidth, cyWidth))) { DeleteDC( hdc_dest ); - goto done; + goto failed; } SelectObject(hdc_dest, hB_off); FillRect(hdc_dest, &r, hbr); @@ -2052,7 +2052,16 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon, oldFg = SetTextColor( hdc, RGB(0,0,0) ); oldBg = SetBkColor( hdc, RGB(255,255,255) ); - if ((flags & DI_MASK) && (!ptr->alpha || !(flags & DI_IMAGE))) + if (ptr->alpha && (flags & DI_IMAGE)) + { + BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; + + SelectObject( hMemDC, ptr->alpha ); + if (GdiAlphaBlend( hdc_dest, x, y, cxWidth, cyWidth, hMemDC, + 0, 0, ptr->width, ptr->height, pixelblend )) goto done; + } + + if (flags & DI_MASK) { SelectObject( hMemDC, ptr->mask ); StretchBlt( hdc_dest, x, y, cxWidth, cyWidth, @@ -2061,15 +2070,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon, if (flags & DI_IMAGE) { - if (ptr->alpha) - { - BLENDFUNCTION pixelblend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - - SelectObject( hMemDC, ptr->alpha ); - GdiAlphaBlend( hdc_dest, x, y, cxWidth, cyWidth, hMemDC, - 0, 0, ptr->width, ptr->height, pixelblend ); - } - else if (ptr->color) + if (ptr->color) { DWORD rop = (flags & DI_MASK) ? SRCINVERT : SRCCOPY; SelectObject( hMemDC, ptr->color ); @@ -2085,6 +2086,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon, } } +done: if (DoOffscreen) BitBlt( hdc, x0, y0, cxWidth, cyWidth, hdc_dest, 0, 0, SRCCOPY ); SetTextColor( hdc, oldFg ); @@ -2093,7 +2095,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon, result = TRUE; if (hdc_dest != hdc) DeleteDC( hdc_dest ); if (hB_off) DeleteObject(hB_off); -done: +failed: DeleteDC( hMemDC ); release_icon_ptr( hIcon, ptr ); return result;