From 5cdf8d3253591c092b1b7ed6f2b3aec0fcf8e153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 16 Apr 2011 18:38:18 -0400 Subject: Added tests for ROP2 --- GdiTest.userprefs | 4 +- GdiTest/FreeRDPGDI.cs | 5 + GdiTest/GDI.cs | 19 ++++ GdiTest/GdiTest.pidb | Bin 31459 -> 31478 bytes GdiTest/LineToDrawingArea.cs | 223 ++++++++++++++++++++++++++++++++++++++++++- GdiTest/Win32GDI.cs | 11 +++ 6 files changed, 258 insertions(+), 4 deletions(-) diff --git a/GdiTest.userprefs b/GdiTest.userprefs index 8a3f6bd..e139121 100644 --- a/GdiTest.userprefs +++ b/GdiTest.userprefs @@ -1,12 +1,12 @@  - + - + diff --git a/GdiTest/FreeRDPGDI.cs b/GdiTest/FreeRDPGDI.cs index 833d5cf..1ad1620 100644 --- a/GdiTest/FreeRDPGDI.cs +++ b/GdiTest/FreeRDPGDI.cs @@ -142,6 +142,11 @@ namespace GdiTest return 0; } + public override int SetROP2(IntPtr hdc, int fnDrawMode) + { + return 0; + } + public override int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop) { diff --git a/GdiTest/GDI.cs b/GdiTest/GDI.cs index 6b2a39d..96f8590 100644 --- a/GdiTest/GDI.cs +++ b/GdiTest/GDI.cs @@ -45,6 +45,24 @@ namespace GdiTest public static System.Int32 WHITENESS = 0x00FF0062; /* D = 1 */ public static System.Int32 DSPDxax = 0x00E20746; /* D = (S & P) | (~S & D) */ public static System.Int32 SPna = 0x000C0324; /* D = S & ~P */ + public static System.Int32 DSna = 0x00220326; /* D = D & ~S */ + + public static System.Int32 R2_BLACK = 1; + public static System.Int32 R2_NOTMERGEPEN = 2; + public static System.Int32 R2_MASKNOTPEN = 3; + public static System.Int32 R2_NOTCOPYPEN = 4; + public static System.Int32 R2_MASKPENNOT = 5; + public static System.Int32 R2_NOT = 6; + public static System.Int32 R2_XORPEN = 7; + public static System.Int32 R2_NOTMASKPEN = 8; + public static System.Int32 R2_MASKPEN = 9; + public static System.Int32 R2_NOTXORPEN = 10; + public static System.Int32 R2_NOP = 11; + public static System.Int32 R2_MERGENOTPEN = 12; + public static System.Int32 R2_COPYPEN = 13; + public static System.Int32 R2_MERGEPENNOT = 14; + public static System.Int32 R2_MERGEPEN = 15; + public static System.Int32 R2_WHITE = 16; public GDI () { @@ -69,6 +87,7 @@ namespace GdiTest public abstract bool Polygon(IntPtr hdc, POINT [] lpPoints, int nCount); public abstract IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect); public abstract int SelectClipRgn(IntPtr hdc, IntPtr hrgn); + public abstract int SetROP2(IntPtr hdc, int fnDrawMode); public abstract int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop); } diff --git a/GdiTest/GdiTest.pidb b/GdiTest/GdiTest.pidb index b27af99..572c1a4 100644 Binary files a/GdiTest/GdiTest.pidb and b/GdiTest/GdiTest.pidb differ diff --git a/GdiTest/LineToDrawingArea.cs b/GdiTest/LineToDrawingArea.cs index 22a2253..3a6655e 100644 --- a/GdiTest/LineToDrawingArea.cs +++ b/GdiTest/LineToDrawingArea.cs @@ -27,13 +27,15 @@ namespace GdiTest IntPtr hdc = wg.GetHdc(); int i = 0; - int n = 11; + int n = 27; int w = 16; int h = 16; + int k = 12; Area[] areas = new Area[n]; Point[] startp = new Point[n]; Point[] endp = new Point[n]; + int[] rop2 = new int[n - k + 1]; /* Test Case 1: (0,0) -> (15,15) */ areas[i].X = 0; @@ -156,7 +158,223 @@ namespace GdiTest endp[i].Y = areas[i].Y + h + 10; i++; - for (i = 0; i < n; i++) + /* Test Case 12: (0,0) -> (16,16), R2_BLACK */ + areas[i].X = 0; + areas[i].Y = 2 * h; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_BLACK; + i++; + + /* Test Case 13: (0,0) -> (16,16), R2_MERGENOTPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MERGENOTPEN; + i++; + + /* Test Case 14: (0,0) -> (16,16), R2_MASKNOTPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MASKNOTPEN; + i++; + + /* Test Case 15: (0,0) -> (16,16), R2_NOTCOPYPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_NOTCOPYPEN; + i++; + + /* Test Case 16: (0,0) -> (16,16), R2_MASKPENNOT */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MASKPENNOT; + i++; + + /* Test Case 17: (0,0) -> (16,16), R2_NOT */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_NOT; + i++; + + /* Test Case 18: (0,0) -> (16,16), R2_XORPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_XORPEN; + i++; + + /* Test Case 19: (0,0) -> (16,16), R2_NOTMASKPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_NOTMASKPEN; + i++; + + /* Test Case 20: (0,0) -> (16,16), R2_MASKPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MASKPEN; + i++; + + /* Test Case 21: (0,0) -> (16,16), R2_NOTXORPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_NOTXORPEN; + i++; + + /* Test Case 22: (0,0) -> (16,16), R2_NOP */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_NOP; + i++; + + /* Test Case 23: (0,0) -> (16,16), R2_MERGENOTPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MERGENOTPEN; + i++; + + /* Test Case 24: (0,0) -> (16,16), R2_COPYPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_COPYPEN; + i++; + + /* Test Case 25: (0,0) -> (16,16), R2_MERGEPENNOT */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MERGEPENNOT; + i++; + + /* Test Case 26: (0,0) -> (16,16), R2_MERGEPEN */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_MERGEPEN; + i++; + + /* Test Case 27: (0,0) -> (16,16), R2_WHITE */ + areas[i].X = areas[i - 1].X + areas[i - 1].W; + areas[i].Y = areas[i - 1].Y; + areas[i].W = w; + areas[i].H = h; + startp[i].X = areas[i].X; + startp[i].Y = areas[i].Y; + endp[i].X = areas[i].X + w; + endp[i].Y = areas[i].Y + h; + rop2[i - k + 1] = GDI.R2_WHITE; + i++; + + for (i = 0; i < k; i++) + { + /* Set Clipping Region */ + IntPtr clippingRegion = GDI_Win32.CreateRectRgn(areas[i].X, areas[i].Y, areas[i].X + areas[i].W, areas[i].Y + areas[i].H); + GDI_Win32.SelectClipRgn(hdc, IntPtr.Zero); + GDI_Win32.SelectClipRgn(hdc, clippingRegion); + + /* Fill Area with White */ + g.Color = new Color(255,255,255); + Rectangle rect = new Rectangle(areas[i].X, areas[i].Y, areas[i].W, areas[i].H); + g.Rectangle(rect); + g.Fill(); + g.Stroke(); + + /* Render Test Case */ + IntPtr pen = GDI_Win32.CreatePen(1, 1, 0); + IntPtr oldPen = GDI_Win32.SelectObject(hdc, pen); + GDI_Win32.MoveToEx(hdc, startp[i].X, startp[i].Y, IntPtr.Zero); + GDI_Win32.LineTo(hdc, endp[i].X, endp[i].Y); + + dumpText += "unsigned char line_to_case_" + (i + 1) + "[" + areas[i].W * areas[i].H + "] = \n"; + dumpText += dumpPixelArea(GDI_Win32, hdc, areas[i].X, areas[i].Y, areas[i].W, areas[i].H) + "\n"; + } + + for (i = k; i < n; i++) { /* Set Clipping Region */ IntPtr clippingRegion = GDI_Win32.CreateRectRgn(areas[i].X, areas[i].Y, areas[i].X + areas[i].W, areas[i].Y + areas[i].H); @@ -171,6 +389,7 @@ namespace GdiTest g.Stroke(); /* Render Test Case */ + GDI_Win32.SetROP2(hdc, rop2[i - k + 1]); IntPtr pen = GDI_Win32.CreatePen(1, 1, 0); IntPtr oldPen = GDI_Win32.SelectObject(hdc, pen); GDI_Win32.MoveToEx(hdc, startp[i].X, startp[i].Y, IntPtr.Zero); diff --git a/GdiTest/Win32GDI.cs b/GdiTest/Win32GDI.cs index 38041e0..f478c37 100644 --- a/GdiTest/Win32GDI.cs +++ b/GdiTest/Win32GDI.cs @@ -62,6 +62,9 @@ namespace GdiTest [DllImport("gdi32")] public static extern int SelectClipRgn(IntPtr hdc, IntPtr hrgn); + [DllImport("gdi32")] + public static extern int SetROP2(IntPtr hdc, int fnDrawMode); + [DllImport("gdi32")] public static extern int BitBlt( IntPtr hdcDest, @@ -253,6 +256,14 @@ namespace GdiTest return (IntPtr) null; } + public override int SetROP2(IntPtr hdc, int fnDrawMode) + { + if (available) + return Callbacks.SetROP2(hdc, fnDrawMode); + else + return 0; + } + public override int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop) { -- cgit v1.2.3