Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/user32/tests/cursoricon.c | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index f84312f3ea2..dbe2b3a57f0 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -3094,6 +3094,89 @@ static void test_copy_image(void) } }
+/* The test the logic for the same function in user32 */ +static HBITMAP create_masked_bitmap( int width, int height, const void *and, const void *xor ) +{ + HDC dc = CreateCompatibleDC( 0 ); + HBITMAP bitmap; + int line_size = width/8; + const char* and2 = (const char*)and; + const char* xor2 = (const char*)xor; + char buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2] = {0}; + + BITMAPINFO *bitmap_info = (BITMAPINFO*)buffer; + bitmap_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmap_info->bmiHeader.biWidth = width; + bitmap_info->bmiHeader.biHeight = height * 2; + bitmap_info->bmiHeader.biPlanes = 1; + bitmap_info->bmiHeader.biBitCount = 1; + bitmap_info->bmiColors[1].rgbRed = 255; + bitmap_info->bmiColors[1].rgbGreen = 255; + bitmap_info->bmiColors[1].rgbBlue = 255; + + bitmap = CreateBitmap( width, height * 2, 1, 1, NULL ); + + for (int i = 0; i < height; i++) + { + SetDIBits( dc, bitmap, height - i - 1, 1, &xor2[i*line_size], bitmap_info, FALSE ); + SetDIBits( dc, bitmap, 2*height - i - 1, 1, &and2[i*line_size], bitmap_info, FALSE ); + } + DeleteDC( dc ); + return bitmap; +} + +static void check_monochrome_icon(HICON icon, int draw_flag, int line, BOOL todo) +{ + HDC dc = CreateCompatibleDC(0); + HBITMAP canvas = CreateCompatibleBitmap(dc, 32, 32); + + SelectObject(dc, canvas); + + DrawIconEx(dc, 0, 0, icon, 16, 16, 0, NULL, draw_flag); + + for (int i = 0; i < 16; i++) + { + COLORREF color = GetPixel(dc, i, 8); + int expect = i % 2 == 0 ? 0 : 0xFFFFFF; + todo_wine_if(todo && (i%2 != 0)) + ok_(__FILE__,line)(color == expect, "At index %d got %x\n", i, color); + } + DeleteObject(canvas); + DeleteDC(dc); +} + +static void test_monochrome_icon_creation(void) +{ + HCURSOR cursor; + HICON icon; + ICONINFO iconinfo = {0}; + static const unsigned char monochrome_bits[] = + { + 0xFF, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x55, 0x55, 0x00, 0x00, 0xAA, 0xAA, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xAA, 0xAA, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xAA, 0xAA, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }; + + iconinfo.fIcon = 1; + iconinfo.hbmMask = create_masked_bitmap(16, 16, monochrome_bits, &monochrome_bits[32]); + + cursor = CreateCursor(0, 8, 8, 16, 16, monochrome_bits, &monochrome_bits[32]); + ok(cursor != NULL, "CreateCursor failed\n"); + check_monochrome_icon(cursor, DI_NORMAL, __LINE__, TRUE); + DestroyCursor(cursor); + + icon = CreateIcon(0, 16, 16, 1, 1, monochrome_bits, &monochrome_bits[32]); + ok(icon != NULL, "CreateIcon failed\n"); + check_monochrome_icon(icon, DI_NORMAL, __LINE__, TRUE); + DestroyIcon(icon); + + icon = CreateIconIndirect(&iconinfo); + ok(icon != NULL, "CreateIconIndirect failed\n"); + check_monochrome_icon(icon, DI_NORMAL, __LINE__, FALSE); + DestroyIcon(icon); +} + START_TEST(cursoricon) { pGetCursorInfo = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetCursorInfo" ); @@ -3130,6 +3213,7 @@ START_TEST(cursoricon) test_DestroyCursor(); test_PrivateExtractIcons(); test_monochrome_icon(); + test_monochrome_icon_creation(); do_parent(); test_child_process(); finish_child_process(); -- 2.33.0
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here: 1) We must use a color table to avoid undefined behavior 2) We must set the bitmap line by line, in reverse
The same function is already used and tested in the previous patch.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51296 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/user32/cursoricon.c | 31 ++++++++++++++++++++----------- dlls/user32/tests/cursoricon.c | 9 ++++----- 2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 7ad0a04a551..605cd6a3f61 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1574,19 +1574,28 @@ static HBITMAP create_masked_bitmap( int width, int height, const void *and, con { HDC dc = CreateCompatibleDC( 0 ); HBITMAP bitmap; - - const BITMAPINFO bitmap_info = - { - .bmiHeader.biSize = sizeof(BITMAPINFOHEADER), - .bmiHeader.biWidth = width, - .bmiHeader.biHeight = height * 2, - .bmiHeader.biPlanes = 1, - .bmiHeader.biBitCount = 1, - }; + int line_size = width/8; + const char* and2 = (const char*)and; + const char* xor2 = (const char*)xor; + char buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2] = {0}; + + BITMAPINFO *bitmap_info = (BITMAPINFO*)buffer; + bitmap_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmap_info->bmiHeader.biWidth = width; + bitmap_info->bmiHeader.biHeight = height * 2; + bitmap_info->bmiHeader.biPlanes = 1; + bitmap_info->bmiHeader.biBitCount = 1; + bitmap_info->bmiColors[1].rgbRed = 255; + bitmap_info->bmiColors[1].rgbGreen = 255; + bitmap_info->bmiColors[1].rgbBlue = 255;
bitmap = CreateBitmap( width, height * 2, 1, 1, NULL ); - SetDIBits( dc, bitmap, 0, height, and, &bitmap_info, FALSE ); - SetDIBits( dc, bitmap, height, height, xor, &bitmap_info, FALSE ); + + for (int i = 0; i < height; i++) + { + SetDIBits( dc, bitmap, height - i - 1, 1, &xor2[i*line_size], bitmap_info, FALSE ); + SetDIBits( dc, bitmap, 2*height - i - 1, 1, &and2[i*line_size], bitmap_info, FALSE ); + } DeleteDC( dc ); return bitmap; } diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index dbe2b3a57f0..ef3d4b2870f 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -3125,7 +3125,7 @@ static HBITMAP create_masked_bitmap( int width, int height, const void *and, con return bitmap; }
-static void check_monochrome_icon(HICON icon, int draw_flag, int line, BOOL todo) +static void check_monochrome_icon(HICON icon, int draw_flag, int line) { HDC dc = CreateCompatibleDC(0); HBITMAP canvas = CreateCompatibleBitmap(dc, 32, 32); @@ -3138,7 +3138,6 @@ static void check_monochrome_icon(HICON icon, int draw_flag, int line, BOOL todo { COLORREF color = GetPixel(dc, i, 8); int expect = i % 2 == 0 ? 0 : 0xFFFFFF; - todo_wine_if(todo && (i%2 != 0)) ok_(__FILE__,line)(color == expect, "At index %d got %x\n", i, color); } DeleteObject(canvas); @@ -3163,17 +3162,17 @@ static void test_monochrome_icon_creation(void)
cursor = CreateCursor(0, 8, 8, 16, 16, monochrome_bits, &monochrome_bits[32]); ok(cursor != NULL, "CreateCursor failed\n"); - check_monochrome_icon(cursor, DI_NORMAL, __LINE__, TRUE); + check_monochrome_icon(cursor, DI_NORMAL, __LINE__); DestroyCursor(cursor);
icon = CreateIcon(0, 16, 16, 1, 1, monochrome_bits, &monochrome_bits[32]); ok(icon != NULL, "CreateIcon failed\n"); - check_monochrome_icon(icon, DI_NORMAL, __LINE__, TRUE); + check_monochrome_icon(icon, DI_NORMAL, __LINE__); DestroyIcon(icon);
icon = CreateIconIndirect(&iconinfo); ok(icon != NULL, "CreateIconIndirect failed\n"); - check_monochrome_icon(icon, DI_NORMAL, __LINE__, FALSE); + check_monochrome_icon(icon, DI_NORMAL, __LINE__); DestroyIcon(icon); }
-- 2.33.0
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=96065
Your paranoid android.
=== w1064v1507 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1809 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1507 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1809 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064_2qxl (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_ar (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_he (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_ja (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_zh_CN (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
Hello wine-devel,
any news on this?
Regards, Fabian Maurer
On 8/21/21 8:18 AM, Fabian Maurer wrote:
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here:
- We must use a color table to avoid undefined behavior
- We must set the bitmap line by line, in reverse
This sounds like a sign that the patch should be split...
On Montag, 30. August 2021 18:26:12 CEST Zebediah Figura (she/her) wrote:
On 8/21/21 8:18 AM, Fabian Maurer wrote:
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here:
- We must use a color table to avoid undefined behavior
- We must set the bitmap line by line, in reverse
This sounds like a sign that the patch should be split...
How exactly? Realistically, you need both for it to work, just having half of it isn't useful.
Regards, Fabian Maurer
On 8/30/21 4:31 PM, Fabian Maurer wrote:
On Montag, 30. August 2021 18:26:12 CEST Zebediah Figura (she/her) wrote:
On 8/21/21 8:18 AM, Fabian Maurer wrote:
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here:
- We must use a color table to avoid undefined behavior
- We must set the bitmap line by line, in reverse
This sounds like a sign that the patch should be split...
How exactly? Realistically, you need both for it to work, just having half of it isn't useful.
I must be missing something, but I didn't suggest only submitting one part.
On Montag, 30. August 2021 23:38:25 CEST you wrote:
On 8/30/21 4:31 PM, Fabian Maurer wrote:
On Montag, 30. August 2021 18:26:12 CEST Zebediah Figura (she/her) wrote:
On 8/21/21 8:18 AM, Fabian Maurer wrote:
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here:
- We must use a color table to avoid undefined behavior
- We must set the bitmap line by line, in reverse
This sounds like a sign that the patch should be split...
How exactly? Realistically, you need both for it to work, just having half of it isn't useful.
I must be missing something, but I didn't suggest only submitting one part.
Sorry, I mean, patches should be able to stand on their own, right? I don't see a reason for splitting if just adding the one wouldn't add an improvement, although I'm open for it.
Regards, Fabian Maurer
On 8/30/21 4:54 PM, Fabian Maurer wrote:
On Montag, 30. August 2021 23:38:25 CEST you wrote:
On 8/30/21 4:31 PM, Fabian Maurer wrote:
On Montag, 30. August 2021 18:26:12 CEST Zebediah Figura (she/her) wrote:
On 8/21/21 8:18 AM, Fabian Maurer wrote:
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here:
- We must use a color table to avoid undefined behavior
- We must set the bitmap line by line, in reverse
This sounds like a sign that the patch should be split...
How exactly? Realistically, you need both for it to work, just having half of it isn't useful.
I must be missing something, but I didn't suggest only submitting one part.
Sorry, I mean, patches should be able to stand on their own, right? I don't see a reason for splitting if just adding the one wouldn't add an improvement, although I'm open for it.
Sure, patches should be able to stand on their own, but "improvement" doesn't have to be user-visible. Though even if it were, I'm not sure why these wouldn't qualify.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=96064
Your paranoid android.
=== w1064v1507 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1809 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1507 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1809 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064_2qxl (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_ar (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_he (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_ja (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_zh_CN (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== debiant2 (32 bit report) ===
user32: cursoricon.c:3166: Test failed: At index 0 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test failed: At index 2 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test failed: At index 4 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test failed: At index 6 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test failed: At index 8 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test failed: At index 10 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test failed: At index 12 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test failed: At index 14 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff
user32: cursoricon.c:3166: Test failed: At index 0 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test failed: At index 2 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test failed: At index 4 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test failed: At index 6 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test failed: At index 8 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test failed: At index 10 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test failed: At index 12 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test failed: At index 14 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff
It seems to work reliably on my PC. But then again, it's undefined (as of current wine), so how I deal with that?
Regards, Fabian Maurer