2 * Unit test suite for gdiplus regions
4 * Copyright (C) 2008 Huw Davies
5 * Copyright (C) 2013 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
26 //#include "windows.h"
27 #include <wine/test.h>
33 #define RGNDATA_RECT 0x10000000
34 #define RGNDATA_PATH 0x10000001
35 #define RGNDATA_EMPTY_RECT 0x10000002
36 #define RGNDATA_INFINITE_RECT 0x10000003
38 #define RGNDATA_MAGIC 0xdbc01001
39 #define RGNDATA_MAGIC2 0xdbc01002
41 #define expect(expected, got) ok((got) == (expected), "Expected %.8x, got %.8x\n", (expected), (got))
42 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))
43 #define expectf(expected, got) expectf_((expected), (got), 0.001)
45 #define expect_magic(value) ok(*(value) == RGNDATA_MAGIC || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *(value))
46 #define expect_dword(value, expected) expect((expected), *(value))
47 #define expect_float(value, expected) expectf((expected), *(FLOAT *)(value))
49 /* We get shorts back, not INTs like a GpPoint */
50 typedef struct RegionDataPoint
55 static void verify_region(HRGN hrgn
, const RECT
*rc
)
60 char buf
[sizeof(RGNDATAHEADER
) + sizeof(RECT
)];
65 ret
= GetRegionData(hrgn
, 0, NULL
);
67 ok(ret
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", ret
);
69 ok(ret
== sizeof(rgn
.data
.rdh
) + sizeof(RECT
), "expected sizeof(rgn), got %u\n", ret
);
73 ret
= GetRegionData(hrgn
, sizeof(rgn
), &rgn
.data
);
75 ok(ret
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", ret
);
77 ok(ret
== sizeof(rgn
.data
.rdh
) + sizeof(RECT
), "expected sizeof(rgn), got %u\n", ret
);
79 trace("size %u, type %u, count %u, rgn size %u, bound (%d,%d-%d,%d)\n",
80 rgn
.data
.rdh
.dwSize
, rgn
.data
.rdh
.iType
,
81 rgn
.data
.rdh
.nCount
, rgn
.data
.rdh
.nRgnSize
,
82 rgn
.data
.rdh
.rcBound
.left
, rgn
.data
.rdh
.rcBound
.top
,
83 rgn
.data
.rdh
.rcBound
.right
, rgn
.data
.rdh
.rcBound
.bottom
);
84 if (rgn
.data
.rdh
.nCount
!= 0)
86 rect
= (const RECT
*)rgn
.data
.Buffer
;
87 trace("rect (%d,%d-%d,%d)\n", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
88 ok(EqualRect(rect
, rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
89 rc
->left
, rc
->top
, rc
->right
, rc
->bottom
,
90 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
93 ok(rgn
.data
.rdh
.dwSize
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", rgn
.data
.rdh
.dwSize
);
94 ok(rgn
.data
.rdh
.iType
== RDH_RECTANGLES
, "expected RDH_RECTANGLES, got %u\n", rgn
.data
.rdh
.iType
);
97 ok(rgn
.data
.rdh
.nCount
== 0, "expected 0, got %u\n", rgn
.data
.rdh
.nCount
);
98 ok(rgn
.data
.rdh
.nRgnSize
== 0, "expected 0, got %u\n", rgn
.data
.rdh
.nRgnSize
);
102 ok(rgn
.data
.rdh
.nCount
== 1, "expected 1, got %u\n", rgn
.data
.rdh
.nCount
);
103 ok(rgn
.data
.rdh
.nRgnSize
== sizeof(RECT
), "expected sizeof(RECT), got %u\n", rgn
.data
.rdh
.nRgnSize
);
105 ok(EqualRect(&rgn
.data
.rdh
.rcBound
, rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
106 rc
->left
, rc
->top
, rc
->right
, rc
->bottom
,
107 rgn
.data
.rdh
.rcBound
.left
, rgn
.data
.rdh
.rcBound
.top
, rgn
.data
.rdh
.rcBound
.right
, rgn
.data
.rdh
.rcBound
.bottom
);
110 static void test_region_data(DWORD
*data
, UINT size
, INT line
)
117 status
= GdipCreateRegionRgnData((BYTE
*)data
, size
, ®ion
);
118 /* Windows always fails to create an empty path in a region */
119 if (data
[4] == RGNDATA_PATH
)
127 } *path_header
= (struct _path_header
*)(data
+ 5);
128 if (!path_header
->count
)
130 ok_(__FILE__
, line
)(status
== GenericError
, "expected GenericError, got %d\n", status
);
135 ok_(__FILE__
, line
)(status
== Ok
, "GdipCreateRegionRgnData error %d\n", status
);
136 if (status
!= Ok
) return;
139 status
= GdipGetRegionDataSize(region
, &needed
);
140 ok_(__FILE__
, line
)(status
== Ok
, "status %d\n", status
);
141 ok_(__FILE__
, line
)(needed
== size
, "data size mismatch: %u != %u\n", needed
, size
);
143 memset(buf
, 0xee, sizeof(buf
));
145 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
146 ok_(__FILE__
, line
)(status
== Ok
, "status %08x\n", status
);
147 ok_(__FILE__
, line
)(needed
== size
, "data size mismatch: %u != %u\n", needed
, size
);
149 size
/= sizeof(DWORD
);
150 for (i
= 0; i
< size
- 1; i
++)
152 if (i
== 1) continue; /* data[1] never matches */
153 ok_(__FILE__
, line
)(data
[i
] == buf
[i
], "off %u: %#x != %#x\n", i
, data
[i
], buf
[i
]);
155 /* some Windows versions fail to properly clear the aligned DWORD */
156 ok_(__FILE__
, line
)(data
[size
- 1] == buf
[size
- 1] || broken(data
[size
- 1] != buf
[size
- 1]),
157 "off %u: %#x != %#x\n", size
- 1, data
[size
- 1], buf
[size
- 1]);
160 static void test_getregiondata(void)
163 GpRegion
*region
, *region2
;
164 RegionDataPoint
*point
;
171 status
= GdipCreateRegion(®ion
);
172 ok(status
== Ok
, "status %08x\n", status
);
175 status
= GdipGetRegionDataSize(region
, &needed
);
176 ok(status
== Ok
, "status %08x\n", status
);
180 status
= GdipGetRegionData(region
, (BYTE
*)buf
, 0, &needed
);
181 ok(status
== InvalidParameter
, "status %08x\n", status
);
183 memset(buf
, 0xee, sizeof(buf
));
185 status
= GdipGetRegionData(region
, (BYTE
*)buf
, 4, &needed
);
186 ok(status
== InsufficientBuffer
, "status %08x\n", status
);
188 expect_dword(buf
, 0xeeeeeeee);
190 memset(buf
, 0xee, sizeof(buf
));
192 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
193 ok(status
== Ok
, "status %08x\n", status
);
195 expect_dword(buf
, 12);
196 trace("buf[1] = %08x\n", buf
[1]);
197 expect_magic(buf
+ 2);
198 expect_dword(buf
+ 3, 0);
199 expect_dword(buf
+ 4, RGNDATA_INFINITE_RECT
);
200 expect_dword(buf
+ 6, 0xeeeeeeee);
201 test_region_data(buf
, needed
, __LINE__
);
203 status
= GdipSetEmpty(region
);
204 ok(status
== Ok
, "status %08x\n", status
);
205 status
= GdipGetRegionDataSize(region
, &needed
);
206 ok(status
== Ok
, "status %08x\n", status
);
208 memset(buf
, 0xee, sizeof(buf
));
210 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
211 ok(status
== Ok
, "status %08x\n", status
);
213 expect_dword(buf
, 12);
214 trace("buf[1] = %08x\n", buf
[1]);
215 expect_magic(buf
+ 2);
216 expect_dword(buf
+ 3, 0);
217 expect_dword(buf
+ 4, RGNDATA_EMPTY_RECT
);
218 expect_dword(buf
+ 6, 0xeeeeeeee);
219 test_region_data(buf
, needed
, __LINE__
);
221 status
= GdipSetInfinite(region
);
222 ok(status
== Ok
, "status %08x\n", status
);
223 status
= GdipGetRegionDataSize(region
, &needed
);
224 ok(status
== Ok
, "status %08x\n", status
);
226 memset(buf
, 0xee, sizeof(buf
));
228 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
229 ok(status
== Ok
, "status %08x\n", status
);
231 expect_dword(buf
, 12);
232 trace("buf[1] = %08x\n", buf
[1]);
233 expect_magic(buf
+ 2);
234 expect_dword(buf
+ 3, 0);
235 expect_dword(buf
+ 4, RGNDATA_INFINITE_RECT
);
236 expect_dword(buf
+ 6, 0xeeeeeeee);
237 test_region_data(buf
, needed
, __LINE__
);
239 status
= GdipDeleteRegion(region
);
240 ok(status
== Ok
, "status %08x\n", status
);
246 status
= GdipCreateRegionRectI(&rect
, ®ion
);
247 ok(status
== Ok
, "status %08x\n", status
);
248 status
= GdipGetRegionDataSize(region
, &needed
);
249 ok(status
== Ok
, "status %08x\n", status
);
251 memset(buf
, 0xee, sizeof(buf
));
253 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
254 ok(status
== Ok
, "status %08x\n", status
);
256 expect_dword(buf
, 28);
257 trace("buf[1] = %08x\n", buf
[1]);
258 expect_magic(buf
+ 2);
259 expect_dword(buf
+ 3, 0);
260 expect_dword(buf
+ 4, RGNDATA_RECT
);
261 expect_float(buf
+ 5, 10.0);
262 expect_float(buf
+ 6, 20.0);
263 expect_float(buf
+ 7, 100.0);
264 expect_float(buf
+ 8, 200.0);
265 expect_dword(buf
+ 10, 0xeeeeeeee);
266 test_region_data(buf
, needed
, __LINE__
);
272 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeIntersect
);
273 ok(status
== Ok
, "status %08x\n", status
);
278 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeXor
);
279 ok(status
== Ok
, "status %08x\n", status
);
285 status
= GdipCreateRegionRectI(&rect
, ®ion2
);
286 ok(status
== Ok
, "status %08x\n", status
);
291 status
= GdipCombineRegionRectI(region2
, &rect
, CombineModeUnion
);
292 ok(status
== Ok
, "status %08x\n", status
);
294 status
= GdipCombineRegionRegion(region
, region2
, CombineModeComplement
);
295 ok(status
== Ok
, "status %08x\n", status
);
301 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeExclude
);
302 ok(status
== Ok
, "status %08x\n", status
);
304 status
= GdipGetRegionDataSize(region
, &needed
);
305 ok(status
== Ok
, "status %08x\n", status
);
307 memset(buf
, 0xee, sizeof(buf
));
309 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
310 ok(status
== Ok
, "status %08x\n", status
);
312 expect_dword(buf
, 148);
313 trace("buf[1] = %08x\n", buf
[1]);
314 expect_magic(buf
+ 2);
315 expect_dword(buf
+ 3, 10);
316 expect_dword(buf
+ 4, CombineModeExclude
);
317 expect_dword(buf
+ 5, CombineModeComplement
);
318 expect_dword(buf
+ 6, CombineModeXor
);
319 expect_dword(buf
+ 7, CombineModeIntersect
);
320 expect_dword(buf
+ 8, RGNDATA_RECT
);
321 expect_float(buf
+ 9, 10.0);
322 expect_float(buf
+ 10, 20.0);
323 expect_float(buf
+ 11, 100.0);
324 expect_float(buf
+ 12, 200.0);
325 expect_dword(buf
+ 13, RGNDATA_RECT
);
326 expect_float(buf
+ 14, 50.0);
327 expect_float(buf
+ 15, 30.0);
328 expect_float(buf
+ 16, 10.0);
329 expect_float(buf
+ 17, 20.0);
330 expect_dword(buf
+ 18, RGNDATA_RECT
);
331 expect_float(buf
+ 19, 100.0);
332 expect_float(buf
+ 20, 300.0);
333 expect_float(buf
+ 21, 30.0);
334 expect_float(buf
+ 22, 50.0);
335 expect_dword(buf
+ 23, CombineModeUnion
);
336 expect_dword(buf
+ 24, RGNDATA_RECT
);
337 expect_float(buf
+ 25, 200.0);
338 expect_float(buf
+ 26, 100.0);
339 expect_float(buf
+ 27, 133.0);
340 expect_float(buf
+ 28, 266.0);
341 expect_dword(buf
+ 29, RGNDATA_RECT
);
342 expect_float(buf
+ 30, 20.0);
343 expect_float(buf
+ 31, 10.0);
344 expect_float(buf
+ 32, 40.0);
345 expect_float(buf
+ 33, 66.0);
346 expect_dword(buf
+ 34, RGNDATA_RECT
);
347 expect_float(buf
+ 35, 400.0);
348 expect_float(buf
+ 36, 500.0);
349 expect_float(buf
+ 37, 22.0);
350 expect_float(buf
+ 38, 55.0);
351 expect_dword(buf
+ 39, 0xeeeeeeee);
352 test_region_data(buf
, needed
, __LINE__
);
354 status
= GdipDeleteRegion(region2
);
355 ok(status
== Ok
, "status %08x\n", status
);
356 status
= GdipDeleteRegion(region
);
357 ok(status
== Ok
, "status %08x\n", status
);
361 status
= GdipCreatePath(FillModeAlternate
, &path
);
362 ok(status
== Ok
, "status %08x\n", status
);
363 GdipAddPathRectangle(path
, 12.5, 13.0, 14.0, 15.0);
365 status
= GdipCreateRegionPath(path
, ®ion
);
366 ok(status
== Ok
, "status %08x\n", status
);
367 status
= GdipGetRegionDataSize(region
, &needed
);
368 ok(status
== Ok
, "status %08x\n", status
);
370 memset(buf
, 0xee, sizeof(buf
));
372 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
373 ok(status
== Ok
, "status %08x\n", status
);
375 expect_dword(buf
, 64);
376 trace("buf[1] = %08x\n", buf
[1]);
377 expect_magic(buf
+ 2);
378 expect_dword(buf
+ 3, 0);
379 expect_dword(buf
+ 4, RGNDATA_PATH
);
380 expect_dword(buf
+ 5, 0x00000030);
381 expect_magic(buf
+ 6);
382 expect_dword(buf
+ 7, 0x00000004);
383 expect_dword(buf
+ 8, 0x00000000);
384 expect_float(buf
+ 9, 12.5);
385 expect_float(buf
+ 10, 13.0);
386 expect_float(buf
+ 11, 26.5);
387 expect_float(buf
+ 12, 13.0);
388 expect_float(buf
+ 13, 26.5);
389 expect_float(buf
+ 14, 28.0);
390 expect_float(buf
+ 15, 12.5);
391 expect_float(buf
+ 16, 28.0);
392 expect_dword(buf
+ 17, 0x81010100);
393 expect_dword(buf
+ 18, 0xeeeeeeee);
394 test_region_data(buf
, needed
, __LINE__
);
400 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeIntersect
);
401 ok(status
== Ok
, "status %08x\n", status
);
402 status
= GdipGetRegionDataSize(region
, &needed
);
403 ok(status
== Ok
, "status %08x\n", status
);
405 memset(buf
, 0xee, sizeof(buf
));
407 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
408 ok(status
== Ok
, "status %08x\n", status
);
410 expect_dword(buf
, 88);
411 trace("buf[1] = %08x\n", buf
[1]);
412 expect_magic(buf
+ 2);
413 expect_dword(buf
+ 3, 2);
414 expect_dword(buf
+ 4, CombineModeIntersect
);
415 expect_dword(buf
+ 5, RGNDATA_PATH
);
416 expect_dword(buf
+ 6, 0x00000030);
417 expect_magic(buf
+ 7);
418 expect_dword(buf
+ 8, 0x00000004);
419 expect_dword(buf
+ 9, 0x00000000);
420 expect_float(buf
+ 10, 12.5);
421 expect_float(buf
+ 11, 13.0);
422 expect_float(buf
+ 12, 26.5);
423 expect_float(buf
+ 13, 13.0);
424 expect_float(buf
+ 14, 26.5);
425 expect_float(buf
+ 15, 28.0);
426 expect_float(buf
+ 16, 12.5);
427 expect_float(buf
+ 17, 28.0);
428 expect_dword(buf
+ 18, 0x81010100);
429 expect_dword(buf
+ 19, RGNDATA_RECT
);
430 expect_float(buf
+ 20, 50.0);
431 expect_float(buf
+ 21, 30.0);
432 expect_float(buf
+ 22, 10.0);
433 expect_float(buf
+ 23, 20.0);
434 expect_dword(buf
+ 24, 0xeeeeeeee);
435 test_region_data(buf
, needed
, __LINE__
);
437 status
= GdipDeleteRegion(region
);
438 ok(status
== Ok
, "status %08x\n", status
);
439 status
= GdipDeletePath(path
);
440 ok(status
== Ok
, "status %08x\n", status
);
442 /* Test an empty path */
443 status
= GdipCreatePath(FillModeAlternate
, &path
);
445 status
= GdipCreateRegionPath(path
, ®ion
);
447 status
= GdipGetRegionDataSize(region
, &needed
);
450 memset(buf
, 0xee, sizeof(buf
));
452 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
455 expect_dword(buf
, 28);
456 trace("buf[1] = %08x\n", buf
[1]);
457 expect_magic(buf
+ 2);
458 expect_dword(buf
+ 3, 0);
459 expect_dword(buf
+ 4, RGNDATA_PATH
);
460 /* Second signature for pathdata */
461 expect_dword(buf
+ 5, 12);
462 expect_magic(buf
+ 6);
463 expect_dword(buf
+ 7, 0);
464 /* flags 0 means that a path is an array of FLOATs */
465 ok(*(buf
+ 8) == 0x4000 /* before win7 */ || *(buf
+ 8) == 0,
466 "expected 0x4000 or 0, got %08x\n", *(buf
+ 8));
467 expect_dword(buf
+ 10, 0xeeeeeeee);
468 test_region_data(buf
, needed
, __LINE__
);
470 /* Transform an empty region */
471 status
= GdipCreateMatrix(&matrix
);
473 status
= GdipTransformRegion(region
, matrix
);
475 GdipDeleteMatrix(matrix
);
477 status
= GdipDeleteRegion(region
);
480 /* Test a simple triangle of INTs */
481 status
= GdipAddPathLine(path
, 5, 6, 7, 8);
483 status
= GdipAddPathLine(path
, 8, 1, 5, 6);
485 status
= GdipClosePathFigure(path
);
487 status
= GdipCreateRegionPath(path
, ®ion
);
489 status
= GdipGetRegionDataSize(region
, &needed
);
492 memset(buf
, 0xee, sizeof(buf
));
494 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
497 expect_dword(buf
, 48);
498 trace("buf[1] = %08x\n", buf
[1]);
499 expect_magic(buf
+ 2);
500 expect_dword(buf
+ 3 , 0);
501 expect_dword(buf
+ 4 , RGNDATA_PATH
);
502 expect_dword(buf
+ 5, 32);
503 expect_magic(buf
+ 6);
504 expect_dword(buf
+ 7, 4);
505 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
506 expect_dword(buf
+ 8, 0x4000);
508 point
= (RegionDataPoint
*)(buf
+ 9);
509 expect(5, point
[0].X
);
510 expect(6, point
[0].Y
);
511 expect(7, point
[1].X
); /* buf + 10 */
512 expect(8, point
[1].Y
);
513 expect(8, point
[2].X
); /* buf + 11 */
514 expect(1, point
[2].Y
);
515 expect(5, point
[3].X
); /* buf + 12 */
516 expect(6, point
[3].Y
);
517 expect_dword(buf
+ 13, 0x81010100); /* 0x01010100 if we don't close the path */
518 expect_dword(buf
+ 14, 0xeeeeeeee);
519 test_region_data(buf
, needed
, __LINE__
);
521 status
= GdipTranslateRegion(region
, 0.6, 0.8);
523 memset(buf
, 0xee, sizeof(buf
));
525 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
528 expect_dword(buf
, 64);
529 expect_magic(buf
+ 2);
530 expect_dword(buf
+ 3 , 0);
531 expect_dword(buf
+ 4 , RGNDATA_PATH
);
532 expect_dword(buf
+ 5, 48);
533 expect_magic(buf
+ 6);
534 expect_dword(buf
+ 7, 4);
535 /* flags 0 means that a path is an array of FLOATs */
536 expect_dword(buf
+ 8, 0);
537 expect_float(buf
+ 9, 5.6);
538 expect_float(buf
+ 10, 6.8);
539 expect_float(buf
+ 11, 7.6);
540 expect_float(buf
+ 12, 8.8);
541 expect_float(buf
+ 13, 8.6);
542 expect_float(buf
+ 14, 1.8);
543 expect_float(buf
+ 15, 5.6);
544 expect_float(buf
+ 16, 6.8);
545 expect_dword(buf
+ 17, 0x81010100); /* 0x01010100 if we don't close the path */
546 expect_dword(buf
+ 18, 0xeeeeeeee);
547 test_region_data(buf
, needed
, __LINE__
);
549 status
= GdipDeletePath(path
);
551 status
= GdipDeleteRegion(region
);
554 /* Test a floating-point triangle */
555 status
= GdipCreatePath(FillModeAlternate
, &path
);
557 status
= GdipAddPathLine(path
, 5.6, 6.2, 7.2, 8.9);
559 status
= GdipAddPathLine(path
, 8.1, 1.6, 5.6, 6.2);
561 status
= GdipCreateRegionPath(path
, ®ion
);
563 status
= GdipGetRegionDataSize(region
, &needed
);
566 memset(buf
, 0xee, sizeof(buf
));
568 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
571 expect_dword(buf
, 64);
572 trace("buf[1] = %08x\n", buf
[1]);
573 expect_magic(buf
+ 2);
574 expect_dword(buf
+ 3, 0);
575 expect_dword(buf
+ 4, RGNDATA_PATH
);
576 expect_dword(buf
+ 5, 48);
577 expect_magic(buf
+ 6);
578 expect_dword(buf
+ 7, 4);
579 expect_dword(buf
+ 8, 0);
580 expect_float(buf
+ 9, 5.6);
581 expect_float(buf
+ 10, 6.2);
582 expect_float(buf
+ 11, 7.2);
583 expect_float(buf
+ 12, 8.9);
584 expect_float(buf
+ 13, 8.1);
585 expect_float(buf
+ 14, 1.6);
586 expect_float(buf
+ 15, 5.6);
587 expect_float(buf
+ 16, 6.2);
588 expect_dword(buf
+ 17, 0x01010100);
589 expect_dword(buf
+ 18, 0xeeeeeeee);
590 test_region_data(buf
, needed
, __LINE__
);
592 status
= GdipDeletePath(path
);
594 status
= GdipDeleteRegion(region
);
597 /* Test for a path with > 4 points, and CombineRegionPath */
598 GdipCreatePath(FillModeAlternate
, &path
);
599 status
= GdipAddPathLine(path
, 50, 70.2, 60, 102.8);
601 status
= GdipAddPathLine(path
, 55.4, 122.4, 40.4, 60.2);
603 status
= GdipAddPathLine(path
, 45.6, 20.2, 50, 70.2);
609 status
= GdipCreateRegionRectI(&rect
, ®ion
);
611 status
= GdipCombineRegionPath(region
, path
, CombineModeUnion
);
614 status
= GdipGetRegionDataSize(region
, &needed
);
617 memset(buf
, 0xee, sizeof(buf
));
619 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
622 expect_dword(buf
, 108);
623 trace("buf[1] = %08x\n", buf
[1]);
624 expect_magic(buf
+ 2);
625 expect_dword(buf
+ 3, 2);
626 expect_dword(buf
+ 4, CombineModeUnion
);
627 expect_dword(buf
+ 5, RGNDATA_RECT
);
628 expect_float(buf
+ 6, 20.0);
629 expect_float(buf
+ 7, 25.0);
630 expect_float(buf
+ 8, 60.0);
631 expect_float(buf
+ 9, 120.0);
632 expect_dword(buf
+ 10, RGNDATA_PATH
);
633 expect_dword(buf
+ 11, 68);
634 expect_magic(buf
+ 12);
635 expect_dword(buf
+ 13, 6);
636 expect_float(buf
+ 14, 0.0);
637 expect_float(buf
+ 15, 50.0);
638 expect_float(buf
+ 16, 70.2);
639 expect_float(buf
+ 17, 60.0);
640 expect_float(buf
+ 18, 102.8);
641 expect_float(buf
+ 19, 55.4);
642 expect_float(buf
+ 20, 122.4);
643 expect_float(buf
+ 21, 40.4);
644 expect_float(buf
+ 22, 60.2);
645 expect_float(buf
+ 23, 45.6);
646 expect_float(buf
+ 24, 20.2);
647 expect_float(buf
+ 25, 50.0);
648 expect_float(buf
+ 26, 70.2);
649 expect_dword(buf
+ 27, 0x01010100);
650 ok(*(buf
+ 28) == 0x00000101 || *(buf
+ 28) == 0x43050101 /* Win 7 */,
651 "expected 00000101 or 43050101 got %08x\n", *(buf
+ 28));
652 expect_dword(buf
+ 29, 0xeeeeeeee);
653 test_region_data(buf
, needed
, __LINE__
);
655 status
= GdipDeletePath(path
);
657 status
= GdipDeleteRegion(region
);
660 /* Test how shorts are stored in the region path data */
661 status
= GdipCreatePath(FillModeAlternate
, &path
);
662 ok(status
== Ok
, "status %08x\n", status
);
663 GdipAddPathRectangleI(path
, -1969, -1974, 1995, 1997);
665 status
= GdipCreateRegionPath(path
, ®ion
);
666 ok(status
== Ok
, "status %08x\n", status
);
668 status
= GdipGetRegionDataSize(region
, &needed
);
669 ok(status
== Ok
, "status %08x\n", status
);
671 memset(buf
, 0xee, sizeof(buf
));
673 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
674 ok(status
== Ok
, "status %08x\n", status
);
676 expect_dword(buf
, 48);
677 trace("buf[1] = %08x\n", buf
[1]);
678 expect_magic(buf
+ 2);
679 expect_dword(buf
+ 3, 0);
680 expect_dword(buf
+ 4, RGNDATA_PATH
);
681 expect_dword(buf
+ 5, 32);
682 expect_magic(buf
+ 6);
683 expect_dword(buf
+ 7, 4);
684 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
685 expect_dword(buf
+ 8, 0x4000);
686 point
= (RegionDataPoint
*)(buf
+ 9);
687 expect(-1969, point
[0].X
);
688 expect(-1974, point
[0].Y
);
689 expect(26, point
[1].X
); /* buf + 10 */
690 expect(-1974, point
[1].Y
);
691 expect(26, point
[2].X
); /* buf + 11 */
692 expect(23, point
[2].Y
);
693 expect(-1969, point
[3].X
); /* buf + 12 */
694 expect(23, point
[3].Y
);
695 expect_dword(buf
+ 13, 0x81010100); /* 0x01010100 if we don't close the path */
696 expect_dword(buf
+ 14, 0xeeeeeeee);
697 test_region_data(buf
, needed
, __LINE__
);
699 status
= GdipDeletePath(path
);
701 status
= GdipDeleteRegion(region
);
704 /* Test with integers that can't be stored as shorts */
705 status
= GdipCreatePath(FillModeAlternate
, &path
);
706 ok(status
== Ok
, "status %08x\n", status
);
707 GdipAddPathRectangleI(path
, -196900, -197400, 199500, 199700);
709 status
= GdipCreateRegionPath(path
, ®ion
);
710 ok(status
== Ok
, "status %08x\n", status
);
712 status
= GdipGetRegionDataSize(region
, &needed
);
713 ok(status
== Ok
, "status %08x\n", status
);
715 memset(buf
, 0xee, sizeof(buf
));
717 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
718 ok(status
== Ok
, "status %08x\n", status
);
720 expect_dword(buf
, 64);
721 trace("buf[1] = %08x\n", buf
[1]);
722 expect_magic(buf
+ 2);
723 expect_dword(buf
+ 3, 0);
724 expect_dword(buf
+ 4, RGNDATA_PATH
);
725 expect_dword(buf
+ 5, 48);
726 expect_magic(buf
+ 6);
727 expect_dword(buf
+ 7, 4);
728 /* flags 0 means that a path is an array of FLOATs */
729 expect_dword(buf
+ 8, 0);
730 expect_float(buf
+ 9, -196900.0);
731 expect_float(buf
+ 10, -197400.0);
732 expect_float(buf
+ 11, 2600.0);
733 expect_float(buf
+ 12, -197400.0);
734 expect_float(buf
+ 13, 2600.0);
735 expect_float(buf
+ 14, 2300.0);
736 expect_float(buf
+ 15, -196900.0);
737 expect_float(buf
+ 16, 2300.0);
738 expect_dword(buf
+ 17, 0x81010100); /* 0x01010100 if we don't close the path */
739 expect_dword(buf
+ 18, 0xeeeeeeee);
740 test_region_data(buf
, needed
, __LINE__
);
742 status
= GdipDeletePath(path
);
744 status
= GdipDeleteRegion(region
);
748 GdipCreatePath(FillModeAlternate
, &path
);
749 /* Exactly 90 degrees */
750 status
= GdipAddPathArc(path
, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
752 /* Over 90 degrees */
753 status
= GdipAddPathArc(path
, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
755 status
= GdipCreateRegionPath(path
, ®ion
);
756 ok(status
== Ok
, "status %08x\n", status
);
758 status
= GdipGetRegionDataSize(region
, &needed
);
759 ok(status
== Ok
, "status %08x\n", status
);
761 memset(buf
, 0xee, sizeof(buf
));
763 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
764 ok(status
== Ok
, "status %08x\n", status
);
766 expect_dword(buf
, 128);
767 trace("buf[1] = %08x\n", buf
[1]);
768 expect_magic(buf
+ 2);
769 expect_dword(buf
+ 3, 0);
770 expect_dword(buf
+ 4, RGNDATA_PATH
);
771 expect_dword(buf
+ 5, 112);
772 expect_magic(buf
+ 6);
773 expect_dword(buf
+ 7, 11);
774 /* flags 0 means that a path is an array of FLOATs */
775 expect_dword(buf
+ 8, 0);
776 expect_float(buf
+ 9, 600.0);
777 expect_float(buf
+ 10, 450.0);
778 expect_float(buf
+ 11, 600.0);
779 expect_float(buf
+ 12, 643.299561);
780 expect_float(buf
+ 13, 488.071198);
781 expect_float(buf
+ 14, 800.0);
782 expect_float(buf
+ 15, 350.0);
783 expect_float(buf
+ 16, 800.0);
784 expect_float(buf
+ 17, 600.0);
785 expect_float(buf
+ 18, 450.0);
786 expect_float(buf
+ 19, 600.0);
787 expect_float(buf
+ 20, 643.299622);
788 expect_float(buf
+ 21, 488.071167);
789 expect_float(buf
+ 22, 800.0);
790 expect_float(buf
+ 23, 350.0);
791 expect_float(buf
+ 24, 800.0);
792 expect_float(buf
+ 25, 329.807129);
793 expect_float(buf
+ 26, 800.0);
794 expect_float(buf
+ 27, 309.688568);
795 expect_float(buf
+ 28, 796.574890);
796 expect_float(buf
+ 29, 290.084167);
797 expect_float(buf
+ 30, 789.799561);
798 expect_dword(buf
+ 31, 0x03030300);
799 expect_dword(buf
+ 32, 0x03030301);
800 ok(*(buf
+ 33) == 0x00030303 /* before win7 */ ||
801 *(buf
+ 33) == 0x43030303 /* 32-bit win7 */ || *(buf
+ 33) == 0x4c030303 /* 64-bit win7 */,
802 "expected 0x00030303 or 0x43030303 or 0x4c030303 got %08x\n", *(buf
+ 33));
803 expect_dword(buf
+ 34, 0xeeeeeeee);
804 test_region_data(buf
, needed
, __LINE__
);
806 status
= GdipDeletePath(path
);
808 status
= GdipDeleteRegion(region
);
812 static void test_isinfinite(void)
816 GpGraphics
*graphics
= NULL
;
821 status
= GdipCreateFromHDC(hdc
, &graphics
);
823 GdipCreateRegion(®ion
);
825 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m
);
828 status
= GdipIsInfiniteRegion(NULL
, NULL
, NULL
);
829 expect(InvalidParameter
, status
);
830 status
= GdipIsInfiniteRegion(region
, NULL
, NULL
);
831 expect(InvalidParameter
, status
);
832 status
= GdipIsInfiniteRegion(NULL
, graphics
, NULL
);
833 expect(InvalidParameter
, status
);
834 status
= GdipIsInfiniteRegion(NULL
, NULL
, &res
);
835 expect(InvalidParameter
, status
);
836 status
= GdipIsInfiniteRegion(region
, NULL
, &res
);
837 expect(InvalidParameter
, status
);
840 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
844 /* after world transform */
845 status
= GdipSetWorldTransform(graphics
, m
);
849 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
854 GdipDeleteRegion(region
);
855 GdipDeleteGraphics(graphics
);
859 static void test_isempty(void)
863 GpGraphics
*graphics
= NULL
;
867 status
= GdipCreateFromHDC(hdc
, &graphics
);
869 GdipCreateRegion(®ion
);
872 status
= GdipIsEmptyRegion(NULL
, NULL
, NULL
);
873 expect(InvalidParameter
, status
);
874 status
= GdipIsEmptyRegion(region
, NULL
, NULL
);
875 expect(InvalidParameter
, status
);
876 status
= GdipIsEmptyRegion(NULL
, graphics
, NULL
);
877 expect(InvalidParameter
, status
);
878 status
= GdipIsEmptyRegion(NULL
, NULL
, &res
);
879 expect(InvalidParameter
, status
);
880 status
= GdipIsEmptyRegion(region
, NULL
, &res
);
881 expect(InvalidParameter
, status
);
883 /* default is infinite */
885 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
889 status
= GdipSetEmpty(region
);
893 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
897 GdipDeleteRegion(region
);
898 GdipDeleteGraphics(graphics
);
902 static void test_combinereplace(void)
905 GpRegion
*region
, *region2
;
911 rectf
.X
= rectf
.Y
= 0.0;
912 rectf
.Width
= rectf
.Height
= 100.0;
914 status
= GdipCreateRegionRect(&rectf
, ®ion
);
917 /* replace with the same rectangle */
918 status
= GdipCombineRegionRect(region
, &rectf
,CombineModeReplace
);
921 status
= GdipGetRegionDataSize(region
, &needed
);
924 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
927 expect_dword(buf
, 28);
928 trace("buf[1] = %08x\n", buf
[1]);
929 expect_magic(buf
+ 2);
930 expect_dword(buf
+ 3, 0);
931 expect_dword(buf
+ 4, RGNDATA_RECT
);
933 /* replace with path */
934 status
= GdipCreatePath(FillModeAlternate
, &path
);
936 status
= GdipAddPathEllipse(path
, 0.0, 0.0, 100.0, 250.0);
938 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
941 status
= GdipGetRegionDataSize(region
, &needed
);
944 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
947 expect_dword(buf
, 148);
948 trace("buf[1] = %08x\n", buf
[1]);
949 expect_magic(buf
+ 2);
950 expect_dword(buf
+ 3, 0);
951 expect_dword(buf
+ 4, RGNDATA_PATH
);
952 GdipDeletePath(path
);
954 /* replace with infinite rect */
955 status
= GdipCreateRegion(®ion2
);
957 status
= GdipCombineRegionRegion(region
, region2
, CombineModeReplace
);
960 status
= GdipGetRegionDataSize(region
, &needed
);
963 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
966 expect_dword(buf
, 12);
967 trace("buf[1] = %08x\n", buf
[1]);
968 expect_magic(buf
+ 2);
969 expect_dword(buf
+ 3, 0);
970 expect_dword(buf
+ 4, RGNDATA_INFINITE_RECT
);
971 GdipDeleteRegion(region2
);
973 /* more complex case : replace with a combined region */
974 status
= GdipCreateRegionRect(&rectf
, ®ion2
);
976 status
= GdipCreatePath(FillModeAlternate
, &path
);
978 status
= GdipAddPathEllipse(path
, 0.0, 0.0, 100.0, 250.0);
980 status
= GdipCombineRegionPath(region2
, path
, CombineModeUnion
);
982 GdipDeletePath(path
);
983 status
= GdipCombineRegionRegion(region
, region2
, CombineModeReplace
);
985 GdipDeleteRegion(region2
);
987 status
= GdipGetRegionDataSize(region
, &needed
);
990 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
993 expect_dword(buf
, 172);
994 trace("buf[1] = %08x\n", buf
[1]);
995 expect_magic(buf
+ 2);
996 expect_dword(buf
+ 3, 2);
997 expect_dword(buf
+ 4, CombineModeUnion
);
999 GdipDeleteRegion(region
);
1002 static void test_fromhrgn(void)
1005 GpRegion
*region
= (GpRegion
*)0xabcdef01;
1009 RegionDataPoint
*point
;
1010 GpGraphics
*graphics
= NULL
;
1015 status
= GdipCreateRegionHrgn(NULL
, NULL
);
1016 expect(InvalidParameter
, status
);
1017 status
= GdipCreateRegionHrgn(NULL
, ®ion
);
1018 expect(InvalidParameter
, status
);
1019 status
= GdipCreateRegionHrgn((HRGN
)0xdeadbeef, ®ion
);
1020 expect(InvalidParameter
, status
);
1021 ok(region
== (GpRegion
*)0xabcdef01, "Expected region not to be created\n");
1023 /* empty rectangle */
1024 hrgn
= CreateRectRgn(0, 0, 0, 0);
1025 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
1030 status
= GdipCreateFromHDC(hdc
, &graphics
);
1033 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
1036 GdipDeleteGraphics(graphics
);
1038 GdipDeleteRegion(region
);
1044 hrgn
= CreateRectRgn(0, 0, 100, 10);
1045 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
1048 status
= GdipGetRegionDataSize(region
, &needed
);
1052 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
1058 expect_dword(buf
, 48);
1059 expect_magic(buf
+ 2);
1060 expect_dword(buf
+ 3, 0);
1061 expect_dword(buf
+ 4, RGNDATA_PATH
);
1062 expect_dword(buf
+ 5, 0x00000020);
1063 expect_magic(buf
+ 6);
1064 expect_dword(buf
+ 7, 0x00000004);
1065 todo_wine
expect_dword(buf
+ 8, 0x00006000); /* ?? */
1067 point
= (RegionDataPoint
*)buf
+ 9;
1069 expect(0, point
[0].X
);
1070 expect(0, point
[0].Y
);
1072 expect(100,point
[1].X
); /* buf + 10 */
1073 expect(0, point
[1].Y
);
1074 expect(100,point
[2].X
); /* buf + 11 */
1075 expect(10, point
[2].Y
);
1077 expect(0, point
[3].X
); /* buf + 12 */
1079 expect(10, point
[3].Y
);
1080 expect_dword(buf
+ 13, 0x81010100); /* closed */
1084 GdipDeleteRegion(region
);
1088 hrgn
= CreateEllipticRgn(0, 0, 100, 10);
1089 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
1092 status
= GdipGetRegionDataSize(region
, &needed
);
1095 needed
== 196, /* win98 */
1096 "Got %.8x\n", needed
);
1098 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
1101 if(status
== Ok
&& needed
== 216) /* Don't try to test win98 layout */
1104 expect(216, needed
);
1105 expect_dword(buf
, 208);
1106 expect_magic(buf
+ 2);
1107 expect_dword(buf
+ 3, 0);
1108 expect_dword(buf
+ 4, RGNDATA_PATH
);
1109 expect_dword(buf
+ 5, 0x000000C0);
1110 expect_magic(buf
+ 6);
1111 expect_dword(buf
+ 7, 0x00000024);
1112 todo_wine
expect_dword(buf
+ 8, 0x00006000); /* ?? */
1115 GdipDeleteRegion(region
);
1119 static void test_gethrgn(void)
1122 GpRegion
*region
, *region2
;
1124 GpGraphics
*graphics
;
1127 static const RECT empty_rect
= {0,0,0,0};
1128 static const RECT test_rect
= {10, 11, 20, 21};
1129 static const GpRectF test_rectF
= {10.0, 11.0, 10.0, 10.0};
1130 static const RECT scaled_rect
= {20, 22, 40, 42};
1131 static const RECT test_rect2
= {10, 21, 20, 31};
1132 static const GpRectF test_rect2F
= {10.0, 21.0, 10.0, 10.0};
1133 static const RECT test_rect3
= {10, 11, 20, 31};
1134 static const GpRectF test_rect3F
= {10.0, 11.0, 10.0, 20.0};
1136 status
= GdipCreateFromHDC(hdc
, &graphics
);
1137 ok(status
== Ok
, "status %08x\n", status
);
1139 status
= GdipCreateRegion(®ion
);
1140 ok(status
== Ok
, "status %08x\n", status
);
1142 status
= GdipGetRegionHRgn(NULL
, graphics
, &hrgn
);
1143 ok(status
== InvalidParameter
, "status %08x\n", status
);
1144 status
= GdipGetRegionHRgn(region
, graphics
, NULL
);
1145 ok(status
== InvalidParameter
, "status %08x\n", status
);
1147 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1148 ok(status
== Ok
, "status %08x\n", status
);
1149 ok(hrgn
== NULL
, "hrgn=%p\n", hrgn
);
1151 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
1152 ok(status
== Ok
, "status %08x\n", status
);
1153 ok(hrgn
== NULL
, "hrgn=%p\n", hrgn
);
1155 status
= GdipSetEmpty(region
);
1156 ok(status
== Ok
, "status %08x\n", status
);
1157 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1158 ok(status
== Ok
, "status %08x\n", status
);
1159 verify_region(hrgn
, &empty_rect
);
1162 status
= GdipCreatePath(FillModeAlternate
, &path
);
1163 ok(status
== Ok
, "status %08x\n", status
);
1164 status
= GdipAddPathRectangle(path
, 10.0, 11.0, 10.0, 10.0);
1165 ok(status
== Ok
, "status %08x\n", status
);
1167 status
= GdipCreateRegionPath(path
, ®ion2
);
1168 ok(status
== Ok
, "status %08x\n", status
);
1169 status
= GdipGetRegionHRgn(region2
, NULL
, &hrgn
);
1170 ok(status
== Ok
, "status %08x\n", status
);
1171 verify_region(hrgn
, &test_rect
);
1174 /* resulting HRGN is in device coordinates */
1175 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
1176 ok(status
== Ok
, "status %08x\n", status
);
1177 status
= GdipGetRegionHRgn(region2
, graphics
, &hrgn
);
1178 ok(status
== Ok
, "status %08x\n", status
);
1179 verify_region(hrgn
, &scaled_rect
);
1182 status
= GdipCombineRegionRect(region2
, &test_rectF
, CombineModeReplace
);
1183 ok(status
== Ok
, "status %08x\n", status
);
1184 status
= GdipGetRegionHRgn(region2
, NULL
, &hrgn
);
1185 ok(status
== Ok
, "status %08x\n", status
);
1186 verify_region(hrgn
, &test_rect
);
1189 status
= GdipGetRegionHRgn(region2
, graphics
, &hrgn
);
1190 ok(status
== Ok
, "status %08x\n", status
);
1191 verify_region(hrgn
, &scaled_rect
);
1194 status
= GdipSetInfinite(region
);
1195 ok(status
== Ok
, "status %08x\n", status
);
1196 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeIntersect
);
1197 ok(status
== Ok
, "status %08x\n", status
);
1198 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1199 ok(status
== Ok
, "status %08x\n", status
);
1200 verify_region(hrgn
, &test_rect
);
1203 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeReplace
);
1204 ok(status
== Ok
, "status %08x\n", status
);
1205 status
= GdipCombineRegionRect(region
, &test_rect2F
, CombineModeUnion
);
1206 ok(status
== Ok
, "status %08x\n", status
);
1207 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1208 ok(status
== Ok
, "status %08x\n", status
);
1209 verify_region(hrgn
, &test_rect3
);
1212 status
= GdipCombineRegionRect(region
, &test_rect3F
, CombineModeReplace
);
1213 ok(status
== Ok
, "status %08x\n", status
);
1214 status
= GdipCombineRegionRect(region
, &test_rect2F
, CombineModeXor
);
1215 ok(status
== Ok
, "status %08x\n", status
);
1216 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1217 ok(status
== Ok
, "status %08x\n", status
);
1218 verify_region(hrgn
, &test_rect
);
1221 status
= GdipCombineRegionRect(region
, &test_rect3F
, CombineModeReplace
);
1222 ok(status
== Ok
, "status %08x\n", status
);
1223 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeExclude
);
1224 ok(status
== Ok
, "status %08x\n", status
);
1225 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1226 ok(status
== Ok
, "status %08x\n", status
);
1227 verify_region(hrgn
, &test_rect2
);
1230 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeReplace
);
1231 ok(status
== Ok
, "status %08x\n", status
);
1232 status
= GdipCombineRegionRect(region
, &test_rect3F
, CombineModeComplement
);
1233 ok(status
== Ok
, "status %08x\n", status
);
1234 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1235 ok(status
== Ok
, "status %08x\n", status
);
1236 verify_region(hrgn
, &test_rect2
);
1239 status
= GdipDeletePath(path
);
1240 ok(status
== Ok
, "status %08x\n", status
);
1241 status
= GdipDeleteRegion(region
);
1242 ok(status
== Ok
, "status %08x\n", status
);
1243 status
= GdipDeleteRegion(region2
);
1244 ok(status
== Ok
, "status %08x\n", status
);
1245 status
= GdipDeleteGraphics(graphics
);
1246 ok(status
== Ok
, "status %08x\n", status
);
1250 static void test_isequal(void)
1252 GpRegion
*region1
, *region2
;
1253 GpGraphics
*graphics
;
1259 status
= GdipCreateFromHDC(hdc
, &graphics
);
1260 ok(status
== Ok
, "status %08x\n", status
);
1262 status
= GdipCreateRegion(®ion1
);
1263 ok(status
== Ok
, "status %08x\n", status
);
1264 status
= GdipCreateRegion(®ion2
);
1265 ok(status
== Ok
, "status %08x\n", status
);
1268 status
= GdipIsEqualRegion(NULL
, NULL
, NULL
, NULL
);
1269 ok(status
== InvalidParameter
, "status %08x\n", status
);
1270 status
= GdipIsEqualRegion(region1
, region2
, NULL
, NULL
);
1271 ok(status
== InvalidParameter
, "status %08x\n", status
);
1272 status
= GdipIsEqualRegion(region1
, region2
, graphics
, NULL
);
1273 ok(status
== InvalidParameter
, "status %08x\n", status
);
1274 status
= GdipIsEqualRegion(region1
, region2
, NULL
, &res
);
1275 ok(status
== InvalidParameter
, "status %08x\n", status
);
1277 /* infinite regions */
1279 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1280 ok(status
== Ok
, "status %08x\n", status
);
1281 ok(res
, "Expected to be equal.\n");
1283 status
= GdipSetEmpty(region1
);
1284 ok(status
== Ok
, "status %08x\n", status
);
1285 status
= GdipSetEmpty(region2
);
1286 ok(status
== Ok
, "status %08x\n", status
);
1288 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1289 ok(status
== Ok
, "status %08x\n", status
);
1290 ok(res
, "Expected to be equal.\n");
1291 /* empty & infinite */
1292 status
= GdipSetInfinite(region1
);
1293 ok(status
== Ok
, "status %08x\n", status
);
1295 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1296 ok(status
== Ok
, "status %08x\n", status
);
1297 ok(!res
, "Expected to be unequal.\n");
1298 /* rect & (inf/empty) */
1299 rectf
.X
= rectf
.Y
= 0.0;
1300 rectf
.Width
= rectf
.Height
= 100.0;
1301 status
= GdipCombineRegionRect(region1
, &rectf
, CombineModeReplace
);
1302 ok(status
== Ok
, "status %08x\n", status
);
1304 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1305 ok(status
== Ok
, "status %08x\n", status
);
1306 ok(!res
, "Expected to be unequal.\n");
1307 status
= GdipSetInfinite(region2
);
1308 ok(status
== Ok
, "status %08x\n", status
);
1310 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1311 ok(status
== Ok
, "status %08x\n", status
);
1312 ok(!res
, "Expected to be unequal.\n");
1313 /* roughly equal rectangles */
1314 rectf
.X
= rectf
.Y
= 0.0;
1315 rectf
.Width
= rectf
.Height
= 100.001;
1316 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1317 ok(status
== Ok
, "status %08x\n", status
);
1319 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1320 ok(status
== Ok
, "status %08x\n", status
);
1321 ok(res
, "Expected to be equal.\n");
1322 /* equal rectangles */
1323 rectf
.X
= rectf
.Y
= 0.0;
1324 rectf
.Width
= rectf
.Height
= 100.0;
1325 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1326 ok(status
== Ok
, "status %08x\n", status
);
1328 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1329 ok(status
== Ok
, "status %08x\n", status
);
1330 ok(res
, "Expected to be equal.\n");
1333 status
= GdipDeleteRegion(region1
);
1334 ok(status
== Ok
, "status %08x\n", status
);
1335 status
= GdipDeleteRegion(region2
);
1336 ok(status
== Ok
, "status %08x\n", status
);
1337 status
= GdipDeleteGraphics(graphics
);
1338 ok(status
== Ok
, "status %08x\n", status
);
1342 static void test_translate(void)
1344 GpRegion
*region
, *region2
;
1345 GpGraphics
*graphics
;
1352 status
= GdipCreateFromHDC(hdc
, &graphics
);
1353 ok(status
== Ok
, "status %08x\n", status
);
1355 status
= GdipCreatePath(FillModeAlternate
, &path
);
1356 ok(status
== Ok
, "status %08x\n", status
);
1358 status
= GdipCreateRegion(®ion
);
1359 ok(status
== Ok
, "status %08x\n", status
);
1360 status
= GdipCreateRegion(®ion2
);
1361 ok(status
== Ok
, "status %08x\n", status
);
1364 status
= GdipTranslateRegion(NULL
, 0.0, 0.0);
1365 ok(status
== InvalidParameter
, "status %08x\n", status
);
1368 status
= GdipTranslateRegion(region
, 10.0, 10.0);
1369 ok(status
== Ok
, "status %08x\n", status
);
1371 status
= GdipSetEmpty(region
);
1372 ok(status
== Ok
, "status %08x\n", status
);
1373 status
= GdipTranslateRegion(region
, 10.0, 10.0);
1374 ok(status
== Ok
, "status %08x\n", status
);
1376 rectf
.X
= 10.0; rectf
.Y
= 0.0;
1377 rectf
.Width
= rectf
.Height
= 100.0;
1378 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1379 ok(status
== Ok
, "status %08x\n", status
);
1380 rectf
.X
= 15.0; rectf
.Y
= -2.0;
1381 rectf
.Width
= rectf
.Height
= 100.0;
1382 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1383 ok(status
== Ok
, "status %08x\n", status
);
1384 status
= GdipTranslateRegion(region
, 5.0, -2.0);
1385 ok(status
== Ok
, "status %08x\n", status
);
1387 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1388 ok(status
== Ok
, "status %08x\n", status
);
1389 ok(res
, "Expected to be equal.\n");
1391 status
= GdipAddPathEllipse(path
, 0.0, 10.0, 100.0, 150.0);
1392 ok(status
== Ok
, "status %08x\n", status
);
1393 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1394 ok(status
== Ok
, "status %08x\n", status
);
1395 status
= GdipResetPath(path
);
1396 ok(status
== Ok
, "status %08x\n", status
);
1397 status
= GdipAddPathEllipse(path
, 10.0, 21.0, 100.0, 150.0);
1398 ok(status
== Ok
, "status %08x\n", status
);
1399 status
= GdipCombineRegionPath(region2
, path
, CombineModeReplace
);
1400 ok(status
== Ok
, "status %08x\n", status
);
1401 status
= GdipTranslateRegion(region
, 10.0, 11.0);
1402 ok(status
== Ok
, "status %08x\n", status
);
1404 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1405 ok(status
== Ok
, "status %08x\n", status
);
1406 ok(res
, "Expected to be equal.\n");
1408 status
= GdipDeleteRegion(region
);
1409 ok(status
== Ok
, "status %08x\n", status
);
1410 status
= GdipDeleteRegion(region2
);
1411 ok(status
== Ok
, "status %08x\n", status
);
1412 status
= GdipDeleteGraphics(graphics
);
1413 ok(status
== Ok
, "status %08x\n", status
);
1414 status
= GdipDeletePath(path
);
1415 ok(status
== Ok
, "status %08x\n", status
);
1419 static void test_transform(void)
1421 GpRegion
*region
, *region2
;
1423 GpGraphics
*graphics
;
1430 status
= GdipCreateFromHDC(hdc
, &graphics
);
1433 status
= GdipCreatePath(FillModeAlternate
, &path
);
1436 status
= GdipCreateRegion(®ion
);
1438 status
= GdipCreateRegion(®ion2
);
1441 status
= GdipCreateMatrix(&matrix
);
1443 status
= GdipScaleMatrix(matrix
, 2.0, 3.0, MatrixOrderAppend
);
1447 status
= GdipTransformRegion(NULL
, matrix
);
1448 expect(InvalidParameter
, status
);
1450 status
= GdipTransformRegion(region
, NULL
);
1451 expect(InvalidParameter
, status
);
1454 status
= GdipTransformRegion(region
, matrix
);
1458 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1460 ok(res
, "Expected to be equal.\n");
1463 status
= GdipSetEmpty(region
);
1465 status
= GdipTransformRegion(region
, matrix
);
1468 status
= GdipSetEmpty(region2
);
1472 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1474 ok(res
, "Expected to be equal.\n");
1479 rectf
.Width
= rectf
.Height
= 100.0;
1480 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1484 rectf
.Width
= 200.0;
1485 rectf
.Height
= 300.0;
1486 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1488 status
= GdipTransformRegion(region
, matrix
);
1491 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1493 ok(res
, "Expected to be equal.\n");
1496 status
= GdipAddPathEllipse(path
, 0.0, 10.0, 100.0, 150.0);
1498 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1500 status
= GdipResetPath(path
);
1502 status
= GdipAddPathEllipse(path
, 0.0, 30.0, 200.0, 450.0);
1504 status
= GdipCombineRegionPath(region2
, path
, CombineModeReplace
);
1506 status
= GdipTransformRegion(region
, matrix
);
1509 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1511 ok(res
, "Expected to be equal.\n");
1513 status
= GdipDeleteRegion(region
);
1515 status
= GdipDeleteRegion(region2
);
1517 status
= GdipDeleteGraphics(graphics
);
1519 status
= GdipDeletePath(path
);
1521 status
= GdipDeleteMatrix(matrix
);
1526 static void test_scans(void)
1537 status
= GdipCreateRegion(®ion
);
1540 status
= GdipCreateMatrix(&matrix
);
1543 /* test NULL values */
1544 status
= GdipGetRegionScansCount(NULL
, &count
, matrix
);
1545 expect(InvalidParameter
, status
);
1547 status
= GdipGetRegionScansCount(region
, NULL
, matrix
);
1548 expect(InvalidParameter
, status
);
1550 status
= GdipGetRegionScansCount(region
, &count
, NULL
);
1551 expect(InvalidParameter
, status
);
1553 status
= GdipGetRegionScans(NULL
, scans
, &icount
, matrix
);
1554 expect(InvalidParameter
, status
);
1556 status
= GdipGetRegionScans(region
, scans
, NULL
, matrix
);
1557 expect(InvalidParameter
, status
);
1559 status
= GdipGetRegionScans(region
, scans
, &icount
, NULL
);
1560 expect(InvalidParameter
, status
);
1563 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1567 status
= GdipGetRegionScans(region
, NULL
, &icount
, matrix
);
1571 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1575 status
= GdipGetRegionScansI(region
, scansi
, &icount
, matrix
);
1578 expect(-0x400000, scansi
[0].X
);
1579 expect(-0x400000, scansi
[0].Y
);
1580 expect(0x800000, scansi
[0].Width
);
1581 expect(0x800000, scansi
[0].Height
);
1583 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1586 expectf((double)-0x400000, scans
[0].X
);
1587 expectf((double)-0x400000, scans
[0].Y
);
1588 expectf((double)0x800000, scans
[0].Width
);
1589 expectf((double)0x800000, scans
[0].Height
);
1592 status
= GdipSetEmpty(region
);
1595 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1599 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1603 /* single rectangle */
1604 rectf
.X
= rectf
.Y
= 0.0;
1605 rectf
.Width
= rectf
.Height
= 5.0;
1606 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1609 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1613 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1616 expectf(0.0, scans
[0].X
);
1617 expectf(0.0, scans
[0].Y
);
1618 expectf(5.0, scans
[0].Width
);
1619 expectf(5.0, scans
[0].Height
);
1621 /* two rectangles */
1622 rectf
.X
= rectf
.Y
= 5.0;
1623 rectf
.Width
= rectf
.Height
= 5.0;
1624 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeUnion
);
1627 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1631 /* Native ignores the initial value of count */
1632 scans
[1].X
= scans
[1].Y
= scans
[1].Width
= scans
[1].Height
= 8.0;
1634 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1637 expectf(0.0, scans
[0].X
);
1638 expectf(0.0, scans
[0].Y
);
1639 expectf(5.0, scans
[0].Width
);
1640 expectf(5.0, scans
[0].Height
);
1641 expectf(5.0, scans
[1].X
);
1642 expectf(5.0, scans
[1].Y
);
1643 expectf(5.0, scans
[1].Width
);
1644 expectf(5.0, scans
[1].Height
);
1646 status
= GdipGetRegionScansI(region
, scansi
, &icount
, matrix
);
1649 expect(0, scansi
[0].X
);
1650 expect(0, scansi
[0].Y
);
1651 expect(5, scansi
[0].Width
);
1652 expect(5, scansi
[0].Height
);
1653 expect(5, scansi
[1].X
);
1654 expect(5, scansi
[1].Y
);
1655 expect(5, scansi
[1].Width
);
1656 expect(5, scansi
[1].Height
);
1658 status
= GdipDeleteRegion(region
);
1660 status
= GdipDeleteMatrix(matrix
);
1664 static void test_getbounds(void)
1667 GpGraphics
*graphics
;
1672 status
= GdipCreateFromHDC(hdc
, &graphics
);
1673 ok(status
== Ok
, "status %08x\n", status
);
1674 status
= GdipCreateRegion(®ion
);
1675 ok(status
== Ok
, "status %08x\n", status
);
1678 status
= GdipGetRegionBounds(NULL
, NULL
, NULL
);
1679 ok(status
== InvalidParameter
, "status %08x\n", status
);
1680 status
= GdipGetRegionBounds(region
, NULL
, NULL
);
1681 ok(status
== InvalidParameter
, "status %08x\n", status
);
1682 status
= GdipGetRegionBounds(region
, graphics
, NULL
);
1683 ok(status
== InvalidParameter
, "status %08x\n", status
);
1685 rectf
.X
= rectf
.Y
= 0.0;
1686 rectf
.Height
= rectf
.Width
= 100.0;
1687 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1688 ok(status
== Ok
, "status %08x\n", status
);
1689 ok(rectf
.X
== -(REAL
)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL
)(1 << 22), rectf
.X
);
1690 ok(rectf
.Y
== -(REAL
)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL
)(1 << 22), rectf
.Y
);
1691 ok(rectf
.Width
== (REAL
)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL
)(1 << 23), rectf
.Width
);
1692 ok(rectf
.Height
== (REAL
)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL
)(1 << 23), rectf
.Height
);
1694 rectf
.X
= rectf
.Y
= 0.0;
1695 rectf
.Height
= rectf
.Width
= 100.0;
1696 status
= GdipSetEmpty(region
);
1697 ok(status
== Ok
, "status %08x\n", status
);
1698 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1699 ok(status
== Ok
, "status %08x\n", status
);
1700 ok(rectf
.X
== 0.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1701 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1702 ok(rectf
.Width
== 0.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1703 ok(rectf
.Height
== 0.0, "Expected height = 0.0, got %.2f\n", rectf
.Height
);
1705 rectf
.X
= 10.0; rectf
.Y
= 0.0;
1706 rectf
.Width
= rectf
.Height
= 100.0;
1707 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1708 ok(status
== Ok
, "status %08x\n", status
);
1709 rectf
.X
= rectf
.Y
= 0.0;
1710 rectf
.Height
= rectf
.Width
= 0.0;
1711 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1712 ok(status
== Ok
, "status %08x\n", status
);
1713 ok(rectf
.X
== 10.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1714 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1715 ok(rectf
.Width
== 100.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1716 ok(rectf
.Height
== 100.0, "Expected height = 0.0, got %.2f\n", rectf
.Height
);
1718 /* the world and page transforms are ignored */
1719 GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
1720 GdipSetPageUnit(graphics
, UnitInch
);
1721 GdipSetPageScale(graphics
, 2.0);
1722 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1723 ok(status
== Ok
, "status %08x\n", status
);
1724 ok(rectf
.X
== 10.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1725 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1726 ok(rectf
.Width
== 100.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1728 rectf
.X
= 10.0; rectf
.Y
= 0.0;
1729 rectf
.Width
= rectf
.Height
= 100.0;
1730 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1731 ok(status
== Ok
, "status %08x\n", status
);
1732 rectf
.X
= rectf
.Y
= 0.0;
1733 rectf
.Height
= rectf
.Width
= 0.0;
1734 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1735 ok(status
== Ok
, "status %08x\n", status
);
1736 ok(rectf
.X
== 10.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1737 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1738 ok(rectf
.Width
== 100.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1739 ok(rectf
.Height
== 100.0, "Expected height = 0.0, got %.2f\n", rectf
.Height
);
1741 status
= GdipDeleteRegion(region
);
1742 ok(status
== Ok
, "status %08x\n", status
);
1743 status
= GdipDeleteGraphics(graphics
);
1744 ok(status
== Ok
, "status %08x\n", status
);
1748 static void test_isvisiblepoint(void)
1751 GpGraphics
* graphics
;
1759 status
= GdipCreateFromHDC(hdc
, &graphics
);
1762 status
= GdipCreateRegion(®ion
);
1765 /* null parameters */
1766 status
= GdipIsVisibleRegionPoint(NULL
, 0, 0, graphics
, &res
);
1767 expect(InvalidParameter
, status
);
1768 status
= GdipIsVisibleRegionPointI(NULL
, 0, 0, graphics
, &res
);
1769 expect(InvalidParameter
, status
);
1771 status
= GdipIsVisibleRegionPoint(region
, 0, 0, NULL
, &res
);
1773 status
= GdipIsVisibleRegionPointI(region
, 0, 0, NULL
, &res
);
1776 status
= GdipIsVisibleRegionPoint(region
, 0, 0, graphics
, NULL
);
1777 expect(InvalidParameter
, status
);
1778 status
= GdipIsVisibleRegionPointI(region
, 0, 0, graphics
, NULL
);
1779 expect(InvalidParameter
, status
);
1781 /* infinite region */
1782 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
1784 ok(res
== TRUE
, "Region should be infinite\n");
1788 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1790 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1791 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1793 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1797 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1799 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1800 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1802 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1804 /* rectangular region */
1810 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1815 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1817 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1818 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1820 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1824 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1826 ok(res
== FALSE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1830 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1832 ok(res
== FALSE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1836 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1838 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1842 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1844 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1848 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1850 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1854 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1856 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1857 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1859 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1863 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1865 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1866 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1868 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1870 /* translate into the center of the rectangle */
1871 status
= GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
1874 /* native ignores the world transform, so treat these as if
1875 * no transform exists */
1878 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1880 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1881 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1883 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1887 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1889 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1890 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1892 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1896 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1898 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1899 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1901 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1903 /* translate back to origin */
1904 status
= GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
1907 /* region from path */
1908 status
= GdipCreatePath(FillModeAlternate
, &path
);
1911 status
= GdipAddPathEllipse(path
, 10, 20, 30, 40);
1914 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1919 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1921 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1922 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1924 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1928 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1930 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1931 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1933 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1937 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1939 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1940 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1942 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1944 GdipDeletePath(path
);
1946 GdipDeleteRegion(region
);
1947 GdipDeleteGraphics(graphics
);
1951 static void test_isvisiblerect(void)
1954 GpGraphics
* graphics
;
1962 status
= GdipCreateFromHDC(hdc
, &graphics
);
1965 status
= GdipCreateRegion(®ion
);
1968 /* null parameters */
1969 status
= GdipIsVisibleRegionRect(NULL
, 0, 0, 0, 0, graphics
, &res
);
1970 expect(InvalidParameter
, status
);
1971 status
= GdipIsVisibleRegionRectI(NULL
, 0, 0, 0, 0, graphics
, &res
);
1972 expect(InvalidParameter
, status
);
1974 status
= GdipIsVisibleRegionRect(region
, 0, 0, 0, 0, NULL
, &res
);
1976 status
= GdipIsVisibleRegionRectI(region
, 0, 0, 0, 0, NULL
, &res
);
1979 status
= GdipIsVisibleRegionRect(region
, 0, 0, 0, 0, graphics
, NULL
);
1980 expect(InvalidParameter
, status
);
1981 status
= GdipIsVisibleRegionRectI(region
, 0, 0, 0, 0, graphics
, NULL
);
1982 expect(InvalidParameter
, status
);
1984 /* infinite region */
1985 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
1987 ok(res
== TRUE
, "Region should be infinite\n");
1991 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1993 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1997 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1999 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2001 /* rectangular region */
2007 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeIntersect
);
2010 /* entirely within the region */
2013 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2015 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2016 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2018 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2020 /* entirely outside of the region */
2023 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2025 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2026 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2028 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2033 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2035 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2039 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2041 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2045 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2047 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2051 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2053 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2055 /* corners outside, but some intersection */
2058 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2060 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2064 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2066 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2070 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2072 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2074 /* translate into the center of the rectangle */
2075 status
= GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2078 /* native ignores the world transform, so treat these as if
2079 * no transform exists */
2082 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2084 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2085 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2087 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2091 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2093 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2094 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2096 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2098 /* translate back to origin */
2099 status
= GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2102 /* region from path */
2103 status
= GdipCreatePath(FillModeAlternate
, &path
);
2106 status
= GdipAddPathEllipse(path
, 10, 20, 30, 40);
2109 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
2114 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2116 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2117 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2119 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2123 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2125 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2126 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2128 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2132 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2134 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
2135 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2137 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2141 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
2143 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
2144 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
2146 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
2148 GdipDeletePath(path
);
2150 GdipDeleteRegion(region
);
2151 GdipDeleteGraphics(graphics
);
2155 static void test_excludeinfinite(void)
2159 UINT count
=0xdeadbeef;
2162 static const RectF rect_exclude
= {0.0, 0.0, 1.0, 1.0};
2164 status
= GdipCreateMatrix(&identity
);
2167 status
= GdipCreateRegion(®ion
);
2170 status
= GdipCombineRegionRect(region
, &rect_exclude
, CombineModeExclude
);
2173 status
= GdipGetRegionScansCount(region
, &count
, identity
);
2178 status
= GdipGetRegionScans(region
, scans
, (INT
*)&count
, identity
);
2181 expectf(-4194304.0, scans
[0].X
);
2182 expectf(-4194304.0, scans
[0].Y
);
2183 expectf(8388608.0, scans
[0].Width
);
2184 expectf(4194304.0, scans
[0].Height
);
2186 expectf(-4194304.0, scans
[1].X
);
2187 expectf(0.0, scans
[1].Y
);
2188 expectf(4194304.0, scans
[1].Width
);
2189 expectf(1.0, scans
[1].Height
);
2191 expectf(1.0, scans
[2].X
);
2192 expectf(0.0, scans
[2].Y
);
2193 expectf(4194303.0, scans
[2].Width
);
2194 expectf(1.0, scans
[2].Height
);
2196 expectf(-4194304.0, scans
[3].X
);
2197 expectf(1.0, scans
[3].Y
);
2198 expectf(8388608.0, scans
[3].Width
);
2199 expectf(4194303.0, scans
[3].Height
);
2201 GdipDeleteRegion(region
);
2202 GdipDeleteMatrix(identity
);
2207 struct GdiplusStartupInput gdiplusStartupInput
;
2208 ULONG_PTR gdiplusToken
;
2210 gdiplusStartupInput
.GdiplusVersion
= 1;
2211 gdiplusStartupInput
.DebugEventCallback
= NULL
;
2212 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
2213 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2215 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2217 test_getregiondata();
2220 test_combinereplace();
2228 test_isvisiblepoint();
2229 test_isvisiblerect();
2230 test_excludeinfinite();
2232 GdiplusShutdown(gdiplusToken
);