#include <freerdp/gdi/pen.h>
#include <freerdp/gdi/region.h>
#include <freerdp/gdi/bitmap.h>
-#include <freerdp/gdi/drawing.h>
#include <winpr/crt.h>
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
};
/* 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"
"\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 minw = (hBmp1->width < hBmp2->width) ? hBmp1->width : hBmp2->width;
- UINT32 minh = (hBmp1->height < hBmp2->height) ? hBmp1->height : hBmp2->height;
-
- if (hBmp1->format == hBmp2->format)
- {
- UINT32 colorA, colorB;
- p1 = hBmp1->data;
- p2 = hBmp2->data;
-
- for (y = 0; y < minh; y++)
- {
- for (x = 0; x < minw; x++)
- {
- colorA = ReadColor(p1, hBmp1->format);
- colorB = ReadColor(p2, hBmp2->format);
-
- p1 += GetBytesPerPixel(hBmp1->format);
- p2 += GetBytesPerPixel(hBmp2->format);
- }
- }
- }
- else
- {
- return 0;
- }
-
- return 1;
-}
-
-static void test_dump_data(unsigned char* p, int len, int width, const char* name)
-{
- 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;
- 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;
- UINT32* 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 = NULL; // TODO: Get a real palette!
-
- 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))
- {
- 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))
- {
- 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;
+ UINT32 rop;
+ const BYTE* src;
+ HGDI_BITMAP* bmp;
+};
+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, (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;
- }
+ gdi_SelectObject(hdcSrc, hBmpDstOriginal);
+ gdi_SelectObject(hdcDst, hBmpDst);
- //if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATPAINT, "PATPAINT") < 0)
- // return -1;
+ if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY, hPalette))
+ return FALSE;
- /* 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 (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, rop, hPalette))
+ return FALSE;
- if (test_assert_bitmaps_equal(hBmpDst, hBmp_SPna, "SPna") < 0)
- return -1;
+ if (!test_assert_bitmaps_equal(hBmpDst, expected,
+ gdi_rop_to_string(rop), hPalette))
+ return FALSE;
- return 0;
+ return TRUE;
}
-int test_gdi_BitBlt_8bpp(void)
+static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat)
{
- 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;
- DWORD* 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;
-
- data = calloc(1024, 1024);
- if (!data)
- return -1;
+ hdcSrc->format = SrcFormat;
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;
- }
-
- //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;
+ goto fail;
}
- 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);
+ hdcDst->format = DstFormat;
+ hBmpSrc = test_convert_to_bitmap(bmp_SRC, RawFormat, 0, 0, 0,
+ SrcFormat, 0, 0, 0, 16, 16, hPalette);
- /* 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 (!hBmpSrc)
+ goto fail;
- if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATCOPY, "PATCOPY") < 0)
- return -1;
+ hBmpDst = test_convert_to_bitmap(bmp_DST, RawFormat, 0, 0, 0,
+ DstFormat, 0, 0, 0, 16, 16, hPalette);
- /* 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);
+ if (!hBmpDst)
+ goto fail;
- /* PATINVERT */
- if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_PATINVERT))
- {
- printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
- return -1;
- }
+ hBmpDstOriginal = test_convert_to_bitmap(bmp_DST, RawFormat, 0, 0, 0,
+ DstFormat, 0, 0, 0, 16, 16, hPalette);
- if (test_assert_bitmaps_equal(hBmpDst, hBmp_PATINVERT, "PATINVERT") < 0)
- return -1;
+ if (!hBmpDstOriginal)
+ goto fail;
- /* restore original destination bitmap */
- gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpDstOriginal);
- if (!gdi_BitBlt(hdcDst, 0, 0, 16, 16, hdcSrc, 0, 0, GDI_SRCCOPY))
+ for (x = 0; x < number_tests; x++)
{
- printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
- return -1;
- }
- gdi_SelectObject(hdcSrc, (HGDIOBJECT) hBmpSrc);
+ tests[x].bmp = test_convert_to_bitmap(tests[x].src, RawFormat, 0, 0, 0,
+ SrcFormat, 0, 0, 0, 16, 16, hPalette);
- /* 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 (!tests[x].bmp)
+ goto fail;
}
- 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))
+ 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;
}
- 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 */
-
- 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;
+ 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]);
+
+ 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;
}
#include <freerdp/gdi/pen.h>
#include <freerdp/gdi/region.h>
#include <freerdp/gdi/bitmap.h>
-#include <freerdp/gdi/drawing.h>
#include <winpr/crt.h>
}
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))
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))
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;
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;
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;
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;
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))
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))
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))
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))
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))
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))
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))
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()))
{
}
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))