Ziqing Hui : comctl32/tests: Add tests for grayscale.

Alexandre Julliard julliard at winehq.org
Mon Mar 9 17:42:34 CDT 2020


Module: wine
Branch: master
Commit: e8c2e505a8b12b2f4ec5eb98ef25a7ce416a7535
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e8c2e505a8b12b2f4ec5eb98ef25a7ce416a7535

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Fri Mar  6 17:57:28 2020 +0800

comctl32/tests: Add tests for grayscale.

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/tests/imagelist.c | 42 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c
index 806cec7bd9..24b33f54d7 100644
--- a/dlls/comctl32/tests/imagelist.c
+++ b/dlls/comctl32/tests/imagelist.c
@@ -1444,6 +1444,43 @@ static void check_ImageList_DrawIndirect_broken(HDC hdc, HIMAGELIST himl, UINT32
        bits[0] & 0x00FFFFFF, expected, line);
 }
 
+static void check_ImageList_DrawIndirect_grayscale(HDC hdc, HIMAGELIST himl, UINT32 *dst_bits, const UINT32 *bitmap_bits,
+                                                   int index, UINT width, UINT height, int line)
+{
+    int i;
+    BOOL has_alpha = FALSE;
+    IMAGELISTDRAWPARAMS ildp = { sizeof(IMAGELISTDRAWPARAMS), himl, index, hdc,
+                                 0, 0, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL, 0, ILS_SATURATE, 0, 0x00000000 };
+    memset(dst_bits, 0, width * height * sizeof(*dst_bits));
+    pImageList_DrawIndirect(&ildp);
+
+    for (i = 0; i < width *  height; i++)
+        if ((has_alpha = ((bitmap_bits[i] & 0xFF000000) != 0))) break;
+
+    for (i = 0; i < width * height; i++)
+    {
+        UINT32 expected, expected_winxp;
+        UINT32 red   = (bitmap_bits[i] & 0x00FF0000) >> 16;
+        UINT32 green = (bitmap_bits[i] & 0x0000FF00) >>  8;
+        UINT32 blue  = (bitmap_bits[i] & 0x000000FF) >>  0;
+        UINT32 gray = (red * 299 + green * 587 + blue * 114 + 500) / 1000;
+        UINT32 gray_winxp = (red + green  + blue) / 3;
+        if (has_alpha)
+        {
+            UINT32 alpha = (bitmap_bits[i] & 0xFF000000) >> 24;
+            gray = gray * alpha / 0xff * alpha / 0xff;
+            gray_winxp = gray_winxp * alpha / 0xff * 0x96 / 0xff;
+        }
+        expected = (gray << 16) | (gray << 8) | gray;
+        expected_winxp = (gray_winxp << 16) | (gray_winxp << 8) | gray_winxp;
+
+        todo_wine_if(expected != 0 && expected != 0x00FFFFFF)
+        ok(colour_match(dst_bits[i], expected) || broken(colour_match(dst_bits[i], expected_winxp)),
+           "ImageList_DrawIndirect: got Pixel(%d,%d) %08X, Expected a close match to %08X from line %d\n",
+           i % width, i / width, dst_bits[i] & 0x00FFFFFF, expected, line);
+    }
+}
+
 static void test_ImageList_DrawIndirect(void)
 {
     const UINT32 bits_image[] =       { 0x00ABCDEF, 0x00ABCDEF };
@@ -1546,8 +1583,9 @@ static void test_ImageList_DrawIndirect(void)
     check_ImageList_DrawIndirect_ILD_ROP(hdcDst, himl, bits, iAlphaImage, SRCCOPY, 0x00D3E5F7, __LINE__);
     check_ImageList_DrawIndirect_ILD_ROP(hdcDst, himl, bits, iAlphaImage, SRCINVERT, 0x00D3E5F7, __LINE__);
 
-    todo_wine check_ImageList_DrawIndirect_fState(hdcDst, himl, bits, iImage, ILD_NORMAL, ILS_SATURATE, 0, 0x00CCCCCC, __LINE__);
-    todo_wine check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iAlphaImage, ILD_NORMAL, ILS_SATURATE, 0, 0x00AFAFAF, 0x00F0F0F0, __LINE__);
+    check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_image, iImage, 2, 1, __LINE__);
+    check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_alpha, iAlphaImage, 2, 1, __LINE__);
+    check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_transparent, iTransparentImage, 2, 1, __LINE__);
 
     check_ImageList_DrawIndirect_fState(hdcDst, himl, bits, iImage, ILD_NORMAL, ILS_GLOW, 0, 0x00ABCDEF, __LINE__);
     check_ImageList_DrawIndirect_fState(hdcDst, himl, bits, iImage, ILD_NORMAL, ILS_SHADOW, 0, 0x00ABCDEF, __LINE__);




More information about the wine-cvs mailing list