2 #include <freerdp/gdi/gdi.h>
4 #include <freerdp/gdi/dc.h>
5 #include <freerdp/gdi/pen.h>
6 #include <freerdp/gdi/region.h>
7 #include <freerdp/gdi/bitmap.h>
10 #include <winpr/print.h>
14 int TestGdiRegion(
int argc,
char* argv[])
33 rgn1 = gdi_CreateRectRgn(111, 2, 65, 77);
34 rect1 = gdi_CreateRect(2311, 11, 42, 17);
37 rgn1 = gdi_CreateRectRgn(1, 2, 65, 77);
38 rgn2 = gdi_CreateRectRgn(11, 2, 65, 77);
39 rect1 = gdi_CreateRect(23, 11, 42, 17);
40 rect2 = gdi_CreateRect(23, 11, 42, 17);
41 if (!rgn1 || !rgn2 || !rect1 || !rect2)
44 if (!gdi_RectToRgn(rect1, rgn1))
46 if (rgn1->x != rect1->left)
48 if (rgn1->y != rect1->top)
50 if (rgn1->w != (rect1->right - rect1->left + 1))
52 if (rgn1->h != (rect1->bottom - rect1->top + 1))
55 if (gdi_CRectToRgn(1123, 111, 333, 444, rgn2))
57 if (gdi_CRectToRgn(123, 1111, 333, 444, rgn2))
59 if (!gdi_CRectToRgn(123, 111, 333, 444, rgn2))
65 if (rgn2->w != (333 - 123 + 1))
67 if (rgn2->h != (444 - 111 + 1))
70 if (!gdi_RectToCRgn(rect1, &x, &y, &w, &h))
76 if (rect1->right != (x + w - 1))
78 if (rect1->bottom != (y + h - 1))
83 if (gdi_CRectToCRgn(1, 2, 0, 4, &x, &y, &w, &h))
85 if ((w != 0) || (h != 0))
89 if (gdi_CRectToCRgn(1, 2, 3, 1, &x, &y, &w, &h))
91 if ((w != 0) || (h != 0))
95 if (!gdi_CRectToCRgn(1, 2, 3, 4, &x, &y, &w, &h))
101 if (w != (3 - 1 + 1))
103 if (h != (4 - 2 + 1))
106 if (!gdi_RgnToRect(rgn1, rect2))
109 if (rgn1->x != rect2->left)
111 if (rgn1->y != rect2->top)
113 if (rgn1->w != (rect2->right - rect2->left + 1))
115 if (rgn1->h != (rect2->bottom - rect2->top + 1))
118 if (gdi_CRgnToRect(1, 2, 0, 4, rect2))
120 if (gdi_CRgnToRect(1, 2, -1, 4, rect2))
122 if (gdi_CRgnToRect(1, 2, 3, 0, rect2))
124 if (gdi_CRgnToRect(1, 2, 3, -1, rect2))
126 if (!gdi_CRgnToRect(1, 2, 3, 4, rect2))
128 if (rect2->left != 1)
130 if (rect2->right != (1 + 3 - 1))
134 if (rect2->bottom != (2 + 4 - 1))
137 if (!gdi_RgnToCRect(rgn1, &l, &t, &r, &b))
143 if (rgn1->w != (r - l + 1))
145 if (rgn1->h != (b - t + 1))
148 if (gdi_CRgnToCRect(1, 2, -1, 4, &l, &t, &r, &b))
150 if (gdi_CRgnToCRect(1, 2, 0, 4, &l, &t, &r, &b))
152 if (gdi_CRgnToCRect(1, 2, 3, -1, &l, &t, &r, &b))
154 if (gdi_CRgnToCRect(1, 2, 3, -0, &l, &t, &r, &b))
156 if (!gdi_CRgnToCRect(1, 2, 3, 4, &l, &t, &r, &b))
162 if (r != (1 + 3 - 1))
167 if (gdi_CopyOverlap(1, 2, 5, 3, -5, 3))
169 if (gdi_CopyOverlap(1, 2, 5, 3, 3, -2))
171 if (!gdi_CopyOverlap(1, 2, 5, 3, 2, 3))
174 if (gdi_SetRect(rect2, -4, 500, 66, -5))
176 if (gdi_SetRect(rect2, -4, -500, -66, -5))
178 if (!gdi_SetRect(rect2, -4, 500, 66, 754))
181 if (gdi_SetRgn(NULL, -23, -42, 33, 99))
183 if (gdi_SetRgn(rgn2, -23, -42, -33, 99))
185 if (gdi_SetRgn(rgn2, -23, -42, 33, -99))
187 if (!gdi_SetRgn(rgn2, -23, -42, 33, 99))
200 if (gdi_SetRectRgn(NULL, 33, 22, 44, 33))
202 if (gdi_SetRectRgn(rgn1, 331, 22, 44, 33))
204 if (gdi_SetRectRgn(rgn1, 33, 122, 44, 33))
206 if (!gdi_SetRectRgn(rgn1, 33, 22, 44, 33))
212 if (rgn1->w != (44 - 33 + 1))
214 if (rgn1->h != (33 - 22 + 1))
217 if (gdi_EqualRgn(rgn1, rgn2))
219 if (!gdi_EqualRgn(rgn1, rgn1))
222 if (gdi_CopyRect(rect1, NULL))
224 if (gdi_CopyRect(NULL, rect1))
226 if (gdi_CopyRect(NULL, NULL))
228 if (!gdi_CopyRect(rect1, rect2))
231 if (rect1->left != rect2->left)
233 if (rect1->top != rect2->top)
235 if (rect1->right != rect2->right)
237 if (rect1->bottom != rect2->bottom)
240 if (gdi_PtInRect(rect1, -23, 550))
242 if (gdi_PtInRect(rect1, 2, 3))
244 if (!gdi_PtInRect(rect1, 2, 550))