[PATCH v5 0/2] MR10341: user32/tests: Test FillRect with negativ height and width
Added tests for FillRect function with negative width and height values. These tests address https://bugs.winehq.org/show_bug.cgi?id=27584 Verified on Windows 10. -- v5: user32/uitools: Fix FillRect for negativ height and width https://gitlab.winehq.org/wine/wine/-/merge_requests/10341
From: Thomas Csovcsity <thc.fr13nd@gmail.com> --- dlls/user32/tests/uitools.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dlls/user32/tests/uitools.c b/dlls/user32/tests/uitools.c index a3067c518ea..3f262f7ab7f 100644 --- a/dlls/user32/tests/uitools.c +++ b/dlls/user32/tests/uitools.c @@ -31,6 +31,20 @@ static void test_FillRect(void) COLORREF col; HBRUSH old_brush; RECT r; + int i; + static const struct + { + const int x; + const int y; + const COLORREF col; + const BOOL todo_flag; + } test[] = + { + { 5, 5, 0x0, TRUE }, + { 5, 6, 0xffffff, FALSE }, + { 6, 5, 0xffffff, FALSE }, + { 6, 6, 0xffffff, TRUE }, + }; /* fill bitmap data with white */ memset(bits, 0xff, sizeof(bits)); @@ -57,6 +71,16 @@ static void test_FillRect(void) col = GetPixel(hdcmem, 0, 0); ok(col == 0, "GetPixel returned %08lx, expected 0\n", col); + /* test negative height and width */ + SetRect(&r, 6, 6, 5, 5); + FillRect(hdcmem, &r, GetStockObject(BLACK_BRUSH)); + for (i = 0; i < ARRAYSIZE(test); i++) + { + col = GetPixel(hdcmem, test[i].x, test[i].y); + todo_wine_if (test[i].todo_flag) + ok(col == test[i].col, "GetPixel (%d,%d) returned %08lx, expected %08lx\n", test[i].x, test[i].y, col, test[i].col); + } + SelectObject(hdcmem, oldhbmp); DeleteObject(hbmp); DeleteDC(hdcmem); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10341
From: Thomas Csovcsity <thc.fr13nd@gmail.com> --- dlls/user32/tests/uitools.c | 4 ++-- dlls/user32/uitools.c | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dlls/user32/tests/uitools.c b/dlls/user32/tests/uitools.c index 3f262f7ab7f..298066bff8d 100644 --- a/dlls/user32/tests/uitools.c +++ b/dlls/user32/tests/uitools.c @@ -40,10 +40,10 @@ static void test_FillRect(void) const BOOL todo_flag; } test[] = { - { 5, 5, 0x0, TRUE }, + { 5, 5, 0x0, FALSE }, { 5, 6, 0xffffff, FALSE }, { 6, 5, 0xffffff, FALSE }, - { 6, 6, 0xffffff, TRUE }, + { 6, 6, 0xffffff, FALSE }, }; /* fill bitmap data with white */ diff --git a/dlls/user32/uitools.c b/dlls/user32/uitools.c index a8f3a0af84b..9a863cf4bcd 100644 --- a/dlls/user32/uitools.c +++ b/dlls/user32/uitools.c @@ -1435,12 +1435,34 @@ BOOL WINAPI SubtractRect( LPRECT dest, const RECT *src1, const RECT *src2 ) INT WINAPI FillRect( HDC hdc, const RECT *rect, HBRUSH hbrush ) { HBRUSH prev_brush; + RECT tmpRect; + + if (rect->bottom < rect->top) + { + tmpRect.bottom = rect->top; + tmpRect.top = rect->bottom; + } + else + { + tmpRect.bottom = rect->bottom; + tmpRect.top = rect->top; + } + if (rect->right < rect->left) + { + tmpRect.right = rect->left; + tmpRect.left = rect->right; + } + else + { + tmpRect.right = rect->right; + tmpRect.left = rect->left; + } if (hbrush <= (HBRUSH) (COLOR_MAX + 1)) hbrush = GetSysColorBrush( HandleToULong(hbrush) - 1 ); prev_brush = SelectObject( hdc, hbrush ); - PatBlt( hdc, rect->left, rect->top, - rect->right - rect->left, rect->bottom - rect->top, PATCOPY ); + PatBlt( hdc, tmpRect.left, tmpRect.top, + tmpRect.right - tmpRect.left, tmpRect.bottom - tmpRect.top, PATCOPY ); if (prev_brush) SelectObject( hdc, prev_brush ); return 1; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10341
participants (2)
-
Thomas Csovcsity -
Thomas Csovcsity (@thc13)