Fixed GDI tests.
authorArmin Novak <armin.novak@thincast.com>
Fri, 15 Jul 2016 10:14:14 +0000 (12:14 +0200)
committerArmin Novak <armin.novak@thincast.com>
Thu, 6 Oct 2016 11:43:01 +0000 (13:43 +0200)
libfreerdp/gdi/test/TestGdiLine.c
libfreerdp/gdi/test/helpers.c [new file with mode: 0644]
libfreerdp/gdi/test/helpers.h [new file with mode: 0644]

index aadc1cf..f8f874e 100644 (file)
@@ -5,7 +5,6 @@
 #include <freerdp/gdi/pen.h>
 #include <freerdp/gdi/region.h>
 #include <freerdp/gdi/bitmap.h>
-#include <freerdp/gdi/drawing.h>
 
 #include <winpr/crt.h>
 #include <winpr/print.h>
 #include "brush.h"
 #include "clipping.h"
 
+#include "helpers.h"
+
 /* LineTo() Test Data */
-static BYTE line_to_case_1[256] =
+static const BYTE line_to_case_1[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -35,7 +36,7 @@ static BYTE line_to_case_1[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_2[256] =
+static const BYTE line_to_case_2[256] =
 {
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -55,7 +56,7 @@ static BYTE line_to_case_2[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_case_3[256] =
+static const BYTE line_to_case_3[256] =
 {
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF"
@@ -75,7 +76,7 @@ static BYTE line_to_case_3[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_4[256] =
+static const BYTE line_to_case_4[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\x00\xFF"
@@ -95,7 +96,7 @@ static BYTE line_to_case_4[256] =
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_5[256] =
+static const BYTE line_to_case_5[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"
@@ -115,7 +116,7 @@ static BYTE line_to_case_5[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_6[256] =
+static const BYTE line_to_case_6[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"
@@ -135,7 +136,7 @@ static BYTE line_to_case_6[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_7[256] =
+static const BYTE line_to_case_7[256] =
 {
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -155,7 +156,7 @@ static BYTE line_to_case_7[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_8[256] =
+static const BYTE line_to_case_8[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\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -175,7 +176,7 @@ static BYTE line_to_case_8[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_9[256] =
+static const BYTE line_to_case_9[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"
@@ -195,7 +196,7 @@ static BYTE line_to_case_9[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_10[256] =
+static const BYTE line_to_case_10[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"
@@ -215,7 +216,7 @@ static BYTE line_to_case_10[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_case_11[256] =
+static const BYTE line_to_case_11[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -235,7 +236,23 @@ static BYTE line_to_case_11[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_BLACK[256] =
+static const BYTE* line_to_case[] =
+{
+       line_to_case_1,
+       line_to_case_2,
+       line_to_case_3,
+       line_to_case_4,
+       line_to_case_5,
+       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,
+};
+
+static const BYTE line_to_R2_BLACK[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -255,7 +272,7 @@ static BYTE line_to_R2_BLACK[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_NOTMERGEPEN[256] =
+static const BYTE line_to_R2_NOTMERGEPEN[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -275,7 +292,7 @@ static BYTE line_to_R2_NOTMERGEPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_MASKNOTPEN[256] =
+static const BYTE line_to_R2_MASKNOTPEN[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -295,7 +312,7 @@ static BYTE line_to_R2_MASKNOTPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_NOTCOPYPEN[256] =
+static const BYTE line_to_R2_NOTCOPYPEN[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -315,7 +332,7 @@ static BYTE line_to_R2_NOTCOPYPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_MASKPENNOT[256] =
+static const BYTE line_to_R2_MASKPENNOT[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -335,7 +352,7 @@ static BYTE line_to_R2_MASKPENNOT[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_NOT[256] =
+static const BYTE line_to_R2_NOT[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -355,7 +372,7 @@ static BYTE line_to_R2_NOT[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_XORPEN[256] =
+static const BYTE line_to_R2_XORPEN[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -375,7 +392,7 @@ static BYTE line_to_R2_XORPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_NOTMASKPEN[256] =
+static const BYTE line_to_R2_NOTMASKPEN[256] =
 {
        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -395,7 +412,7 @@ static BYTE line_to_R2_NOTMASKPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00"
 };
 
-static BYTE line_to_R2_MASKPEN[256] =
+static const BYTE line_to_R2_MASKPEN[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"
@@ -415,7 +432,7 @@ static BYTE line_to_R2_MASKPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_NOTXORPEN[256] =
+static const BYTE line_to_R2_NOTXORPEN[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"
@@ -435,7 +452,7 @@ static BYTE line_to_R2_NOTXORPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_NOP[256] =
+static const BYTE line_to_R2_NOP[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"
@@ -455,7 +472,7 @@ static BYTE line_to_R2_NOP[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_MERGENOTPEN[256] =
+static const BYTE line_to_R2_MERGENOTPEN[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"
@@ -475,7 +492,7 @@ static BYTE line_to_R2_MERGENOTPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_COPYPEN[256] =
+static const BYTE line_to_R2_COPYPEN[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"
@@ -495,7 +512,7 @@ static BYTE line_to_R2_COPYPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_MERGEPENNOT[256] =
+static const BYTE line_to_R2_MERGEPENNOT[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"
@@ -515,7 +532,7 @@ static BYTE line_to_R2_MERGEPENNOT[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_MERGEPEN[256] =
+static const BYTE line_to_R2_MERGEPEN[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"
@@ -535,7 +552,7 @@ static BYTE line_to_R2_MERGEPEN[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-static BYTE line_to_R2_WHITE[256] =
+static const BYTE line_to_R2_WHITE[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"
@@ -557,7 +574,7 @@ static BYTE line_to_R2_WHITE[256] =
 
 /* PolylineTo() Test Data */
 
-static BYTE polyline_to_case_1[256] =
+static const BYTE polyline_to_case_1[256] =
 {
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -577,7 +594,7 @@ static BYTE polyline_to_case_1[256] =
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
 };
 
-static BYTE polyline_to_case_2[256] =
+static const BYTE polyline_to_case_2[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"
@@ -597,506 +614,215 @@ static BYTE polyline_to_case_2[256] =
        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
 };
 
-extern int test_assert_bitmaps_equal(HGDI_BITMAP hBmpActual, HGDI_BITMAP hBmpExpected, const char* name);
-
-int TestGdiLine(int argc, char* argv[])
+#define LINTETO_NUMBER 11
+struct ropMap
 {
-       HGDI_DC hdc;
-       HGDI_PEN pen;
-       BYTE* data;
-       HGDI_BITMAP hBmp;
-       HGDI_BITMAP hBmp_LineTo_1;
-       HGDI_BITMAP hBmp_LineTo_2;
-       HGDI_BITMAP hBmp_LineTo_3;
-       HGDI_BITMAP hBmp_LineTo_4;
-       HGDI_BITMAP hBmp_LineTo_5;
-       HGDI_BITMAP hBmp_LineTo_6;
-       HGDI_BITMAP hBmp_LineTo_7;
-       HGDI_BITMAP hBmp_LineTo_8;
-       HGDI_BITMAP hBmp_LineTo_9;
-       HGDI_BITMAP hBmp_LineTo_10;
-       HGDI_BITMAP hBmp_LineTo_11;
-       HGDI_BITMAP hBmp_LineTo_R2_BLACK;
-       HGDI_BITMAP hBmp_LineTo_R2_NOTMERGEPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_MASKNOTPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_NOTCOPYPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_MASKPENNOT;
-       HGDI_BITMAP hBmp_LineTo_R2_NOT;
-       HGDI_BITMAP hBmp_LineTo_R2_XORPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_NOTMASKPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_MASKPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_NOTXORPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_NOP;
-       HGDI_BITMAP hBmp_LineTo_R2_MERGENOTPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_COPYPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_MERGEPENNOT;
-       HGDI_BITMAP hBmp_LineTo_R2_MERGEPEN;
-       HGDI_BITMAP hBmp_LineTo_R2_WHITE;
-       rdpPalette* hPalette;
-       const UINT32 format = PIXEL_FORMAT_ARGB32;
-
-       if (!(hdc = gdi_GetDC()))
-       {
-               printf("failed to get gdi device context\n");
-               return -1;
-       }
-
-       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*) line_to_case_1, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_1 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_2, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_2 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_3, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_3 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_4, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_4 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_5, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_5 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_5, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_5 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_6, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_6 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_7, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_7 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_8, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_8 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_9, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_9 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_10, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_10 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_case_11, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_11 = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_BLACK, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_BLACK = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTMERGEPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_NOTMERGEPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKNOTPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_MASKNOTPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTCOPYPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_NOTCOPYPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKPENNOT, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_MASKPENNOT = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOT, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_NOT = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_XORPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_XORPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTMASKPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_NOTMASKPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MASKPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_MASKPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOTXORPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_NOTXORPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_NOP, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_NOP = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGENOTPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_MERGENOTPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_COPYPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_COPYPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGEPENNOT, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_MERGEPENNOT = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_MERGEPEN, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_MERGEPEN = gdi_CreateBitmap(16, 16, format, data);
-
-       data = (BYTE*) freerdp_image_convert((BYTE*) line_to_R2_WHITE, NULL, 16, 16, 8, format, hPalette);
-       hBmp_LineTo_R2_WHITE = gdi_CreateBitmap(16, 16, format, data);
-
-       /* Test Case 1: (0,0) -> (15, 15) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_LineTo(hdc, 15, 15);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_1, "Case 1") < 0)
-               return -1;
-
-       /* Test Case 2: (15,15) -> (0,0) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 15, 15, NULL);
-       gdi_LineTo(hdc, 0, 0);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_2, "Case 2") < 0)
-               return -1;
-
-       /* Test Case 3: (15,0) -> (0,15) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 15, 0, NULL);
-       gdi_LineTo(hdc, 0, 15);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_3, "Case 3") < 0)
-               return -1;
-
-       /* Test Case 4: (0,15) -> (15,0) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 0, 15, NULL);
-       gdi_LineTo(hdc, 15, 0);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_4, "Case 4") < 0)
-               return -1;
-
-       /* Test Case 5: (0,8) -> (15,8) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 0, 8, NULL);
-       gdi_LineTo(hdc, 15, 8);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_5, "Case 5") < 0)
-               return -1;
-
-       /* Test Case 6: (15,8) -> (0,8) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 15, 8, NULL);
-       gdi_LineTo(hdc, 0, 8);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_6, "Case 6") < 0)
-               return -1;
-
-       /* Test Case 7: (8,0) -> (8,15) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 8, 0, NULL);
-       gdi_LineTo(hdc, 8, 15);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_7, "Case 7") < 0)
-               return -1;
-
-       /* Test Case 8: (8,15) -> (8,0) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 8, 15, NULL);
-       gdi_LineTo(hdc, 8, 0);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_8, "Case 8") < 0)
-               return -1;
-
-       /* Test Case 9: (4,4) -> (12,12) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 4, 4, NULL);
-       gdi_LineTo(hdc, 12, 12);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_9, "Case 9") < 0)
-               return -1;
+       UINT32 rop;
+       HGDI_BITMAP bmp;
+       BYTE* src;
+};
 
+static BOOL test_line(HGDI_DC hdc, const gdiPalette* hPalette, UINT32 mX,
+                      UINT32 mY,
+                      UINT32 lX, UINT32 lY, HGDI_BITMAP hBmp, HGDI_BITMAP hOrgBmp)
+{
        /* Test Case 10: (12,12) -> (4,4) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_MoveToEx(hdc, 12, 12, NULL);
-       gdi_LineTo(hdc, 4, 4);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_10, "Case 10") < 0)
-               return -1;
-
-       /* Test Case 11: (0,0) -> (+10,+10) */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       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_11, "Case 11") < 0)
-               return -1;
-
-       /* Test Case 12: (0,0) -> (16,16), R2_BLACK */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_BLACK);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_BLACK, "Case 12") < 0)
-               return -1;
-
-       /* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_NOTMERGEPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTMERGEPEN, "Case 13") < 0)
-               return -1;
-
-       /* Test Case 14: (0,0) -> (16,16), R2_MASKNOTPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_MASKNOTPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKNOTPEN, "Case 14") < 0)
-               return -1;
-
-       /* Test Case 15: (0,0) -> (16,16), R2_NOTCOPYPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_NOTCOPYPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTCOPYPEN, "Case 15") < 0)
-               return -1;
-
-       /* Test Case 16: (0,0) -> (16,16), R2_MASKPENNOT */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_MASKPENNOT);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKPENNOT, "Case 16") < 0)
-               return -1;
-
-       /* Test Case 17: (0,0) -> (16,16), R2_NOT */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
+       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette))
        {
                printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
+               return FALSE;
        }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_NOT);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOT, "Case 17") < 0)
-               return -1;
 
-       /* Test Case 18: (0,0) -> (16,16), R2_XORPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_XORPEN);
-       gdi_LineTo(hdc, 16, 16);
+       gdi_MoveToEx(hdc, mX, mY, hPalette);
+       gdi_LineTo(hdc, lX, lY);
 
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_XORPEN, "Case 18") < 0)
-               return -1;
+       if (!test_assert_bitmaps_equal(hBmp, hOrgBmp, "Case 10") < 0)
+               return FALSE;
 
-       /* Test Case 19: (0,0) -> (16,16), R2_NOTMASKPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_NOTMASKPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTMASKPEN, "Case 19") < 0)
-               return -1;
-
-       /* Test Case 20: (0,0) -> (16,16), R2_MASKPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_MASKPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MASKPEN, "Case 20") < 0)
-               return -1;
-
-       /* Test Case 21: (0,0) -> (16,16), R2_NOTXORPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_NOTXORPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOTXORPEN, "Case 21") < 0)
-               return -1;
+       return TRUE;
+}
 
-       /* Test Case 22: (0,0) -> (16,16), R2_NOP */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
+int TestGdiLine(int argc, char* argv[])
+{
+       int rc = -1;
+       UINT32 x, i;
+       const UINT32 RawFormat = PIXEL_FORMAT_RGB8;
+       const UINT32 colorFormats[] =
        {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_NOP);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_NOP, "Case 22") < 0)
-               return -1;
-
-       /* Test Case 23: (0,0) -> (16,16), R2_MERGENOTPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
+               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]);
+
+       for (i = 0; i < number_formats; i++)
        {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_MERGENOTPEN);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGENOTPEN, "Case 23") < 0)
-               return -1;
+               HGDI_DC hdc;
+               HGDI_PEN pen;
+               HGDI_BITMAP hBmp = NULL;
+               struct ropMap rop_map[] =
+               {
+                       {GDI_R2_BLACK, NULL, line_to_R2_BLACK},
+                       {GDI_R2_NOTMERGEPEN, NULL, line_to_R2_NOTMERGEPEN},
+                       {GDI_R2_MASKNOTPEN, NULL, line_to_R2_MASKNOTPEN},
+                       {GDI_R2_NOTCOPYPEN, NULL, line_to_R2_NOTCOPYPEN},
+                       {GDI_R2_MASKPENNOT, NULL, line_to_R2_MASKPENNOT},
+                       {GDI_R2_NOT, NULL, line_to_R2_NOT},
+                       {GDI_R2_XORPEN, NULL, line_to_R2_XORPEN},
+                       {GDI_R2_NOTMASKPEN, NULL, line_to_R2_NOTMASKPEN},
+                       {GDI_R2_MASKPEN, NULL, line_to_R2_MASKPEN},
+                       {GDI_R2_NOTXORPEN, NULL, line_to_R2_NOTXORPEN},
+                       {GDI_R2_NOP, NULL, line_to_R2_NOP},
+                       {GDI_R2_MERGENOTPEN, NULL, line_to_R2_MERGENOTPEN},
+                       {GDI_R2_COPYPEN, NULL, line_to_R2_COPYPEN},
+                       {GDI_R2_MERGEPENNOT, NULL, line_to_R2_MERGEPENNOT},
+                       {GDI_R2_MERGEPEN, NULL, line_to_R2_MERGEPEN},
+                       {GDI_R2_WHITE, NULL, line_to_R2_WHITE}
+               };
+               const UINT32 map_size = sizeof(rop_map) / sizeof(rop_map[0]);
+               HGDI_BITMAP hBmp_LineTo[LINTETO_NUMBER] = {NULL};
+               gdiPalette p;
+               gdiPalette* hPalette = &p;
+               const UINT32 format = colorFormats[i];
+               rc = -1;
+               p.format = format;
+
+               // TODO: Initialize palette!!!
+
+               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);
+
+               for (x = 0; x < LINTETO_NUMBER; x++)
+               {
+                       hBmp_LineTo[x] = test_convert_to_bitmap(line_to_case[x], RawFormat, 0, 0, 0,
+                                                               format, 0, 0, 0, 16, 16, hPalette);
+
+                       if (!hBmp_LineTo[x])
+                               goto fail;
+               }
+
+               for (x = 0; x < map_size; x++)
+               {
+                       rop_map[x].bmp = test_convert_to_bitmap(rop_map[x].src, RawFormat, 0, 0, 0,
+                                                               format, 0, 0, 0, 16, 16, hPalette);
+
+                       if (!rop_map[x].bmp)
+                               goto fail;
+               }
+
+               if (!test_line(hdc, hPalette, 0, 0, 15, 15, hBmp, hBmp_LineTo[0]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 15, 15, 0, 0, hBmp, hBmp_LineTo[1]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 15, 0, 0, 15, hBmp, hBmp_LineTo[2]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 0, 15, 15, 0, hBmp, hBmp_LineTo[3]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 0, 8, 15, 8, hBmp, hBmp_LineTo[4]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 15, 8, 0, 8, hBmp, hBmp_LineTo[5]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 8, 0, 8, 15, hBmp, hBmp_LineTo[6]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 8, 15, 8, 0, hBmp, hBmp_LineTo[7]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 4, 4, 12, 12, hBmp, hBmp_LineTo[8]))
+                       goto fail;
+
+               if (!test_line(hdc, hPalette, 0, 0, 16, 16, hBmp, hBmp_LineTo[9]))
+                       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__);
+                       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++)
+               {
+                       /* Test Case 13: (0,0) -> (16,16), R2_NOTMERGEPEN */
+                       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS, hPalette))
+                       {
+                               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
+                               goto fail;
+                       }
 
-       /* Test Case 24: (0,0) -> (16,16), R2_COPYPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_COPYPEN);
-       gdi_LineTo(hdc, 16, 16);
+                       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
+                       gdi_MoveToEx(hdc, 0, 0, NULL);
+                       gdi_SetROP2(hdc, rop_map[x].rop);
+                       gdi_LineTo(hdc, 16, 16);
 
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_COPYPEN, "Case 24") < 0)
-               return -1;
+                       if (!test_assert_bitmaps_equal(hBmp, rop_map[x].bmp, "Case 12") < 0)
+                               goto fail;
+               }
 
-       /* Test Case 25: (0,0) -> (16,16), R2_MERGEPENNOT */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_MERGEPENNOT);
-       gdi_LineTo(hdc, 16, 16);
+               rc = 0;
+       fail:
 
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGEPENNOT, "Case 25") < 0)
-               return -1;
+               for (x = 0; x < LINTETO_NUMBER; x++)
+                       gdi_DeleteObject((HGDIOBJECT) hBmp_LineTo[x]);
 
-       /* Test Case 26: (0,0) -> (16,16), R2_MERGEPEN */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
-       }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_MERGEPEN);
-       gdi_LineTo(hdc, 16, 16);
+               for (x = 0; x < map_size; x++)
+                       gdi_DeleteObject((HGDIOBJECT) rop_map[x].bmp);
 
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_MERGEPEN, "Case 26") < 0)
-               return -1;
+               gdi_DeleteObject((HGDIOBJECT) pen);
+               gdi_DeleteDC(hdc);
 
-       /* Test Case 27: (0,0) -> (16,16), R2_WHITE */
-       if (!gdi_BitBlt(hdc, 0, 0, 16, 16, hdc, 0, 0, GDI_WHITENESS))
-       {
-               printf("gdi_BitBlt failed (line #%u)\n", __LINE__);
-               return -1;
+               if (rc != 0)
+                       break;
        }
-       gdi_SetClipRgn(hdc, 0, 0, 16, 16);
-       gdi_MoveToEx(hdc, 0, 0, NULL);
-       gdi_SetROP2(hdc, GDI_R2_WHITE);
-       gdi_LineTo(hdc, 16, 16);
-
-       if (test_assert_bitmaps_equal(hBmp, hBmp_LineTo_R2_WHITE, "Case 27") < 0)
-               return -1;
 
-       return 0;
+       return rc;
 }
diff --git a/libfreerdp/gdi/test/helpers.c b/libfreerdp/gdi/test/helpers.c
new file mode 100644 (file)
index 0000000..38003f8
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * GDI Library Tests
+ *
+ * Copyright 2016 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2016 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "helpers.h"
+
+HGDI_BITMAP test_convert_to_bitmap(const BYTE* src, UINT32 SrcFormat,
+                                   UINT32 SrcStride,
+                                   UINT32 xSrc, UINT32 ySrc, UINT32 DstFormat, UINT32 DstStride,
+                                   UINT32 xDst, UINT32 yDst, UINT32 nWidth, UINT32 nHeight,
+                                   const gdiPalette* hPalette)
+{
+       HGDI_BITMAP bmp;
+       BYTE* data;
+
+       if (DstStride == 0)
+               DstStride = nWidth * GetBytesPerPixel(DstFormat);
+
+       data = _aligned_malloc(DstStride * nHeight, 16);
+
+       if (!data)
+               return NULL;
+
+       if (!freerdp_image_copy(data, DstFormat, DstStride, xDst, yDst, nWidth, nHeight,
+                               src, SrcFormat, SrcStride, xSrc, ySrc, hPalette))
+       {
+               _aligned_free(data);
+               return NULL;
+       }
+
+       bmp = gdi_CreateBitmap(nWidth, nHeight, DstFormat, data);
+
+       if (!bmp)
+       {
+               _aligned_free(data);
+               return NULL;
+       }
+
+       return bmp;
+}
+
+
+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);
+}
+
+static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2)
+{
+       UINT32 x, y;
+       const BYTE* p1 = hBmp1->data;
+       const BYTE* p2 = hBmp2->data;
+       UINT32 colorA, colorB;
+       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++)
+               {
+                       colorA = ReadColor(p1, hBmp1->format);
+                       colorB = ReadColor(p2, hBmp2->format);
+                       p1 += GetBytesPerPixel(hBmp1->format);
+                       p2 += GetBytesPerPixel(hBmp2->format);
+
+                       if (colorA != colorB)
+                               return FALSE;
+               }
+       }
+
+       return TRUE;
+}
+
+BOOL test_assert_bitmaps_equal(HGDI_BITMAP hBmpActual,
+                               HGDI_BITMAP hBmpExpected,
+                               const char* name)
+{
+       BOOL bitmapsEqual = CompareBitmaps(hBmpActual, hBmpExpected);
+
+       if (!bitmapsEqual)
+       {
+               printf("\n%s\n", name);
+               test_dump_bitmap(hBmpActual, "Actual");
+               test_dump_bitmap(hBmpExpected, "Expected");
+       }
+
+       return bitmapsEqual;
+}
diff --git a/libfreerdp/gdi/test/helpers.h b/libfreerdp/gdi/test/helpers.h
new file mode 100644 (file)
index 0000000..343cda3
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * GDI Library Tests
+ *
+ * Copyright 2016 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2016 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GDI_TEST_HELPERS_H
+#define GDI_TEST_HELPERS_H
+
+#include <freerdp/codec/color.h>
+#include <freerdp/gdi/bitmap.h>
+
+HGDI_BITMAP test_convert_to_bitmap(const BYTE* src, UINT32 SrcFormat,
+                                   UINT32 SrcStride,
+                                   UINT32 xSrc, UINT32 ySrc, UINT32 DstFormat, UINT32 DstStride,
+                                   UINT32 xDst, UINT32 yDst, UINT32 nWidth, UINT32 nHeight,
+                                   const gdiPalette* hPalette);
+
+BOOL test_assert_bitmaps_equal(HGDI_BITMAP hBmpActual,
+                               HGDI_BITMAP hBmpExpected, const char* name);
+
+#endif /* __GDI_CORE_H */