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
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
50 static void verify_region(HRGN hrgn
, const RECT
*rc
)
55 char buf
[sizeof(RGNDATAHEADER
) + sizeof(RECT
)];
60 ret
= GetRegionData(hrgn
, 0, NULL
);
62 ok(ret
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", ret
);
64 ok(ret
== sizeof(rgn
.data
.rdh
) + sizeof(RECT
), "expected sizeof(rgn), got %u\n", ret
);
68 ret
= GetRegionData(hrgn
, sizeof(rgn
), &rgn
.data
);
70 ok(ret
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", ret
);
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
);
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
);
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
)
109 status
= GdipCreateRegionRgnData((BYTE
*)data
, size
, ®ion
);
110 /* Windows always fails to create an empty path in a region */
111 if (data
[4] == RGNDATA_PATH
)
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
);
127 ok_(__FILE__
, line
)(status
== Ok
, "GdipCreateRegionRgnData error %d\n", status
);
128 if (status
!= Ok
) return;
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
));
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)
155 GpRegion
*region
, *region2
;
156 RegionDataPoint
*point
;
163 status
= GdipCreateRegion(®ion
);
164 ok(status
== Ok
, "status %08x\n", status
);
167 status
= GdipGetRegionDataSize(region
, &needed
);
168 ok(status
== Ok
, "status %08x\n", status
);
172 status
= GdipGetRegionData(region
, (BYTE
*)buf
, 0, &needed
);
173 ok(status
== InvalidParameter
, "status %08x\n", status
);
175 memset(buf
, 0xee, sizeof(buf
));
177 status
= GdipGetRegionData(region
, (BYTE
*)buf
, 4, &needed
);
178 ok(status
== InsufficientBuffer
, "status %08x\n", status
);
180 expect_dword(buf
, 0xeeeeeeee);
182 memset(buf
, 0xee, sizeof(buf
));
184 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
185 ok(status
== Ok
, "status %08x\n", status
);
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
);
200 memset(buf
, 0xee, sizeof(buf
));
202 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
203 ok(status
== Ok
, "status %08x\n", status
);
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
);
218 memset(buf
, 0xee, sizeof(buf
));
220 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
221 ok(status
== Ok
, "status %08x\n", status
);
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
);
238 status
= GdipCreateRegionRectI(&rect
, ®ion
);
239 ok(status
== Ok
, "status %08x\n", status
);
240 status
= GdipGetRegionDataSize(region
, &needed
);
241 ok(status
== Ok
, "status %08x\n", status
);
243 memset(buf
, 0xee, sizeof(buf
));
245 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
246 ok(status
== Ok
, "status %08x\n", status
);
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__
);
264 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeIntersect
);
265 ok(status
== Ok
, "status %08x\n", status
);
270 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeXor
);
271 ok(status
== Ok
, "status %08x\n", status
);
277 status
= GdipCreateRegionRectI(&rect
, ®ion2
);
278 ok(status
== Ok
, "status %08x\n", status
);
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
);
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
);
299 memset(buf
, 0xee, sizeof(buf
));
301 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
302 ok(status
== Ok
, "status %08x\n", status
);
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
);
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
, ®ion
);
358 ok(status
== Ok
, "status %08x\n", status
);
359 status
= GdipGetRegionDataSize(region
, &needed
);
360 ok(status
== Ok
, "status %08x\n", status
);
362 memset(buf
, 0xee, sizeof(buf
));
364 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
365 ok(status
== Ok
, "status %08x\n", status
);
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__
);
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
);
397 memset(buf
, 0xee, sizeof(buf
));
399 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
400 ok(status
== Ok
, "status %08x\n", status
);
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
);
437 status
= GdipCreateRegionPath(path
, ®ion
);
439 status
= GdipGetRegionDataSize(region
, &needed
);
442 memset(buf
, 0xee, sizeof(buf
));
444 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
);
465 status
= GdipTransformRegion(region
, matrix
);
467 GdipDeleteMatrix(matrix
);
469 status
= GdipDeleteRegion(region
);
472 /* Test a simple triangle of INTs */
473 status
= GdipAddPathLine(path
, 5, 6, 7, 8);
475 status
= GdipAddPathLine(path
, 8, 1, 5, 6);
477 status
= GdipClosePathFigure(path
);
479 status
= GdipCreateRegionPath(path
, ®ion
);
481 status
= GdipGetRegionDataSize(region
, &needed
);
484 memset(buf
, 0xee, sizeof(buf
));
486 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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);
515 memset(buf
, 0xee, sizeof(buf
));
517 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
);
543 status
= GdipDeleteRegion(region
);
546 /* Test a floating-point triangle */
547 status
= GdipCreatePath(FillModeAlternate
, &path
);
549 status
= GdipAddPathLine(path
, 5.6, 6.2, 7.2, 8.9);
551 status
= GdipAddPathLine(path
, 8.1, 1.6, 5.6, 6.2);
553 status
= GdipCreateRegionPath(path
, ®ion
);
555 status
= GdipGetRegionDataSize(region
, &needed
);
558 memset(buf
, 0xee, sizeof(buf
));
560 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
);
586 status
= GdipDeleteRegion(region
);
589 /* Test for a path with > 4 points, and CombineRegionPath */
590 GdipCreatePath(FillModeAlternate
, &path
);
591 status
= GdipAddPathLine(path
, 50, 70.2, 60, 102.8);
593 status
= GdipAddPathLine(path
, 55.4, 122.4, 40.4, 60.2);
595 status
= GdipAddPathLine(path
, 45.6, 20.2, 50, 70.2);
601 status
= GdipCreateRegionRectI(&rect
, ®ion
);
603 status
= GdipCombineRegionPath(region
, path
, CombineModeUnion
);
606 status
= GdipGetRegionDataSize(region
, &needed
);
609 memset(buf
, 0xee, sizeof(buf
));
611 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
);
649 status
= GdipDeleteRegion(region
);
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
, ®ion
);
658 ok(status
== Ok
, "status %08x\n", status
);
660 status
= GdipGetRegionDataSize(region
, &needed
);
661 ok(status
== Ok
, "status %08x\n", status
);
663 memset(buf
, 0xee, sizeof(buf
));
665 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
666 ok(status
== Ok
, "status %08x\n", status
);
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
);
693 status
= GdipDeleteRegion(region
);
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
, ®ion
);
702 ok(status
== Ok
, "status %08x\n", status
);
704 status
= GdipGetRegionDataSize(region
, &needed
);
705 ok(status
== Ok
, "status %08x\n", status
);
707 memset(buf
, 0xee, sizeof(buf
));
709 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
710 ok(status
== Ok
, "status %08x\n", status
);
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
);
736 status
= GdipDeleteRegion(region
);
740 GdipCreatePath(FillModeAlternate
, &path
);
741 /* Exactly 90 degrees */
742 status
= GdipAddPathArc(path
, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
744 /* Over 90 degrees */
745 status
= GdipAddPathArc(path
, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
747 status
= GdipCreateRegionPath(path
, ®ion
);
748 ok(status
== Ok
, "status %08x\n", status
);
750 status
= GdipGetRegionDataSize(region
, &needed
);
751 ok(status
== Ok
, "status %08x\n", status
);
753 memset(buf
, 0xee, sizeof(buf
));
755 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
756 ok(status
== Ok
, "status %08x\n", status
);
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
);
800 status
= GdipDeleteRegion(region
);
804 static void test_isinfinite(void)
808 GpGraphics
*graphics
= NULL
;
813 status
= GdipCreateFromHDC(hdc
, &graphics
);
815 GdipCreateRegion(®ion
);
817 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m
);
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
);
832 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
836 /* after world transform */
837 status
= GdipSetWorldTransform(graphics
, m
);
841 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
846 GdipDeleteRegion(region
);
847 GdipDeleteGraphics(graphics
);
851 static void test_isempty(void)
855 GpGraphics
*graphics
= NULL
;
859 status
= GdipCreateFromHDC(hdc
, &graphics
);
861 GdipCreateRegion(®ion
);
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 */
877 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
881 status
= GdipSetEmpty(region
);
885 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
889 GdipDeleteRegion(region
);
890 GdipDeleteGraphics(graphics
);
894 static void test_combinereplace(void)
897 GpRegion
*region
, *region2
;
903 rectf
.X
= rectf
.Y
= 0.0;
904 rectf
.Width
= rectf
.Height
= 100.0;
906 status
= GdipCreateRegionRect(&rectf
, ®ion
);
909 /* replace with the same rectangle */
910 status
= GdipCombineRegionRect(region
, &rectf
,CombineModeReplace
);
913 status
= GdipGetRegionDataSize(region
, &needed
);
916 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
);
928 status
= GdipAddPathEllipse(path
, 0.0, 0.0, 100.0, 250.0);
930 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
933 status
= GdipGetRegionDataSize(region
, &needed
);
936 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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(®ion2
);
949 status
= GdipCombineRegionRegion(region
, region2
, CombineModeReplace
);
952 status
= GdipGetRegionDataSize(region
, &needed
);
955 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
, ®ion2
);
968 status
= GdipCreatePath(FillModeAlternate
, &path
);
970 status
= GdipAddPathEllipse(path
, 0.0, 0.0, 100.0, 250.0);
972 status
= GdipCombineRegionPath(region2
, path
, CombineModeUnion
);
974 GdipDeletePath(path
);
975 status
= GdipCombineRegionRegion(region
, region2
, CombineModeReplace
);
977 GdipDeleteRegion(region2
);
979 status
= GdipGetRegionDataSize(region
, &needed
);
982 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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)
997 GpRegion
*region
= (GpRegion
*)0xabcdef01;
1001 RegionDataPoint
*point
;
1002 GpGraphics
*graphics
= NULL
;
1007 status
= GdipCreateRegionHrgn(NULL
, NULL
);
1008 expect(InvalidParameter
, status
);
1009 status
= GdipCreateRegionHrgn(NULL
, ®ion
);
1010 expect(InvalidParameter
, status
);
1011 status
= GdipCreateRegionHrgn((HRGN
)0xdeadbeef, ®ion
);
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
, ®ion
);
1022 status
= GdipCreateFromHDC(hdc
, &graphics
);
1025 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
1028 GdipDeleteGraphics(graphics
);
1030 GdipDeleteRegion(region
);
1036 hrgn
= CreateRectRgn(0, 0, 100, 10);
1037 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
1040 status
= GdipGetRegionDataSize(region
, &needed
);
1044 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &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
);
1080 hrgn
= CreateEllipticRgn(0, 0, 100, 10);
1081 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
1084 status
= GdipGetRegionDataSize(region
, &needed
);
1087 needed
== 196, /* win98 */
1088 "Got %.8x\n", needed
);
1090 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
1093 if(status
== Ok
&& needed
== 216) /* Don't try to test win98 layout */
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
);
1111 static void test_gethrgn(void)
1114 GpRegion
*region
, *region2
;
1116 GpGraphics
*graphics
;
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(®ion
);
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
);
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
, ®ion2
);
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
);
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
);
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
);
1181 status
= GdipGetRegionHRgn(region2
, graphics
, &hrgn
);
1182 ok(status
== Ok
, "status %08x\n", status
);
1183 verify_region(hrgn
, &scaled_rect
);
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
);
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
);
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
);
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
);
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
);
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
);
1242 static void test_isequal(void)
1244 GpRegion
*region1
, *region2
;
1245 GpGraphics
*graphics
;
1251 status
= GdipCreateFromHDC(hdc
, &graphics
);
1252 ok(status
== Ok
, "status %08x\n", status
);
1254 status
= GdipCreateRegion(®ion1
);
1255 ok(status
== Ok
, "status %08x\n", status
);
1256 status
= GdipCreateRegion(®ion2
);
1257 ok(status
== Ok
, "status %08x\n", status
);
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 */
1271 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1272 ok(status
== Ok
, "status %08x\n", status
);
1273 ok(res
, "Expected to be equal.\n");
1275 status
= GdipSetEmpty(region1
);
1276 ok(status
== Ok
, "status %08x\n", status
);
1277 status
= GdipSetEmpty(region2
);
1278 ok(status
== Ok
, "status %08x\n", status
);
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
);
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
);
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
);
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
);
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
);
1320 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1321 ok(status
== Ok
, "status %08x\n", status
);
1322 ok(res
, "Expected to be equal.\n");
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
);
1334 static void test_translate(void)
1336 GpRegion
*region
, *region2
;
1337 GpGraphics
*graphics
;
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(®ion
);
1351 ok(status
== Ok
, "status %08x\n", status
);
1352 status
= GdipCreateRegion(®ion2
);
1353 ok(status
== Ok
, "status %08x\n", status
);
1356 status
= GdipTranslateRegion(NULL
, 0.0, 0.0);
1357 ok(status
== InvalidParameter
, "status %08x\n", status
);
1360 status
= GdipTranslateRegion(region
, 10.0, 10.0);
1361 ok(status
== Ok
, "status %08x\n", status
);
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
);
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
);
1379 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1380 ok(status
== Ok
, "status %08x\n", status
);
1381 ok(res
, "Expected to be equal.\n");
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
);
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
);
1411 static void test_transform(void)
1413 GpRegion
*region
, *region2
;
1415 GpGraphics
*graphics
;
1422 status
= GdipCreateFromHDC(hdc
, &graphics
);
1425 status
= GdipCreatePath(FillModeAlternate
, &path
);
1428 status
= GdipCreateRegion(®ion
);
1430 status
= GdipCreateRegion(®ion2
);
1433 status
= GdipCreateMatrix(&matrix
);
1435 status
= GdipScaleMatrix(matrix
, 2.0, 3.0, MatrixOrderAppend
);
1439 status
= GdipTransformRegion(NULL
, matrix
);
1440 expect(InvalidParameter
, status
);
1442 status
= GdipTransformRegion(region
, NULL
);
1443 expect(InvalidParameter
, status
);
1446 status
= GdipTransformRegion(region
, matrix
);
1450 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1452 ok(res
, "Expected to be equal.\n");
1455 status
= GdipSetEmpty(region
);
1457 status
= GdipTransformRegion(region
, matrix
);
1460 status
= GdipSetEmpty(region2
);
1464 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1466 ok(res
, "Expected to be equal.\n");
1471 rectf
.Width
= rectf
.Height
= 100.0;
1472 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1476 rectf
.Width
= 200.0;
1477 rectf
.Height
= 300.0;
1478 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1480 status
= GdipTransformRegion(region
, matrix
);
1483 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1485 ok(res
, "Expected to be equal.\n");
1488 status
= GdipAddPathEllipse(path
, 0.0, 10.0, 100.0, 150.0);
1490 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1492 status
= GdipResetPath(path
);
1494 status
= GdipAddPathEllipse(path
, 0.0, 30.0, 200.0, 450.0);
1496 status
= GdipCombineRegionPath(region2
, path
, CombineModeReplace
);
1498 status
= GdipTransformRegion(region
, matrix
);
1501 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1503 ok(res
, "Expected to be equal.\n");
1505 status
= GdipDeleteRegion(region
);
1507 status
= GdipDeleteRegion(region2
);
1509 status
= GdipDeleteGraphics(graphics
);
1511 status
= GdipDeletePath(path
);
1513 status
= GdipDeleteMatrix(matrix
);
1518 static void test_scans(void)
1529 status
= GdipCreateRegion(®ion
);
1532 status
= GdipCreateMatrix(&matrix
);
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
);
1555 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1559 status
= GdipGetRegionScans(region
, NULL
, &icount
, matrix
);
1563 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1567 status
= GdipGetRegionScansI(region
, scansi
, &icount
, matrix
);
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
);
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
);
1584 status
= GdipSetEmpty(region
);
1587 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1591 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1595 /* single rectangle */
1596 rectf
.X
= rectf
.Y
= 0.0;
1597 rectf
.Width
= rectf
.Height
= 5.0;
1598 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1601 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1605 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
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
);
1619 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1623 /* Native ignores the initial value of count */
1624 scans
[1].X
= scans
[1].Y
= scans
[1].Width
= scans
[1].Height
= 8.0;
1626 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
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
);
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
);
1652 status
= GdipDeleteMatrix(matrix
);
1656 static void test_getbounds(void)
1659 GpGraphics
*graphics
;
1664 status
= GdipCreateFromHDC(hdc
, &graphics
);
1665 ok(status
== Ok
, "status %08x\n", status
);
1666 status
= GdipCreateRegion(®ion
);
1667 ok(status
== Ok
, "status %08x\n", status
);
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
);
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
);
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
);
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
);
1740 static void test_isvisiblepoint(void)
1743 GpGraphics
* graphics
;
1751 status
= GdipCreateFromHDC(hdc
, &graphics
);
1754 status
= GdipCreateRegion(®ion
);
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
);
1765 status
= GdipIsVisibleRegionPointI(region
, 0, 0, NULL
, &res
);
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
);
1776 ok(res
== TRUE
, "Region should be infinite\n");
1780 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1782 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1783 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1785 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1789 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1791 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1792 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1794 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1796 /* rectangular region */
1802 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1807 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1809 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1810 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1812 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1816 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1818 ok(res
== FALSE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1822 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1824 ok(res
== FALSE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1828 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1830 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1834 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1836 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1840 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1842 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1846 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1848 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1849 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1851 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1855 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1857 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1858 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
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
);
1866 /* native ignores the world transform, so treat these as if
1867 * no transform exists */
1870 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1872 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1873 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1875 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1879 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1881 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1882 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1884 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1888 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1890 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1891 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
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
);
1899 /* region from path */
1900 status
= GdipCreatePath(FillModeAlternate
, &path
);
1903 status
= GdipAddPathEllipse(path
, 10, 20, 30, 40);
1906 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1911 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1913 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1914 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1916 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1920 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1922 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1923 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1925 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1929 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1931 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1932 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
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
);
1943 static void test_isvisiblerect(void)
1946 GpGraphics
* graphics
;
1954 status
= GdipCreateFromHDC(hdc
, &graphics
);
1957 status
= GdipCreateRegion(®ion
);
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
);
1968 status
= GdipIsVisibleRegionRectI(region
, 0, 0, 0, 0, NULL
, &res
);
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
);
1979 ok(res
== TRUE
, "Region should be infinite\n");
1983 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1985 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1989 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1991 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1993 /* rectangular region */
1999 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeIntersect
);
2002 /* entirely within the region */
2005 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
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 */
2015 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
2020 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2025 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2027 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2031 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2033 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2037 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2039 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2043 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2045 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2047 /* corners outside, but some intersection */
2050 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2052 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2056 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2058 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2062 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
2070 /* native ignores the world transform, so treat these as if
2071 * no transform exists */
2074 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
2079 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2083 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
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
);
2094 /* region from path */
2095 status
= GdipCreatePath(FillModeAlternate
, &path
);
2098 status
= GdipAddPathEllipse(path
, 10, 20, 30, 40);
2101 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
2106 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
2111 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2115 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
2120 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2124 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
2129 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2133 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
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
);
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
);
2147 static void test_excludeinfinite(void)
2151 UINT count
=0xdeadbeef;
2154 static const RectF rect_exclude
= {0.0, 0.0, 1.0, 1.0};
2156 status
= GdipCreateMatrix(&identity
);
2159 status
= GdipCreateRegion(®ion
);
2162 status
= GdipCombineRegionRect(region
, &rect_exclude
, CombineModeExclude
);
2165 status
= GdipGetRegionScansCount(region
, &count
, identity
);
2170 status
= GdipGetRegionScans(region
, scans
, (INT
*)&count
, identity
);
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
;
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(®ion
);
2214 ok(status
== Ok
, "status %d\n", status
);
2216 /* infinite region */
2217 memset(buf
, 0xee, sizeof(buf
));
2219 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
2220 ok(status
== Ok
, "status %d\n", status
);
2223 status
= GdipCreateRegionRgnData(buf
, needed
, NULL
);
2224 ok(status
== InvalidParameter
, "status %d\n", status
);
2226 status
= GdipCreateRegionRgnData(buf
, needed
, ®ion2
);
2227 ok(status
== Ok
, "status %d\n", status
);
2230 status
= GdipIsInfiniteRegion(region2
, graphics
, &ret
);
2231 ok(status
== Ok
, "status %d\n", status
);
2232 ok(ret
, "got %d\n", ret
);
2233 GdipDeleteRegion(region2
);
2236 status
= GdipSetEmpty(region
);
2237 ok(status
== Ok
, "status %d\n", status
);
2239 memset(buf
, 0xee, sizeof(buf
));
2241 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
2242 ok(status
== Ok
, "status %d\n", status
);
2245 status
= GdipCreateRegionRgnData(buf
, needed
, ®ion2
);
2246 ok(status
== Ok
, "status %d\n", status
);
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
);
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();
2274 test_combinereplace();
2282 test_isvisiblepoint();
2283 test_isvisiblerect();
2284 test_excludeinfinite();
2285 test_GdipCreateRegionRgnData();
2287 GdiplusShutdown(gdiplusToken
);