dwrite: Fix recently added script properties.
[wine.git] / dlls / gdiplus / tests / region.c
blobe0ad48e8d0b97c767a6012f4f23d3b250aa2a203
1 /*
2 * Unit test suite for gdiplus regions
4 * Copyright (C) 2008 Huw Davies
5 * Copyright (C) 2013 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <math.h>
24 #include "objbase.h"
25 #include "gdiplus.h"
26 #include "wine/test.h"
28 #define RGNDATA_RECT 0x10000000
29 #define RGNDATA_PATH 0x10000001
30 #define RGNDATA_EMPTY_RECT 0x10000002
31 #define RGNDATA_INFINITE_RECT 0x10000003
33 #define RGNDATA_MAGIC 0xdbc01001
34 #define RGNDATA_MAGIC2 0xdbc01002
36 #define expect(expected, got) ok((got) == (expected), "Expected %.8x, got %.8x\n", (expected), (got))
37 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))
38 #define expectf(expected, got) expectf_((expected), (got), 0.001)
40 #define expect_magic(value) ok(*(value) == RGNDATA_MAGIC || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *(value))
41 #define expect_dword(value, expected) expect((expected), *(value))
42 #define expect_float(value, expected) expectf((expected), *(FLOAT *)(value))
44 /* We get shorts back, not INTs like a GpPoint */
45 typedef struct RegionDataPoint
47 short X, Y;
48 } RegionDataPoint;
50 static void verify_region(HRGN hrgn, const RECT *rc)
52 union
54 RGNDATA data;
55 char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
56 } rgn;
57 const RECT *rect;
58 DWORD ret;
60 ret = GetRegionData(hrgn, 0, NULL);
61 if (IsRectEmpty(rc))
62 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
63 else
64 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
66 if (!ret) return;
68 ret = GetRegionData(hrgn, sizeof(rgn), &rgn.data);
69 if (IsRectEmpty(rc))
70 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
71 else
72 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
74 trace("size %u, type %u, count %u, rgn size %u, bound %s\n",
75 rgn.data.rdh.dwSize, rgn.data.rdh.iType,
76 rgn.data.rdh.nCount, rgn.data.rdh.nRgnSize,
77 wine_dbgstr_rect(&rgn.data.rdh.rcBound));
78 if (rgn.data.rdh.nCount != 0)
80 rect = (const RECT *)rgn.data.Buffer;
81 trace("rect %s\n", wine_dbgstr_rect(rect));
82 ok(EqualRect(rect, rc), "expected %s, got %s\n",
83 wine_dbgstr_rect(rc), wine_dbgstr_rect(rect));
86 ok(rgn.data.rdh.dwSize == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", rgn.data.rdh.dwSize);
87 ok(rgn.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn.data.rdh.iType);
88 if (IsRectEmpty(rc))
90 ok(rgn.data.rdh.nCount == 0, "expected 0, got %u\n", rgn.data.rdh.nCount);
91 ok(rgn.data.rdh.nRgnSize == 0, "expected 0, got %u\n", rgn.data.rdh.nRgnSize);
93 else
95 ok(rgn.data.rdh.nCount == 1, "expected 1, got %u\n", rgn.data.rdh.nCount);
96 ok(rgn.data.rdh.nRgnSize == sizeof(RECT), "expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
98 ok(EqualRect(&rgn.data.rdh.rcBound, rc), "expected %s, got %s\n",
99 wine_dbgstr_rect(rc), wine_dbgstr_rect(&rgn.data.rdh.rcBound));
102 static void test_region_data(DWORD *data, UINT size, INT line)
104 GpStatus status;
105 GpRegion *region;
106 DWORD buf[256];
107 UINT needed, i;
109 status = GdipCreateRegionRgnData((BYTE *)data, size, &region);
110 /* Windows always fails to create an empty path in a region */
111 if (data[4] == RGNDATA_PATH)
113 struct path_header
115 DWORD size;
116 DWORD magic;
117 DWORD count;
118 DWORD flags;
119 } *path_header = (struct path_header *)(data + 5);
120 if (!path_header->count)
122 ok_(__FILE__, line)(status == GenericError, "expected GenericError, got %d\n", status);
123 return;
127 ok_(__FILE__, line)(status == Ok, "GdipCreateRegionRgnData error %d\n", status);
128 if (status != Ok) return;
130 needed = 0;
131 status = GdipGetRegionDataSize(region, &needed);
132 ok_(__FILE__, line)(status == Ok, "status %d\n", status);
133 ok_(__FILE__, line)(needed == size, "data size mismatch: %u != %u\n", needed, size);
135 memset(buf, 0xee, sizeof(buf));
136 needed = 0;
137 status = GdipGetRegionData(region, (BYTE *)buf, sizeof(buf), &needed);
138 ok_(__FILE__, line)(status == Ok, "status %08x\n", status);
139 ok_(__FILE__, line)(needed == size, "data size mismatch: %u != %u\n", needed, size);
141 size /= sizeof(DWORD);
142 for (i = 0; i < size - 1; i++)
144 if (i == 1) continue; /* data[1] never matches */
145 ok_(__FILE__, line)(data[i] == buf[i], "off %u: %#x != %#x\n", i, data[i], buf[i]);
147 /* some Windows versions fail to properly clear the aligned DWORD */
148 ok_(__FILE__, line)(data[size - 1] == buf[size - 1] || broken(data[size - 1] != buf[size - 1]),
149 "off %u: %#x != %#x\n", size - 1, data[size - 1], buf[size - 1]);
152 static void test_getregiondata(void)
154 GpStatus status;
155 GpRegion *region, *region2;
156 RegionDataPoint *point;
157 UINT needed;
158 DWORD buf[256];
159 GpRect rect;
160 GpPath *path;
161 GpMatrix *matrix;
163 status = GdipCreateRegion(&region);
164 ok(status == Ok, "status %08x\n", status);
166 needed = 0;
167 status = GdipGetRegionDataSize(region, &needed);
168 ok(status == Ok, "status %08x\n", status);
169 expect(20, needed);
171 needed = 0;
172 status = GdipGetRegionData(region, (BYTE*)buf, 0, &needed);
173 ok(status == InvalidParameter, "status %08x\n", status);
175 memset(buf, 0xee, sizeof(buf));
176 needed = 0;
177 status = GdipGetRegionData(region, (BYTE*)buf, 4, &needed);
178 ok(status == InsufficientBuffer, "status %08x\n", status);
179 expect(4, needed);
180 expect_dword(buf, 0xeeeeeeee);
182 memset(buf, 0xee, sizeof(buf));
183 needed = 0;
184 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
185 ok(status == Ok, "status %08x\n", status);
186 expect(20, needed);
187 expect_dword(buf, 12);
188 trace("buf[1] = %08x\n", buf[1]);
189 expect_magic(buf + 2);
190 expect_dword(buf + 3, 0);
191 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
192 expect_dword(buf + 6, 0xeeeeeeee);
193 test_region_data(buf, needed, __LINE__);
195 status = GdipSetEmpty(region);
196 ok(status == Ok, "status %08x\n", status);
197 status = GdipGetRegionDataSize(region, &needed);
198 ok(status == Ok, "status %08x\n", status);
199 expect(20, needed);
200 memset(buf, 0xee, sizeof(buf));
201 needed = 0;
202 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
203 ok(status == Ok, "status %08x\n", status);
204 expect(20, needed);
205 expect_dword(buf, 12);
206 trace("buf[1] = %08x\n", buf[1]);
207 expect_magic(buf + 2);
208 expect_dword(buf + 3, 0);
209 expect_dword(buf + 4, RGNDATA_EMPTY_RECT);
210 expect_dword(buf + 6, 0xeeeeeeee);
211 test_region_data(buf, needed, __LINE__);
213 status = GdipSetInfinite(region);
214 ok(status == Ok, "status %08x\n", status);
215 status = GdipGetRegionDataSize(region, &needed);
216 ok(status == Ok, "status %08x\n", status);
217 expect(20, needed);
218 memset(buf, 0xee, sizeof(buf));
219 needed = 0;
220 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
221 ok(status == Ok, "status %08x\n", status);
222 expect(20, needed);
223 expect_dword(buf, 12);
224 trace("buf[1] = %08x\n", buf[1]);
225 expect_magic(buf + 2);
226 expect_dword(buf + 3, 0);
227 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
228 expect_dword(buf + 6, 0xeeeeeeee);
229 test_region_data(buf, needed, __LINE__);
231 status = GdipDeleteRegion(region);
232 ok(status == Ok, "status %08x\n", status);
234 rect.X = 10;
235 rect.Y = 20;
236 rect.Width = 100;
237 rect.Height = 200;
238 status = GdipCreateRegionRectI(&rect, &region);
239 ok(status == Ok, "status %08x\n", status);
240 status = GdipGetRegionDataSize(region, &needed);
241 ok(status == Ok, "status %08x\n", status);
242 expect(36, needed);
243 memset(buf, 0xee, sizeof(buf));
244 needed = 0;
245 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
246 ok(status == Ok, "status %08x\n", status);
247 expect(36, needed);
248 expect_dword(buf, 28);
249 trace("buf[1] = %08x\n", buf[1]);
250 expect_magic(buf + 2);
251 expect_dword(buf + 3, 0);
252 expect_dword(buf + 4, RGNDATA_RECT);
253 expect_float(buf + 5, 10.0);
254 expect_float(buf + 6, 20.0);
255 expect_float(buf + 7, 100.0);
256 expect_float(buf + 8, 200.0);
257 expect_dword(buf + 10, 0xeeeeeeee);
258 test_region_data(buf, needed, __LINE__);
260 rect.X = 50;
261 rect.Y = 30;
262 rect.Width = 10;
263 rect.Height = 20;
264 status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
265 ok(status == Ok, "status %08x\n", status);
266 rect.X = 100;
267 rect.Y = 300;
268 rect.Width = 30;
269 rect.Height = 50;
270 status = GdipCombineRegionRectI(region, &rect, CombineModeXor);
271 ok(status == Ok, "status %08x\n", status);
273 rect.X = 200;
274 rect.Y = 100;
275 rect.Width = 133;
276 rect.Height = 266;
277 status = GdipCreateRegionRectI(&rect, &region2);
278 ok(status == Ok, "status %08x\n", status);
279 rect.X = 20;
280 rect.Y = 10;
281 rect.Width = 40;
282 rect.Height = 66;
283 status = GdipCombineRegionRectI(region2, &rect, CombineModeUnion);
284 ok(status == Ok, "status %08x\n", status);
286 status = GdipCombineRegionRegion(region, region2, CombineModeComplement);
287 ok(status == Ok, "status %08x\n", status);
289 rect.X = 400;
290 rect.Y = 500;
291 rect.Width = 22;
292 rect.Height = 55;
293 status = GdipCombineRegionRectI(region, &rect, CombineModeExclude);
294 ok(status == Ok, "status %08x\n", status);
296 status = GdipGetRegionDataSize(region, &needed);
297 ok(status == Ok, "status %08x\n", status);
298 expect(156, needed);
299 memset(buf, 0xee, sizeof(buf));
300 needed = 0;
301 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
302 ok(status == Ok, "status %08x\n", status);
303 expect(156, needed);
304 expect_dword(buf, 148);
305 trace("buf[1] = %08x\n", buf[1]);
306 expect_magic(buf + 2);
307 expect_dword(buf + 3, 10);
308 expect_dword(buf + 4, CombineModeExclude);
309 expect_dword(buf + 5, CombineModeComplement);
310 expect_dword(buf + 6, CombineModeXor);
311 expect_dword(buf + 7, CombineModeIntersect);
312 expect_dword(buf + 8, RGNDATA_RECT);
313 expect_float(buf + 9, 10.0);
314 expect_float(buf + 10, 20.0);
315 expect_float(buf + 11, 100.0);
316 expect_float(buf + 12, 200.0);
317 expect_dword(buf + 13, RGNDATA_RECT);
318 expect_float(buf + 14, 50.0);
319 expect_float(buf + 15, 30.0);
320 expect_float(buf + 16, 10.0);
321 expect_float(buf + 17, 20.0);
322 expect_dword(buf + 18, RGNDATA_RECT);
323 expect_float(buf + 19, 100.0);
324 expect_float(buf + 20, 300.0);
325 expect_float(buf + 21, 30.0);
326 expect_float(buf + 22, 50.0);
327 expect_dword(buf + 23, CombineModeUnion);
328 expect_dword(buf + 24, RGNDATA_RECT);
329 expect_float(buf + 25, 200.0);
330 expect_float(buf + 26, 100.0);
331 expect_float(buf + 27, 133.0);
332 expect_float(buf + 28, 266.0);
333 expect_dword(buf + 29, RGNDATA_RECT);
334 expect_float(buf + 30, 20.0);
335 expect_float(buf + 31, 10.0);
336 expect_float(buf + 32, 40.0);
337 expect_float(buf + 33, 66.0);
338 expect_dword(buf + 34, RGNDATA_RECT);
339 expect_float(buf + 35, 400.0);
340 expect_float(buf + 36, 500.0);
341 expect_float(buf + 37, 22.0);
342 expect_float(buf + 38, 55.0);
343 expect_dword(buf + 39, 0xeeeeeeee);
344 test_region_data(buf, needed, __LINE__);
346 status = GdipDeleteRegion(region2);
347 ok(status == Ok, "status %08x\n", status);
348 status = GdipDeleteRegion(region);
349 ok(status == Ok, "status %08x\n", status);
351 /* Try some paths */
353 status = GdipCreatePath(FillModeAlternate, &path);
354 ok(status == Ok, "status %08x\n", status);
355 GdipAddPathRectangle(path, 12.5, 13.0, 14.0, 15.0);
357 status = GdipCreateRegionPath(path, &region);
358 ok(status == Ok, "status %08x\n", status);
359 status = GdipGetRegionDataSize(region, &needed);
360 ok(status == Ok, "status %08x\n", status);
361 expect(72, needed);
362 memset(buf, 0xee, sizeof(buf));
363 needed = 0;
364 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
365 ok(status == Ok, "status %08x\n", status);
366 expect(72, needed);
367 expect_dword(buf, 64);
368 trace("buf[1] = %08x\n", buf[1]);
369 expect_magic(buf + 2);
370 expect_dword(buf + 3, 0);
371 expect_dword(buf + 4, RGNDATA_PATH);
372 expect_dword(buf + 5, 0x00000030);
373 expect_magic(buf + 6);
374 expect_dword(buf + 7, 0x00000004);
375 expect_dword(buf + 8, 0x00000000);
376 expect_float(buf + 9, 12.5);
377 expect_float(buf + 10, 13.0);
378 expect_float(buf + 11, 26.5);
379 expect_float(buf + 12, 13.0);
380 expect_float(buf + 13, 26.5);
381 expect_float(buf + 14, 28.0);
382 expect_float(buf + 15, 12.5);
383 expect_float(buf + 16, 28.0);
384 expect_dword(buf + 17, 0x81010100);
385 expect_dword(buf + 18, 0xeeeeeeee);
386 test_region_data(buf, needed, __LINE__);
388 rect.X = 50;
389 rect.Y = 30;
390 rect.Width = 10;
391 rect.Height = 20;
392 status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
393 ok(status == Ok, "status %08x\n", status);
394 status = GdipGetRegionDataSize(region, &needed);
395 ok(status == Ok, "status %08x\n", status);
396 expect(96, needed);
397 memset(buf, 0xee, sizeof(buf));
398 needed = 0;
399 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
400 ok(status == Ok, "status %08x\n", status);
401 expect(96, needed);
402 expect_dword(buf, 88);
403 trace("buf[1] = %08x\n", buf[1]);
404 expect_magic(buf + 2);
405 expect_dword(buf + 3, 2);
406 expect_dword(buf + 4, CombineModeIntersect);
407 expect_dword(buf + 5, RGNDATA_PATH);
408 expect_dword(buf + 6, 0x00000030);
409 expect_magic(buf + 7);
410 expect_dword(buf + 8, 0x00000004);
411 expect_dword(buf + 9, 0x00000000);
412 expect_float(buf + 10, 12.5);
413 expect_float(buf + 11, 13.0);
414 expect_float(buf + 12, 26.5);
415 expect_float(buf + 13, 13.0);
416 expect_float(buf + 14, 26.5);
417 expect_float(buf + 15, 28.0);
418 expect_float(buf + 16, 12.5);
419 expect_float(buf + 17, 28.0);
420 expect_dword(buf + 18, 0x81010100);
421 expect_dword(buf + 19, RGNDATA_RECT);
422 expect_float(buf + 20, 50.0);
423 expect_float(buf + 21, 30.0);
424 expect_float(buf + 22, 10.0);
425 expect_float(buf + 23, 20.0);
426 expect_dword(buf + 24, 0xeeeeeeee);
427 test_region_data(buf, needed, __LINE__);
429 status = GdipDeleteRegion(region);
430 ok(status == Ok, "status %08x\n", status);
431 status = GdipDeletePath(path);
432 ok(status == Ok, "status %08x\n", status);
434 /* Test an empty path */
435 status = GdipCreatePath(FillModeAlternate, &path);
436 expect(Ok, status);
437 status = GdipCreateRegionPath(path, &region);
438 expect(Ok, status);
439 status = GdipGetRegionDataSize(region, &needed);
440 expect(Ok, status);
441 expect(36, needed);
442 memset(buf, 0xee, sizeof(buf));
443 needed = 0;
444 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
445 expect(Ok, status);
446 expect(36, needed);
447 expect_dword(buf, 28);
448 trace("buf[1] = %08x\n", buf[1]);
449 expect_magic(buf + 2);
450 expect_dword(buf + 3, 0);
451 expect_dword(buf + 4, RGNDATA_PATH);
452 /* Second signature for pathdata */
453 expect_dword(buf + 5, 12);
454 expect_magic(buf + 6);
455 expect_dword(buf + 7, 0);
456 /* flags 0 means that a path is an array of FLOATs */
457 ok(*(buf + 8) == 0x4000 /* before win7 */ || *(buf + 8) == 0,
458 "expected 0x4000 or 0, got %08x\n", *(buf + 8));
459 expect_dword(buf + 10, 0xeeeeeeee);
460 test_region_data(buf, needed, __LINE__);
462 /* Transform an empty region */
463 status = GdipCreateMatrix(&matrix);
464 expect(Ok, status);
465 status = GdipTransformRegion(region, matrix);
466 expect(Ok, status);
467 GdipDeleteMatrix(matrix);
469 status = GdipDeleteRegion(region);
470 expect(Ok, status);
472 /* Test a simple triangle of INTs */
473 status = GdipAddPathLine(path, 5, 6, 7, 8);
474 expect(Ok, status);
475 status = GdipAddPathLine(path, 8, 1, 5, 6);
476 expect(Ok, status);
477 status = GdipClosePathFigure(path);
478 expect(Ok, status);
479 status = GdipCreateRegionPath(path, &region);
480 expect(Ok, status);
481 status = GdipGetRegionDataSize(region, &needed);
482 expect(Ok, status);
483 expect(56, needed);
484 memset(buf, 0xee, sizeof(buf));
485 needed = 0;
486 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
487 expect(Ok, status);
488 expect(56, needed);
489 expect_dword(buf, 48);
490 trace("buf[1] = %08x\n", buf[1]);
491 expect_magic(buf + 2);
492 expect_dword(buf + 3 , 0);
493 expect_dword(buf + 4 , RGNDATA_PATH);
494 expect_dword(buf + 5, 32);
495 expect_magic(buf + 6);
496 expect_dword(buf + 7, 4);
497 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
498 expect_dword(buf + 8, 0x4000);
500 point = (RegionDataPoint*)(buf + 9);
501 expect(5, point[0].X);
502 expect(6, point[0].Y);
503 expect(7, point[1].X); /* buf + 10 */
504 expect(8, point[1].Y);
505 expect(8, point[2].X); /* buf + 11 */
506 expect(1, point[2].Y);
507 expect(5, point[3].X); /* buf + 12 */
508 expect(6, point[3].Y);
509 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
510 expect_dword(buf + 14, 0xeeeeeeee);
511 test_region_data(buf, needed, __LINE__);
513 status = GdipTranslateRegion(region, 0.6, 0.8);
514 expect(Ok, status);
515 memset(buf, 0xee, sizeof(buf));
516 needed = 0;
517 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
518 expect(Ok, status);
519 expect(72, needed);
520 expect_dword(buf, 64);
521 expect_magic(buf + 2);
522 expect_dword(buf + 3 , 0);
523 expect_dword(buf + 4 , RGNDATA_PATH);
524 expect_dword(buf + 5, 48);
525 expect_magic(buf + 6);
526 expect_dword(buf + 7, 4);
527 /* flags 0 means that a path is an array of FLOATs */
528 expect_dword(buf + 8, 0);
529 expect_float(buf + 9, 5.6);
530 expect_float(buf + 10, 6.8);
531 expect_float(buf + 11, 7.6);
532 expect_float(buf + 12, 8.8);
533 expect_float(buf + 13, 8.6);
534 expect_float(buf + 14, 1.8);
535 expect_float(buf + 15, 5.6);
536 expect_float(buf + 16, 6.8);
537 expect_dword(buf + 17, 0x81010100); /* 0x01010100 if we don't close the path */
538 expect_dword(buf + 18, 0xeeeeeeee);
539 test_region_data(buf, needed, __LINE__);
541 status = GdipDeletePath(path);
542 expect(Ok, status);
543 status = GdipDeleteRegion(region);
544 expect(Ok, status);
546 /* Test a floating-point triangle */
547 status = GdipCreatePath(FillModeAlternate, &path);
548 expect(Ok, status);
549 status = GdipAddPathLine(path, 5.6, 6.2, 7.2, 8.9);
550 expect(Ok, status);
551 status = GdipAddPathLine(path, 8.1, 1.6, 5.6, 6.2);
552 expect(Ok, status);
553 status = GdipCreateRegionPath(path, &region);
554 expect(Ok, status);
555 status = GdipGetRegionDataSize(region, &needed);
556 expect(Ok, status);
557 expect(72, needed);
558 memset(buf, 0xee, sizeof(buf));
559 needed = 0;
560 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
561 expect(Ok, status);
562 expect(72, needed);
563 expect_dword(buf, 64);
564 trace("buf[1] = %08x\n", buf[1]);
565 expect_magic(buf + 2);
566 expect_dword(buf + 3, 0);
567 expect_dword(buf + 4, RGNDATA_PATH);
568 expect_dword(buf + 5, 48);
569 expect_magic(buf + 6);
570 expect_dword(buf + 7, 4);
571 expect_dword(buf + 8, 0);
572 expect_float(buf + 9, 5.6);
573 expect_float(buf + 10, 6.2);
574 expect_float(buf + 11, 7.2);
575 expect_float(buf + 12, 8.9);
576 expect_float(buf + 13, 8.1);
577 expect_float(buf + 14, 1.6);
578 expect_float(buf + 15, 5.6);
579 expect_float(buf + 16, 6.2);
580 expect_dword(buf + 17, 0x01010100);
581 expect_dword(buf + 18, 0xeeeeeeee);
582 test_region_data(buf, needed, __LINE__);
584 status = GdipDeletePath(path);
585 expect(Ok, status);
586 status = GdipDeleteRegion(region);
587 expect(Ok, status);
589 /* Test for a path with > 4 points, and CombineRegionPath */
590 GdipCreatePath(FillModeAlternate, &path);
591 status = GdipAddPathLine(path, 50, 70.2, 60, 102.8);
592 expect(Ok, status);
593 status = GdipAddPathLine(path, 55.4, 122.4, 40.4, 60.2);
594 expect(Ok, status);
595 status = GdipAddPathLine(path, 45.6, 20.2, 50, 70.2);
596 expect(Ok, status);
597 rect.X = 20;
598 rect.Y = 25;
599 rect.Width = 60;
600 rect.Height = 120;
601 status = GdipCreateRegionRectI(&rect, &region);
602 expect(Ok, status);
603 status = GdipCombineRegionPath(region, path, CombineModeUnion);
604 expect(Ok, status);
606 status = GdipGetRegionDataSize(region, &needed);
607 expect(Ok, status);
608 expect(116, needed);
609 memset(buf, 0xee, sizeof(buf));
610 needed = 0;
611 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
612 expect(Ok, status);
613 expect(116, needed);
614 expect_dword(buf, 108);
615 trace("buf[1] = %08x\n", buf[1]);
616 expect_magic(buf + 2);
617 expect_dword(buf + 3, 2);
618 expect_dword(buf + 4, CombineModeUnion);
619 expect_dword(buf + 5, RGNDATA_RECT);
620 expect_float(buf + 6, 20.0);
621 expect_float(buf + 7, 25.0);
622 expect_float(buf + 8, 60.0);
623 expect_float(buf + 9, 120.0);
624 expect_dword(buf + 10, RGNDATA_PATH);
625 expect_dword(buf + 11, 68);
626 expect_magic(buf + 12);
627 expect_dword(buf + 13, 6);
628 expect_float(buf + 14, 0.0);
629 expect_float(buf + 15, 50.0);
630 expect_float(buf + 16, 70.2);
631 expect_float(buf + 17, 60.0);
632 expect_float(buf + 18, 102.8);
633 expect_float(buf + 19, 55.4);
634 expect_float(buf + 20, 122.4);
635 expect_float(buf + 21, 40.4);
636 expect_float(buf + 22, 60.2);
637 expect_float(buf + 23, 45.6);
638 expect_float(buf + 24, 20.2);
639 expect_float(buf + 25, 50.0);
640 expect_float(buf + 26, 70.2);
641 expect_dword(buf + 27, 0x01010100);
642 ok(*(buf + 28) == 0x00000101 || *(buf + 28) == 0x43050101 /* Win 7 */,
643 "expected 00000101 or 43050101 got %08x\n", *(buf + 28));
644 expect_dword(buf + 29, 0xeeeeeeee);
645 test_region_data(buf, needed, __LINE__);
647 status = GdipDeletePath(path);
648 expect(Ok, status);
649 status = GdipDeleteRegion(region);
650 expect(Ok, status);
652 /* Test how shorts are stored in the region path data */
653 status = GdipCreatePath(FillModeAlternate, &path);
654 ok(status == Ok, "status %08x\n", status);
655 GdipAddPathRectangleI(path, -1969, -1974, 1995, 1997);
657 status = GdipCreateRegionPath(path, &region);
658 ok(status == Ok, "status %08x\n", status);
659 needed = 0;
660 status = GdipGetRegionDataSize(region, &needed);
661 ok(status == Ok, "status %08x\n", status);
662 expect(56, needed);
663 memset(buf, 0xee, sizeof(buf));
664 needed = 0;
665 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
666 ok(status == Ok, "status %08x\n", status);
667 expect(56, needed);
668 expect_dword(buf, 48);
669 trace("buf[1] = %08x\n", buf[1]);
670 expect_magic(buf + 2);
671 expect_dword(buf + 3, 0);
672 expect_dword(buf + 4, RGNDATA_PATH);
673 expect_dword(buf + 5, 32);
674 expect_magic(buf + 6);
675 expect_dword(buf + 7, 4);
676 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
677 expect_dword(buf + 8, 0x4000);
678 point = (RegionDataPoint*)(buf + 9);
679 expect(-1969, point[0].X);
680 expect(-1974, point[0].Y);
681 expect(26, point[1].X); /* buf + 10 */
682 expect(-1974, point[1].Y);
683 expect(26, point[2].X); /* buf + 11 */
684 expect(23, point[2].Y);
685 expect(-1969, point[3].X); /* buf + 12 */
686 expect(23, point[3].Y);
687 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
688 expect_dword(buf + 14, 0xeeeeeeee);
689 test_region_data(buf, needed, __LINE__);
691 status = GdipDeletePath(path);
692 expect(Ok, status);
693 status = GdipDeleteRegion(region);
694 expect(Ok, status);
696 /* Test with integers that can't be stored as shorts */
697 status = GdipCreatePath(FillModeAlternate, &path);
698 ok(status == Ok, "status %08x\n", status);
699 GdipAddPathRectangleI(path, -196900, -197400, 199500, 199700);
701 status = GdipCreateRegionPath(path, &region);
702 ok(status == Ok, "status %08x\n", status);
703 needed = 0;
704 status = GdipGetRegionDataSize(region, &needed);
705 ok(status == Ok, "status %08x\n", status);
706 expect(72, needed);
707 memset(buf, 0xee, sizeof(buf));
708 needed = 0;
709 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
710 ok(status == Ok, "status %08x\n", status);
711 expect(72, needed);
712 expect_dword(buf, 64);
713 trace("buf[1] = %08x\n", buf[1]);
714 expect_magic(buf + 2);
715 expect_dword(buf + 3, 0);
716 expect_dword(buf + 4, RGNDATA_PATH);
717 expect_dword(buf + 5, 48);
718 expect_magic(buf + 6);
719 expect_dword(buf + 7, 4);
720 /* flags 0 means that a path is an array of FLOATs */
721 expect_dword(buf + 8, 0);
722 expect_float(buf + 9, -196900.0);
723 expect_float(buf + 10, -197400.0);
724 expect_float(buf + 11, 2600.0);
725 expect_float(buf + 12, -197400.0);
726 expect_float(buf + 13, 2600.0);
727 expect_float(buf + 14, 2300.0);
728 expect_float(buf + 15, -196900.0);
729 expect_float(buf + 16, 2300.0);
730 expect_dword(buf + 17, 0x81010100); /* 0x01010100 if we don't close the path */
731 expect_dword(buf + 18, 0xeeeeeeee);
732 test_region_data(buf, needed, __LINE__);
734 status = GdipDeletePath(path);
735 expect(Ok, status);
736 status = GdipDeleteRegion(region);
737 expect(Ok, status);
739 /* Test beziers */
740 GdipCreatePath(FillModeAlternate, &path);
741 /* Exactly 90 degrees */
742 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
743 expect(Ok, status);
744 /* Over 90 degrees */
745 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
746 expect(Ok, status);
747 status = GdipCreateRegionPath(path, &region);
748 ok(status == Ok, "status %08x\n", status);
749 needed = 0;
750 status = GdipGetRegionDataSize(region, &needed);
751 ok(status == Ok, "status %08x\n", status);
752 expect(136, needed);
753 memset(buf, 0xee, sizeof(buf));
754 needed = 0;
755 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
756 ok(status == Ok, "status %08x\n", status);
757 expect(136, needed);
758 expect_dword(buf, 128);
759 trace("buf[1] = %08x\n", buf[1]);
760 expect_magic(buf + 2);
761 expect_dword(buf + 3, 0);
762 expect_dword(buf + 4, RGNDATA_PATH);
763 expect_dword(buf + 5, 112);
764 expect_magic(buf + 6);
765 expect_dword(buf + 7, 11);
766 /* flags 0 means that a path is an array of FLOATs */
767 expect_dword(buf + 8, 0);
768 expect_float(buf + 9, 600.0);
769 expect_float(buf + 10, 450.0);
770 expect_float(buf + 11, 600.0);
771 expect_float(buf + 12, 643.299561);
772 expect_float(buf + 13, 488.071198);
773 expect_float(buf + 14, 800.0);
774 expect_float(buf + 15, 350.0);
775 expect_float(buf + 16, 800.0);
776 expect_float(buf + 17, 600.0);
777 expect_float(buf + 18, 450.0);
778 expect_float(buf + 19, 600.0);
779 expect_float(buf + 20, 643.299622);
780 expect_float(buf + 21, 488.071167);
781 expect_float(buf + 22, 800.0);
782 expect_float(buf + 23, 350.0);
783 expect_float(buf + 24, 800.0);
784 expect_float(buf + 25, 329.807129);
785 expect_float(buf + 26, 800.0);
786 expect_float(buf + 27, 309.688568);
787 expect_float(buf + 28, 796.574890);
788 expect_float(buf + 29, 290.084167);
789 expect_float(buf + 30, 789.799561);
790 expect_dword(buf + 31, 0x03030300);
791 expect_dword(buf + 32, 0x03030301);
792 ok(*(buf + 33) == 0x00030303 /* before win7 */ ||
793 *(buf + 33) == 0x43030303 /* 32-bit win7 */ || *(buf + 33) == 0x4c030303 /* 64-bit win7 */,
794 "expected 0x00030303 or 0x43030303 or 0x4c030303 got %08x\n", *(buf + 33));
795 expect_dword(buf + 34, 0xeeeeeeee);
796 test_region_data(buf, needed, __LINE__);
798 status = GdipDeletePath(path);
799 expect(Ok, status);
800 status = GdipDeleteRegion(region);
801 expect(Ok, status);
804 static void test_isinfinite(void)
806 GpStatus status;
807 GpRegion *region;
808 GpGraphics *graphics = NULL;
809 GpMatrix *m;
810 HDC hdc = GetDC(0);
811 BOOL res;
813 status = GdipCreateFromHDC(hdc, &graphics);
814 expect(Ok, status);
815 GdipCreateRegion(&region);
817 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m);
819 /* NULL arguments */
820 status = GdipIsInfiniteRegion(NULL, NULL, NULL);
821 expect(InvalidParameter, status);
822 status = GdipIsInfiniteRegion(region, NULL, NULL);
823 expect(InvalidParameter, status);
824 status = GdipIsInfiniteRegion(NULL, graphics, NULL);
825 expect(InvalidParameter, status);
826 status = GdipIsInfiniteRegion(NULL, NULL, &res);
827 expect(InvalidParameter, status);
828 status = GdipIsInfiniteRegion(region, NULL, &res);
829 expect(InvalidParameter, status);
831 res = FALSE;
832 status = GdipIsInfiniteRegion(region, graphics, &res);
833 expect(Ok, status);
834 expect(TRUE, res);
836 /* after world transform */
837 status = GdipSetWorldTransform(graphics, m);
838 expect(Ok, status);
840 res = FALSE;
841 status = GdipIsInfiniteRegion(region, graphics, &res);
842 expect(Ok, status);
843 expect(TRUE, res);
845 GdipDeleteMatrix(m);
846 GdipDeleteRegion(region);
847 GdipDeleteGraphics(graphics);
848 ReleaseDC(0, hdc);
851 static void test_isempty(void)
853 GpStatus status;
854 GpRegion *region;
855 GpGraphics *graphics = NULL;
856 HDC hdc = GetDC(0);
857 BOOL res;
859 status = GdipCreateFromHDC(hdc, &graphics);
860 expect(Ok, status);
861 GdipCreateRegion(&region);
863 /* NULL arguments */
864 status = GdipIsEmptyRegion(NULL, NULL, NULL);
865 expect(InvalidParameter, status);
866 status = GdipIsEmptyRegion(region, NULL, NULL);
867 expect(InvalidParameter, status);
868 status = GdipIsEmptyRegion(NULL, graphics, NULL);
869 expect(InvalidParameter, status);
870 status = GdipIsEmptyRegion(NULL, NULL, &res);
871 expect(InvalidParameter, status);
872 status = GdipIsEmptyRegion(region, NULL, &res);
873 expect(InvalidParameter, status);
875 /* default is infinite */
876 res = TRUE;
877 status = GdipIsEmptyRegion(region, graphics, &res);
878 expect(Ok, status);
879 expect(FALSE, res);
881 status = GdipSetEmpty(region);
882 expect(Ok, status);
884 res = FALSE;
885 status = GdipIsEmptyRegion(region, graphics, &res);
886 expect(Ok, status);
887 expect(TRUE, res);
889 GdipDeleteRegion(region);
890 GdipDeleteGraphics(graphics);
891 ReleaseDC(0, hdc);
894 static void test_combinereplace(void)
896 GpStatus status;
897 GpRegion *region, *region2;
898 GpPath *path;
899 GpRectF rectf;
900 UINT needed;
901 DWORD buf[50];
903 rectf.X = rectf.Y = 0.0;
904 rectf.Width = rectf.Height = 100.0;
906 status = GdipCreateRegionRect(&rectf, &region);
907 expect(Ok, status);
909 /* replace with the same rectangle */
910 status = GdipCombineRegionRect(region, &rectf,CombineModeReplace);
911 expect(Ok, status);
913 status = GdipGetRegionDataSize(region, &needed);
914 expect(Ok, status);
915 expect(36, needed);
916 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
917 expect(Ok, status);
918 expect(36, needed);
919 expect_dword(buf, 28);
920 trace("buf[1] = %08x\n", buf[1]);
921 expect_magic(buf + 2);
922 expect_dword(buf + 3, 0);
923 expect_dword(buf + 4, RGNDATA_RECT);
925 /* replace with path */
926 status = GdipCreatePath(FillModeAlternate, &path);
927 expect(Ok, status);
928 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
929 expect(Ok, status);
930 status = GdipCombineRegionPath(region, path, CombineModeReplace);
931 expect(Ok, status);
933 status = GdipGetRegionDataSize(region, &needed);
934 expect(Ok, status);
935 expect(156, needed);
936 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
937 expect(Ok, status);
938 expect(156, needed);
939 expect_dword(buf, 148);
940 trace("buf[1] = %08x\n", buf[1]);
941 expect_magic(buf + 2);
942 expect_dword(buf + 3, 0);
943 expect_dword(buf + 4, RGNDATA_PATH);
944 GdipDeletePath(path);
946 /* replace with infinite rect */
947 status = GdipCreateRegion(&region2);
948 expect(Ok, status);
949 status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
950 expect(Ok, status);
952 status = GdipGetRegionDataSize(region, &needed);
953 expect(Ok, status);
954 expect(20, needed);
955 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
956 expect(Ok, status);
957 expect(20, needed);
958 expect_dword(buf, 12);
959 trace("buf[1] = %08x\n", buf[1]);
960 expect_magic(buf + 2);
961 expect_dword(buf + 3, 0);
962 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
963 GdipDeleteRegion(region2);
965 /* more complex case : replace with a combined region */
966 status = GdipCreateRegionRect(&rectf, &region2);
967 expect(Ok, status);
968 status = GdipCreatePath(FillModeAlternate, &path);
969 expect(Ok, status);
970 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
971 expect(Ok, status);
972 status = GdipCombineRegionPath(region2, path, CombineModeUnion);
973 expect(Ok, status);
974 GdipDeletePath(path);
975 status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
976 expect(Ok, status);
977 GdipDeleteRegion(region2);
979 status = GdipGetRegionDataSize(region, &needed);
980 expect(Ok, status);
981 expect(180, needed);
982 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
983 expect(Ok, status);
984 expect(180, needed);
985 expect_dword(buf, 172);
986 trace("buf[1] = %08x\n", buf[1]);
987 expect_magic(buf + 2);
988 expect_dword(buf + 3, 2);
989 expect_dword(buf + 4, CombineModeUnion);
991 GdipDeleteRegion(region);
994 static void test_fromhrgn(void)
996 GpStatus status;
997 GpRegion *region = (GpRegion*)0xabcdef01;
998 HRGN hrgn;
999 UINT needed;
1000 DWORD buf[220];
1001 RegionDataPoint *point;
1002 GpGraphics *graphics = NULL;
1003 HDC hdc;
1004 BOOL res;
1006 /* NULL */
1007 status = GdipCreateRegionHrgn(NULL, NULL);
1008 expect(InvalidParameter, status);
1009 status = GdipCreateRegionHrgn(NULL, &region);
1010 expect(InvalidParameter, status);
1011 status = GdipCreateRegionHrgn((HRGN)0xdeadbeef, &region);
1012 expect(InvalidParameter, status);
1013 ok(region == (GpRegion*)0xabcdef01, "Expected region not to be created\n");
1015 /* empty rectangle */
1016 hrgn = CreateRectRgn(0, 0, 0, 0);
1017 status = GdipCreateRegionHrgn(hrgn, &region);
1018 expect(Ok, status);
1019 if(status == Ok) {
1021 hdc = GetDC(0);
1022 status = GdipCreateFromHDC(hdc, &graphics);
1023 expect(Ok, status);
1024 res = FALSE;
1025 status = GdipIsEmptyRegion(region, graphics, &res);
1026 expect(Ok, status);
1027 expect(TRUE, res);
1028 GdipDeleteGraphics(graphics);
1029 ReleaseDC(0, hdc);
1030 GdipDeleteRegion(region);
1033 DeleteObject(hrgn);
1035 /* rectangle */
1036 hrgn = CreateRectRgn(0, 0, 100, 10);
1037 status = GdipCreateRegionHrgn(hrgn, &region);
1038 expect(Ok, status);
1040 status = GdipGetRegionDataSize(region, &needed);
1041 expect(Ok, status);
1042 expect(56, needed);
1044 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
1045 expect(Ok, status);
1047 if(status == Ok){
1049 expect(56, needed);
1050 expect_dword(buf, 48);
1051 expect_magic(buf + 2);
1052 expect_dword(buf + 3, 0);
1053 expect_dword(buf + 4, RGNDATA_PATH);
1054 expect_dword(buf + 5, 0x00000020);
1055 expect_magic(buf + 6);
1056 expect_dword(buf + 7, 0x00000004);
1057 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
1059 point = (RegionDataPoint*)buf + 9;
1061 expect(0, point[0].X);
1062 expect(0, point[0].Y);
1064 expect(100,point[1].X); /* buf + 10 */
1065 expect(0, point[1].Y);
1066 expect(100,point[2].X); /* buf + 11 */
1067 expect(10, point[2].Y);
1069 expect(0, point[3].X); /* buf + 12 */
1071 expect(10, point[3].Y);
1072 expect_dword(buf + 13, 0x81010100); /* closed */
1076 GdipDeleteRegion(region);
1077 DeleteObject(hrgn);
1079 /* ellipse */
1080 hrgn = CreateEllipticRgn(0, 0, 100, 10);
1081 status = GdipCreateRegionHrgn(hrgn, &region);
1082 expect(Ok, status);
1084 status = GdipGetRegionDataSize(region, &needed);
1085 expect(Ok, status);
1086 ok(needed == 216 ||
1087 needed == 196, /* win98 */
1088 "Got %.8x\n", needed);
1090 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
1091 expect(Ok, status);
1093 if(status == Ok && needed == 216) /* Don't try to test win98 layout */
1095 expect(Ok, status);
1096 expect(216, needed);
1097 expect_dword(buf, 208);
1098 expect_magic(buf + 2);
1099 expect_dword(buf + 3, 0);
1100 expect_dword(buf + 4, RGNDATA_PATH);
1101 expect_dword(buf + 5, 0x000000C0);
1102 expect_magic(buf + 6);
1103 expect_dword(buf + 7, 0x00000024);
1104 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
1107 GdipDeleteRegion(region);
1108 DeleteObject(hrgn);
1111 static void test_gethrgn(void)
1113 GpStatus status;
1114 GpRegion *region, *region2;
1115 GpPath *path;
1116 GpGraphics *graphics;
1117 HRGN hrgn;
1118 HDC hdc=GetDC(0);
1119 static const RECT empty_rect = {0,0,0,0};
1120 static const RECT test_rect = {10, 11, 20, 21};
1121 static const GpRectF test_rectF = {10.0, 11.0, 10.0, 10.0};
1122 static const RECT scaled_rect = {20, 22, 40, 42};
1123 static const RECT test_rect2 = {10, 21, 20, 31};
1124 static const GpRectF test_rect2F = {10.0, 21.0, 10.0, 10.0};
1125 static const RECT test_rect3 = {10, 11, 20, 31};
1126 static const GpRectF test_rect3F = {10.0, 11.0, 10.0, 20.0};
1128 status = GdipCreateFromHDC(hdc, &graphics);
1129 ok(status == Ok, "status %08x\n", status);
1131 status = GdipCreateRegion(&region);
1132 ok(status == Ok, "status %08x\n", status);
1134 status = GdipGetRegionHRgn(NULL, graphics, &hrgn);
1135 ok(status == InvalidParameter, "status %08x\n", status);
1136 status = GdipGetRegionHRgn(region, graphics, NULL);
1137 ok(status == InvalidParameter, "status %08x\n", status);
1139 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1140 ok(status == Ok, "status %08x\n", status);
1141 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
1143 status = GdipGetRegionHRgn(region, graphics, &hrgn);
1144 ok(status == Ok, "status %08x\n", status);
1145 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
1147 status = GdipSetEmpty(region);
1148 ok(status == Ok, "status %08x\n", status);
1149 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1150 ok(status == Ok, "status %08x\n", status);
1151 verify_region(hrgn, &empty_rect);
1152 DeleteObject(hrgn);
1154 status = GdipCreatePath(FillModeAlternate, &path);
1155 ok(status == Ok, "status %08x\n", status);
1156 status = GdipAddPathRectangle(path, 10.0, 11.0, 10.0, 10.0);
1157 ok(status == Ok, "status %08x\n", status);
1159 status = GdipCreateRegionPath(path, &region2);
1160 ok(status == Ok, "status %08x\n", status);
1161 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
1162 ok(status == Ok, "status %08x\n", status);
1163 verify_region(hrgn, &test_rect);
1164 DeleteObject(hrgn);
1166 /* resulting HRGN is in device coordinates */
1167 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1168 ok(status == Ok, "status %08x\n", status);
1169 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
1170 ok(status == Ok, "status %08x\n", status);
1171 verify_region(hrgn, &scaled_rect);
1172 DeleteObject(hrgn);
1174 status = GdipCombineRegionRect(region2, &test_rectF, CombineModeReplace);
1175 ok(status == Ok, "status %08x\n", status);
1176 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
1177 ok(status == Ok, "status %08x\n", status);
1178 verify_region(hrgn, &test_rect);
1179 DeleteObject(hrgn);
1181 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
1182 ok(status == Ok, "status %08x\n", status);
1183 verify_region(hrgn, &scaled_rect);
1184 DeleteObject(hrgn);
1186 status = GdipSetInfinite(region);
1187 ok(status == Ok, "status %08x\n", status);
1188 status = GdipCombineRegionRect(region, &test_rectF, CombineModeIntersect);
1189 ok(status == Ok, "status %08x\n", status);
1190 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1191 ok(status == Ok, "status %08x\n", status);
1192 verify_region(hrgn, &test_rect);
1193 DeleteObject(hrgn);
1195 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
1196 ok(status == Ok, "status %08x\n", status);
1197 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeUnion);
1198 ok(status == Ok, "status %08x\n", status);
1199 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1200 ok(status == Ok, "status %08x\n", status);
1201 verify_region(hrgn, &test_rect3);
1202 DeleteObject(hrgn);
1204 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
1205 ok(status == Ok, "status %08x\n", status);
1206 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeXor);
1207 ok(status == Ok, "status %08x\n", status);
1208 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1209 ok(status == Ok, "status %08x\n", status);
1210 verify_region(hrgn, &test_rect);
1211 DeleteObject(hrgn);
1213 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
1214 ok(status == Ok, "status %08x\n", status);
1215 status = GdipCombineRegionRect(region, &test_rectF, CombineModeExclude);
1216 ok(status == Ok, "status %08x\n", status);
1217 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1218 ok(status == Ok, "status %08x\n", status);
1219 verify_region(hrgn, &test_rect2);
1220 DeleteObject(hrgn);
1222 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
1223 ok(status == Ok, "status %08x\n", status);
1224 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeComplement);
1225 ok(status == Ok, "status %08x\n", status);
1226 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1227 ok(status == Ok, "status %08x\n", status);
1228 verify_region(hrgn, &test_rect2);
1229 DeleteObject(hrgn);
1231 status = GdipDeletePath(path);
1232 ok(status == Ok, "status %08x\n", status);
1233 status = GdipDeleteRegion(region);
1234 ok(status == Ok, "status %08x\n", status);
1235 status = GdipDeleteRegion(region2);
1236 ok(status == Ok, "status %08x\n", status);
1237 status = GdipDeleteGraphics(graphics);
1238 ok(status == Ok, "status %08x\n", status);
1239 ReleaseDC(0, hdc);
1242 static void test_isequal(void)
1244 GpRegion *region1, *region2;
1245 GpGraphics *graphics;
1246 GpRectF rectf;
1247 GpStatus status;
1248 HDC hdc = GetDC(0);
1249 BOOL res;
1251 status = GdipCreateFromHDC(hdc, &graphics);
1252 ok(status == Ok, "status %08x\n", status);
1254 status = GdipCreateRegion(&region1);
1255 ok(status == Ok, "status %08x\n", status);
1256 status = GdipCreateRegion(&region2);
1257 ok(status == Ok, "status %08x\n", status);
1259 /* NULL */
1260 status = GdipIsEqualRegion(NULL, NULL, NULL, NULL);
1261 ok(status == InvalidParameter, "status %08x\n", status);
1262 status = GdipIsEqualRegion(region1, region2, NULL, NULL);
1263 ok(status == InvalidParameter, "status %08x\n", status);
1264 status = GdipIsEqualRegion(region1, region2, graphics, NULL);
1265 ok(status == InvalidParameter, "status %08x\n", status);
1266 status = GdipIsEqualRegion(region1, region2, NULL, &res);
1267 ok(status == InvalidParameter, "status %08x\n", status);
1269 /* infinite regions */
1270 res = FALSE;
1271 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1272 ok(status == Ok, "status %08x\n", status);
1273 ok(res, "Expected to be equal.\n");
1274 /* empty regions */
1275 status = GdipSetEmpty(region1);
1276 ok(status == Ok, "status %08x\n", status);
1277 status = GdipSetEmpty(region2);
1278 ok(status == Ok, "status %08x\n", status);
1279 res = FALSE;
1280 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1281 ok(status == Ok, "status %08x\n", status);
1282 ok(res, "Expected to be equal.\n");
1283 /* empty & infinite */
1284 status = GdipSetInfinite(region1);
1285 ok(status == Ok, "status %08x\n", status);
1286 res = TRUE;
1287 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1288 ok(status == Ok, "status %08x\n", status);
1289 ok(!res, "Expected to be unequal.\n");
1290 /* rect & (inf/empty) */
1291 rectf.X = rectf.Y = 0.0;
1292 rectf.Width = rectf.Height = 100.0;
1293 status = GdipCombineRegionRect(region1, &rectf, CombineModeReplace);
1294 ok(status == Ok, "status %08x\n", status);
1295 res = TRUE;
1296 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1297 ok(status == Ok, "status %08x\n", status);
1298 ok(!res, "Expected to be unequal.\n");
1299 status = GdipSetInfinite(region2);
1300 ok(status == Ok, "status %08x\n", status);
1301 res = TRUE;
1302 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1303 ok(status == Ok, "status %08x\n", status);
1304 ok(!res, "Expected to be unequal.\n");
1305 /* roughly equal rectangles */
1306 rectf.X = rectf.Y = 0.0;
1307 rectf.Width = rectf.Height = 100.001;
1308 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1309 ok(status == Ok, "status %08x\n", status);
1310 res = FALSE;
1311 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1312 ok(status == Ok, "status %08x\n", status);
1313 ok(res, "Expected to be equal.\n");
1314 /* equal rectangles */
1315 rectf.X = rectf.Y = 0.0;
1316 rectf.Width = rectf.Height = 100.0;
1317 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1318 ok(status == Ok, "status %08x\n", status);
1319 res = FALSE;
1320 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1321 ok(status == Ok, "status %08x\n", status);
1322 ok(res, "Expected to be equal.\n");
1324 /* cleanup */
1325 status = GdipDeleteRegion(region1);
1326 ok(status == Ok, "status %08x\n", status);
1327 status = GdipDeleteRegion(region2);
1328 ok(status == Ok, "status %08x\n", status);
1329 status = GdipDeleteGraphics(graphics);
1330 ok(status == Ok, "status %08x\n", status);
1331 ReleaseDC(0, hdc);
1334 static void test_translate(void)
1336 GpRegion *region, *region2;
1337 GpGraphics *graphics;
1338 GpPath *path;
1339 GpRectF rectf;
1340 GpStatus status;
1341 HDC hdc = GetDC(0);
1342 BOOL res;
1344 status = GdipCreateFromHDC(hdc, &graphics);
1345 ok(status == Ok, "status %08x\n", status);
1347 status = GdipCreatePath(FillModeAlternate, &path);
1348 ok(status == Ok, "status %08x\n", status);
1350 status = GdipCreateRegion(&region);
1351 ok(status == Ok, "status %08x\n", status);
1352 status = GdipCreateRegion(&region2);
1353 ok(status == Ok, "status %08x\n", status);
1355 /* NULL */
1356 status = GdipTranslateRegion(NULL, 0.0, 0.0);
1357 ok(status == InvalidParameter, "status %08x\n", status);
1359 /* infinite */
1360 status = GdipTranslateRegion(region, 10.0, 10.0);
1361 ok(status == Ok, "status %08x\n", status);
1362 /* empty */
1363 status = GdipSetEmpty(region);
1364 ok(status == Ok, "status %08x\n", status);
1365 status = GdipTranslateRegion(region, 10.0, 10.0);
1366 ok(status == Ok, "status %08x\n", status);
1367 /* rect */
1368 rectf.X = 10.0; rectf.Y = 0.0;
1369 rectf.Width = rectf.Height = 100.0;
1370 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1371 ok(status == Ok, "status %08x\n", status);
1372 rectf.X = 15.0; rectf.Y = -2.0;
1373 rectf.Width = rectf.Height = 100.0;
1374 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1375 ok(status == Ok, "status %08x\n", status);
1376 status = GdipTranslateRegion(region, 5.0, -2.0);
1377 ok(status == Ok, "status %08x\n", status);
1378 res = FALSE;
1379 status = GdipIsEqualRegion(region, region2, graphics, &res);
1380 ok(status == Ok, "status %08x\n", status);
1381 ok(res, "Expected to be equal.\n");
1382 /* path */
1383 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1384 ok(status == Ok, "status %08x\n", status);
1385 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1386 ok(status == Ok, "status %08x\n", status);
1387 status = GdipResetPath(path);
1388 ok(status == Ok, "status %08x\n", status);
1389 status = GdipAddPathEllipse(path, 10.0, 21.0, 100.0, 150.0);
1390 ok(status == Ok, "status %08x\n", status);
1391 status = GdipCombineRegionPath(region2, path, CombineModeReplace);
1392 ok(status == Ok, "status %08x\n", status);
1393 status = GdipTranslateRegion(region, 10.0, 11.0);
1394 ok(status == Ok, "status %08x\n", status);
1395 res = FALSE;
1396 status = GdipIsEqualRegion(region, region2, graphics, &res);
1397 ok(status == Ok, "status %08x\n", status);
1398 ok(res, "Expected to be equal.\n");
1400 status = GdipDeleteRegion(region);
1401 ok(status == Ok, "status %08x\n", status);
1402 status = GdipDeleteRegion(region2);
1403 ok(status == Ok, "status %08x\n", status);
1404 status = GdipDeleteGraphics(graphics);
1405 ok(status == Ok, "status %08x\n", status);
1406 status = GdipDeletePath(path);
1407 ok(status == Ok, "status %08x\n", status);
1408 ReleaseDC(0, hdc);
1411 static void test_transform(void)
1413 GpRegion *region, *region2;
1414 GpMatrix *matrix;
1415 GpGraphics *graphics;
1416 GpPath *path;
1417 GpRectF rectf;
1418 GpStatus status;
1419 HDC hdc = GetDC(0);
1420 BOOL res;
1422 status = GdipCreateFromHDC(hdc, &graphics);
1423 expect(Ok, status);
1425 status = GdipCreatePath(FillModeAlternate, &path);
1426 expect(Ok, status);
1428 status = GdipCreateRegion(&region);
1429 expect(Ok, status);
1430 status = GdipCreateRegion(&region2);
1431 expect(Ok, status);
1433 status = GdipCreateMatrix(&matrix);
1434 expect(Ok, status);
1435 status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
1436 expect(Ok, status);
1438 /* NULL */
1439 status = GdipTransformRegion(NULL, matrix);
1440 expect(InvalidParameter, status);
1442 status = GdipTransformRegion(region, NULL);
1443 expect(InvalidParameter, status);
1445 /* infinite */
1446 status = GdipTransformRegion(region, matrix);
1447 expect(Ok, status);
1449 res = FALSE;
1450 status = GdipIsEqualRegion(region, region2, graphics, &res);
1451 expect(Ok, status);
1452 ok(res, "Expected to be equal.\n");
1454 /* empty */
1455 status = GdipSetEmpty(region);
1456 expect(Ok, status);
1457 status = GdipTransformRegion(region, matrix);
1458 expect(Ok, status);
1460 status = GdipSetEmpty(region2);
1461 expect(Ok, status);
1463 res = FALSE;
1464 status = GdipIsEqualRegion(region, region2, graphics, &res);
1465 expect(Ok, status);
1466 ok(res, "Expected to be equal.\n");
1468 /* rect */
1469 rectf.X = 10.0;
1470 rectf.Y = 0.0;
1471 rectf.Width = rectf.Height = 100.0;
1472 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1473 expect(Ok, status);
1474 rectf.X = 20.0;
1475 rectf.Y = 0.0;
1476 rectf.Width = 200.0;
1477 rectf.Height = 300.0;
1478 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1479 expect(Ok, status);
1480 status = GdipTransformRegion(region, matrix);
1481 expect(Ok, status);
1482 res = FALSE;
1483 status = GdipIsEqualRegion(region, region2, graphics, &res);
1484 expect(Ok, status);
1485 ok(res, "Expected to be equal.\n");
1487 /* path */
1488 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1489 expect(Ok, status);
1490 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1491 expect(Ok, status);
1492 status = GdipResetPath(path);
1493 expect(Ok, status);
1494 status = GdipAddPathEllipse(path, 0.0, 30.0, 200.0, 450.0);
1495 expect(Ok, status);
1496 status = GdipCombineRegionPath(region2, path, CombineModeReplace);
1497 expect(Ok, status);
1498 status = GdipTransformRegion(region, matrix);
1499 expect(Ok, status);
1500 res = FALSE;
1501 status = GdipIsEqualRegion(region, region2, graphics, &res);
1502 expect(Ok, status);
1503 ok(res, "Expected to be equal.\n");
1505 status = GdipDeleteRegion(region);
1506 expect(Ok, status);
1507 status = GdipDeleteRegion(region2);
1508 expect(Ok, status);
1509 status = GdipDeleteGraphics(graphics);
1510 expect(Ok, status);
1511 status = GdipDeletePath(path);
1512 expect(Ok, status);
1513 status = GdipDeleteMatrix(matrix);
1514 expect(Ok, status);
1515 ReleaseDC(0, hdc);
1518 static void test_scans(void)
1520 GpRegion *region;
1521 GpMatrix *matrix;
1522 GpRectF rectf;
1523 GpStatus status;
1524 ULONG count=80085;
1525 INT icount;
1526 GpRectF scans[2];
1527 GpRect scansi[2];
1529 status = GdipCreateRegion(&region);
1530 expect(Ok, status);
1532 status = GdipCreateMatrix(&matrix);
1533 expect(Ok, status);
1535 /* test NULL values */
1536 status = GdipGetRegionScansCount(NULL, &count, matrix);
1537 expect(InvalidParameter, status);
1539 status = GdipGetRegionScansCount(region, NULL, matrix);
1540 expect(InvalidParameter, status);
1542 status = GdipGetRegionScansCount(region, &count, NULL);
1543 expect(InvalidParameter, status);
1545 status = GdipGetRegionScans(NULL, scans, &icount, matrix);
1546 expect(InvalidParameter, status);
1548 status = GdipGetRegionScans(region, scans, NULL, matrix);
1549 expect(InvalidParameter, status);
1551 status = GdipGetRegionScans(region, scans, &icount, NULL);
1552 expect(InvalidParameter, status);
1554 /* infinite */
1555 status = GdipGetRegionScansCount(region, &count, matrix);
1556 expect(Ok, status);
1557 expect(1, count);
1559 status = GdipGetRegionScans(region, NULL, &icount, matrix);
1560 expect(Ok, status);
1561 expect(1, icount);
1563 status = GdipGetRegionScans(region, scans, &icount, matrix);
1564 expect(Ok, status);
1565 expect(1, icount);
1567 status = GdipGetRegionScansI(region, scansi, &icount, matrix);
1568 expect(Ok, status);
1569 expect(1, icount);
1570 expect(-0x400000, scansi[0].X);
1571 expect(-0x400000, scansi[0].Y);
1572 expect(0x800000, scansi[0].Width);
1573 expect(0x800000, scansi[0].Height);
1575 status = GdipGetRegionScans(region, scans, &icount, matrix);
1576 expect(Ok, status);
1577 expect(1, icount);
1578 expectf((double)-0x400000, scans[0].X);
1579 expectf((double)-0x400000, scans[0].Y);
1580 expectf((double)0x800000, scans[0].Width);
1581 expectf((double)0x800000, scans[0].Height);
1583 /* empty */
1584 status = GdipSetEmpty(region);
1585 expect(Ok, status);
1587 status = GdipGetRegionScansCount(region, &count, matrix);
1588 expect(Ok, status);
1589 expect(0, count);
1591 status = GdipGetRegionScans(region, scans, &icount, matrix);
1592 expect(Ok, status);
1593 expect(0, icount);
1595 /* single rectangle */
1596 rectf.X = rectf.Y = 0.0;
1597 rectf.Width = rectf.Height = 5.0;
1598 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1599 expect(Ok, status);
1601 status = GdipGetRegionScansCount(region, &count, matrix);
1602 expect(Ok, status);
1603 expect(1, count);
1605 status = GdipGetRegionScans(region, scans, &icount, matrix);
1606 expect(Ok, status);
1607 expect(1, icount);
1608 expectf(0.0, scans[0].X);
1609 expectf(0.0, scans[0].Y);
1610 expectf(5.0, scans[0].Width);
1611 expectf(5.0, scans[0].Height);
1613 /* two rectangles */
1614 rectf.X = rectf.Y = 5.0;
1615 rectf.Width = rectf.Height = 5.0;
1616 status = GdipCombineRegionRect(region, &rectf, CombineModeUnion);
1617 expect(Ok, status);
1619 status = GdipGetRegionScansCount(region, &count, matrix);
1620 expect(Ok, status);
1621 expect(2, count);
1623 /* Native ignores the initial value of count */
1624 scans[1].X = scans[1].Y = scans[1].Width = scans[1].Height = 8.0;
1625 icount = 1;
1626 status = GdipGetRegionScans(region, scans, &icount, matrix);
1627 expect(Ok, status);
1628 expect(2, icount);
1629 expectf(0.0, scans[0].X);
1630 expectf(0.0, scans[0].Y);
1631 expectf(5.0, scans[0].Width);
1632 expectf(5.0, scans[0].Height);
1633 expectf(5.0, scans[1].X);
1634 expectf(5.0, scans[1].Y);
1635 expectf(5.0, scans[1].Width);
1636 expectf(5.0, scans[1].Height);
1638 status = GdipGetRegionScansI(region, scansi, &icount, matrix);
1639 expect(Ok, status);
1640 expect(2, icount);
1641 expect(0, scansi[0].X);
1642 expect(0, scansi[0].Y);
1643 expect(5, scansi[0].Width);
1644 expect(5, scansi[0].Height);
1645 expect(5, scansi[1].X);
1646 expect(5, scansi[1].Y);
1647 expect(5, scansi[1].Width);
1648 expect(5, scansi[1].Height);
1650 status = GdipDeleteRegion(region);
1651 expect(Ok, status);
1652 status = GdipDeleteMatrix(matrix);
1653 expect(Ok, status);
1656 static void test_getbounds(void)
1658 GpRegion *region;
1659 GpGraphics *graphics;
1660 GpStatus status;
1661 GpRectF rectf;
1662 HDC hdc = GetDC(0);
1664 status = GdipCreateFromHDC(hdc, &graphics);
1665 ok(status == Ok, "status %08x\n", status);
1666 status = GdipCreateRegion(&region);
1667 ok(status == Ok, "status %08x\n", status);
1669 /* NULL */
1670 status = GdipGetRegionBounds(NULL, NULL, NULL);
1671 ok(status == InvalidParameter, "status %08x\n", status);
1672 status = GdipGetRegionBounds(region, NULL, NULL);
1673 ok(status == InvalidParameter, "status %08x\n", status);
1674 status = GdipGetRegionBounds(region, graphics, NULL);
1675 ok(status == InvalidParameter, "status %08x\n", status);
1676 /* infinite */
1677 rectf.X = rectf.Y = 0.0;
1678 rectf.Height = rectf.Width = 100.0;
1679 status = GdipGetRegionBounds(region, graphics, &rectf);
1680 ok(status == Ok, "status %08x\n", status);
1681 ok(rectf.X == -(REAL)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.X);
1682 ok(rectf.Y == -(REAL)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.Y);
1683 ok(rectf.Width == (REAL)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL)(1 << 23), rectf.Width);
1684 ok(rectf.Height == (REAL)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL)(1 << 23), rectf.Height);
1685 /* empty */
1686 rectf.X = rectf.Y = 0.0;
1687 rectf.Height = rectf.Width = 100.0;
1688 status = GdipSetEmpty(region);
1689 ok(status == Ok, "status %08x\n", status);
1690 status = GdipGetRegionBounds(region, graphics, &rectf);
1691 ok(status == Ok, "status %08x\n", status);
1692 ok(rectf.X == 0.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1693 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1694 ok(rectf.Width == 0.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1695 ok(rectf.Height == 0.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1696 /* rect */
1697 rectf.X = 10.0; rectf.Y = 0.0;
1698 rectf.Width = rectf.Height = 100.0;
1699 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1700 ok(status == Ok, "status %08x\n", status);
1701 rectf.X = rectf.Y = 0.0;
1702 rectf.Height = rectf.Width = 0.0;
1703 status = GdipGetRegionBounds(region, graphics, &rectf);
1704 ok(status == Ok, "status %08x\n", status);
1705 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1706 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1707 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1708 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1710 /* the world and page transforms are ignored */
1711 GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1712 GdipSetPageUnit(graphics, UnitInch);
1713 GdipSetPageScale(graphics, 2.0);
1714 status = GdipGetRegionBounds(region, graphics, &rectf);
1715 ok(status == Ok, "status %08x\n", status);
1716 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1717 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1718 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1720 rectf.X = 10.0; rectf.Y = 0.0;
1721 rectf.Width = rectf.Height = 100.0;
1722 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1723 ok(status == Ok, "status %08x\n", status);
1724 rectf.X = rectf.Y = 0.0;
1725 rectf.Height = rectf.Width = 0.0;
1726 status = GdipGetRegionBounds(region, graphics, &rectf);
1727 ok(status == Ok, "status %08x\n", status);
1728 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1729 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1730 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1731 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1733 status = GdipDeleteRegion(region);
1734 ok(status == Ok, "status %08x\n", status);
1735 status = GdipDeleteGraphics(graphics);
1736 ok(status == Ok, "status %08x\n", status);
1737 ReleaseDC(0, hdc);
1740 static void test_isvisiblepoint(void)
1742 HDC hdc = GetDC(0);
1743 GpGraphics* graphics;
1744 GpRegion* region;
1745 GpPath* path;
1746 GpRectF rectf;
1747 GpStatus status;
1748 BOOL res;
1749 REAL x, y;
1751 status = GdipCreateFromHDC(hdc, &graphics);
1752 expect(Ok, status);
1754 status = GdipCreateRegion(&region);
1755 expect(Ok, status);
1757 /* null parameters */
1758 status = GdipIsVisibleRegionPoint(NULL, 0, 0, graphics, &res);
1759 expect(InvalidParameter, status);
1760 status = GdipIsVisibleRegionPointI(NULL, 0, 0, graphics, &res);
1761 expect(InvalidParameter, status);
1763 status = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &res);
1764 expect(Ok, status);
1765 status = GdipIsVisibleRegionPointI(region, 0, 0, NULL, &res);
1766 expect(Ok, status);
1768 status = GdipIsVisibleRegionPoint(region, 0, 0, graphics, NULL);
1769 expect(InvalidParameter, status);
1770 status = GdipIsVisibleRegionPointI(region, 0, 0, graphics, NULL);
1771 expect(InvalidParameter, status);
1773 /* infinite region */
1774 status = GdipIsInfiniteRegion(region, graphics, &res);
1775 expect(Ok, status);
1776 ok(res == TRUE, "Region should be infinite\n");
1778 x = 10;
1779 y = 10;
1780 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1781 expect(Ok, status);
1782 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1783 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1784 expect(Ok, status);
1785 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1787 x = -10;
1788 y = -10;
1789 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1790 expect(Ok, status);
1791 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1792 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1793 expect(Ok, status);
1794 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1796 /* rectangular region */
1797 rectf.X = 10;
1798 rectf.Y = 20;
1799 rectf.Width = 30;
1800 rectf.Height = 40;
1802 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1803 expect(Ok, status);
1805 x = 0;
1806 y = 0;
1807 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1808 expect(Ok, status);
1809 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1810 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1811 expect(Ok, status);
1812 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1814 x = 9;
1815 y = 19;
1816 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1817 expect(Ok, status);
1818 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1820 x = 9.25;
1821 y = 19.25;
1822 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1823 expect(Ok, status);
1824 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1826 x = 9.5;
1827 y = 19.5;
1828 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1829 expect(Ok, status);
1830 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1832 x = 9.75;
1833 y = 19.75;
1834 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1835 expect(Ok, status);
1836 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1838 x = 10;
1839 y = 20;
1840 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1841 expect(Ok, status);
1842 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1844 x = 25;
1845 y = 40;
1846 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1847 expect(Ok, status);
1848 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1849 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1850 expect(Ok, status);
1851 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1853 x = 40;
1854 y = 60;
1855 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1856 expect(Ok, status);
1857 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1858 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1859 expect(Ok, status);
1860 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1862 /* translate into the center of the rectangle */
1863 status = GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
1864 expect(Ok, status);
1866 /* native ignores the world transform, so treat these as if
1867 * no transform exists */
1868 x = -20;
1869 y = -30;
1870 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1871 expect(Ok, status);
1872 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1873 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1874 expect(Ok, status);
1875 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1877 x = 0;
1878 y = 0;
1879 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1880 expect(Ok, status);
1881 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1882 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1883 expect(Ok, status);
1884 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1886 x = 25;
1887 y = 40;
1888 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1889 expect(Ok, status);
1890 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1891 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1892 expect(Ok, status);
1893 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1895 /* translate back to origin */
1896 status = GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
1897 expect(Ok, status);
1899 /* region from path */
1900 status = GdipCreatePath(FillModeAlternate, &path);
1901 expect(Ok, status);
1903 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
1904 expect(Ok, status);
1906 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1907 expect(Ok, status);
1909 x = 11;
1910 y = 21;
1911 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1912 expect(Ok, status);
1913 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1914 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1915 expect(Ok, status);
1916 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1918 x = 25;
1919 y = 40;
1920 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1921 expect(Ok, status);
1922 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1923 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1924 expect(Ok, status);
1925 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1927 x = 40;
1928 y = 60;
1929 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1930 expect(Ok, status);
1931 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1932 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1933 expect(Ok, status);
1934 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1936 GdipDeletePath(path);
1938 GdipDeleteRegion(region);
1939 GdipDeleteGraphics(graphics);
1940 ReleaseDC(0, hdc);
1943 static void test_isvisiblerect(void)
1945 HDC hdc = GetDC(0);
1946 GpGraphics* graphics;
1947 GpRegion* region;
1948 GpPath* path;
1949 GpRectF rectf;
1950 GpStatus status;
1951 BOOL res;
1952 REAL x, y, w, h;
1954 status = GdipCreateFromHDC(hdc, &graphics);
1955 expect(Ok, status);
1957 status = GdipCreateRegion(&region);
1958 expect(Ok, status);
1960 /* null parameters */
1961 status = GdipIsVisibleRegionRect(NULL, 0, 0, 0, 0, graphics, &res);
1962 expect(InvalidParameter, status);
1963 status = GdipIsVisibleRegionRectI(NULL, 0, 0, 0, 0, graphics, &res);
1964 expect(InvalidParameter, status);
1966 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, NULL, &res);
1967 expect(Ok, status);
1968 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, NULL, &res);
1969 expect(Ok, status);
1971 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, graphics, NULL);
1972 expect(InvalidParameter, status);
1973 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, graphics, NULL);
1974 expect(InvalidParameter, status);
1976 /* infinite region */
1977 status = GdipIsInfiniteRegion(region, graphics, &res);
1978 expect(Ok, status);
1979 ok(res == TRUE, "Region should be infinite\n");
1981 x = 10; w = 10;
1982 y = 10; h = 10;
1983 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1984 expect(Ok, status);
1985 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1987 x = -10; w = 5;
1988 y = -10; h = 5;
1989 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1990 expect(Ok, status);
1991 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1993 /* rectangular region */
1994 rectf.X = 10;
1995 rectf.Y = 20;
1996 rectf.Width = 30;
1997 rectf.Height = 40;
1999 status = GdipCombineRegionRect(region, &rectf, CombineModeIntersect);
2000 expect(Ok, status);
2002 /* entirely within the region */
2003 x = 11; w = 10;
2004 y = 12; h = 10;
2005 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2006 expect(Ok, status);
2007 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2008 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2009 expect(Ok, status);
2010 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2012 /* entirely outside of the region */
2013 x = 0; w = 5;
2014 y = 0; h = 5;
2015 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2016 expect(Ok, status);
2017 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2018 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2019 expect(Ok, status);
2020 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2022 /* corner cases */
2023 x = 0; w = 10;
2024 y = 0; h = 20;
2025 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2026 expect(Ok, status);
2027 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2029 x = 0; w = 10.25;
2030 y = 0; h = 20.25;
2031 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2032 expect(Ok, status);
2033 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2035 x = 39; w = 10;
2036 y = 59; h = 10;
2037 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2038 expect(Ok, status);
2039 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2041 x = 39.25; w = 10;
2042 y = 59.25; h = 10;
2043 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2044 expect(Ok, status);
2045 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2047 /* corners outside, but some intersection */
2048 x = 0; w = 100;
2049 y = 0; h = 100;
2050 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2051 expect(Ok, status);
2052 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2054 x = 0; w = 100;
2055 y = 0; h = 40;
2056 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2057 expect(Ok, status);
2058 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2060 x = 0; w = 25;
2061 y = 0; h = 100;
2062 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2063 expect(Ok, status);
2064 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2066 /* translate into the center of the rectangle */
2067 status = GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2068 expect(Ok, status);
2070 /* native ignores the world transform, so treat these as if
2071 * no transform exists */
2072 x = 0; w = 5;
2073 y = 0; h = 5;
2074 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2075 expect(Ok, status);
2076 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2077 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2078 expect(Ok, status);
2079 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2081 x = 11; w = 10;
2082 y = 12; h = 10;
2083 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2084 expect(Ok, status);
2085 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2086 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2087 expect(Ok, status);
2088 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2090 /* translate back to origin */
2091 status = GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2092 expect(Ok, status);
2094 /* region from path */
2095 status = GdipCreatePath(FillModeAlternate, &path);
2096 expect(Ok, status);
2098 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
2099 expect(Ok, status);
2101 status = GdipCombineRegionPath(region, path, CombineModeReplace);
2102 expect(Ok, status);
2104 x = 0; w = 12;
2105 y = 0; h = 22;
2106 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2107 expect(Ok, status);
2108 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2109 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2110 expect(Ok, status);
2111 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2113 x = 0; w = 25;
2114 y = 0; h = 40;
2115 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2116 expect(Ok, status);
2117 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2118 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2119 expect(Ok, status);
2120 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2122 x = 38; w = 10;
2123 y = 55; h = 10;
2124 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2125 expect(Ok, status);
2126 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2127 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2128 expect(Ok, status);
2129 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2131 x = 0; w = 100;
2132 y = 0; h = 100;
2133 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2134 expect(Ok, status);
2135 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2136 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2137 expect(Ok, status);
2138 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2140 GdipDeletePath(path);
2142 GdipDeleteRegion(region);
2143 GdipDeleteGraphics(graphics);
2144 ReleaseDC(0, hdc);
2147 static void test_excludeinfinite(void)
2149 GpStatus status;
2150 GpRegion *region;
2151 UINT count=0xdeadbeef;
2152 GpRectF scans[4];
2153 GpMatrix *identity;
2154 static const RectF rect_exclude = {0.0, 0.0, 1.0, 1.0};
2156 status = GdipCreateMatrix(&identity);
2157 expect(Ok, status);
2159 status = GdipCreateRegion(&region);
2160 expect(Ok, status);
2162 status = GdipCombineRegionRect(region, &rect_exclude, CombineModeExclude);
2163 expect(Ok, status);
2165 status = GdipGetRegionScansCount(region, &count, identity);
2166 expect(Ok, status);
2167 expect(4, count);
2169 count = 4;
2170 status = GdipGetRegionScans(region, scans, (INT*)&count, identity);
2171 expect(Ok, status);
2173 expectf(-4194304.0, scans[0].X);
2174 expectf(-4194304.0, scans[0].Y);
2175 expectf(8388608.0, scans[0].Width);
2176 expectf(4194304.0, scans[0].Height);
2178 expectf(-4194304.0, scans[1].X);
2179 expectf(0.0, scans[1].Y);
2180 expectf(4194304.0, scans[1].Width);
2181 expectf(1.0, scans[1].Height);
2183 expectf(1.0, scans[2].X);
2184 expectf(0.0, scans[2].Y);
2185 expectf(4194303.0, scans[2].Width);
2186 expectf(1.0, scans[2].Height);
2188 expectf(-4194304.0, scans[3].X);
2189 expectf(1.0, scans[3].Y);
2190 expectf(8388608.0, scans[3].Width);
2191 expectf(4194303.0, scans[3].Height);
2193 GdipDeleteRegion(region);
2194 GdipDeleteMatrix(identity);
2197 static void test_GdipCreateRegionRgnData(void)
2199 GpGraphics *graphics = NULL;
2200 GpRegion *region, *region2;
2201 HDC hdc = GetDC(0);
2202 GpStatus status;
2203 BYTE buf[512];
2204 UINT needed;
2205 BOOL ret;
2207 status = GdipCreateRegionRgnData(NULL, 0, NULL);
2208 ok(status == InvalidParameter, "status %d\n", status);
2210 status = GdipCreateFromHDC(hdc, &graphics);
2211 ok(status == Ok, "status %d\n", status);
2213 status = GdipCreateRegion(&region);
2214 ok(status == Ok, "status %d\n", status);
2216 /* infinite region */
2217 memset(buf, 0xee, sizeof(buf));
2218 needed = 0;
2219 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
2220 ok(status == Ok, "status %d\n", status);
2221 expect(20, needed);
2223 status = GdipCreateRegionRgnData(buf, needed, NULL);
2224 ok(status == InvalidParameter, "status %d\n", status);
2226 status = GdipCreateRegionRgnData(buf, needed, &region2);
2227 ok(status == Ok, "status %d\n", status);
2229 ret = FALSE;
2230 status = GdipIsInfiniteRegion(region2, graphics, &ret);
2231 ok(status == Ok, "status %d\n", status);
2232 ok(ret, "got %d\n", ret);
2233 GdipDeleteRegion(region2);
2235 /* empty region */
2236 status = GdipSetEmpty(region);
2237 ok(status == Ok, "status %d\n", status);
2239 memset(buf, 0xee, sizeof(buf));
2240 needed = 0;
2241 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
2242 ok(status == Ok, "status %d\n", status);
2243 expect(20, needed);
2245 status = GdipCreateRegionRgnData(buf, needed, &region2);
2246 ok(status == Ok, "status %d\n", status);
2248 ret = FALSE;
2249 status = GdipIsEmptyRegion(region2, graphics, &ret);
2250 ok(status == Ok, "status %d\n", status);
2251 ok(ret, "got %d\n", ret);
2252 GdipDeleteRegion(region2);
2254 GdipDeleteGraphics(graphics);
2255 GdipDeleteRegion(region);
2256 ReleaseDC(0, hdc);
2259 START_TEST(region)
2261 struct GdiplusStartupInput gdiplusStartupInput;
2262 ULONG_PTR gdiplusToken;
2264 gdiplusStartupInput.GdiplusVersion = 1;
2265 gdiplusStartupInput.DebugEventCallback = NULL;
2266 gdiplusStartupInput.SuppressBackgroundThread = 0;
2267 gdiplusStartupInput.SuppressExternalCodecs = 0;
2269 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2271 test_getregiondata();
2272 test_isinfinite();
2273 test_isempty();
2274 test_combinereplace();
2275 test_fromhrgn();
2276 test_gethrgn();
2277 test_isequal();
2278 test_translate();
2279 test_transform();
2280 test_scans();
2281 test_getbounds();
2282 test_isvisiblepoint();
2283 test_isvisiblerect();
2284 test_excludeinfinite();
2285 test_GdipCreateRegionRgnData();
2287 GdiplusShutdown(gdiplusToken);