diff --git a/libfreerdp/gdi/test/CMakeLists.txt b/libfreerdp/gdi/test/CMakeLists.txt index 8f9845bf1..395db777e 100644 --- a/libfreerdp/gdi/test/CMakeLists.txt +++ b/libfreerdp/gdi/test/CMakeLists.txt @@ -16,12 +16,15 @@ set(${MODULE_PREFIX}_TESTS create_test_sourcelist(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_DRIVER} ${${MODULE_PREFIX}_TESTS}) - + include_directories(..) +add_library(helpers STATIC + helpers.c) + add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -target_link_libraries(${MODULE_NAME} winpr freerdp) +target_link_libraries(${MODULE_NAME} winpr freerdp helpers) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") diff --git a/libfreerdp/gdi/test/TestGdiBitBlt.c b/libfreerdp/gdi/test/TestGdiBitBlt.c index 956be8032..f016273db 100644 --- a/libfreerdp/gdi/test/TestGdiBitBlt.c +++ b/libfreerdp/gdi/test/TestGdiBitBlt.c @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -15,7 +14,7 @@ /* BitBlt() Test Data */ /* source bitmap (16x16) */ -static BYTE bmp_SRC[256] = +static const BYTE bmp_SRC[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -36,7 +35,7 @@ static BYTE bmp_SRC[256] = }; /* destination bitmap (16x16) */ -static BYTE bmp_DST[256] = +static const BYTE bmp_DST[256] = { "\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -57,7 +56,7 @@ static BYTE bmp_DST[256] = }; /* pattern bitmap (8x8) */ -static BYTE bmp_PAT[64] = +static const BYTE bmp_PAT[64] = { "\xFF\xFF\x00\x00\xFF\xFF\x00\x00" "\xFF\xFF\x00\x00\xFF\xFF\x00\x00" @@ -70,7 +69,7 @@ static BYTE bmp_PAT[64] = }; /* SRCCOPY (0x00CC0020) */ -static BYTE bmp_SRCCOPY[256] = +static const BYTE bmp_SRCCOPY[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -91,7 +90,7 @@ static BYTE bmp_SRCCOPY[256] = }; /* BLACKNESS (0x00000042) */ -static BYTE bmp_BLACKNESS[256] = +static const BYTE bmp_BLACKNESS[256] = { "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" @@ -112,7 +111,7 @@ static BYTE bmp_BLACKNESS[256] = }; /* WHITENESS (0x00FF0062) */ -static BYTE bmp_WHITENESS[256] = +static const BYTE bmp_WHITENESS[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -133,7 +132,7 @@ static BYTE bmp_WHITENESS[256] = }; /* SRCAND (0x008800C6) */ -static BYTE bmp_SRCAND[256] = +static const BYTE bmp_SRCAND[256] = { "\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -154,7 +153,7 @@ static BYTE bmp_SRCAND[256] = }; /* SRCPAINT (0x00EE0086) */ -static BYTE bmp_SRCPAINT[256] = +static const BYTE bmp_SRCPAINT[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -175,7 +174,7 @@ static BYTE bmp_SRCPAINT[256] = }; /* SRCINVERT (0x00660046) */ -static BYTE bmp_SRCINVERT[256] = +static const BYTE bmp_SRCINVERT[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" @@ -196,7 +195,7 @@ static BYTE bmp_SRCINVERT[256] = }; /* SRCERASE (0x00440328) */ -static BYTE bmp_SRCERASE[256] = +static const BYTE bmp_SRCERASE[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" @@ -217,7 +216,7 @@ static BYTE bmp_SRCERASE[256] = }; /* NOTSRCCOPY (0x00330008) */ -static BYTE bmp_NOTSRCCOPY[256] = +static const BYTE bmp_NOTSRCCOPY[256] = { "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" @@ -238,7 +237,7 @@ static BYTE bmp_NOTSRCCOPY[256] = }; /* NOTSRCERASE (0x001100A6) */ -static BYTE bmp_NOTSRCERASE[256] = +static const BYTE bmp_NOTSRCERASE[256] = { "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" @@ -259,7 +258,7 @@ static BYTE bmp_NOTSRCERASE[256] = }; /* DSTINVERT (0x00550009) */ -static BYTE bmp_DSTINVERT[256] = +static const BYTE bmp_DSTINVERT[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" @@ -280,7 +279,7 @@ static BYTE bmp_DSTINVERT[256] = }; /* SPna (0x000C0324) */ -static BYTE bmp_SPna[256] = +static const BYTE bmp_SPna[256] = { "\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF" "\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF" @@ -301,7 +300,7 @@ static BYTE bmp_SPna[256] = }; /* MERGEPAINT (0x00BB0226) */ -static BYTE bmp_MERGEPAINT[256] = +static const BYTE bmp_MERGEPAINT[256] = { "\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -322,7 +321,7 @@ static BYTE bmp_MERGEPAINT[256] = }; /* MERGECOPY (0x00C000CA) */ -static BYTE bmp_MERGECOPY[256] = +static const BYTE bmp_MERGECOPY[256] = { "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00" "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00" @@ -343,7 +342,7 @@ static BYTE bmp_MERGECOPY[256] = }; /* PATPAINT (0x00FB0A09) */ -static BYTE bmp_PATPAINT[256] = +static const BYTE bmp_PATPAINT[256] = { "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -364,7 +363,7 @@ static BYTE bmp_PATPAINT[256] = }; /* PATCOPY (0x00F00021) */ -static BYTE bmp_PATCOPY[256] = +static const BYTE bmp_PATCOPY[256] = { "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00" "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00" @@ -385,7 +384,7 @@ static BYTE bmp_PATCOPY[256] = }; /* PATINVERT (0x005A0049) */ -static BYTE bmp_PATINVERT[256] = +static const BYTE bmp_PATINVERT[256] = { "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\x00\x00\xFF\xFF\x00\x00\xFF\xFF" "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\x00\x00\xFF\xFF\x00\x00\xFF\xFF" @@ -405,1390 +404,201 @@ static BYTE bmp_PATINVERT[256] = "\xFF\xFF\x00\x00\xFF\xFF\x00\x00\x00\x00\xFF\xFF\x00\x00\xFF\xFF" }; -static int CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2) +struct test_bitblt { - UINT32 x, y; - BYTE *p1, *p2; + UINT32 rop; + const BYTE* src; + HGDI_BITMAP* bmp; +}; - UINT32 minw = (hBmp1->width < hBmp2->width) ? hBmp1->width : hBmp2->width; - UINT32 minh = (hBmp1->height < hBmp2->height) ? hBmp1->height : hBmp2->height; +static BOOL test_rop(HGDI_DC hdcDst, HGDI_DC hdcSrc, HGDI_BITMAP hBmpSrc, + HGDI_BITMAP hBmpDst, + HGDI_BITMAP hBmpDstOriginal, UINT32 rop, HGDI_BITMAP* expected, + const gdiPalette* hPalette) +{ + /* restore original destination bitmap */ + gdi_SelectObject(hdcSrc, hBmpDstOriginal); + gdi_SelectObject(hdcDst, hBmpDst); - if (hBmp1->format == hBmp2->format) - { - UINT32 colorA, colorB; - p1 = hBmp1->data; - p2 = hBmp2->data; + if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY, hPalette)) + return FALSE; - for (y = 0; y < minh; y++) - { - for (x = 0; x < minw; x++) - { - colorA = ReadColor(p1, hBmp1->format); - colorB = ReadColor(p2, hBmp2->format); + gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - p1 += GetBytesPerPixel(hBmp1->format); - p2 += GetBytesPerPixel(hBmp2->format); - } - } - } - else - { - return 0; - } + if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, rop, hPalette)) + return FALSE; - return 1; + if (!test_assert_bitmaps_equal(hBmpDst, expected, + gdi_rop_to_string(rop), hPalette)) + return FALSE; + + return TRUE; } -static void test_dump_data(unsigned char* p, int len, int width, const char* name) +static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) { - unsigned char *line = p; - int i, thisline, offset = 0; - - printf("\n%s[%d][%d]:\n", name, len / width, width); - - while (offset < len) - { - printf("%04x ", offset); - thisline = len - offset; - if (thisline > width) - thisline = width; - - for (i = 0; i < thisline; i++) - printf("%02x ", line[i]); - - for (; i < width; i++) - printf(" "); - - printf("\n"); - offset += thisline; - line += thisline; - } - - printf("\n"); -} - -static void test_dump_bitmap(HGDI_BITMAP hBmp, const char* name) -{ - UINT32 stride = hBmp->width * GetBytesPerPixel(hBmp->format); - - test_dump_data(hBmp->data, hBmp->height * stride, stride, name); -} - -int test_assert_bitmaps_equal(HGDI_BITMAP hBmpActual, HGDI_BITMAP hBmpExpected, const char* name) -{ - int bitmapsEqual = CompareBitmaps(hBmpActual, hBmpExpected); - - if (bitmapsEqual != 1) - { - printf("\n%s\n", name); - test_dump_bitmap(hBmpActual, "Actual"); - test_dump_bitmap(hBmpExpected, "Expected"); - } - - if (bitmapsEqual != 1) - return -1; - - return 0; -} - -int test_gdi_BitBlt_32bpp(void) -{ - BYTE* data; + BOOL rc; + UINT32 x; HGDI_DC hdcSrc; HGDI_DC hdcDst; - HGDI_BRUSH hBrush; + const UINT32 RawFormat = PIXEL_FORMAT_RGB8; + struct test_bitblt tests[] = + { + {GDI_SRCCOPY, bmp_SRCCOPY, NULL}, + {GDI_SPna, bmp_SPna, NULL}, + {GDI_BLACKNESS, bmp_BLACKNESS, NULL}, + {GDI_WHITENESS, bmp_WHITENESS, NULL}, + {GDI_SRCAND, bmp_SRCAND, NULL}, + {GDI_SRCPAINT, bmp_SRCPAINT, NULL}, + {GDI_SRCINVERT, bmp_SRCINVERT, NULL}, + {GDI_SRCERASE, bmp_SRCERASE, NULL}, + {GDI_NOTSRCCOPY, bmp_NOTSRCCOPY, NULL}, + {GDI_NOTSRCERASE, bmp_NOTSRCERASE, NULL}, + {GDI_DSTINVERT, bmp_DSTINVERT, NULL}, + {GDI_MERGECOPY, bmp_MERGECOPY, NULL}, + {GDI_MERGEPAINT, bmp_MERGEPAINT, NULL}, + {GDI_PATCOPY, bmp_PATCOPY, NULL}, + {GDI_PATPAINT, bmp_PATPAINT, NULL}, + {GDI_PATINVERT, bmp_PATINVERT, NULL}, + {GDI_DSTINVERT, bmp_SRC, NULL}, + {GDI_DSPDxax, bmp_SRC, NULL}, + {GDI_PSDPxax, bmp_SRC, NULL}, + {GDI_DSna, bmp_SRC, NULL}, + {GDI_DPa, bmp_SRC, NULL}, + {GDI_PDxn, bmp_SRC, NULL}, + {GDI_DSxn, bmp_SRC, NULL}, + {GDI_PSDnox, bmp_SRC, NULL}, + {GDI_PDSona, bmp_SRC, NULL}, + {GDI_DSPDxox, bmp_SRC, NULL}, + {GDI_DPSDonox, bmp_SRC, NULL}, + {GDI_SPDSxax, bmp_SRC, NULL}, + {GDI_DPon, bmp_SRC, NULL}, + {GDI_DPna, bmp_SRC, NULL}, + {GDI_Pn, bmp_SRC, NULL}, + {GDI_PDna, bmp_SRC, NULL}, + {GDI_DPan, bmp_SRC, NULL}, + {GDI_DSan, bmp_SRC, NULL}, + {GDI_DSxn, bmp_SRC, NULL}, + {GDI_DPa, bmp_SRC, NULL}, + {GDI_D, bmp_SRC, NULL}, + {GDI_DPno, bmp_SRC, NULL}, + {GDI_SDno, bmp_SRC, NULL}, + {GDI_PDno, bmp_SRC, NULL}, + {GDI_DPo, bmp_SRC, NULL} + }; + const UINT32 number_tests = sizeof(tests) / sizeof(tests[0]); HGDI_BITMAP hBmpSrc; HGDI_BITMAP hBmpDst; - HGDI_BITMAP hBmpPat; - HGDI_BITMAP hBmp_SPna; - HGDI_BITMAP hBmp_BLACKNESS; - HGDI_BITMAP hBmp_WHITENESS; - HGDI_BITMAP hBmp_SRCCOPY; - HGDI_BITMAP hBmp_SRCAND; - HGDI_BITMAP hBmp_SRCPAINT; - HGDI_BITMAP hBmp_SRCINVERT; - HGDI_BITMAP hBmp_SRCERASE; - HGDI_BITMAP hBmp_NOTSRCCOPY; - HGDI_BITMAP hBmp_NOTSRCERASE; - HGDI_BITMAP hBmp_DSTINVERT; - HGDI_BITMAP hBmp_MERGECOPY; - HGDI_BITMAP hBmp_MERGEPAINT; - HGDI_BITMAP hBmp_PATCOPY; - HGDI_BITMAP hBmp_PATPAINT; - HGDI_BITMAP hBmp_PATINVERT; HGDI_BITMAP hBmpDstOriginal; - UINT32* hPalette; - const UINT32 format = PIXEL_FORMAT_XRGB32; + gdiPalette g; + gdiPalette* hPalette = &g; + g.format = DstFormat; + + for (x = 0; x < 256; x++) + g.palette[x] = GetColor(DstFormat, x, x, x, 0xFF); if (!(hdcSrc = gdi_GetDC())) { printf("failed to get gdi device context\n"); - return -1; + goto fail; } - hdcSrc->format = format; + + hdcSrc->format = SrcFormat; if (!(hdcDst = gdi_GetDC())) { printf("failed to get gdi device context\n"); - return -1; + goto fail; } - hdcDst->format = format; - hPalette = NULL; // TODO: Get a real palette! + hdcDst->format = DstFormat; + hBmpSrc = test_convert_to_bitmap(bmp_SRC, RawFormat, 0, 0, 0, + SrcFormat, 0, 0, 0, 16, 16, hPalette); - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRC, NULL, 16, 16, 8, format, hPalette); - hBmpSrc = gdi_CreateBitmap(16, 16, format, data); + if (!hBmpSrc) + goto fail; - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_DST, NULL, 16, 16, 8, format, hPalette); - hBmpDst = gdi_CreateBitmap(16, 16, format, data); + hBmpDst = test_convert_to_bitmap(bmp_DST, RawFormat, 0, 0, 0, + DstFormat, 0, 0, 0, 16, 16, hPalette); - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_DST, NULL, 16, 16, 8, format, hPalette); - hBmpDstOriginal = gdi_CreateBitmap(16, 16, format, data); + if (!hBmpDst) + goto fail; - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PAT, NULL, 8, 8, 8, format, hPalette); - hBmpPat = gdi_CreateBitmap(8, 8, format, data); + hBmpDstOriginal = test_convert_to_bitmap(bmp_DST, RawFormat, 0, 0, 0, + DstFormat, 0, 0, 0, 16, 16, hPalette); - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCCOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCCOPY = gdi_CreateBitmap(16, 16, format, data); + if (!hBmpDstOriginal) + goto fail; - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SPna, NULL, 16, 16, 8, format, hPalette); - hBmp_SPna = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_BLACKNESS, NULL, 16, 16, 8, format, hPalette); - hBmp_BLACKNESS = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_WHITENESS, NULL, 16, 16, 8, format, hPalette); - hBmp_WHITENESS = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCAND, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCAND = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCPAINT, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCPAINT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCINVERT, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCINVERT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCERASE, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCERASE = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_NOTSRCCOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_NOTSRCCOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_NOTSRCERASE, NULL, 16, 16, 8, format, hPalette); - hBmp_NOTSRCERASE = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_DSTINVERT, NULL, 16, 16, 8, format, hPalette); - hBmp_DSTINVERT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_MERGECOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_MERGECOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_MERGEPAINT, NULL, 16, 16, 8, format, hPalette); - hBmp_MERGEPAINT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PATCOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_PATCOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PATPAINT, NULL, 16, 16, 8, format, hPalette); - hBmp_PATPAINT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PATINVERT, NULL, 16, 16, 8, format, hPalette); - hBmp_PATINVERT = gdi_CreateBitmap(16, 16, format, data); - - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - gdi_SelectObject(hdcDst, (HGDIOBJECT) hBmpDst); - - /* SRCCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCCOPY, "SRCCOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* BLACKNESS */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_BLACKNESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_BLACKNESS, "BLACKNESS") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* WHITENESS */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_WHITENESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_WHITENESS, "WHITENESS") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCAND */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCAND)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCAND, "SRCAND") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCPAINT, "SRCPAINT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCINVERT, "SRCINVERT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCERASE */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCERASE)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCERASE, "SRCERASE") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* NOTSRCCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_NOTSRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_NOTSRCCOPY, "NOTSRCCOPY") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* NOTSRCERASE */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_NOTSRCERASE)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_NOTSRCERASE, "NOTSRCERASE") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* DSTINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_DSTINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_DSTINVERT, "DSTINVERT") < 0) - // return -1; - - /* select a brush for operations using a pattern */ - hBrush = gdi_CreatePatternBrush(hBmpPat); - gdi_SelectObject(hdcDst, (HGDIOBJECT) hBrush); - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* MERGECOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_MERGECOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_MERGECOPY, "MERGECOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* MERGEPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_MERGEPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_MERGEPAINT, "MERGEPAINT") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATCOPY, "PATCOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATINVERT, "PATINVERT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATPAINT, "PATPAINT") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SPna */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SPna)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SPna, "SPna") < 0) - return -1; - - return 0; -} - -int test_gdi_BitBlt_16bpp(void) -{ - BYTE* data; - HGDI_DC hdcSrc; - HGDI_DC hdcDst; - HGDI_BRUSH hBrush; - HGDI_BITMAP hBmpSrc; - HGDI_BITMAP hBmpDst; - HGDI_BITMAP hBmpPat; - HGDI_BITMAP hBmp_SPna; - HGDI_BITMAP hBmp_BLACKNESS; - HGDI_BITMAP hBmp_WHITENESS; - HGDI_BITMAP hBmp_SRCCOPY; - HGDI_BITMAP hBmp_SRCAND; - HGDI_BITMAP hBmp_SRCPAINT; - HGDI_BITMAP hBmp_SRCINVERT; - HGDI_BITMAP hBmp_SRCERASE; - HGDI_BITMAP hBmp_NOTSRCCOPY; - HGDI_BITMAP hBmp_NOTSRCERASE; - HGDI_BITMAP hBmp_DSTINVERT; - HGDI_BITMAP hBmp_MERGECOPY; - HGDI_BITMAP hBmp_MERGEPAINT; - HGDI_BITMAP hBmp_PATCOPY; - HGDI_BITMAP hBmp_PATPAINT; - HGDI_BITMAP hBmp_PATINVERT; - HGDI_BITMAP hBmpDstOriginal; - rdpPalette* hPalette; - const UINT32 format = PIXEL_FORMAT_XRGB32; - - if (!(hdcSrc = gdi_GetDC())) - { - printf("failed to get gdi device context\n"); - return -1; - } - - hdcSrc->format = format; - - if (!(hdcDst = gdi_GetDC())) - { - printf("failed to get gdi device context\n"); - return -1; - } - - hdcDst->format = format; - - hPalette = (rdpPalette*) gdi_GetSystemPalette(); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRC, NULL, 16, 16, 8, format, hPalette); - hBmpSrc = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_DST, NULL, 16, 16, 8, format, hPalette); - hBmpDst = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_DST, NULL, 16, 16, 8, format, hPalette); - hBmpDstOriginal = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PAT, NULL, 8, 8, 8, format, hPalette); - hBmpPat = gdi_CreateBitmap(8, 8, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCCOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCCOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SPna, NULL, 16, 16, 8, format, hPalette); - hBmp_SPna = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_BLACKNESS, NULL, 16, 16, 8, format, hPalette); - hBmp_BLACKNESS = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_WHITENESS, NULL, 16, 16, 8, format, hPalette); - hBmp_WHITENESS = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCAND, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCAND = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCPAINT, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCPAINT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCINVERT, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCINVERT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_SRCERASE, NULL, 16, 16, 8, format, hPalette); - hBmp_SRCERASE = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_NOTSRCCOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_NOTSRCCOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_NOTSRCERASE, NULL, 16, 16, 8, format, hPalette); - hBmp_NOTSRCERASE = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_DSTINVERT, NULL, 16, 16, 8, format, hPalette); - hBmp_DSTINVERT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_MERGECOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_MERGECOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_MERGEPAINT, NULL, 16, 16, 8, format, hPalette); - hBmp_MERGEPAINT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PATCOPY, NULL, 16, 16, 8, format, hPalette); - hBmp_PATCOPY = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PATPAINT, NULL, 16, 16, 8, format, hPalette); - hBmp_PATPAINT = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) bmp_PATINVERT, NULL, 16, 16, 8, format, hPalette); - hBmp_PATINVERT = gdi_CreateBitmap(16, 16, format, data); - - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - gdi_SelectObject(hdcDst, (HGDIOBJECT) hBmpDst); - - /* SRCCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCCOPY, "SRCCOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* BLACKNESS */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_BLACKNESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_BLACKNESS, "BLACKNESS") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* WHITENESS */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_WHITENESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_WHITENESS, "WHITENESS") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCAND */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCAND)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCAND, "SRCAND") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCPAINT, "SRCPAINT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCINVERT, "SRCINVERT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCERASE */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCERASE)) + for (x = 0; x < number_tests; x++) { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCERASE, "SRCERASE") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* NOTSRCCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_NOTSRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_NOTSRCCOPY, "NOTSRCCOPY") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* NOTSRCERASE */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_NOTSRCERASE)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_NOTSRCERASE, "NOTSRCERASE") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* DSTINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_DSTINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_DSTINVERT, "DSTINVERT") < 0) - // return -1; - - /* select a brush for operations using a pattern */ - hBrush = gdi_CreatePatternBrush(hBmpPat); - gdi_SelectObject(hdcDst, (HGDIOBJECT) hBrush); - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* MERGECOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_MERGECOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_MERGECOPY, "MERGECOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* MERGEPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_MERGEPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_MERGEPAINT, "MERGEPAINT") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATCOPY, "PATCOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATINVERT, "PATINVERT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATPAINT, "PATPAINT") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SPna */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SPna)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SPna, "SPna") < 0) - return -1; - - return 0; -} - -int test_gdi_BitBlt_8bpp(void) -{ - BYTE* data; - HGDI_DC hdcSrc; - HGDI_DC hdcDst; - HGDI_BRUSH hBrush; - HGDI_BITMAP hBmpSrc; - HGDI_BITMAP hBmpDst; - HGDI_BITMAP hBmpPat; - HGDI_BITMAP hBmp_SPna; - HGDI_BITMAP hBmp_BLACKNESS; - HGDI_BITMAP hBmp_WHITENESS; - HGDI_BITMAP hBmp_SRCCOPY; - HGDI_BITMAP hBmp_SRCAND; - HGDI_BITMAP hBmp_SRCPAINT; - HGDI_BITMAP hBmp_SRCINVERT; - HGDI_BITMAP hBmp_SRCERASE; - HGDI_BITMAP hBmp_NOTSRCCOPY; - HGDI_BITMAP hBmp_NOTSRCERASE; - HGDI_BITMAP hBmp_DSTINVERT; - HGDI_BITMAP hBmp_MERGECOPY; - HGDI_BITMAP hBmp_MERGEPAINT; - HGDI_BITMAP hBmp_PATCOPY; - HGDI_BITMAP hBmp_PATPAINT; - HGDI_BITMAP hBmp_PATINVERT; - HGDI_BITMAP hBmpDstOriginal; - DWORD* hPalette; - const UINT32 format = PIXEL_FORMAT_XRGB32; - - if (!(hdcSrc = gdi_GetDC())) - { - printf("failed to get gdi device context\n"); - return -1; - } - - hdcSrc->format = format; - - data = calloc(1024, 1024); - if (!data) - return -1; - - if (!(hdcDst = gdi_GetDC())) - { - printf("failed to get gdi device context\n"); - return -1; - } - - hdcDst->format = format; - - hPalette = NULL; // TODO - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SRC, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmpSrc = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_DST, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmpDst = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_DST, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmpDstOriginal = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 8, 8, - bmp_DST, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmpPat = gdi_CreateBitmap(8, 8, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SRCCOPY, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_SRCCOPY = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SPna, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_SPna = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_BLACKNESS, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_BLACKNESS = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_WHITENESS, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_WHITENESS = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SRCAND, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_SRCAND = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SRCPAINT, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_SRCPAINT = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SRCINVERT, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_SRCINVERT = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_SRCERASE, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_SRCERASE = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_NOTSRCCOPY, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_NOTSRCCOPY = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_NOTSRCERASE, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_NOTSRCERASE = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_DSTINVERT, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_DSTINVERT = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_MERGECOPY, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_MERGECOPY = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_MERGEPAINT, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_MERGEPAINT = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_PATCOPY, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_PATCOPY = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_PATPAINT, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_PATPAINT = gdi_CreateBitmap(16, 16, format, data); - - if (!freerdp_image_copy(data, format, -1, 0, 0, 16, 16, - bmp_PATINVERT, PIXEL_FORMAT_RGB8, -1, 0, 0, hPalette)) - return -1; - hBmp_PATINVERT = gdi_CreateBitmap(16, 16, format, data); - - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - gdi_SelectObject(hdcDst, (HGDIOBJECT) hBmpDst); - - /* SRCCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (CompareBitmaps(hBmpDst, hBmp_SRCCOPY) != 1) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* BLACKNESS */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_BLACKNESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_BLACKNESS, "BLACKNESS") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* WHITENESS */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_WHITENESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } + tests[x].bmp = test_convert_to_bitmap(tests[x].src, RawFormat, 0, 0, 0, + SrcFormat, 0, 0, 0, 16, 16, hPalette); - //if (test_assert_bitmaps_equal(hBmpDst, hBmp_WHITENESS, "WHITENESS") < 0) - // return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; + if (!tests[x].bmp) + goto fail; } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - /* SRCAND */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCAND)) + for (x = 0; x < number_tests; x++) { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; + if (!test_rop(hdcDst, hdcSrc, hBmpSrc, hBmpDst, hBmpDstOriginal, tests[x].rop, + tests[x].bmp, hPalette)) + goto fail; } - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCAND, "SRCAND") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCPAINT, "SRCPAINT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCINVERT, "SRCINVERT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SRCERASE */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCERASE)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SRCERASE, "SRCERASE") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* NOTSRCCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_NOTSRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_NOTSRCCOPY, "NOTSRCCOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* NOTSRCERASE */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_NOTSRCERASE)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_NOTSRCERASE, "NOTSRCERASE") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* DSTINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_DSTINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_DSTINVERT, "DSTINVERT") < 0) - return -1; - - /* select a brush for operations using a pattern */ - hBrush = gdi_CreatePatternBrush(hBmpPat); - gdi_SelectObject(hdcDst, (HGDIOBJECT) hBrush); - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* MERGECOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_MERGECOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_MERGECOPY, "MERGECOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* MERGEPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_MERGEPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_MERGEPAINT, "MERGEPAINT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATCOPY */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATCOPY, "PATCOPY") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATINVERT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATINVERT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATINVERT, "PATINVERT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* PATPAINT */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATPAINT)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - - if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATPAINT, "PATPAINT") < 0) - return -1; - - /* restore original destination bitmap */ - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal); - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc); - - /* SPna */ - if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SPna)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } + rc = TRUE; +fail: - if (test_assert_bitmaps_equal(hBmpDst, hBmp_SPna, "SPna") < 0) - return -1; + for (x = 0; x < number_tests; x++) + gdi_DeleteObject((HGDIOBJECT)tests[x].bmp); - return 0; + gdi_DeleteObject((HGDIOBJECT)hBmpSrc); + gdi_DeleteObject((HGDIOBJECT)hBmpDst); + gdi_DeleteObject((HGDIOBJECT)hBmpDstOriginal); + gdi_DeleteDC(hdcSrc); + gdi_DeleteDC(hdcDst); + return rc; } int TestGdiBitBlt(int argc, char* argv[]) { - return 0; /* FIXME: broken tests */ + UINT32 x, y; + const UINT32 formatList[] = + { + PIXEL_FORMAT_RGB8, + PIXEL_FORMAT_RGB15, + PIXEL_FORMAT_ARGB15, + PIXEL_FORMAT_RGB16, + PIXEL_FORMAT_RGB24, + PIXEL_FORMAT_RGBA32, + PIXEL_FORMAT_RGBX32, + PIXEL_FORMAT_ARGB32, + PIXEL_FORMAT_XRGB32, + PIXEL_FORMAT_BGR15, + PIXEL_FORMAT_ABGR15, + PIXEL_FORMAT_BGR16, + PIXEL_FORMAT_BGR24, + PIXEL_FORMAT_BGRA32, + PIXEL_FORMAT_BGRX32, + PIXEL_FORMAT_ABGR32, + PIXEL_FORMAT_XBGR32 + }; + const UINT32 listSize = sizeof(formatList) / sizeof(formatList[0]); - fprintf(stderr, "test_gdi_BitBlt_32bpp()\n"); - - if (test_gdi_BitBlt_32bpp() < 0) - return -1; - - fprintf(stderr, "test_gdi_BitBlt_16bpp()\n"); - - if (test_gdi_BitBlt_16bpp() < 0) - return -1; - - fprintf(stderr, "test_gdi_BitBlt_8bpp()\n"); - - if (test_gdi_BitBlt_8bpp() < 0) - return -1; + for (x = 0; x < listSize; x++) + { + /* Skip 8bpp, only supported on remote end. */ + for (y = 1; y < listSize; y++) + { + if (test_gdi_BitBlt(formatList[x], formatList[y]) != 0) + { + fprintf(stderr, "test_gdi_BitBlt(SrcFormat=%s, DstFormat=%s) failed!\n", + GetColorFormatName(formatList[x]), + GetColorFormatName(formatList[y])); + return -1; + } + } + } return 0; } diff --git a/libfreerdp/gdi/test/TestGdiClip.c b/libfreerdp/gdi/test/TestGdiClip.c index b3b390a69..6fbf2c049 100644 --- a/libfreerdp/gdi/test/TestGdiClip.c +++ b/libfreerdp/gdi/test/TestGdiClip.c @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -29,20 +28,17 @@ static int test_gdi_ClipCoords(void) } hdc->format = format; - bmp = gdi_CreateBitmapEx(1024, 768, PIXEL_FORMAT_XRGB32, 0, NULL, NULL); + bmp = gdi_CreateBitmapEx(1024, 768, PIXEL_FORMAT_XRGB32, 0, NULL, NULL); gdi_SelectObject(hdc, (HGDIOBJECT) bmp); gdi_SetNullClipRgn(hdc); - rgn1 = gdi_CreateRectRgn(0, 0, 0, 0); rgn2 = gdi_CreateRectRgn(0, 0, 0, 0); rgn1->null = 1; rgn2->null = 1; - /* null clipping region */ gdi_SetNullClipRgn(hdc); gdi_SetRgn(rgn1, 20, 20, 100, 100); gdi_SetRgn(rgn2, 20, 20, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -52,7 +48,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 0, 0, 1024, 768); gdi_SetRgn(rgn1, 20, 20, 100, 100); gdi_SetRgn(rgn2, 20, 20, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -62,8 +57,8 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 20, 20, 100, 100); gdi_SetRgn(rgn2, 0, 0, 0, 0); - - draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); + draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, + NULL); if (draw) return -1; @@ -72,8 +67,8 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 420, 420, 100, 100); gdi_SetRgn(rgn2, 0, 0, 0, 0); - - draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); + draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, + NULL); if (draw) return -1; @@ -82,8 +77,8 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 20, 100, 100); gdi_SetRgn(rgn2, 0, 0, 0, 0); - - draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); + draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, + NULL); if (draw) return -1; @@ -92,8 +87,8 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 420, 100, 100); gdi_SetRgn(rgn2, 0, 0, 0, 0); - - draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); + draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, + NULL); if (draw) return -1; @@ -102,7 +97,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 100, 300, 300, 100); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -112,7 +106,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 100, 300, 250, 100); gdi_SetRgn(rgn2, 300, 300, 50, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -122,7 +115,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 300, 300, 100); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -132,7 +124,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 350, 300, 200, 100); gdi_SetRgn(rgn2, 350, 300, 50, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -142,7 +133,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 100, 300, 300); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -152,7 +142,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 300, 100, 200); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -162,7 +151,6 @@ static int test_gdi_ClipCoords(void) gdi_SetClipRgn(hdc, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 300, 100, 100); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL); if (!gdi_EqualRgn(rgn1, rgn2)) @@ -177,8 +165,8 @@ static int test_gdi_InvalidateRegion(void) HGDI_RGN rgn1; HGDI_RGN rgn2; HGDI_RGN invalid; - HGDI_BITMAP bmp; - const UINT32 format = PIXEL_FORMAT_XRGB32; + HGDI_BITMAP bmp; + const UINT32 format = PIXEL_FORMAT_XRGB32; if (!(hdc = gdi_GetDC())) { @@ -187,28 +175,23 @@ static int test_gdi_InvalidateRegion(void) } hdc->format = format; - bmp = gdi_CreateBitmapEx(1024, 768, PIXEL_FORMAT_XRGB32, 0, NULL, NULL); + bmp = gdi_CreateBitmapEx(1024, 768, PIXEL_FORMAT_XRGB32, 0, NULL, NULL); gdi_SelectObject(hdc, (HGDIOBJECT) bmp); gdi_SetNullClipRgn(hdc); - hdc->hwnd = (HGDI_WND) calloc(1, sizeof(GDI_WND)); hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0); hdc->hwnd->invalid->null = 1; invalid = hdc->hwnd->invalid; - hdc->hwnd->count = 16; hdc->hwnd->cinvalid = (HGDI_RGN) calloc(hdc->hwnd->count, sizeof(GDI_RGN)); - rgn1 = gdi_CreateRectRgn(0, 0, 0, 0); rgn2 = gdi_CreateRectRgn(0, 0, 0, 0); rgn1->null = 1; rgn2->null = 1; - /* no previous invalid region */ invalid->null = 1; gdi_SetRgn(rgn1, 300, 300, 100, 100); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -218,7 +201,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 300, 100, 100); gdi_SetRgn(rgn2, 300, 300, 100, 100); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -228,7 +210,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 100, 300, 300, 100); gdi_SetRgn(rgn2, 100, 300, 300, 100); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -238,7 +219,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 300, 300, 100); gdi_SetRgn(rgn2, 300, 300, 300, 100); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -248,7 +228,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 100, 100, 300); gdi_SetRgn(rgn2, 300, 100, 100, 300); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -258,7 +237,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 300, 100, 300); gdi_SetRgn(rgn2, 300, 300, 100, 300); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -268,7 +246,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 100, 300, 600, 300); gdi_SetRgn(rgn2, 100, 300, 600, 300); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -278,7 +255,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 100, 100, 500); gdi_SetRgn(rgn2, 300, 100, 100, 500); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -288,7 +264,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 100, 300, 100, 100); gdi_SetRgn(rgn2, 100, 300, 300, 100); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -298,7 +273,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 700, 300, 100, 100); gdi_SetRgn(rgn2, 300, 300, 500, 100); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -308,7 +282,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 100, 100, 100); gdi_SetRgn(rgn2, 300, 100, 100, 300); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -318,7 +291,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 300, 500, 100, 100); gdi_SetRgn(rgn2, 300, 300, 100, 300); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -328,7 +300,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 100, 100, 600, 600); gdi_SetRgn(rgn2, 100, 100, 600, 600); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) @@ -338,7 +309,6 @@ static int test_gdi_InvalidateRegion(void) gdi_SetRgn(invalid, 300, 300, 100, 100); gdi_SetRgn(rgn1, 0, 0, 1024, 768); gdi_SetRgn(rgn2, 0, 0, 1024, 768); - gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h); if (!gdi_EqualRgn(invalid, rgn2)) diff --git a/libfreerdp/gdi/test/TestGdiCreate.c b/libfreerdp/gdi/test/TestGdiCreate.c index 7994abd7b..9a0e29aa5 100644 --- a/libfreerdp/gdi/test/TestGdiCreate.c +++ b/libfreerdp/gdi/test/TestGdiCreate.c @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -22,7 +21,7 @@ static int test_gdi_GetDC(void) return -1; } - if (hdc->format != PIXEL_FORMAT_XRGB32) + if (hdc->format != PIXEL_FORMAT_XRGB32) return -1; if (hdc->drawMode != GDI_R2_BLACK) @@ -67,9 +66,9 @@ static int test_gdi_CreateBitmap(void) UINT32 height; BYTE* data; HGDI_BITMAP hBitmap; - width = 32; height = 16; + if (!(data = (BYTE*) _aligned_malloc(width * height * 4, 16))) { printf("failed to allocate aligned bitmap data memory\n"); @@ -98,7 +97,6 @@ static int test_gdi_CreateBitmap(void) return -1; gdi_DeleteObject((HGDIOBJECT) hBitmap); - return 0; } @@ -116,7 +114,6 @@ static int test_gdi_CreateCompatibleBitmap(void) } hdc->format = PIXEL_FORMAT_ARGB32; - width = 32; height = 16; hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); @@ -137,13 +134,14 @@ static int test_gdi_CreateCompatibleBitmap(void) return -1; gdi_DeleteObject((HGDIOBJECT) hBitmap); - return 0; } static int test_gdi_CreatePen(void) { - HGDI_PEN hPen = gdi_CreatePen(GDI_PS_SOLID, 8, 0xAABBCCDD); + const UINT32 format = PIXEL_FORMAT_RGBA32; + HGDI_PEN hPen = gdi_CreatePen(GDI_PS_SOLID, 8, 0xAABBCCDD, + format, NULL); if (!hPen) { @@ -161,7 +159,6 @@ static int test_gdi_CreatePen(void) return -1; gdi_DeleteObject((HGDIOBJECT) hPen); - return 0; } @@ -179,7 +176,6 @@ static int test_gdi_CreateSolidBrush(void) return -1; gdi_DeleteObject((HGDIOBJECT) hBrush); - return 0; } @@ -187,7 +183,6 @@ static int test_gdi_CreatePatternBrush(void) { HGDI_BRUSH hBrush; HGDI_BITMAP hBitmap; - hBitmap = gdi_CreateBitmap(64, 64, 32, NULL); hBrush = gdi_CreatePatternBrush(hBitmap); @@ -201,7 +196,6 @@ static int test_gdi_CreatePatternBrush(void) return -1; gdi_DeleteObject((HGDIOBJECT) hBitmap); - return 0; } @@ -211,7 +205,6 @@ static int test_gdi_CreateRectRgn(void) int y1 = 64; int x2 = 128; int y2 = 256; - HGDI_RGN hRegion = gdi_CreateRectRgn(x1, y1, x2, y2); if (hRegion->objectType != GDIOBJECT_REGION) @@ -233,7 +226,6 @@ static int test_gdi_CreateRectRgn(void) return -1; gdi_DeleteObject((HGDIOBJECT) hRegion); - return 0; } @@ -267,7 +259,6 @@ static int test_gdi_CreateRect(void) return -1; gdi_DeleteObject((HGDIOBJECT) hRect); - return 0; } @@ -285,10 +276,8 @@ static int test_gdi_GetPixel(void) } hdc->format = PIXEL_FORMAT_ARGB32; - hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); gdi_SelectObject(hdc, (HGDIOBJECT) hBitmap); - hBitmap->data[(64 * width * 4) + 32 * 4 + 0] = 0xDD; hBitmap->data[(64 * width * 4) + 32 * 4 + 1] = 0xCC; hBitmap->data[(64 * width * 4) + 32 * 4 + 2] = 0xBB; @@ -298,7 +287,6 @@ static int test_gdi_GetPixel(void) return -1; gdi_DeleteObject((HGDIOBJECT) hBitmap); - return 0; } @@ -316,10 +304,8 @@ static int test_gdi_SetPixel(void) } hdc->format = PIXEL_FORMAT_ARGB32; - hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); gdi_SelectObject(hdc, (HGDIOBJECT) hBitmap); - gdi_SetPixel(hdc, 32, 64, 0xAABBCCDD); if (gdi_GetPixel(hdc, 32, 64) != 0xAABBCCDD) @@ -331,7 +317,6 @@ static int test_gdi_SetPixel(void) return -1; gdi_DeleteObject((HGDIOBJECT) hBitmap); - return 0; } @@ -358,6 +343,8 @@ static int test_gdi_MoveToEx(void) HGDI_DC hdc; HGDI_PEN hPen; HGDI_POINT prevPoint; + const UINT32 format = PIXEL_FORMAT_RGBA32; + rdpPalette* palette = NULL; if (!(hdc = gdi_GetDC())) { @@ -365,7 +352,7 @@ static int test_gdi_MoveToEx(void) return -1; } - if (!(hPen = gdi_CreatePen(GDI_PS_SOLID, 8, 0xAABBCCDD))) + if (!(hPen = gdi_CreatePen(GDI_PS_SOLID, 8, 0xAABBCCDD, format, palette))) { printf("gdi_CreatePen failed\n"); return -1; @@ -382,7 +369,6 @@ static int test_gdi_MoveToEx(void) prevPoint = (HGDI_POINT) malloc(sizeof(GDI_POINT)); ZeroMemory(prevPoint, sizeof(GDI_POINT)); - gdi_MoveToEx(hdc, 64, 128, prevPoint); if (prevPoint->x != 128) diff --git a/libfreerdp/gdi/test/TestGdiEllipse.c b/libfreerdp/gdi/test/TestGdiEllipse.c index c32640e12..fdc544bb5 100644 --- a/libfreerdp/gdi/test/TestGdiEllipse.c +++ b/libfreerdp/gdi/test/TestGdiEllipse.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -14,10 +13,11 @@ #include "line.h" #include "brush.h" #include "clipping.h" +#include "helpers.h" /* Ellipse() Test Data */ -static BYTE ellipse_case_1[256] = +static const BYTE ellipse_case_1[256] = { "\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF" @@ -37,7 +37,7 @@ static BYTE ellipse_case_1[256] = "\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF" }; -static BYTE ellipse_case_2[256] = +static const BYTE ellipse_case_2[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF" @@ -57,7 +57,7 @@ static BYTE ellipse_case_2[256] = "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF" }; -static BYTE ellipse_case_3[256] = +static const BYTE ellipse_case_3[256] = { "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" @@ -79,55 +79,106 @@ static BYTE ellipse_case_3[256] = int TestGdiEllipse(int argc, char* argv[]) { + int rc = -1; + UINT32 i, j; HGDI_DC hdc; HGDI_PEN pen; - BYTE* data; HGDI_BITMAP hBmp; HGDI_BITMAP hBmp_Ellipse_1; HGDI_BITMAP hBmp_Ellipse_2; HGDI_BITMAP hBmp_Ellipse_3; - rdpPalette* hPalette; - const UINT32 format = PIXEL_FORMAT_RGB8; - - if (!(hdc = gdi_GetDC())) + const UINT32 RawFormat = PIXEL_FORMAT_RGB8; + const UINT32 colorFormats[] = { - printf("failed to get gdi device context\n"); - return -1; + PIXEL_FORMAT_RGB15, + PIXEL_FORMAT_ARGB15, + PIXEL_FORMAT_RGB16, + PIXEL_FORMAT_RGB24, + PIXEL_FORMAT_ARGB32, + PIXEL_FORMAT_XRGB32, + PIXEL_FORMAT_RGBA32, + PIXEL_FORMAT_RGBX32, + PIXEL_FORMAT_BGR15, + PIXEL_FORMAT_ABGR15, + PIXEL_FORMAT_BGR16, + PIXEL_FORMAT_BGR24, + PIXEL_FORMAT_ABGR32, + PIXEL_FORMAT_XBGR32, + PIXEL_FORMAT_BGRA32, + PIXEL_FORMAT_BGRX32 + }; + const UINT32 number_formats = sizeof(colorFormats) / sizeof(colorFormats[0]); + gdiPalette g; + + for (i = 0; i < number_formats; i++) + { + const UINT32 format = colorFormats[i]; + rdpPalette* hPalette = &g; + g.format = format; + + for (i = 0; i < 256; i++) + g.palette[i] = GetColor(format, i, i, i, 0xFF); + + rc = -1; + + if (!(hdc = gdi_GetDC())) + { + printf("failed to get gdi device context\n"); + goto fail; + } + + hdc->format = format; + gdi_SetNullClipRgn(hdc); + + if (!(pen = gdi_CreatePen(1, 1, 0, format, hPalette))) + { + printf("gdi_CreatePen failed\n"); + goto fail; + } + + gdi_SelectObject(hdc, (HGDIOBJECT) pen); + hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16); + gdi_SelectObject(hdc, (HGDIOBJECT) hBmp); + hBmp_Ellipse_1 = test_convert_to_bitmap(ellipse_case_1, RawFormat, 0, 0, 0, + format, 0, 0, 0, 16, 16, hPalette); + + if (!hBmp_Ellipse_1) + goto fail; + + hBmp_Ellipse_2 = test_convert_to_bitmap(ellipse_case_2, RawFormat, 0, 0, 0, + format, 0, 0, 0, 16, 16, hPalette); + + if (!hBmp_Ellipse_2) + goto fail; + + hBmp_Ellipse_3 = test_convert_to_bitmap(ellipse_case_3, RawFormat, 0, 0, 0, + format, 0, 0, 0, 16, 16, hPalette); + + if (!hBmp_Ellipse_3) + goto fail; + + /* Test Case 1: (0,0) -> (16, 16) */ + if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette)) + { + printf("gdi_BitBlt failed (line #%u)\n", __LINE__); + return -1; + } + + if (!gdi_Ellipse(hdc, 0, 0, 16, 16)) + goto fail; + + rc = 0; + fail: + gdi_DeleteObject((HGDIOBJECT) hBmp_Ellipse_1); + gdi_DeleteObject((HGDIOBJECT) hBmp_Ellipse_2); + gdi_DeleteObject((HGDIOBJECT) hBmp_Ellipse_3); + gdi_DeleteObject((HGDIOBJECT) pen); + gdi_DeleteDC(hdc); + + if (rc != 0) + break; } - hdc->format = format; - gdi_SetNullClipRgn(hdc); - - if (!(pen = gdi_CreatePen(1, 1, 0))) - { - printf("gdi_CreatePen failed\n"); - return -1; - } - - gdi_SelectObject(hdc, (HGDIOBJECT) pen); - - hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16); - gdi_SelectObject(hdc, (HGDIOBJECT) hBmp); - - hPalette = (rdpPalette*) gdi_GetSystemPalette(); - - data = (BYTE*) freerdp_image_convert((BYTE*) ellipse_case_1, NULL, 16, 16, 8, format, hPalette); - hBmp_Ellipse_1 = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) ellipse_case_2, NULL, 16, 16, 8, format, hPalette); - hBmp_Ellipse_2 = gdi_CreateBitmap(16, 16, format, data); - - data = (BYTE*) freerdp_image_convert((BYTE*) ellipse_case_3, NULL, 16, 16, 8, format, hPalette); - hBmp_Ellipse_3 = gdi_CreateBitmap(16, 16, format, data); - - /* Test Case 1: (0,0) -> (16, 16) */ - if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - return -1; - } - gdi_Ellipse(hdc, 0, 0, 16, 16); - - return 0; + return rc; } diff --git a/libfreerdp/gdi/test/TestGdiLine.c b/libfreerdp/gdi/test/TestGdiLine.c index f8f874e64..eaaca391b 100644 --- a/libfreerdp/gdi/test/TestGdiLine.c +++ b/libfreerdp/gdi/test/TestGdiLine.c @@ -246,10 +246,9 @@ static const BYTE* line_to_case[] = line_to_case_6, line_to_case_7, line_to_case_8, - line_to_case_1, - line_to_case_1, - line_to_case_1, - line_to_case_1, + line_to_case_9, + line_to_case_10, + line_to_case_11 }; static const BYTE line_to_R2_BLACK[256] = @@ -623,20 +622,19 @@ struct ropMap }; static BOOL test_line(HGDI_DC hdc, const gdiPalette* hPalette, UINT32 mX, - UINT32 mY, - UINT32 lX, UINT32 lY, HGDI_BITMAP hBmp, HGDI_BITMAP hOrgBmp) + UINT32 mY, UINT32 lX, UINT32 lY, HGDI_BITMAP hBmp, + HGDI_BITMAP hOrgBmp, UINT32 cX, UINT32 cY, UINT32 cW, UINT32 cH) { - /* Test Case 10: (12,12) -> (4,4) */ if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); return FALSE; - } + + if ((cX > 0) || (cY > 0) || (cW > 0) || (cH > 0)) + gdi_SetClipRgn(hdc, cX, cY, cW, cH); gdi_MoveToEx(hdc, mX, mY, hPalette); gdi_LineTo(hdc, lX, lY); - if (!test_assert_bitmaps_equal(hBmp, hOrgBmp, "Case 10") < 0) + if (!test_assert_bitmaps_equal(hBmp, hOrgBmp, "Case 10", hPalette)) return FALSE; return TRUE; @@ -645,7 +643,8 @@ static BOOL test_line(HGDI_DC hdc, const gdiPalette* hPalette, UINT32 mX, int TestGdiLine(int argc, char* argv[]) { int rc = -1; - UINT32 x, i; + UINT32 x, i, j; + gdiPalette g; const UINT32 RawFormat = PIXEL_FORMAT_RGB8; const UINT32 colorFormats[] = { @@ -694,13 +693,14 @@ int TestGdiLine(int argc, char* argv[]) }; const UINT32 map_size = sizeof(rop_map) / sizeof(rop_map[0]); HGDI_BITMAP hBmp_LineTo[LINTETO_NUMBER] = {NULL}; - gdiPalette p; - gdiPalette* hPalette = &p; + gdiPalette* hPalette = &g; const UINT32 format = colorFormats[i]; - rc = -1; - p.format = format; + g.format = format; - // TODO: Initialize palette!!! + for (i = 0; i < 256; i++) + g.palette[i] = GetColor(format, i, i, i, 0xFF); + + rc = -1; if (!(hdc = gdi_GetDC())) { @@ -739,56 +739,39 @@ int TestGdiLine(int argc, char* argv[]) goto fail; } - if (!test_line(hdc, hPalette, 0, 0, 15, 15, hBmp, hBmp_LineTo[0])) + if (!test_line(hdc, hPalette, 0, 0, 15, 15, hBmp, hBmp_LineTo[0], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 15, 15, 0, 0, hBmp, hBmp_LineTo[1])) + if (!test_line(hdc, hPalette, 15, 15, 0, 0, hBmp, hBmp_LineTo[1], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 15, 0, 0, 15, hBmp, hBmp_LineTo[2])) + if (!test_line(hdc, hPalette, 15, 0, 0, 15, hBmp, hBmp_LineTo[2], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 0, 15, 15, 0, hBmp, hBmp_LineTo[3])) + if (!test_line(hdc, hPalette, 0, 15, 15, 0, hBmp, hBmp_LineTo[3], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 0, 8, 15, 8, hBmp, hBmp_LineTo[4])) + if (!test_line(hdc, hPalette, 0, 8, 15, 8, hBmp, hBmp_LineTo[4], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 15, 8, 0, 8, hBmp, hBmp_LineTo[5])) + if (!test_line(hdc, hPalette, 15, 8, 0, 8, hBmp, hBmp_LineTo[5], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 8, 0, 8, 15, hBmp, hBmp_LineTo[6])) + if (!test_line(hdc, hPalette, 8, 0, 8, 15, hBmp, hBmp_LineTo[6], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 8, 15, 8, 0, hBmp, hBmp_LineTo[7])) + if (!test_line(hdc, hPalette, 8, 15, 8, 0, hBmp, hBmp_LineTo[7], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 4, 4, 12, 12, hBmp, hBmp_LineTo[8])) + if (!test_line(hdc, hPalette, 4, 4, 12, 12, hBmp, hBmp_LineTo[8], 0, 0, 16, 16)) goto fail; - if (!test_line(hdc, hPalette, 0, 0, 16, 16, hBmp, hBmp_LineTo[9])) + if (!test_line(hdc, hPalette, 0, 0, 16, 16, hBmp, hBmp_LineTo[9], 5, 5, 8, 8)) goto fail; - /* Test Case 11: (0,0) -> (+10,+10) */ - if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); + if (!test_line(hdc, hPalette, 0, 0, 26, 26, hBmp, hBmp_LineTo[10], 0, 0, 16, + 16)) goto fail; - } - - gdi_SetClipRgn(hdc, 0, 0, 16, 16); - gdi_MoveToEx(hdc, 0, 0, NULL); - gdi_LineTo(hdc, 16 + 10, 16 + 10); - - if (!test_assert_bitmaps_equal(hBmp, hBmp_LineTo[10], "Case 11") < 0) - goto fail; - - /* Test Case 12: (0,0) -> (16,16), R2_BLACK */ - if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette)) - { - printf("gdi_BitBlt failed (line #%u)\n", __LINE__); - goto fail; - } for (x = 0; x < map_size; x++) { @@ -804,7 +787,9 @@ int TestGdiLine(int argc, char* argv[]) gdi_SetROP2(hdc, rop_map[x].rop); gdi_LineTo(hdc, 16, 16); - if (!test_assert_bitmaps_equal(hBmp, rop_map[x].bmp, "Case 12") < 0) + if (!test_assert_bitmaps_equal(hBmp, rop_map[x].bmp, + gdi_rop_to_string(rop_map[x].rop), + hPalette)) goto fail; } diff --git a/libfreerdp/gdi/test/TestGdiRect.c b/libfreerdp/gdi/test/TestGdiRect.c index 2acbabdcf..12b838938 100644 --- a/libfreerdp/gdi/test/TestGdiRect.c +++ b/libfreerdp/gdi/test/TestGdiRect.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -14,9 +13,8 @@ #include "line.h" #include "brush.h" #include "clipping.h" -#include "32bpp.h" -int test_gdi_PtInRect(void) +static int test_gdi_PtInRect(void) { HGDI_RECT hRect; int left = 20; @@ -62,6 +60,7 @@ int test_gdi_PtInRect(void) int test_gdi_FillRect(void) { + int rc = -1; HGDI_DC hdc; HGDI_RECT hRect; HGDI_BRUSH hBrush; @@ -82,7 +81,7 @@ int test_gdi_FillRect(void) if (!(hdc = gdi_GetDC())) { printf("failed to get gdi device context\n"); - return -1; + goto fail; } hdc->format = PIXEL_FORMAT_XRGB32; @@ -90,7 +89,7 @@ int test_gdi_FillRect(void) if (!(hRect = gdi_CreateRect(left, top, right, bottom))) { printf("gdi_CreateRect failed\n"); - return -1; + goto fail; } hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); @@ -136,14 +135,16 @@ int test_gdi_FillRect(void) } if (goodPixels != width * height) - return -1; + goto fail; if (badPixels != 0) - return -1; + goto fail; + rc = 0; +fail: gdi_DeleteObject((HGDIOBJECT) hBrush); gdi_DeleteObject((HGDIOBJECT) hBitmap); - return 0; + return rc; } int TestGdiRect(int argc, char* argv[]) diff --git a/libfreerdp/gdi/test/TestGdiRop3.c b/libfreerdp/gdi/test/TestGdiRop3.c index f33d68feb..24fc0b0dc 100644 --- a/libfreerdp/gdi/test/TestGdiRop3.c +++ b/libfreerdp/gdi/test/TestGdiRop3.c @@ -93,22 +93,20 @@ * */ -const BYTE rop_P = 0xF0; /* 11110000 */ -const BYTE rop_S = 0xCC; /* 11001100 */ -const BYTE rop_D = 0xAA; /* 10101010 */ +static const BYTE rop_P = 0xF0; /* 11110000 */ +static const BYTE rop_S = 0xCC; /* 11001100 */ +static const BYTE rop_D = 0xAA; /* 10101010 */ -char* gdi_convert_postfix_to_infix(char* postfix) +static char* gdi_convert_postfix_to_infix(const char* postfix) { int i; int length; BOOL unary; wStack* stack; int al, bl, cl, dl; - char *a, *b, *c, *d; - al = bl = cl = dl =0; - + char* a, *b, *c, *d; + al = bl = cl = dl = 0; stack = Stack_New(FALSE); - length = strlen(postfix); for (i = 0; i < length; i++) @@ -116,21 +114,16 @@ char* gdi_convert_postfix_to_infix(char* postfix) if ((postfix[i] == 'P') || (postfix[i] == 'D') || (postfix[i] == 'S')) { /* token is an operand, push on the stack */ - a = malloc(2); a[0] = postfix[i]; a[1] = '\0'; - //printf("Operand: %s\n", a); - Stack_Push(stack, a); } else { /* token is an operator */ - unary = FALSE; - c = malloc(2); c[0] = postfix[i]; c[1] = '\0'; @@ -158,7 +151,6 @@ char* gdi_convert_postfix_to_infix(char* postfix) } //printf("Operator: %s\n", c); - a = (char*) Stack_Pop(stack); if (unary) @@ -172,14 +164,10 @@ char* gdi_convert_postfix_to_infix(char* postfix) bl = strlen(b); cl = 1; - dl = al + bl + cl + 3; - d = malloc(dl + 1); sprintf_s(d, dl, "(%s%s%s)", b ? b : "", c, a); - Stack_Push(stack, d); - free(a); free(b); free(c); @@ -188,11 +176,10 @@ char* gdi_convert_postfix_to_infix(char* postfix) d = (char*) Stack_Pop(stack); Stack_Free(stack); - return d; } -static char* test_ROP3[] = +static const char* test_ROP3[] = { "DSPDxax", "PSDPxax", @@ -224,13 +211,15 @@ static char* test_ROP3[] = int TestGdiRop3(int argc, char* argv[]) { int index; - char* infix; - char* postfix; for (index = 0; index < sizeof(test_ROP3) / sizeof(test_ROP3[0]); index++) { - postfix = test_ROP3[index]; - infix = gdi_convert_postfix_to_infix(postfix); + const char* postfix = test_ROP3[index]; + char* infix = gdi_convert_postfix_to_infix(postfix); + + if (!infix) + return -1; + printf("%s\t\t%s\n", postfix, infix); free(infix); } diff --git a/libfreerdp/gdi/test/helpers.c b/libfreerdp/gdi/test/helpers.c index 38003f834..5646ed3fc 100644 --- a/libfreerdp/gdi/test/helpers.c +++ b/libfreerdp/gdi/test/helpers.c @@ -90,7 +90,8 @@ static void test_dump_bitmap(HGDI_BITMAP hBmp, const char* name) test_dump_data(hBmp->data, hBmp->height * stride, stride, name); } -static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2) +static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2, + const gdiPalette* palette) { UINT32 x, y; const BYTE* p1 = hBmp1->data; @@ -99,9 +100,6 @@ static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2) UINT32 minw = (hBmp1->width < hBmp2->width) ? hBmp1->width : hBmp2->width; UINT32 minh = (hBmp1->height < hBmp2->height) ? hBmp1->height : hBmp2->height; - if (hBmp1->format != hBmp2->format) - return FALSE; - for (y = 0; y < minh; y++) { for (x = 0; x < minw; x++) @@ -111,6 +109,9 @@ static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2) p1 += GetBytesPerPixel(hBmp1->format); p2 += GetBytesPerPixel(hBmp2->format); + if (hBmp1->format != hBmp2->format) + colorB = ConvertColor(colorB, hBmp2->format, hBmp1->format, palette); + if (colorA != colorB) return FALSE; } @@ -121,15 +122,18 @@ static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2) BOOL test_assert_bitmaps_equal(HGDI_BITMAP hBmpActual, HGDI_BITMAP hBmpExpected, - const char* name) + const char* name, + const gdiPalette* palette) { - BOOL bitmapsEqual = CompareBitmaps(hBmpActual, hBmpExpected); + BOOL bitmapsEqual = CompareBitmaps(hBmpActual, hBmpExpected, palette); if (!bitmapsEqual) { printf("\n%s\n", name); test_dump_bitmap(hBmpActual, "Actual"); test_dump_bitmap(hBmpExpected, "Expected"); + fflush(stdout); + fflush(stderr); } return bitmapsEqual; diff --git a/libfreerdp/gdi/test/helpers.h b/libfreerdp/gdi/test/helpers.h index 343cda385..9c0906cc4 100644 --- a/libfreerdp/gdi/test/helpers.h +++ b/libfreerdp/gdi/test/helpers.h @@ -31,6 +31,7 @@ HGDI_BITMAP test_convert_to_bitmap(const BYTE* src, UINT32 SrcFormat, const gdiPalette* hPalette); BOOL test_assert_bitmaps_equal(HGDI_BITMAP hBmpActual, - HGDI_BITMAP hBmpExpected, const char* name); + HGDI_BITMAP hBmpExpected, const char* name, + const gdiPalette* palette); #endif /* __GDI_CORE_H */