2 * Unit test suite for gdiplus regions
4 * Copyright (C) 2008 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
26 #define RGNDATA_RECT 0x10000000
27 #define RGNDATA_PATH 0x10000001
28 #define RGNDATA_EMPTY_RECT 0x10000002
29 #define RGNDATA_INFINITE_RECT 0x10000003
31 #define RGNDATA_MAGIC 0xdbc01001
32 #define RGNDATA_MAGIC2 0xdbc01002
34 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
36 #define expect_magic(value) ok(*value == RGNDATA_MAGIC || *value == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *value)
38 #define expect_dword(value, expected) ok(*(value) == expected, "expected %08x got %08x\n", expected, *(value))
40 static inline void expect_float(DWORD *value, FLOAT expected)
42 FLOAT valuef = *(FLOAT*)value;
43 ok(valuef == expected, "expected %f got %f\n", expected, valuef);
46 /* We get shorts back, not INTs like a GpPoint */
47 typedef struct RegionDataPoint
52 static void verify_region(HRGN hrgn, const RECT *rc)
57 char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
62 ret = GetRegionData(hrgn, 0, NULL);
64 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
66 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
70 ret = GetRegionData(hrgn, sizeof(rgn), &rgn.data);
72 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
74 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
76 trace("size %u, type %u, count %u, rgn size %u, bound (%d,%d-%d,%d)\n",
77 rgn.data.rdh.dwSize, rgn.data.rdh.iType,
78 rgn.data.rdh.nCount, rgn.data.rdh.nRgnSize,
79 rgn.data.rdh.rcBound.left, rgn.data.rdh.rcBound.top,
80 rgn.data.rdh.rcBound.right, rgn.data.rdh.rcBound.bottom);
81 if (rgn.data.rdh.nCount != 0)
83 rect = (const RECT *)rgn.data.Buffer;
84 trace("rect (%d,%d-%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom);
85 ok(EqualRect(rect, rc), "rects don't match\n");
88 ok(rgn.data.rdh.dwSize == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", rgn.data.rdh.dwSize);
89 ok(rgn.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn.data.rdh.iType);
92 ok(rgn.data.rdh.nCount == 0, "expected 0, got %u\n", rgn.data.rdh.nCount);
93 ok(rgn.data.rdh.nRgnSize == 0, "expected 0, got %u\n", rgn.data.rdh.nRgnSize);
97 ok(rgn.data.rdh.nCount == 1, "expected 1, got %u\n", rgn.data.rdh.nCount);
98 ok(rgn.data.rdh.nRgnSize == sizeof(RECT), "expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
100 ok(EqualRect(&rgn.data.rdh.rcBound, rc), "rects don't match\n");
103 static void test_getregiondata(void)
106 GpRegion *region, *region2;
107 RegionDataPoint *point;
113 memset(buf, 0xee, sizeof(buf));
115 status = GdipCreateRegion(®ion);
116 ok(status == Ok, "status %08x\n", status);
118 status = GdipGetRegionDataSize(region, &needed);
119 ok(status == Ok, "status %08x\n", status);
121 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
122 ok(status == Ok, "status %08x\n", status);
124 expect_dword(buf, 12);
125 trace("buf[1] = %08x\n", buf[1]);
126 expect_magic((DWORD*)(buf + 2));
127 expect_dword(buf + 3, 0);
128 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
130 status = GdipSetEmpty(region);
131 ok(status == Ok, "status %08x\n", status);
132 status = GdipGetRegionDataSize(region, &needed);
133 ok(status == Ok, "status %08x\n", status);
135 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
136 ok(status == Ok, "status %08x\n", status);
138 expect_dword(buf, 12);
139 trace("buf[1] = %08x\n", buf[1]);
140 expect_magic((DWORD*)(buf + 2));
141 expect_dword(buf + 3, 0);
142 expect_dword(buf + 4, RGNDATA_EMPTY_RECT);
144 status = GdipSetInfinite(region);
145 ok(status == Ok, "status %08x\n", status);
146 status = GdipGetRegionDataSize(region, &needed);
147 ok(status == Ok, "status %08x\n", status);
149 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
150 ok(status == Ok, "status %08x\n", status);
152 expect_dword(buf, 12);
153 trace("buf[1] = %08x\n", buf[1]);
154 expect_magic((DWORD*)(buf + 2));
155 expect_dword(buf + 3, 0);
156 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
158 status = GdipDeleteRegion(region);
159 ok(status == Ok, "status %08x\n", status);
165 status = GdipCreateRegionRectI(&rect, ®ion);
166 ok(status == Ok, "status %08x\n", status);
167 status = GdipGetRegionDataSize(region, &needed);
168 ok(status == Ok, "status %08x\n", status);
170 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
171 ok(status == Ok, "status %08x\n", status);
173 expect_dword(buf, 28);
174 trace("buf[1] = %08x\n", buf[1]);
175 expect_magic((DWORD*)(buf + 2));
176 expect_dword(buf + 3, 0);
177 expect_dword(buf + 4, RGNDATA_RECT);
178 expect_float(buf + 5, 10.0);
179 expect_float(buf + 6, 20.0);
180 expect_float(buf + 7, 100.0);
181 expect_float(buf + 8, 200.0);
187 status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
188 ok(status == Ok, "status %08x\n", status);
193 status = GdipCombineRegionRectI(region, &rect, CombineModeXor);
194 ok(status == Ok, "status %08x\n", status);
200 status = GdipCreateRegionRectI(&rect, ®ion2);
201 ok(status == Ok, "status %08x\n", status);
206 status = GdipCombineRegionRectI(region2, &rect, CombineModeUnion);
207 ok(status == Ok, "status %08x\n", status);
209 status = GdipCombineRegionRegion(region, region2, CombineModeComplement);
210 ok(status == Ok, "status %08x\n", status);
216 status = GdipCombineRegionRectI(region, &rect, CombineModeExclude);
217 ok(status == Ok, "status %08x\n", status);
219 status = GdipGetRegionDataSize(region, &needed);
220 ok(status == Ok, "status %08x\n", status);
222 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
223 ok(status == Ok, "status %08x\n", status);
225 expect_dword(buf, 148);
226 trace("buf[1] = %08x\n", buf[1]);
227 expect_magic((DWORD*)(buf + 2));
228 expect_dword(buf + 3, 10);
229 expect_dword(buf + 4, CombineModeExclude);
230 expect_dword(buf + 5, CombineModeComplement);
231 expect_dword(buf + 6, CombineModeXor);
232 expect_dword(buf + 7, CombineModeIntersect);
233 expect_dword(buf + 8, RGNDATA_RECT);
234 expect_float(buf + 9, 10.0);
235 expect_float(buf + 10, 20.0);
236 expect_float(buf + 11, 100.0);
237 expect_float(buf + 12, 200.0);
238 expect_dword(buf + 13, RGNDATA_RECT);
239 expect_float(buf + 14, 50.0);
240 expect_float(buf + 15, 30.0);
241 expect_float(buf + 16, 10.0);
242 expect_float(buf + 17, 20.0);
243 expect_dword(buf + 18, RGNDATA_RECT);
244 expect_float(buf + 19, 100.0);
245 expect_float(buf + 20, 300.0);
246 expect_float(buf + 21, 30.0);
247 expect_float(buf + 22, 50.0);
248 expect_dword(buf + 23, CombineModeUnion);
249 expect_dword(buf + 24, RGNDATA_RECT);
250 expect_float(buf + 25, 200.0);
251 expect_float(buf + 26, 100.0);
252 expect_float(buf + 27, 133.0);
253 expect_float(buf + 28, 266.0);
254 expect_dword(buf + 29, RGNDATA_RECT);
255 expect_float(buf + 30, 20.0);
256 expect_float(buf + 31, 10.0);
257 expect_float(buf + 32, 40.0);
258 expect_float(buf + 33, 66.0);
259 expect_dword(buf + 34, RGNDATA_RECT);
260 expect_float(buf + 35, 400.0);
261 expect_float(buf + 36, 500.0);
262 expect_float(buf + 37, 22.0);
263 expect_float(buf + 38, 55.0);
265 status = GdipDeleteRegion(region2);
266 ok(status == Ok, "status %08x\n", status);
267 status = GdipDeleteRegion(region);
268 ok(status == Ok, "status %08x\n", status);
272 status = GdipCreatePath(FillModeAlternate, &path);
273 ok(status == Ok, "status %08x\n", status);
274 GdipAddPathRectangle(path, 12.5, 13.0, 14.0, 15.0);
276 status = GdipCreateRegionPath(path, ®ion);
277 ok(status == Ok, "status %08x\n", status);
278 status = GdipGetRegionDataSize(region, &needed);
279 ok(status == Ok, "status %08x\n", status);
281 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
282 ok(status == Ok, "status %08x\n", status);
284 expect_dword(buf, 64);
285 trace("buf[1] = %08x\n", buf[1]);
286 expect_magic((DWORD*)(buf + 2));
287 expect_dword(buf + 3, 0);
288 expect_dword(buf + 4, RGNDATA_PATH);
289 expect_dword(buf + 5, 0x00000030);
290 expect_magic((DWORD*)(buf + 6));
291 expect_dword(buf + 7, 0x00000004);
292 expect_dword(buf + 8, 0x00000000);
293 expect_float(buf + 9, 12.5);
294 expect_float(buf + 10, 13.0);
295 expect_float(buf + 11, 26.5);
296 expect_float(buf + 12, 13.0);
297 expect_float(buf + 13, 26.5);
298 expect_float(buf + 14, 28.0);
299 expect_float(buf + 15, 12.5);
300 expect_float(buf + 16, 28.0);
301 expect_dword(buf + 17, 0x81010100);
308 status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
309 ok(status == Ok, "status %08x\n", status);
310 status = GdipGetRegionDataSize(region, &needed);
311 ok(status == Ok, "status %08x\n", status);
313 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
314 ok(status == Ok, "status %08x\n", status);
316 expect_dword(buf, 88);
317 trace("buf[1] = %08x\n", buf[1]);
318 expect_magic((DWORD*)(buf + 2));
319 expect_dword(buf + 3, 2);
320 expect_dword(buf + 4, CombineModeIntersect);
321 expect_dword(buf + 5, RGNDATA_PATH);
322 expect_dword(buf + 6, 0x00000030);
323 expect_magic((DWORD*)(buf + 7));
324 expect_dword(buf + 8, 0x00000004);
325 expect_dword(buf + 9, 0x00000000);
326 expect_float(buf + 10, 12.5);
327 expect_float(buf + 11, 13.0);
328 expect_float(buf + 12, 26.5);
329 expect_float(buf + 13, 13.0);
330 expect_float(buf + 14, 26.5);
331 expect_float(buf + 15, 28.0);
332 expect_float(buf + 16, 12.5);
333 expect_float(buf + 17, 28.0);
334 expect_dword(buf + 18, 0x81010100);
335 expect_dword(buf + 19, RGNDATA_RECT);
336 expect_float(buf + 20, 50.0);
337 expect_float(buf + 21, 30.0);
338 expect_float(buf + 22, 10.0);
339 expect_float(buf + 23, 20.0);
341 status = GdipDeleteRegion(region);
342 ok(status == Ok, "status %08x\n", status);
343 status = GdipDeletePath(path);
344 ok(status == Ok, "status %08x\n", status);
346 /* Test an empty path */
347 status = GdipCreatePath(FillModeAlternate, &path);
349 status = GdipCreateRegionPath(path, ®ion);
351 status = GdipGetRegionDataSize(region, &needed);
354 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
357 expect_dword(buf, 28);
358 trace("buf[1] = %08x\n", buf[1]);
359 expect_magic((DWORD*)(buf + 2));
360 expect_dword(buf + 3, 0);
361 expect_dword(buf + 4, RGNDATA_PATH);
363 /* Second signature for pathdata */
364 expect_dword(buf + 5, 12);
365 expect_magic((DWORD*)(buf + 6));
366 expect_dword(buf + 7, 0);
367 /* flags 0x4000 means its a path of shorts instead of FLOAT */
368 ok((*(buf + 8) & (~ 0x00004000)) == 0x00000000,
369 "expected 00000000 got %08x\n", *(buf + 8) & (~ 0x00004000));
371 status = GdipDeleteRegion(region);
374 /* Test a simple triangle of INTs */
375 status = GdipAddPathLine(path, 5, 6, 7, 8);
377 status = GdipAddPathLine(path, 8, 1, 5, 6);
379 status = GdipClosePathFigure(path);
381 status = GdipCreateRegionPath(path, ®ion);
383 status = GdipGetRegionDataSize(region, &needed);
386 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
389 expect_dword(buf, 48);
390 trace("buf[1] = %08x\n", buf[1]);
391 expect_magic((DWORD*)(buf + 2));
392 expect_dword(buf + 3 , 0);
393 expect_dword(buf + 4 , RGNDATA_PATH);
395 expect_dword(buf + 5, 32);
396 expect_magic((DWORD*)(buf + 6));
397 expect_dword(buf + 7, 4);
398 expect_dword(buf + 8, 0x00004000); /* ?? */
400 point = (RegionDataPoint*)buf + 9;
401 expect(5, point[0].X);
402 expect(6, point[0].Y);
403 expect(7, point[1].X); /* buf + 10 */
404 expect(8, point[1].Y);
405 expect(8, point[2].X); /* buf + 11 */
406 expect(1, point[2].Y);
407 expect(5, point[3].X); /* buf + 12 */
408 expect(6, point[3].Y);
409 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
411 status = GdipDeletePath(path);
413 status = GdipDeleteRegion(region);
416 /* Test a floating-point triangle */
417 status = GdipCreatePath(FillModeAlternate, &path);
419 status = GdipAddPathLine(path, 5.6, 6.2, 7.2, 8.9);
421 status = GdipAddPathLine(path, 8.1, 1.6, 5.6, 6.2);
423 status = GdipCreateRegionPath(path, ®ion);
425 status = GdipGetRegionDataSize(region, &needed);
428 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
431 expect_dword(buf, 64);
432 trace("buf[1] = %08x\n", buf[1]);
433 expect_magic((DWORD*)(buf + 2));
434 expect_dword(buf + 3, 0);
435 expect_dword(buf + 4, RGNDATA_PATH);
437 expect_dword(buf + 5, 48);
438 expect_magic((DWORD*)(buf + 6));
439 expect_dword(buf + 7, 4);
440 expect_dword(buf + 8, 0);
441 expect_float(buf + 9, 5.6);
442 expect_float(buf + 10, 6.2);
443 expect_float(buf + 11, 7.2);
444 expect_float(buf + 12, 8.9);
445 expect_float(buf + 13, 8.1);
446 expect_float(buf + 14, 1.6);
447 expect_float(buf + 15, 5.6);
448 expect_float(buf + 16, 6.2);
450 status = GdipDeletePath(path);
452 status = GdipDeleteRegion(region);
455 /* Test for a path with > 4 points, and CombineRegionPath */
456 GdipCreatePath(FillModeAlternate, &path);
457 status = GdipAddPathLine(path, 50, 70.2, 60, 102.8);
459 status = GdipAddPathLine(path, 55.4, 122.4, 40.4, 60.2);
461 status = GdipAddPathLine(path, 45.6, 20.2, 50, 70.2);
467 status = GdipCreateRegionRectI(&rect, ®ion);
469 status = GdipCombineRegionPath(region, path, CombineModeUnion);
472 status = GdipGetRegionDataSize(region, &needed);
475 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
478 expect_dword(buf, 108);
479 trace("buf[1] = %08x\n", buf[1]);
480 expect_magic((DWORD*)(buf + 2));
481 expect_dword(buf + 3, 2);
482 expect_dword(buf + 4, CombineModeUnion);
483 expect_dword(buf + 5, RGNDATA_RECT);
484 expect_float(buf + 6, 20);
485 expect_float(buf + 7, 25);
486 expect_float(buf + 8, 60);
487 expect_float(buf + 9, 120);
488 expect_dword(buf + 10, RGNDATA_PATH);
490 expect_dword(buf + 11, 68);
491 expect_magic((DWORD*)(buf + 12));
492 expect_dword(buf + 13, 6);
493 expect_float(buf + 14, 0x0);
495 expect_float(buf + 15, 50);
496 expect_float(buf + 16, 70.2);
497 expect_float(buf + 17, 60);
498 expect_float(buf + 18, 102.8);
499 expect_float(buf + 19, 55.4);
500 expect_float(buf + 20, 122.4);
501 expect_float(buf + 21, 40.4);
502 expect_float(buf + 22, 60.2);
503 expect_float(buf + 23, 45.6);
504 expect_float(buf + 24, 20.2);
505 expect_float(buf + 25, 50);
506 expect_float(buf + 26, 70.2);
507 expect_dword(buf + 27, 0x01010100);
508 ok(*(buf + 28) == 0x00000101 || *(buf + 28) == 0x43050101 /* Win 7 */,
509 "expected 00000101 or 43050101 got %08x\n", *(buf + 28));
511 status = GdipDeletePath(path);
513 status = GdipDeleteRegion(region);
517 static void test_isinfinite(void)
521 GpGraphics *graphics = NULL;
526 status = GdipCreateFromHDC(hdc, &graphics);
528 GdipCreateRegion(®ion);
530 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m);
533 status = GdipIsInfiniteRegion(NULL, NULL, NULL);
534 expect(InvalidParameter, status);
535 status = GdipIsInfiniteRegion(region, NULL, NULL);
536 expect(InvalidParameter, status);
537 status = GdipIsInfiniteRegion(NULL, graphics, NULL);
538 expect(InvalidParameter, status);
539 status = GdipIsInfiniteRegion(NULL, NULL, &res);
540 expect(InvalidParameter, status);
541 status = GdipIsInfiniteRegion(region, NULL, &res);
542 expect(InvalidParameter, status);
545 status = GdipIsInfiniteRegion(region, graphics, &res);
549 /* after world transform */
550 status = GdipSetWorldTransform(graphics, m);
554 status = GdipIsInfiniteRegion(region, graphics, &res);
559 GdipDeleteRegion(region);
560 GdipDeleteGraphics(graphics);
564 static void test_isempty(void)
568 GpGraphics *graphics = NULL;
572 status = GdipCreateFromHDC(hdc, &graphics);
574 GdipCreateRegion(®ion);
577 status = GdipIsEmptyRegion(NULL, NULL, NULL);
578 expect(InvalidParameter, status);
579 status = GdipIsEmptyRegion(region, NULL, NULL);
580 expect(InvalidParameter, status);
581 status = GdipIsEmptyRegion(NULL, graphics, NULL);
582 expect(InvalidParameter, status);
583 status = GdipIsEmptyRegion(NULL, NULL, &res);
584 expect(InvalidParameter, status);
585 status = GdipIsEmptyRegion(region, NULL, &res);
586 expect(InvalidParameter, status);
588 /* default is infinite */
590 status = GdipIsEmptyRegion(region, graphics, &res);
594 status = GdipSetEmpty(region);
598 status = GdipIsEmptyRegion(region, graphics, &res);
602 GdipDeleteRegion(region);
603 GdipDeleteGraphics(graphics);
607 static void test_combinereplace(void)
610 GpRegion *region, *region2;
616 rectf.X = rectf.Y = 0.0;
617 rectf.Width = rectf.Height = 100.0;
619 status = GdipCreateRegionRect(&rectf, ®ion);
622 /* replace with the same rectangle */
623 status = GdipCombineRegionRect(region, &rectf,CombineModeReplace);
626 status = GdipGetRegionDataSize(region, &needed);
629 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
632 expect_dword(buf, 28);
633 trace("buf[1] = %08x\n", buf[1]);
634 expect_magic((DWORD*)(buf + 2));
635 expect_dword(buf + 3, 0);
636 expect_dword(buf + 4, RGNDATA_RECT);
638 /* replace with path */
639 status = GdipCreatePath(FillModeAlternate, &path);
641 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
643 status = GdipCombineRegionPath(region, path, CombineModeReplace);
646 status = GdipGetRegionDataSize(region, &needed);
649 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
652 expect_dword(buf, 148);
653 trace("buf[1] = %08x\n", buf[1]);
654 expect_magic((DWORD*)(buf + 2));
655 expect_dword(buf + 3, 0);
656 expect_dword(buf + 4, RGNDATA_PATH);
657 GdipDeletePath(path);
659 /* replace with infinite rect */
660 status = GdipCreateRegion(®ion2);
662 status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
665 status = GdipGetRegionDataSize(region, &needed);
668 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
671 expect_dword(buf, 12);
672 trace("buf[1] = %08x\n", buf[1]);
673 expect_magic((DWORD*)(buf + 2));
674 expect_dword(buf + 3, 0);
675 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
676 GdipDeleteRegion(region2);
678 /* more complex case : replace with a combined region */
679 status = GdipCreateRegionRect(&rectf, ®ion2);
681 status = GdipCreatePath(FillModeAlternate, &path);
683 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
685 status = GdipCombineRegionPath(region2, path, CombineModeUnion);
687 GdipDeletePath(path);
688 status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
690 GdipDeleteRegion(region2);
692 status = GdipGetRegionDataSize(region, &needed);
695 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
698 expect_dword(buf, 172);
699 trace("buf[1] = %08x\n", buf[1]);
700 expect_magic((DWORD*)(buf + 2));
701 expect_dword(buf + 3, 2);
702 expect_dword(buf + 4, CombineModeUnion);
704 GdipDeleteRegion(region);
707 static void test_fromhrgn(void)
710 GpRegion *region = (GpRegion*)0xabcdef01;
714 RegionDataPoint *point;
715 GpGraphics *graphics = NULL;
720 status = GdipCreateRegionHrgn(NULL, NULL);
721 expect(InvalidParameter, status);
722 status = GdipCreateRegionHrgn(NULL, ®ion);
723 expect(InvalidParameter, status);
724 status = GdipCreateRegionHrgn((HRGN)0xdeadbeef, ®ion);
725 expect(InvalidParameter, status);
726 ok(region == (GpRegion*)0xabcdef01, "Expected region not to be created\n");
728 /* empty rectangle */
729 hrgn = CreateRectRgn(0, 0, 0, 0);
730 status = GdipCreateRegionHrgn(hrgn, ®ion);
735 status = GdipCreateFromHDC(hdc, &graphics);
738 status = GdipIsEmptyRegion(region, graphics, &res);
741 GdipDeleteGraphics(graphics);
743 GdipDeleteRegion(region);
749 hrgn = CreateRectRgn(0, 0, 100, 10);
750 status = GdipCreateRegionHrgn(hrgn, ®ion);
753 status = GdipGetRegionDataSize(region, &needed);
757 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
763 expect_dword(buf, 48);
764 expect_magic((DWORD*)(buf + 2));
765 expect_dword(buf + 3, 0);
766 expect_dword(buf + 4, RGNDATA_PATH);
767 expect_dword(buf + 5, 0x00000020);
768 expect_magic((DWORD*)(buf + 6));
769 expect_dword(buf + 7, 0x00000004);
770 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
772 point = (RegionDataPoint*)buf + 9;
774 expect(0, point[0].X);
775 expect(0, point[0].Y);
777 expect(100,point[1].X); /* buf + 10 */
778 expect(0, point[1].Y);
779 expect(100,point[2].X); /* buf + 11 */
780 expect(10, point[2].Y);
782 expect(0, point[3].X); /* buf + 12 */
784 expect(10, point[3].Y);
785 expect_dword(buf + 13, 0x81010100); /* closed */
789 GdipDeleteRegion(region);
793 hrgn = CreateEllipticRgn(0, 0, 100, 10);
794 status = GdipCreateRegionHrgn(hrgn, ®ion);
797 status = GdipGetRegionDataSize(region, &needed);
800 needed == 196, /* win98 */
801 "Got %.8x\n", needed);
803 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
806 if(status == Ok && needed == 216) /* Don't try to test win98 layout */
810 expect_dword(buf, 208);
811 expect_magic((DWORD*)(buf + 2));
812 expect_dword(buf + 3, 0);
813 expect_dword(buf + 4, RGNDATA_PATH);
814 expect_dword(buf + 5, 0x000000C0);
815 expect_magic((DWORD*)(buf + 6));
816 expect_dword(buf + 7, 0x00000024);
817 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
820 GdipDeleteRegion(region);
824 static void test_gethrgn(void)
827 GpRegion *region, *region2;
829 GpGraphics *graphics;
832 static const RECT empty_rect = {0,0,0,0};
833 static const RECT test_rect = {10, 11, 20, 21};
834 static const GpRectF test_rectF = {10.0, 11.0, 10.0, 10.0};
835 static const RECT scaled_rect = {20, 22, 40, 42};
836 static const RECT test_rect2 = {10, 21, 20, 31};
837 static const GpRectF test_rect2F = {10.0, 21.0, 10.0, 10.0};
838 static const RECT test_rect3 = {10, 11, 20, 31};
839 static const GpRectF test_rect3F = {10.0, 11.0, 10.0, 20.0};
841 status = GdipCreateFromHDC(hdc, &graphics);
842 ok(status == Ok, "status %08x\n", status);
844 status = GdipCreateRegion(®ion);
845 ok(status == Ok, "status %08x\n", status);
847 status = GdipGetRegionHRgn(NULL, graphics, &hrgn);
848 ok(status == InvalidParameter, "status %08x\n", status);
849 status = GdipGetRegionHRgn(region, graphics, NULL);
850 ok(status == InvalidParameter, "status %08x\n", status);
852 status = GdipGetRegionHRgn(region, NULL, &hrgn);
853 ok(status == Ok, "status %08x\n", status);
854 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
857 status = GdipGetRegionHRgn(region, graphics, &hrgn);
858 ok(status == Ok, "status %08x\n", status);
859 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
862 status = GdipSetEmpty(region);
863 ok(status == Ok, "status %08x\n", status);
864 status = GdipGetRegionHRgn(region, NULL, &hrgn);
865 ok(status == Ok, "status %08x\n", status);
866 verify_region(hrgn, &empty_rect);
869 status = GdipCreatePath(FillModeAlternate, &path);
870 ok(status == Ok, "status %08x\n", status);
871 status = GdipAddPathRectangle(path, 10.0, 11.0, 10.0, 10.0);
872 ok(status == Ok, "status %08x\n", status);
874 status = GdipCreateRegionPath(path, ®ion2);
875 ok(status == Ok, "status %08x\n", status);
876 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
877 ok(status == Ok, "status %08x\n", status);
878 verify_region(hrgn, &test_rect);
881 /* resulting HRGN is in device coordinates */
882 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
883 ok(status == Ok, "status %08x\n", status);
884 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
885 ok(status == Ok, "status %08x\n", status);
886 verify_region(hrgn, &scaled_rect);
889 status = GdipCombineRegionRect(region2, &test_rectF, CombineModeReplace);
890 ok(status == Ok, "status %08x\n", status);
891 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
892 ok(status == Ok, "status %08x\n", status);
893 verify_region(hrgn, &test_rect);
896 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
897 ok(status == Ok, "status %08x\n", status);
898 verify_region(hrgn, &scaled_rect);
901 status = GdipSetInfinite(region);
902 ok(status == Ok, "status %08x\n", status);
903 status = GdipCombineRegionRect(region, &test_rectF, CombineModeIntersect);
904 ok(status == Ok, "status %08x\n", status);
905 status = GdipGetRegionHRgn(region, NULL, &hrgn);
906 ok(status == Ok, "status %08x\n", status);
907 verify_region(hrgn, &test_rect);
910 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
911 ok(status == Ok, "status %08x\n", status);
912 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeUnion);
913 ok(status == Ok, "status %08x\n", status);
914 status = GdipGetRegionHRgn(region, NULL, &hrgn);
915 ok(status == Ok, "status %08x\n", status);
916 verify_region(hrgn, &test_rect3);
919 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
920 ok(status == Ok, "status %08x\n", status);
921 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeXor);
922 ok(status == Ok, "status %08x\n", status);
923 status = GdipGetRegionHRgn(region, NULL, &hrgn);
924 ok(status == Ok, "status %08x\n", status);
925 verify_region(hrgn, &test_rect);
928 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
929 ok(status == Ok, "status %08x\n", status);
930 status = GdipCombineRegionRect(region, &test_rectF, CombineModeExclude);
931 ok(status == Ok, "status %08x\n", status);
932 status = GdipGetRegionHRgn(region, NULL, &hrgn);
933 ok(status == Ok, "status %08x\n", status);
934 verify_region(hrgn, &test_rect2);
937 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
938 ok(status == Ok, "status %08x\n", status);
939 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeComplement);
940 ok(status == Ok, "status %08x\n", status);
941 status = GdipGetRegionHRgn(region, NULL, &hrgn);
942 ok(status == Ok, "status %08x\n", status);
943 verify_region(hrgn, &test_rect2);
946 status = GdipDeletePath(path);
947 ok(status == Ok, "status %08x\n", status);
948 status = GdipDeleteRegion(region);
949 ok(status == Ok, "status %08x\n", status);
950 status = GdipDeleteRegion(region2);
951 ok(status == Ok, "status %08x\n", status);
952 status = GdipDeleteGraphics(graphics);
953 ok(status == Ok, "status %08x\n", status);
957 static void test_isequal(void)
959 GpRegion *region1, *region2;
960 GpGraphics *graphics;
966 status = GdipCreateFromHDC(hdc, &graphics);
967 ok(status == Ok, "status %08x\n", status);
969 status = GdipCreateRegion(®ion1);
970 ok(status == Ok, "status %08x\n", status);
971 status = GdipCreateRegion(®ion2);
972 ok(status == Ok, "status %08x\n", status);
975 status = GdipIsEqualRegion(NULL, NULL, NULL, NULL);
976 ok(status == InvalidParameter, "status %08x\n", status);
977 status = GdipIsEqualRegion(region1, region2, NULL, NULL);
978 ok(status == InvalidParameter, "status %08x\n", status);
979 status = GdipIsEqualRegion(region1, region2, graphics, NULL);
980 ok(status == InvalidParameter, "status %08x\n", status);
981 status = GdipIsEqualRegion(region1, region2, NULL, &res);
982 ok(status == InvalidParameter, "status %08x\n", status);
984 /* infinite regions */
986 status = GdipIsEqualRegion(region1, region2, graphics, &res);
987 ok(status == Ok, "status %08x\n", status);
988 ok(res, "Expected to be equal.\n");
990 status = GdipSetEmpty(region1);
991 ok(status == Ok, "status %08x\n", status);
992 status = GdipSetEmpty(region2);
993 ok(status == Ok, "status %08x\n", status);
995 status = GdipIsEqualRegion(region1, region2, graphics, &res);
996 ok(status == Ok, "status %08x\n", status);
997 ok(res, "Expected to be equal.\n");
998 /* empty & infinite */
999 status = GdipSetInfinite(region1);
1000 ok(status == Ok, "status %08x\n", status);
1002 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1003 ok(status == Ok, "status %08x\n", status);
1004 ok(!res, "Expected to be unequal.\n");
1005 /* rect & (inf/empty) */
1006 rectf.X = rectf.Y = 0.0;
1007 rectf.Width = rectf.Height = 100.0;
1008 status = GdipCombineRegionRect(region1, &rectf, CombineModeReplace);
1009 ok(status == Ok, "status %08x\n", status);
1011 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1012 ok(status == Ok, "status %08x\n", status);
1013 ok(!res, "Expected to be unequal.\n");
1014 status = GdipSetInfinite(region2);
1015 ok(status == Ok, "status %08x\n", status);
1017 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1018 ok(status == Ok, "status %08x\n", status);
1019 ok(!res, "Expected to be unequal.\n");
1020 /* roughly equal rectangles */
1021 rectf.X = rectf.Y = 0.0;
1022 rectf.Width = rectf.Height = 100.001;
1023 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1024 ok(status == Ok, "status %08x\n", status);
1026 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1027 ok(status == Ok, "status %08x\n", status);
1028 ok(res, "Expected to be equal.\n");
1029 /* equal rectangles */
1030 rectf.X = rectf.Y = 0.0;
1031 rectf.Width = rectf.Height = 100.0;
1032 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1033 ok(status == Ok, "status %08x\n", status);
1035 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1036 ok(status == Ok, "status %08x\n", status);
1037 ok(res, "Expected to be equal.\n");
1040 status = GdipDeleteRegion(region1);
1041 ok(status == Ok, "status %08x\n", status);
1042 status = GdipDeleteRegion(region2);
1043 ok(status == Ok, "status %08x\n", status);
1044 status = GdipDeleteGraphics(graphics);
1045 ok(status == Ok, "status %08x\n", status);
1049 static void test_translate(void)
1051 GpRegion *region, *region2;
1052 GpGraphics *graphics;
1059 status = GdipCreateFromHDC(hdc, &graphics);
1060 ok(status == Ok, "status %08x\n", status);
1062 status = GdipCreatePath(FillModeAlternate, &path);
1063 ok(status == Ok, "status %08x\n", status);
1065 status = GdipCreateRegion(®ion);
1066 ok(status == Ok, "status %08x\n", status);
1067 status = GdipCreateRegion(®ion2);
1068 ok(status == Ok, "status %08x\n", status);
1071 status = GdipTranslateRegion(NULL, 0.0, 0.0);
1072 ok(status == InvalidParameter, "status %08x\n", status);
1075 status = GdipTranslateRegion(region, 10.0, 10.0);
1076 ok(status == Ok, "status %08x\n", status);
1078 status = GdipSetEmpty(region);
1079 ok(status == Ok, "status %08x\n", status);
1080 status = GdipTranslateRegion(region, 10.0, 10.0);
1081 ok(status == Ok, "status %08x\n", status);
1083 rectf.X = 10.0; rectf.Y = 0.0;
1084 rectf.Width = rectf.Height = 100.0;
1085 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1086 ok(status == Ok, "status %08x\n", status);
1087 rectf.X = 15.0; rectf.Y = -2.0;
1088 rectf.Width = rectf.Height = 100.0;
1089 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1090 ok(status == Ok, "status %08x\n", status);
1091 status = GdipTranslateRegion(region, 5.0, -2.0);
1092 ok(status == Ok, "status %08x\n", status);
1094 status = GdipIsEqualRegion(region, region2, graphics, &res);
1095 ok(status == Ok, "status %08x\n", status);
1096 ok(res, "Expected to be equal.\n");
1098 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1099 ok(status == Ok, "status %08x\n", status);
1100 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1101 ok(status == Ok, "status %08x\n", status);
1102 status = GdipResetPath(path);
1103 ok(status == Ok, "status %08x\n", status);
1104 status = GdipAddPathEllipse(path, 10.0, 21.0, 100.0, 150.0);
1105 ok(status == Ok, "status %08x\n", status);
1106 status = GdipCombineRegionPath(region2, path, CombineModeReplace);
1107 ok(status == Ok, "status %08x\n", status);
1108 status = GdipTranslateRegion(region, 10.0, 11.0);
1109 ok(status == Ok, "status %08x\n", status);
1111 status = GdipIsEqualRegion(region, region2, graphics, &res);
1112 ok(status == Ok, "status %08x\n", status);
1113 ok(res, "Expected to be equal.\n");
1115 status = GdipDeleteRegion(region);
1116 ok(status == Ok, "status %08x\n", status);
1117 status = GdipDeleteRegion(region2);
1118 ok(status == Ok, "status %08x\n", status);
1119 status = GdipDeleteGraphics(graphics);
1120 ok(status == Ok, "status %08x\n", status);
1121 status = GdipDeletePath(path);
1122 ok(status == Ok, "status %08x\n", status);
1126 static void test_transform(void)
1128 GpRegion *region, *region2;
1130 GpGraphics *graphics;
1137 status = GdipCreateFromHDC(hdc, &graphics);
1140 status = GdipCreatePath(FillModeAlternate, &path);
1143 status = GdipCreateRegion(®ion);
1145 status = GdipCreateRegion(®ion2);
1148 status = GdipCreateMatrix(&matrix);
1150 status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
1154 status = GdipTransformRegion(NULL, matrix);
1155 expect(InvalidParameter, status);
1157 status = GdipTransformRegion(region, NULL);
1158 expect(InvalidParameter, status);
1161 status = GdipTransformRegion(region, matrix);
1165 status = GdipIsEqualRegion(region, region2, graphics, &res);
1167 ok(res, "Expected to be equal.\n");
1170 status = GdipSetEmpty(region);
1172 status = GdipTransformRegion(region, matrix);
1175 status = GdipSetEmpty(region2);
1179 status = GdipIsEqualRegion(region, region2, graphics, &res);
1181 ok(res, "Expected to be equal.\n");
1186 rectf.Width = rectf.Height = 100.0;
1187 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1191 rectf.Width = 200.0;
1192 rectf.Height = 300.0;
1193 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1195 status = GdipTransformRegion(region, matrix);
1198 status = GdipIsEqualRegion(region, region2, graphics, &res);
1200 ok(res, "Expected to be equal.\n");
1203 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1205 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1207 status = GdipResetPath(path);
1209 status = GdipAddPathEllipse(path, 0.0, 30.0, 200.0, 450.0);
1211 status = GdipCombineRegionPath(region2, path, CombineModeReplace);
1213 status = GdipTransformRegion(region, matrix);
1216 status = GdipIsEqualRegion(region, region2, graphics, &res);
1218 ok(res, "Expected to be equal.\n");
1220 status = GdipDeleteRegion(region);
1222 status = GdipDeleteRegion(region2);
1224 status = GdipDeleteGraphics(graphics);
1226 status = GdipDeletePath(path);
1228 status = GdipDeleteMatrix(matrix);
1233 static void test_getbounds(void)
1236 GpGraphics *graphics;
1241 status = GdipCreateFromHDC(hdc, &graphics);
1242 ok(status == Ok, "status %08x\n", status);
1243 status = GdipCreateRegion(®ion);
1244 ok(status == Ok, "status %08x\n", status);
1247 status = GdipGetRegionBounds(NULL, NULL, NULL);
1248 ok(status == InvalidParameter, "status %08x\n", status);
1249 status = GdipGetRegionBounds(region, NULL, NULL);
1250 ok(status == InvalidParameter, "status %08x\n", status);
1251 status = GdipGetRegionBounds(region, graphics, NULL);
1252 ok(status == InvalidParameter, "status %08x\n", status);
1254 rectf.X = rectf.Y = 0.0;
1255 rectf.Height = rectf.Width = 100.0;
1256 status = GdipGetRegionBounds(region, graphics, &rectf);
1257 ok(status == Ok, "status %08x\n", status);
1258 ok(rectf.X == -(REAL)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.X);
1259 ok(rectf.Y == -(REAL)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.Y);
1260 ok(rectf.Width == (REAL)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL)(1 << 23), rectf.Width);
1261 ok(rectf.Height == (REAL)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL)(1 << 23), rectf.Height);
1263 rectf.X = rectf.Y = 0.0;
1264 rectf.Height = rectf.Width = 100.0;
1265 status = GdipSetEmpty(region);
1266 ok(status == Ok, "status %08x\n", status);
1267 status = GdipGetRegionBounds(region, graphics, &rectf);
1268 ok(status == Ok, "status %08x\n", status);
1269 ok(rectf.X == 0.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1270 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1271 ok(rectf.Width == 0.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1272 ok(rectf.Height == 0.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1274 rectf.X = 10.0; rectf.Y = 0.0;
1275 rectf.Width = rectf.Height = 100.0;
1276 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1277 ok(status == Ok, "status %08x\n", status);
1278 rectf.X = rectf.Y = 0.0;
1279 rectf.Height = rectf.Width = 0.0;
1280 status = GdipGetRegionBounds(region, graphics, &rectf);
1281 ok(status == Ok, "status %08x\n", status);
1282 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1283 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1284 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1285 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1287 /* the world and page transforms are ignored */
1288 GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1289 GdipSetPageUnit(graphics, UnitInch);
1290 GdipSetPageScale(graphics, 2.0);
1291 status = GdipGetRegionBounds(region, graphics, &rectf);
1292 ok(status == Ok, "status %08x\n", status);
1293 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1294 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1295 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1297 rectf.X = 10.0; rectf.Y = 0.0;
1298 rectf.Width = rectf.Height = 100.0;
1299 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1300 ok(status == Ok, "status %08x\n", status);
1301 rectf.X = rectf.Y = 0.0;
1302 rectf.Height = rectf.Width = 0.0;
1303 status = GdipGetRegionBounds(region, graphics, &rectf);
1304 ok(status == Ok, "status %08x\n", status);
1305 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1306 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1307 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1308 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1310 status = GdipDeleteRegion(region);
1311 ok(status == Ok, "status %08x\n", status);
1312 status = GdipDeleteGraphics(graphics);
1313 ok(status == Ok, "status %08x\n", status);
1317 static void test_isvisiblepoint(void)
1320 GpGraphics* graphics;
1328 status = GdipCreateFromHDC(hdc, &graphics);
1331 status = GdipCreateRegion(®ion);
1334 /* null parameters */
1335 status = GdipIsVisibleRegionPoint(NULL, 0, 0, graphics, &res);
1336 expect(InvalidParameter, status);
1337 status = GdipIsVisibleRegionPointI(NULL, 0, 0, graphics, &res);
1338 expect(InvalidParameter, status);
1340 status = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &res);
1342 status = GdipIsVisibleRegionPointI(region, 0, 0, NULL, &res);
1345 status = GdipIsVisibleRegionPoint(region, 0, 0, graphics, NULL);
1346 expect(InvalidParameter, status);
1347 status = GdipIsVisibleRegionPointI(region, 0, 0, graphics, NULL);
1348 expect(InvalidParameter, status);
1350 /* infinite region */
1351 status = GdipIsInfiniteRegion(region, graphics, &res);
1353 ok(res == TRUE, "Region should be infinite\n");
1357 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1359 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1360 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1362 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1366 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1368 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1369 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1371 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1373 /* rectangular region */
1379 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1384 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1386 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1387 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1389 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1393 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1395 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1399 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1401 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1405 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1407 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1411 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1413 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1417 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1419 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1423 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1425 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1426 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1428 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1432 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1434 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1435 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1437 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1439 /* translate into the center of the rectangle */
1440 status = GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
1443 /* native ignores the world transform, so treat these as if
1444 * no transform exists */
1447 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1449 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1450 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1452 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1456 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1458 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1459 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1461 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1465 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1467 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1468 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1470 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1472 /* translate back to origin */
1473 status = GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
1476 /* region from path */
1477 status = GdipCreatePath(FillModeAlternate, &path);
1480 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
1483 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1488 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1490 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1491 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1493 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1497 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1499 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1500 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1502 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1506 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1508 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1509 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1511 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1513 GdipDeletePath(path);
1515 GdipDeleteRegion(region);
1516 GdipDeleteGraphics(graphics);
1520 static void test_isvisiblerect(void)
1523 GpGraphics* graphics;
1531 status = GdipCreateFromHDC(hdc, &graphics);
1534 status = GdipCreateRegion(®ion);
1537 /* null parameters */
1538 status = GdipIsVisibleRegionRect(NULL, 0, 0, 0, 0, graphics, &res);
1539 expect(InvalidParameter, status);
1540 status = GdipIsVisibleRegionRectI(NULL, 0, 0, 0, 0, graphics, &res);
1541 expect(InvalidParameter, status);
1543 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, NULL, &res);
1545 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, NULL, &res);
1548 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, graphics, NULL);
1549 expect(InvalidParameter, status);
1550 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, graphics, NULL);
1551 expect(InvalidParameter, status);
1553 /* infinite region */
1554 status = GdipIsInfiniteRegion(region, graphics, &res);
1556 ok(res == TRUE, "Region should be infinite\n");
1560 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1562 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1566 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1568 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1570 /* rectangular region */
1576 status = GdipCombineRegionRect(region, &rectf, CombineModeIntersect);
1579 /* entirely within the region */
1582 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1584 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1585 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1587 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1589 /* entirely outside of the region */
1592 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1594 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
1595 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1597 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1602 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1604 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
1608 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1610 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1614 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1616 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1620 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1622 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
1624 /* corners outside, but some intersection */
1627 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1629 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1633 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1635 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1639 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1641 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1643 /* translate into the center of the rectangle */
1644 status = GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
1647 /* native ignores the world transform, so treat these as if
1648 * no transform exists */
1651 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1653 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
1654 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1656 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1660 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1662 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1663 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1665 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1667 /* translate back to origin */
1668 status = GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
1671 /* region from path */
1672 status = GdipCreatePath(FillModeAlternate, &path);
1675 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
1678 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1683 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1685 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
1686 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1688 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1692 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1694 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1695 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1697 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1701 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1703 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
1704 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1706 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1710 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1712 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1713 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
1715 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
1717 GdipDeletePath(path);
1719 GdipDeleteRegion(region);
1720 GdipDeleteGraphics(graphics);
1726 struct GdiplusStartupInput gdiplusStartupInput;
1727 ULONG_PTR gdiplusToken;
1729 gdiplusStartupInput.GdiplusVersion = 1;
1730 gdiplusStartupInput.DebugEventCallback = NULL;
1731 gdiplusStartupInput.SuppressBackgroundThread = 0;
1732 gdiplusStartupInput.SuppressExternalCodecs = 0;
1734 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1736 test_getregiondata();
1739 test_combinereplace();
1746 test_isvisiblepoint();
1747 test_isvisiblerect();
1749 GdiplusShutdown(gdiplusToken);