Commit b7644afa authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

uxtheme: Do not transfer glyph alpha values when drawing opaque background.

Fix QSpinBox artifacts for Qt5 applications. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53066Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com>
parent 709722be
......@@ -523,6 +523,39 @@ static inline void get_transparency (HTHEME hTheme, int iPartId, int iStateId,
}
}
/* Reset alpha values in hdc to 0xFF if the background is opaque */
static void reset_dc_alpha_values(HTHEME htheme, HDC hdc, int part_id, int state_id,
const RECT *rect)
{
static const RGBQUAD bitmap_bits = {0x0, 0x0, 0x0, 0xFF};
BITMAPINFO bitmap_info = {{0}};
RECT image_rect;
BOOL has_alpha;
HBITMAP hbmp;
int bg_type;
if (GetDeviceCaps(hdc, BITSPIXEL) != 32)
return;
if (FAILED(GetThemeEnumValue(htheme, part_id, state_id, TMT_BGTYPE, &bg_type))
|| bg_type != BT_IMAGEFILE)
return;
if (FAILED(UXTHEME_LoadImage(htheme, part_id, state_id, rect, FALSE, &hbmp, &image_rect,
&has_alpha, NULL)) || has_alpha)
return;
bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmap_info.bmiHeader.biWidth = 1;
bitmap_info.bmiHeader.biHeight = 1;
bitmap_info.bmiHeader.biPlanes = 1;
bitmap_info.bmiHeader.biBitCount = 32;
bitmap_info.bmiHeader.biCompression = BI_RGB;
StretchDIBits(hdc, rect->left, rect->top, abs(rect->right - rect->left),
abs(rect->bottom - rect->top), 0, 0, 1, 1, &bitmap_bits, &bitmap_info,
DIB_RGB_COLORS, SRCPAINT);
}
/***********************************************************************
* UXTHEME_DrawImageGlyph
*
......@@ -581,6 +614,11 @@ static HRESULT UXTHEME_DrawImageGlyph(HTHEME hTheme, HDC hdc, int iPartId,
SelectObject(hdcSrc, oldSrc);
DeleteDC(hdcSrc);
/* Don't transfer alpha values from the glyph when drawing opaque background */
if (SUCCEEDED(hr) && hasAlpha)
reset_dc_alpha_values(hTheme, hdc, iPartId, iStateId, pRect);
return hr;
}
......
......@@ -2322,7 +2322,6 @@ static void test_DrawThemeBackgroundEx(void)
ptr += 4;
}
todo_wine
ok(i == width * height || broken(ptr[3] == 0) /* Spin button glyphs on XP don't use alpha */,
"Unexpected alpha value %#x at (%d,%d).\n", ptr[3], i % height, i / height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment