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>
15 static int test_gdi_ClipCoords(
void)
23 const UINT32 format = PIXEL_FORMAT_ARGB32;
25 if (!(hdc = gdi_GetDC()))
27 printf(
"failed to get gdi device context\n");
32 bmp = gdi_CreateBitmapEx(1024, 768, PIXEL_FORMAT_XRGB32, 0, NULL, NULL);
34 gdi_SetNullClipRgn(hdc);
35 rgn1 = gdi_CreateRectRgn(0, 0, 0, 0);
36 rgn2 = gdi_CreateRectRgn(0, 0, 0, 0);
40 gdi_SetNullClipRgn(hdc);
41 gdi_SetRgn(rgn1, 20, 20, 100, 100);
42 gdi_SetRgn(rgn2, 20, 20, 100, 100);
43 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
45 if (!gdi_EqualRgn(rgn1, rgn2))
49 gdi_SetClipRgn(hdc, 0, 0, 1024, 768);
50 gdi_SetRgn(rgn1, 20, 20, 100, 100);
51 gdi_SetRgn(rgn2, 20, 20, 100, 100);
52 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
54 if (!gdi_EqualRgn(rgn1, rgn2))
58 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
59 gdi_SetRgn(rgn1, 20, 20, 100, 100);
60 gdi_SetRgn(rgn2, 0, 0, 0, 0);
61 draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
67 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
68 gdi_SetRgn(rgn1, 420, 420, 100, 100);
69 gdi_SetRgn(rgn2, 0, 0, 0, 0);
70 draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
76 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
77 gdi_SetRgn(rgn1, 300, 20, 100, 100);
78 gdi_SetRgn(rgn2, 0, 0, 0, 0);
79 draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
85 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
86 gdi_SetRgn(rgn1, 300, 420, 100, 100);
87 gdi_SetRgn(rgn2, 0, 0, 0, 0);
88 draw = gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
94 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
95 gdi_SetRgn(rgn1, 100, 300, 300, 100);
96 gdi_SetRgn(rgn2, 300, 300, 100, 100);
97 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
99 if (!gdi_EqualRgn(rgn1, rgn2))
103 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
104 gdi_SetRgn(rgn1, 100, 300, 250, 100);
105 gdi_SetRgn(rgn2, 300, 300, 50, 100);
106 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
108 if (!gdi_EqualRgn(rgn1, rgn2))
112 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
113 gdi_SetRgn(rgn1, 300, 300, 300, 100);
114 gdi_SetRgn(rgn2, 300, 300, 100, 100);
115 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
117 if (!gdi_EqualRgn(rgn1, rgn2))
121 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
122 gdi_SetRgn(rgn1, 350, 300, 200, 100);
123 gdi_SetRgn(rgn2, 350, 300, 50, 100);
124 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
126 if (!gdi_EqualRgn(rgn1, rgn2))
130 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
131 gdi_SetRgn(rgn1, 300, 100, 300, 300);
132 gdi_SetRgn(rgn2, 300, 300, 100, 100);
133 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
135 if (!gdi_EqualRgn(rgn1, rgn2))
139 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
140 gdi_SetRgn(rgn1, 300, 300, 100, 200);
141 gdi_SetRgn(rgn2, 300, 300, 100, 100);
142 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
144 if (!gdi_EqualRgn(rgn1, rgn2))
148 gdi_SetClipRgn(hdc, 300, 300, 100, 100);
149 gdi_SetRgn(rgn1, 300, 300, 100, 100);
150 gdi_SetRgn(rgn2, 300, 300, 100, 100);
151 gdi_ClipCoords(hdc, &(rgn1->x), &(rgn1->y), &(rgn1->w), &(rgn1->h), NULL, NULL);
153 if (!gdi_EqualRgn(rgn1, rgn2))
165 static int test_gdi_InvalidateRegion(
void)
173 const UINT32 format = PIXEL_FORMAT_XRGB32;
175 if (!(hdc = gdi_GetDC()))
177 printf(
"failed to get gdi device context\n");
181 hdc->format = format;
182 bmp = gdi_CreateBitmapEx(1024, 768, PIXEL_FORMAT_XRGB32, 0, NULL, NULL);
184 gdi_SetNullClipRgn(hdc);
186 hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0);
187 hdc->hwnd->invalid->null = TRUE;
188 invalid = hdc->hwnd->invalid;
189 hdc->hwnd->count = 16;
190 hdc->hwnd->cinvalid = (
HGDI_RGN)calloc(hdc->hwnd->count,
sizeof(
GDI_RGN));
191 rgn1 = gdi_CreateRectRgn(0, 0, 0, 0);
192 rgn2 = gdi_CreateRectRgn(0, 0, 0, 0);
196 invalid->null = TRUE;
197 gdi_SetRgn(rgn1, 300, 300, 100, 100);
198 gdi_SetRgn(rgn2, 300, 300, 100, 100);
199 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
201 if (!gdi_EqualRgn(invalid, rgn2))
205 gdi_SetRgn(invalid, 300, 300, 100, 100);
206 gdi_SetRgn(rgn1, 300, 300, 100, 100);
207 gdi_SetRgn(rgn2, 300, 300, 100, 100);
208 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
210 if (!gdi_EqualRgn(invalid, rgn2))
214 gdi_SetRgn(invalid, 300, 300, 100, 100);
215 gdi_SetRgn(rgn1, 100, 300, 300, 100);
216 gdi_SetRgn(rgn2, 100, 300, 300, 100);
217 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
219 if (!gdi_EqualRgn(invalid, rgn2))
223 gdi_SetRgn(invalid, 300, 300, 100, 100);
224 gdi_SetRgn(rgn1, 300, 300, 300, 100);
225 gdi_SetRgn(rgn2, 300, 300, 300, 100);
226 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
228 if (!gdi_EqualRgn(invalid, rgn2))
232 gdi_SetRgn(invalid, 300, 300, 100, 100);
233 gdi_SetRgn(rgn1, 300, 100, 100, 300);
234 gdi_SetRgn(rgn2, 300, 100, 100, 300);
235 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
237 if (!gdi_EqualRgn(invalid, rgn2))
241 gdi_SetRgn(invalid, 300, 300, 100, 100);
242 gdi_SetRgn(rgn1, 300, 300, 100, 300);
243 gdi_SetRgn(rgn2, 300, 300, 100, 300);
244 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
246 if (!gdi_EqualRgn(invalid, rgn2))
250 gdi_SetRgn(invalid, 300, 300, 100, 100);
251 gdi_SetRgn(rgn1, 100, 300, 600, 300);
252 gdi_SetRgn(rgn2, 100, 300, 600, 300);
253 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
255 if (!gdi_EqualRgn(invalid, rgn2))
259 gdi_SetRgn(invalid, 300, 300, 100, 100);
260 gdi_SetRgn(rgn1, 300, 100, 100, 500);
261 gdi_SetRgn(rgn2, 300, 100, 100, 500);
262 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
264 if (!gdi_EqualRgn(invalid, rgn2))
268 gdi_SetRgn(invalid, 300, 300, 100, 100);
269 gdi_SetRgn(rgn1, 100, 300, 100, 100);
270 gdi_SetRgn(rgn2, 100, 300, 300, 100);
271 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
273 if (!gdi_EqualRgn(invalid, rgn2))
277 gdi_SetRgn(invalid, 300, 300, 100, 100);
278 gdi_SetRgn(rgn1, 700, 300, 100, 100);
279 gdi_SetRgn(rgn2, 300, 300, 500, 100);
280 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
282 if (!gdi_EqualRgn(invalid, rgn2))
286 gdi_SetRgn(invalid, 300, 300, 100, 100);
287 gdi_SetRgn(rgn1, 300, 100, 100, 100);
288 gdi_SetRgn(rgn2, 300, 100, 100, 300);
289 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
291 if (!gdi_EqualRgn(invalid, rgn2))
295 gdi_SetRgn(invalid, 300, 300, 100, 100);
296 gdi_SetRgn(rgn1, 300, 500, 100, 100);
297 gdi_SetRgn(rgn2, 300, 300, 100, 300);
298 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
300 if (!gdi_EqualRgn(invalid, rgn2))
304 gdi_SetRgn(invalid, 300, 300, 100, 100);
305 gdi_SetRgn(rgn1, 100, 100, 600, 600);
306 gdi_SetRgn(rgn2, 100, 100, 600, 600);
307 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
309 if (!gdi_EqualRgn(invalid, rgn2))
313 gdi_SetRgn(invalid, 300, 300, 100, 100);
314 gdi_SetRgn(rgn1, 0, 0, 1024, 768);
315 gdi_SetRgn(rgn2, 0, 0, 1024, 768);
316 gdi_InvalidateRegion(hdc, rgn1->x, rgn1->y, rgn1->w, rgn1->h);
318 if (!gdi_EqualRgn(invalid, rgn2))
330 int TestGdiClip(
int argc,
char* argv[])
334 (void)fprintf(stderr,
"test_gdi_ClipCoords()\n");
336 if (test_gdi_ClipCoords() < 0)
339 (void)fprintf(stderr,
"test_gdi_InvalidateRegion()\n");
341 if (test_gdi_InvalidateRegion() < 0)