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.0001)
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 (%d,%d-%d,%d)\n",
75 rgn
.data
.rdh
.dwSize
, rgn
.data
.rdh
.iType
,
76 rgn
.data
.rdh
.nCount
, rgn
.data
.rdh
.nRgnSize
,
77 rgn
.data
.rdh
.rcBound
.left
, rgn
.data
.rdh
.rcBound
.top
,
78 rgn
.data
.rdh
.rcBound
.right
, rgn
.data
.rdh
.rcBound
.bottom
);
79 if (rgn
.data
.rdh
.nCount
!= 0)
81 rect
= (const RECT
*)rgn
.data
.Buffer
;
82 trace("rect (%d,%d-%d,%d)\n", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
83 ok(EqualRect(rect
, rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
84 rc
->left
, rc
->top
, rc
->right
, rc
->bottom
,
85 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
88 ok(rgn
.data
.rdh
.dwSize
== sizeof(rgn
.data
.rdh
), "expected sizeof(rdh), got %u\n", rgn
.data
.rdh
.dwSize
);
89 ok(rgn
.data
.rdh
.iType
== RDH_RECTANGLES
, "expected RDH_RECTANGLES, got %u\n", rgn
.data
.rdh
.iType
);
92 ok(rgn
.data
.rdh
.nCount
== 0, "expected 0, got %u\n", rgn
.data
.rdh
.nCount
);
93 ok(rgn
.data
.rdh
.nRgnSize
== 0, "expected 0, got %u\n", rgn
.data
.rdh
.nRgnSize
);
97 ok(rgn
.data
.rdh
.nCount
== 1, "expected 1, got %u\n", rgn
.data
.rdh
.nCount
);
98 ok(rgn
.data
.rdh
.nRgnSize
== sizeof(RECT
), "expected sizeof(RECT), got %u\n", rgn
.data
.rdh
.nRgnSize
);
100 ok(EqualRect(&rgn
.data
.rdh
.rcBound
, rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
101 rc
->left
, rc
->top
, rc
->right
, rc
->bottom
,
102 rgn
.data
.rdh
.rcBound
.left
, rgn
.data
.rdh
.rcBound
.top
, rgn
.data
.rdh
.rcBound
.right
, rgn
.data
.rdh
.rcBound
.bottom
);
105 static void test_getregiondata(void)
108 GpRegion
*region
, *region2
;
109 RegionDataPoint
*point
;
116 status
= GdipCreateRegion(®ion
);
117 ok(status
== Ok
, "status %08x\n", status
);
120 status
= GdipGetRegionDataSize(region
, &needed
);
121 ok(status
== Ok
, "status %08x\n", status
);
125 status
= GdipGetRegionData(region
, (BYTE
*)buf
, 0, &needed
);
126 ok(status
== InvalidParameter
, "status %08x\n", status
);
128 memset(buf
, 0xee, sizeof(buf
));
130 status
= GdipGetRegionData(region
, (BYTE
*)buf
, 4, &needed
);
131 ok(status
== InsufficientBuffer
, "status %08x\n", status
);
133 expect_dword(buf
, 0xeeeeeeee);
135 memset(buf
, 0xee, sizeof(buf
));
137 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
138 ok(status
== Ok
, "status %08x\n", status
);
140 expect_dword(buf
, 12);
141 trace("buf[1] = %08x\n", buf
[1]);
142 expect_magic(buf
+ 2);
143 expect_dword(buf
+ 3, 0);
144 expect_dword(buf
+ 4, RGNDATA_INFINITE_RECT
);
146 status
= GdipSetEmpty(region
);
147 ok(status
== Ok
, "status %08x\n", status
);
148 status
= GdipGetRegionDataSize(region
, &needed
);
149 ok(status
== Ok
, "status %08x\n", status
);
151 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
152 ok(status
== Ok
, "status %08x\n", status
);
154 expect_dword(buf
, 12);
155 trace("buf[1] = %08x\n", buf
[1]);
156 expect_magic(buf
+ 2);
157 expect_dword(buf
+ 3, 0);
158 expect_dword(buf
+ 4, RGNDATA_EMPTY_RECT
);
160 status
= GdipSetInfinite(region
);
161 ok(status
== Ok
, "status %08x\n", status
);
162 status
= GdipGetRegionDataSize(region
, &needed
);
163 ok(status
== Ok
, "status %08x\n", status
);
165 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
166 ok(status
== Ok
, "status %08x\n", status
);
168 expect_dword(buf
, 12);
169 trace("buf[1] = %08x\n", buf
[1]);
170 expect_magic(buf
+ 2);
171 expect_dword(buf
+ 3, 0);
172 expect_dword(buf
+ 4, RGNDATA_INFINITE_RECT
);
174 status
= GdipDeleteRegion(region
);
175 ok(status
== Ok
, "status %08x\n", status
);
181 status
= GdipCreateRegionRectI(&rect
, ®ion
);
182 ok(status
== Ok
, "status %08x\n", status
);
183 status
= GdipGetRegionDataSize(region
, &needed
);
184 ok(status
== Ok
, "status %08x\n", status
);
186 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
187 ok(status
== Ok
, "status %08x\n", status
);
189 expect_dword(buf
, 28);
190 trace("buf[1] = %08x\n", buf
[1]);
191 expect_magic(buf
+ 2);
192 expect_dword(buf
+ 3, 0);
193 expect_dword(buf
+ 4, RGNDATA_RECT
);
194 expect_float(buf
+ 5, 10.0);
195 expect_float(buf
+ 6, 20.0);
196 expect_float(buf
+ 7, 100.0);
197 expect_float(buf
+ 8, 200.0);
203 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeIntersect
);
204 ok(status
== Ok
, "status %08x\n", status
);
209 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeXor
);
210 ok(status
== Ok
, "status %08x\n", status
);
216 status
= GdipCreateRegionRectI(&rect
, ®ion2
);
217 ok(status
== Ok
, "status %08x\n", status
);
222 status
= GdipCombineRegionRectI(region2
, &rect
, CombineModeUnion
);
223 ok(status
== Ok
, "status %08x\n", status
);
225 status
= GdipCombineRegionRegion(region
, region2
, CombineModeComplement
);
226 ok(status
== Ok
, "status %08x\n", status
);
232 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeExclude
);
233 ok(status
== Ok
, "status %08x\n", status
);
235 status
= GdipGetRegionDataSize(region
, &needed
);
236 ok(status
== Ok
, "status %08x\n", status
);
238 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
239 ok(status
== Ok
, "status %08x\n", status
);
241 expect_dword(buf
, 148);
242 trace("buf[1] = %08x\n", buf
[1]);
243 expect_magic(buf
+ 2);
244 expect_dword(buf
+ 3, 10);
245 expect_dword(buf
+ 4, CombineModeExclude
);
246 expect_dword(buf
+ 5, CombineModeComplement
);
247 expect_dword(buf
+ 6, CombineModeXor
);
248 expect_dword(buf
+ 7, CombineModeIntersect
);
249 expect_dword(buf
+ 8, RGNDATA_RECT
);
250 expect_float(buf
+ 9, 10.0);
251 expect_float(buf
+ 10, 20.0);
252 expect_float(buf
+ 11, 100.0);
253 expect_float(buf
+ 12, 200.0);
254 expect_dword(buf
+ 13, RGNDATA_RECT
);
255 expect_float(buf
+ 14, 50.0);
256 expect_float(buf
+ 15, 30.0);
257 expect_float(buf
+ 16, 10.0);
258 expect_float(buf
+ 17, 20.0);
259 expect_dword(buf
+ 18, RGNDATA_RECT
);
260 expect_float(buf
+ 19, 100.0);
261 expect_float(buf
+ 20, 300.0);
262 expect_float(buf
+ 21, 30.0);
263 expect_float(buf
+ 22, 50.0);
264 expect_dword(buf
+ 23, CombineModeUnion
);
265 expect_dword(buf
+ 24, RGNDATA_RECT
);
266 expect_float(buf
+ 25, 200.0);
267 expect_float(buf
+ 26, 100.0);
268 expect_float(buf
+ 27, 133.0);
269 expect_float(buf
+ 28, 266.0);
270 expect_dword(buf
+ 29, RGNDATA_RECT
);
271 expect_float(buf
+ 30, 20.0);
272 expect_float(buf
+ 31, 10.0);
273 expect_float(buf
+ 32, 40.0);
274 expect_float(buf
+ 33, 66.0);
275 expect_dword(buf
+ 34, RGNDATA_RECT
);
276 expect_float(buf
+ 35, 400.0);
277 expect_float(buf
+ 36, 500.0);
278 expect_float(buf
+ 37, 22.0);
279 expect_float(buf
+ 38, 55.0);
281 status
= GdipDeleteRegion(region2
);
282 ok(status
== Ok
, "status %08x\n", status
);
283 status
= GdipDeleteRegion(region
);
284 ok(status
== Ok
, "status %08x\n", status
);
288 status
= GdipCreatePath(FillModeAlternate
, &path
);
289 ok(status
== Ok
, "status %08x\n", status
);
290 GdipAddPathRectangle(path
, 12.5, 13.0, 14.0, 15.0);
292 status
= GdipCreateRegionPath(path
, ®ion
);
293 ok(status
== Ok
, "status %08x\n", status
);
294 status
= GdipGetRegionDataSize(region
, &needed
);
295 ok(status
== Ok
, "status %08x\n", status
);
297 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
298 ok(status
== Ok
, "status %08x\n", status
);
300 expect_dword(buf
, 64);
301 trace("buf[1] = %08x\n", buf
[1]);
302 expect_magic(buf
+ 2);
303 expect_dword(buf
+ 3, 0);
304 expect_dword(buf
+ 4, RGNDATA_PATH
);
305 expect_dword(buf
+ 5, 0x00000030);
306 expect_magic(buf
+ 6);
307 expect_dword(buf
+ 7, 0x00000004);
308 expect_dword(buf
+ 8, 0x00000000);
309 expect_float(buf
+ 9, 12.5);
310 expect_float(buf
+ 10, 13.0);
311 expect_float(buf
+ 11, 26.5);
312 expect_float(buf
+ 12, 13.0);
313 expect_float(buf
+ 13, 26.5);
314 expect_float(buf
+ 14, 28.0);
315 expect_float(buf
+ 15, 12.5);
316 expect_float(buf
+ 16, 28.0);
317 expect_dword(buf
+ 17, 0x81010100);
323 status
= GdipCombineRegionRectI(region
, &rect
, CombineModeIntersect
);
324 ok(status
== Ok
, "status %08x\n", status
);
325 status
= GdipGetRegionDataSize(region
, &needed
);
326 ok(status
== Ok
, "status %08x\n", status
);
328 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
329 ok(status
== Ok
, "status %08x\n", status
);
331 expect_dword(buf
, 88);
332 trace("buf[1] = %08x\n", buf
[1]);
333 expect_magic(buf
+ 2);
334 expect_dword(buf
+ 3, 2);
335 expect_dword(buf
+ 4, CombineModeIntersect
);
336 expect_dword(buf
+ 5, RGNDATA_PATH
);
337 expect_dword(buf
+ 6, 0x00000030);
338 expect_magic(buf
+ 7);
339 expect_dword(buf
+ 8, 0x00000004);
340 expect_dword(buf
+ 9, 0x00000000);
341 expect_float(buf
+ 10, 12.5);
342 expect_float(buf
+ 11, 13.0);
343 expect_float(buf
+ 12, 26.5);
344 expect_float(buf
+ 13, 13.0);
345 expect_float(buf
+ 14, 26.5);
346 expect_float(buf
+ 15, 28.0);
347 expect_float(buf
+ 16, 12.5);
348 expect_float(buf
+ 17, 28.0);
349 expect_dword(buf
+ 18, 0x81010100);
350 expect_dword(buf
+ 19, RGNDATA_RECT
);
351 expect_float(buf
+ 20, 50.0);
352 expect_float(buf
+ 21, 30.0);
353 expect_float(buf
+ 22, 10.0);
354 expect_float(buf
+ 23, 20.0);
356 status
= GdipDeleteRegion(region
);
357 ok(status
== Ok
, "status %08x\n", status
);
358 status
= GdipDeletePath(path
);
359 ok(status
== Ok
, "status %08x\n", status
);
361 /* Test an empty path */
362 status
= GdipCreatePath(FillModeAlternate
, &path
);
364 status
= GdipCreateRegionPath(path
, ®ion
);
366 status
= GdipGetRegionDataSize(region
, &needed
);
369 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
372 expect_dword(buf
, 28);
373 trace("buf[1] = %08x\n", buf
[1]);
374 expect_magic(buf
+ 2);
375 expect_dword(buf
+ 3, 0);
376 expect_dword(buf
+ 4, RGNDATA_PATH
);
377 /* Second signature for pathdata */
378 expect_dword(buf
+ 5, 12);
379 expect_magic(buf
+ 6);
380 expect_dword(buf
+ 7, 0);
381 /* flags 0 means that a path is an array of FLOATs */
382 ok(*(buf
+ 8) == 0x4000 /* before win7 */ || *(buf
+ 8) == 0,
383 "expected 0x4000 or 0, got %08x\n", *(buf
+ 8));
385 /* Transform an empty region */
386 status
= GdipCreateMatrix(&matrix
);
388 status
= GdipTransformRegion(region
, matrix
);
390 GdipDeleteMatrix(matrix
);
392 status
= GdipDeleteRegion(region
);
395 /* Test a simple triangle of INTs */
396 status
= GdipAddPathLine(path
, 5, 6, 7, 8);
398 status
= GdipAddPathLine(path
, 8, 1, 5, 6);
400 status
= GdipClosePathFigure(path
);
402 status
= GdipCreateRegionPath(path
, ®ion
);
404 status
= GdipGetRegionDataSize(region
, &needed
);
407 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
410 expect_dword(buf
, 48);
411 trace("buf[1] = %08x\n", buf
[1]);
412 expect_magic(buf
+ 2);
413 expect_dword(buf
+ 3 , 0);
414 expect_dword(buf
+ 4 , RGNDATA_PATH
);
415 expect_dword(buf
+ 5, 32);
416 expect_magic(buf
+ 6);
417 expect_dword(buf
+ 7, 4);
418 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
419 expect_dword(buf
+ 8, 0x4000);
421 point
= (RegionDataPoint
*)(buf
+ 9);
422 expect(5, point
[0].X
);
423 expect(6, point
[0].Y
);
424 expect(7, point
[1].X
); /* buf + 10 */
425 expect(8, point
[1].Y
);
426 expect(8, point
[2].X
); /* buf + 11 */
427 expect(1, point
[2].Y
);
428 expect(5, point
[3].X
); /* buf + 12 */
429 expect(6, point
[3].Y
);
430 expect_dword(buf
+ 13, 0x81010100); /* 0x01010100 if we don't close the path */
432 status
= GdipTranslateRegion(region
, 0.6, 0.8);
434 memset(buf
, 0, sizeof(buf
));
436 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
439 expect_dword(buf
, 64);
440 expect_magic(buf
+ 2);
441 expect_dword(buf
+ 3 , 0);
442 expect_dword(buf
+ 4 , RGNDATA_PATH
);
443 expect_dword(buf
+ 5, 48);
444 expect_magic(buf
+ 6);
445 expect_dword(buf
+ 7, 4);
446 /* flags 0 means that a path is an array of FLOATs */
447 expect_dword(buf
+ 8, 0);
448 expect_float(buf
+ 9, 5.6);
449 expect_float(buf
+ 10, 6.8);
450 expect_float(buf
+ 11, 7.6);
451 expect_float(buf
+ 12, 8.8);
452 expect_float(buf
+ 13, 8.6);
453 expect_float(buf
+ 14, 1.8);
454 expect_float(buf
+ 15, 5.6);
455 expect_float(buf
+ 16, 6.8);
456 expect_dword(buf
+ 17, 0x81010100); /* 0x01010100 if we don't close the path */
458 status
= GdipDeletePath(path
);
460 status
= GdipDeleteRegion(region
);
463 /* Test a floating-point triangle */
464 status
= GdipCreatePath(FillModeAlternate
, &path
);
466 status
= GdipAddPathLine(path
, 5.6, 6.2, 7.2, 8.9);
468 status
= GdipAddPathLine(path
, 8.1, 1.6, 5.6, 6.2);
470 status
= GdipCreateRegionPath(path
, ®ion
);
472 status
= GdipGetRegionDataSize(region
, &needed
);
475 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
478 expect_dword(buf
, 64);
479 trace("buf[1] = %08x\n", buf
[1]);
480 expect_magic(buf
+ 2);
481 expect_dword(buf
+ 3, 0);
482 expect_dword(buf
+ 4, RGNDATA_PATH
);
484 expect_dword(buf
+ 5, 48);
485 expect_magic(buf
+ 6);
486 expect_dword(buf
+ 7, 4);
487 expect_dword(buf
+ 8, 0);
488 expect_float(buf
+ 9, 5.6);
489 expect_float(buf
+ 10, 6.2);
490 expect_float(buf
+ 11, 7.2);
491 expect_float(buf
+ 12, 8.9);
492 expect_float(buf
+ 13, 8.1);
493 expect_float(buf
+ 14, 1.6);
494 expect_float(buf
+ 15, 5.6);
495 expect_float(buf
+ 16, 6.2);
497 status
= GdipDeletePath(path
);
499 status
= GdipDeleteRegion(region
);
502 /* Test for a path with > 4 points, and CombineRegionPath */
503 GdipCreatePath(FillModeAlternate
, &path
);
504 status
= GdipAddPathLine(path
, 50, 70.2, 60, 102.8);
506 status
= GdipAddPathLine(path
, 55.4, 122.4, 40.4, 60.2);
508 status
= GdipAddPathLine(path
, 45.6, 20.2, 50, 70.2);
514 status
= GdipCreateRegionRectI(&rect
, ®ion
);
516 status
= GdipCombineRegionPath(region
, path
, CombineModeUnion
);
519 status
= GdipGetRegionDataSize(region
, &needed
);
522 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
525 expect_dword(buf
, 108);
526 trace("buf[1] = %08x\n", buf
[1]);
527 expect_magic(buf
+ 2);
528 expect_dword(buf
+ 3, 2);
529 expect_dword(buf
+ 4, CombineModeUnion
);
530 expect_dword(buf
+ 5, RGNDATA_RECT
);
531 expect_float(buf
+ 6, 20.0);
532 expect_float(buf
+ 7, 25.0);
533 expect_float(buf
+ 8, 60.0);
534 expect_float(buf
+ 9, 120.0);
535 expect_dword(buf
+ 10, RGNDATA_PATH
);
537 expect_dword(buf
+ 11, 68);
538 expect_magic(buf
+ 12);
539 expect_dword(buf
+ 13, 6);
540 expect_float(buf
+ 14, 0.0);
542 expect_float(buf
+ 15, 50.0);
543 expect_float(buf
+ 16, 70.2);
544 expect_float(buf
+ 17, 60.0);
545 expect_float(buf
+ 18, 102.8);
546 expect_float(buf
+ 19, 55.4);
547 expect_float(buf
+ 20, 122.4);
548 expect_float(buf
+ 21, 40.4);
549 expect_float(buf
+ 22, 60.2);
550 expect_float(buf
+ 23, 45.6);
551 expect_float(buf
+ 24, 20.2);
552 expect_float(buf
+ 25, 50.0);
553 expect_float(buf
+ 26, 70.2);
554 expect_dword(buf
+ 27, 0x01010100);
555 ok(*(buf
+ 28) == 0x00000101 || *(buf
+ 28) == 0x43050101 /* Win 7 */,
556 "expected 00000101 or 43050101 got %08x\n", *(buf
+ 28));
558 status
= GdipDeletePath(path
);
560 status
= GdipDeleteRegion(region
);
563 /* Test how shorts are stored in the region path data */
564 status
= GdipCreatePath(FillModeAlternate
, &path
);
565 ok(status
== Ok
, "status %08x\n", status
);
566 GdipAddPathRectangleI(path
, -1969, -1974, 1995, 1997);
568 status
= GdipCreateRegionPath(path
, ®ion
);
569 ok(status
== Ok
, "status %08x\n", status
);
571 status
= GdipGetRegionDataSize(region
, &needed
);
572 ok(status
== Ok
, "status %08x\n", status
);
574 memset(buf
, 0xee, sizeof(buf
));
576 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
577 ok(status
== Ok
, "status %08x\n", status
);
579 expect_dword(buf
, 48);
580 trace("buf[1] = %08x\n", buf
[1]);
581 expect_magic(buf
+ 2);
582 expect_dword(buf
+ 3, 0);
583 expect_dword(buf
+ 4, RGNDATA_PATH
);
584 expect_dword(buf
+ 5, 32);
585 expect_magic(buf
+ 6);
586 expect_dword(buf
+ 7, 4);
587 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
588 expect_dword(buf
+ 8, 0x4000);
589 point
= (RegionDataPoint
*)(buf
+ 9);
590 expect(-1969, point
[0].X
);
591 expect(-1974, point
[0].Y
);
592 expect(26, point
[1].X
); /* buf + 10 */
593 expect(-1974, point
[1].Y
);
594 expect(26, point
[2].X
); /* buf + 11 */
595 expect(23, point
[2].Y
);
596 expect(-1969, point
[3].X
); /* buf + 12 */
597 expect(23, point
[3].Y
);
598 expect_dword(buf
+ 13, 0x81010100); /* 0x01010100 if we don't close the path */
600 status
= GdipDeletePath(path
);
602 status
= GdipDeleteRegion(region
);
605 /* Test with integers that can't be stored as shorts */
606 status
= GdipCreatePath(FillModeAlternate
, &path
);
607 ok(status
== Ok
, "status %08x\n", status
);
608 GdipAddPathRectangleI(path
, -196900, -197400, 199500, 199700);
610 status
= GdipCreateRegionPath(path
, ®ion
);
611 ok(status
== Ok
, "status %08x\n", status
);
613 status
= GdipGetRegionDataSize(region
, &needed
);
614 ok(status
== Ok
, "status %08x\n", status
);
616 memset(buf
, 0xee, sizeof(buf
));
618 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
619 ok(status
== Ok
, "status %08x\n", status
);
621 expect_dword(buf
, 64);
622 trace("buf[1] = %08x\n", buf
[1]);
623 expect_magic(buf
+ 2);
624 expect_dword(buf
+ 3, 0);
625 expect_dword(buf
+ 4, RGNDATA_PATH
);
626 expect_dword(buf
+ 5, 48);
627 expect_magic(buf
+ 6);
628 expect_dword(buf
+ 7, 4);
629 /* flags 0 means that a path is an array of FLOATs */
630 expect_dword(buf
+ 8, 0);
631 expect_float(buf
+ 9, -196900.0);
632 expect_float(buf
+ 10, -197400.0);
633 expect_float(buf
+ 11, 2600.0);
634 expect_float(buf
+ 12, -197400.0);
635 expect_float(buf
+ 13, 2600.0);
636 expect_float(buf
+ 14, 2300.0);
637 expect_float(buf
+ 15, -196900.0);
638 expect_float(buf
+ 16, 2300.0);
639 expect_dword(buf
+ 17, 0x81010100); /* 0x01010100 if we don't close the path */
641 status
= GdipDeletePath(path
);
643 status
= GdipDeleteRegion(region
);
647 static void test_isinfinite(void)
651 GpGraphics
*graphics
= NULL
;
656 status
= GdipCreateFromHDC(hdc
, &graphics
);
658 GdipCreateRegion(®ion
);
660 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m
);
663 status
= GdipIsInfiniteRegion(NULL
, NULL
, NULL
);
664 expect(InvalidParameter
, status
);
665 status
= GdipIsInfiniteRegion(region
, NULL
, NULL
);
666 expect(InvalidParameter
, status
);
667 status
= GdipIsInfiniteRegion(NULL
, graphics
, NULL
);
668 expect(InvalidParameter
, status
);
669 status
= GdipIsInfiniteRegion(NULL
, NULL
, &res
);
670 expect(InvalidParameter
, status
);
671 status
= GdipIsInfiniteRegion(region
, NULL
, &res
);
672 expect(InvalidParameter
, status
);
675 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
679 /* after world transform */
680 status
= GdipSetWorldTransform(graphics
, m
);
684 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
689 GdipDeleteRegion(region
);
690 GdipDeleteGraphics(graphics
);
694 static void test_isempty(void)
698 GpGraphics
*graphics
= NULL
;
702 status
= GdipCreateFromHDC(hdc
, &graphics
);
704 GdipCreateRegion(®ion
);
707 status
= GdipIsEmptyRegion(NULL
, NULL
, NULL
);
708 expect(InvalidParameter
, status
);
709 status
= GdipIsEmptyRegion(region
, NULL
, NULL
);
710 expect(InvalidParameter
, status
);
711 status
= GdipIsEmptyRegion(NULL
, graphics
, NULL
);
712 expect(InvalidParameter
, status
);
713 status
= GdipIsEmptyRegion(NULL
, NULL
, &res
);
714 expect(InvalidParameter
, status
);
715 status
= GdipIsEmptyRegion(region
, NULL
, &res
);
716 expect(InvalidParameter
, status
);
718 /* default is infinite */
720 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
724 status
= GdipSetEmpty(region
);
728 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
732 GdipDeleteRegion(region
);
733 GdipDeleteGraphics(graphics
);
737 static void test_combinereplace(void)
740 GpRegion
*region
, *region2
;
746 rectf
.X
= rectf
.Y
= 0.0;
747 rectf
.Width
= rectf
.Height
= 100.0;
749 status
= GdipCreateRegionRect(&rectf
, ®ion
);
752 /* replace with the same rectangle */
753 status
= GdipCombineRegionRect(region
, &rectf
,CombineModeReplace
);
756 status
= GdipGetRegionDataSize(region
, &needed
);
759 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
762 expect_dword(buf
, 28);
763 trace("buf[1] = %08x\n", buf
[1]);
764 expect_magic(buf
+ 2);
765 expect_dword(buf
+ 3, 0);
766 expect_dword(buf
+ 4, RGNDATA_RECT
);
768 /* replace with path */
769 status
= GdipCreatePath(FillModeAlternate
, &path
);
771 status
= GdipAddPathEllipse(path
, 0.0, 0.0, 100.0, 250.0);
773 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
776 status
= GdipGetRegionDataSize(region
, &needed
);
779 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
782 expect_dword(buf
, 148);
783 trace("buf[1] = %08x\n", buf
[1]);
784 expect_magic(buf
+ 2);
785 expect_dword(buf
+ 3, 0);
786 expect_dword(buf
+ 4, RGNDATA_PATH
);
787 GdipDeletePath(path
);
789 /* replace with infinite rect */
790 status
= GdipCreateRegion(®ion2
);
792 status
= GdipCombineRegionRegion(region
, region2
, CombineModeReplace
);
795 status
= GdipGetRegionDataSize(region
, &needed
);
798 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
801 expect_dword(buf
, 12);
802 trace("buf[1] = %08x\n", buf
[1]);
803 expect_magic(buf
+ 2);
804 expect_dword(buf
+ 3, 0);
805 expect_dword(buf
+ 4, RGNDATA_INFINITE_RECT
);
806 GdipDeleteRegion(region2
);
808 /* more complex case : replace with a combined region */
809 status
= GdipCreateRegionRect(&rectf
, ®ion2
);
811 status
= GdipCreatePath(FillModeAlternate
, &path
);
813 status
= GdipAddPathEllipse(path
, 0.0, 0.0, 100.0, 250.0);
815 status
= GdipCombineRegionPath(region2
, path
, CombineModeUnion
);
817 GdipDeletePath(path
);
818 status
= GdipCombineRegionRegion(region
, region2
, CombineModeReplace
);
820 GdipDeleteRegion(region2
);
822 status
= GdipGetRegionDataSize(region
, &needed
);
825 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
828 expect_dword(buf
, 172);
829 trace("buf[1] = %08x\n", buf
[1]);
830 expect_magic(buf
+ 2);
831 expect_dword(buf
+ 3, 2);
832 expect_dword(buf
+ 4, CombineModeUnion
);
834 GdipDeleteRegion(region
);
837 static void test_fromhrgn(void)
840 GpRegion
*region
= (GpRegion
*)0xabcdef01;
844 RegionDataPoint
*point
;
845 GpGraphics
*graphics
= NULL
;
850 status
= GdipCreateRegionHrgn(NULL
, NULL
);
851 expect(InvalidParameter
, status
);
852 status
= GdipCreateRegionHrgn(NULL
, ®ion
);
853 expect(InvalidParameter
, status
);
854 status
= GdipCreateRegionHrgn((HRGN
)0xdeadbeef, ®ion
);
855 expect(InvalidParameter
, status
);
856 ok(region
== (GpRegion
*)0xabcdef01, "Expected region not to be created\n");
858 /* empty rectangle */
859 hrgn
= CreateRectRgn(0, 0, 0, 0);
860 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
865 status
= GdipCreateFromHDC(hdc
, &graphics
);
868 status
= GdipIsEmptyRegion(region
, graphics
, &res
);
871 GdipDeleteGraphics(graphics
);
873 GdipDeleteRegion(region
);
879 hrgn
= CreateRectRgn(0, 0, 100, 10);
880 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
883 status
= GdipGetRegionDataSize(region
, &needed
);
887 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
893 expect_dword(buf
, 48);
894 expect_magic(buf
+ 2);
895 expect_dword(buf
+ 3, 0);
896 expect_dword(buf
+ 4, RGNDATA_PATH
);
897 expect_dword(buf
+ 5, 0x00000020);
898 expect_magic(buf
+ 6);
899 expect_dword(buf
+ 7, 0x00000004);
900 todo_wine
expect_dword(buf
+ 8, 0x00006000); /* ?? */
902 point
= (RegionDataPoint
*)buf
+ 9;
904 expect(0, point
[0].X
);
905 expect(0, point
[0].Y
);
907 expect(100,point
[1].X
); /* buf + 10 */
908 expect(0, point
[1].Y
);
909 expect(100,point
[2].X
); /* buf + 11 */
910 expect(10, point
[2].Y
);
912 expect(0, point
[3].X
); /* buf + 12 */
914 expect(10, point
[3].Y
);
915 expect_dword(buf
+ 13, 0x81010100); /* closed */
919 GdipDeleteRegion(region
);
923 hrgn
= CreateEllipticRgn(0, 0, 100, 10);
924 status
= GdipCreateRegionHrgn(hrgn
, ®ion
);
927 status
= GdipGetRegionDataSize(region
, &needed
);
930 needed
== 196, /* win98 */
931 "Got %.8x\n", needed
);
933 status
= GdipGetRegionData(region
, (BYTE
*)buf
, sizeof(buf
), &needed
);
936 if(status
== Ok
&& needed
== 216) /* Don't try to test win98 layout */
940 expect_dword(buf
, 208);
941 expect_magic(buf
+ 2);
942 expect_dword(buf
+ 3, 0);
943 expect_dword(buf
+ 4, RGNDATA_PATH
);
944 expect_dword(buf
+ 5, 0x000000C0);
945 expect_magic(buf
+ 6);
946 expect_dword(buf
+ 7, 0x00000024);
947 todo_wine
expect_dword(buf
+ 8, 0x00006000); /* ?? */
950 GdipDeleteRegion(region
);
954 static void test_gethrgn(void)
957 GpRegion
*region
, *region2
;
959 GpGraphics
*graphics
;
962 static const RECT empty_rect
= {0,0,0,0};
963 static const RECT test_rect
= {10, 11, 20, 21};
964 static const GpRectF test_rectF
= {10.0, 11.0, 10.0, 10.0};
965 static const RECT scaled_rect
= {20, 22, 40, 42};
966 static const RECT test_rect2
= {10, 21, 20, 31};
967 static const GpRectF test_rect2F
= {10.0, 21.0, 10.0, 10.0};
968 static const RECT test_rect3
= {10, 11, 20, 31};
969 static const GpRectF test_rect3F
= {10.0, 11.0, 10.0, 20.0};
971 status
= GdipCreateFromHDC(hdc
, &graphics
);
972 ok(status
== Ok
, "status %08x\n", status
);
974 status
= GdipCreateRegion(®ion
);
975 ok(status
== Ok
, "status %08x\n", status
);
977 status
= GdipGetRegionHRgn(NULL
, graphics
, &hrgn
);
978 ok(status
== InvalidParameter
, "status %08x\n", status
);
979 status
= GdipGetRegionHRgn(region
, graphics
, NULL
);
980 ok(status
== InvalidParameter
, "status %08x\n", status
);
982 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
983 ok(status
== Ok
, "status %08x\n", status
);
984 ok(hrgn
== NULL
, "hrgn=%p\n", hrgn
);
986 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
987 ok(status
== Ok
, "status %08x\n", status
);
988 ok(hrgn
== NULL
, "hrgn=%p\n", hrgn
);
990 status
= GdipSetEmpty(region
);
991 ok(status
== Ok
, "status %08x\n", status
);
992 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
993 ok(status
== Ok
, "status %08x\n", status
);
994 verify_region(hrgn
, &empty_rect
);
997 status
= GdipCreatePath(FillModeAlternate
, &path
);
998 ok(status
== Ok
, "status %08x\n", status
);
999 status
= GdipAddPathRectangle(path
, 10.0, 11.0, 10.0, 10.0);
1000 ok(status
== Ok
, "status %08x\n", status
);
1002 status
= GdipCreateRegionPath(path
, ®ion2
);
1003 ok(status
== Ok
, "status %08x\n", status
);
1004 status
= GdipGetRegionHRgn(region2
, NULL
, &hrgn
);
1005 ok(status
== Ok
, "status %08x\n", status
);
1006 verify_region(hrgn
, &test_rect
);
1009 /* resulting HRGN is in device coordinates */
1010 status
= GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
1011 ok(status
== Ok
, "status %08x\n", status
);
1012 status
= GdipGetRegionHRgn(region2
, graphics
, &hrgn
);
1013 ok(status
== Ok
, "status %08x\n", status
);
1014 verify_region(hrgn
, &scaled_rect
);
1017 status
= GdipCombineRegionRect(region2
, &test_rectF
, CombineModeReplace
);
1018 ok(status
== Ok
, "status %08x\n", status
);
1019 status
= GdipGetRegionHRgn(region2
, NULL
, &hrgn
);
1020 ok(status
== Ok
, "status %08x\n", status
);
1021 verify_region(hrgn
, &test_rect
);
1024 status
= GdipGetRegionHRgn(region2
, graphics
, &hrgn
);
1025 ok(status
== Ok
, "status %08x\n", status
);
1026 verify_region(hrgn
, &scaled_rect
);
1029 status
= GdipSetInfinite(region
);
1030 ok(status
== Ok
, "status %08x\n", status
);
1031 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeIntersect
);
1032 ok(status
== Ok
, "status %08x\n", status
);
1033 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1034 ok(status
== Ok
, "status %08x\n", status
);
1035 verify_region(hrgn
, &test_rect
);
1038 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeReplace
);
1039 ok(status
== Ok
, "status %08x\n", status
);
1040 status
= GdipCombineRegionRect(region
, &test_rect2F
, CombineModeUnion
);
1041 ok(status
== Ok
, "status %08x\n", status
);
1042 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1043 ok(status
== Ok
, "status %08x\n", status
);
1044 verify_region(hrgn
, &test_rect3
);
1047 status
= GdipCombineRegionRect(region
, &test_rect3F
, CombineModeReplace
);
1048 ok(status
== Ok
, "status %08x\n", status
);
1049 status
= GdipCombineRegionRect(region
, &test_rect2F
, CombineModeXor
);
1050 ok(status
== Ok
, "status %08x\n", status
);
1051 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1052 ok(status
== Ok
, "status %08x\n", status
);
1053 verify_region(hrgn
, &test_rect
);
1056 status
= GdipCombineRegionRect(region
, &test_rect3F
, CombineModeReplace
);
1057 ok(status
== Ok
, "status %08x\n", status
);
1058 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeExclude
);
1059 ok(status
== Ok
, "status %08x\n", status
);
1060 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1061 ok(status
== Ok
, "status %08x\n", status
);
1062 verify_region(hrgn
, &test_rect2
);
1065 status
= GdipCombineRegionRect(region
, &test_rectF
, CombineModeReplace
);
1066 ok(status
== Ok
, "status %08x\n", status
);
1067 status
= GdipCombineRegionRect(region
, &test_rect3F
, CombineModeComplement
);
1068 ok(status
== Ok
, "status %08x\n", status
);
1069 status
= GdipGetRegionHRgn(region
, NULL
, &hrgn
);
1070 ok(status
== Ok
, "status %08x\n", status
);
1071 verify_region(hrgn
, &test_rect2
);
1074 status
= GdipDeletePath(path
);
1075 ok(status
== Ok
, "status %08x\n", status
);
1076 status
= GdipDeleteRegion(region
);
1077 ok(status
== Ok
, "status %08x\n", status
);
1078 status
= GdipDeleteRegion(region2
);
1079 ok(status
== Ok
, "status %08x\n", status
);
1080 status
= GdipDeleteGraphics(graphics
);
1081 ok(status
== Ok
, "status %08x\n", status
);
1085 static void test_isequal(void)
1087 GpRegion
*region1
, *region2
;
1088 GpGraphics
*graphics
;
1094 status
= GdipCreateFromHDC(hdc
, &graphics
);
1095 ok(status
== Ok
, "status %08x\n", status
);
1097 status
= GdipCreateRegion(®ion1
);
1098 ok(status
== Ok
, "status %08x\n", status
);
1099 status
= GdipCreateRegion(®ion2
);
1100 ok(status
== Ok
, "status %08x\n", status
);
1103 status
= GdipIsEqualRegion(NULL
, NULL
, NULL
, NULL
);
1104 ok(status
== InvalidParameter
, "status %08x\n", status
);
1105 status
= GdipIsEqualRegion(region1
, region2
, NULL
, NULL
);
1106 ok(status
== InvalidParameter
, "status %08x\n", status
);
1107 status
= GdipIsEqualRegion(region1
, region2
, graphics
, NULL
);
1108 ok(status
== InvalidParameter
, "status %08x\n", status
);
1109 status
= GdipIsEqualRegion(region1
, region2
, NULL
, &res
);
1110 ok(status
== InvalidParameter
, "status %08x\n", status
);
1112 /* infinite regions */
1114 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1115 ok(status
== Ok
, "status %08x\n", status
);
1116 ok(res
, "Expected to be equal.\n");
1118 status
= GdipSetEmpty(region1
);
1119 ok(status
== Ok
, "status %08x\n", status
);
1120 status
= GdipSetEmpty(region2
);
1121 ok(status
== Ok
, "status %08x\n", status
);
1123 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1124 ok(status
== Ok
, "status %08x\n", status
);
1125 ok(res
, "Expected to be equal.\n");
1126 /* empty & infinite */
1127 status
= GdipSetInfinite(region1
);
1128 ok(status
== Ok
, "status %08x\n", status
);
1130 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1131 ok(status
== Ok
, "status %08x\n", status
);
1132 ok(!res
, "Expected to be unequal.\n");
1133 /* rect & (inf/empty) */
1134 rectf
.X
= rectf
.Y
= 0.0;
1135 rectf
.Width
= rectf
.Height
= 100.0;
1136 status
= GdipCombineRegionRect(region1
, &rectf
, CombineModeReplace
);
1137 ok(status
== Ok
, "status %08x\n", status
);
1139 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1140 ok(status
== Ok
, "status %08x\n", status
);
1141 ok(!res
, "Expected to be unequal.\n");
1142 status
= GdipSetInfinite(region2
);
1143 ok(status
== Ok
, "status %08x\n", status
);
1145 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1146 ok(status
== Ok
, "status %08x\n", status
);
1147 ok(!res
, "Expected to be unequal.\n");
1148 /* roughly equal rectangles */
1149 rectf
.X
= rectf
.Y
= 0.0;
1150 rectf
.Width
= rectf
.Height
= 100.001;
1151 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1152 ok(status
== Ok
, "status %08x\n", status
);
1154 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1155 ok(status
== Ok
, "status %08x\n", status
);
1156 ok(res
, "Expected to be equal.\n");
1157 /* equal rectangles */
1158 rectf
.X
= rectf
.Y
= 0.0;
1159 rectf
.Width
= rectf
.Height
= 100.0;
1160 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1161 ok(status
== Ok
, "status %08x\n", status
);
1163 status
= GdipIsEqualRegion(region1
, region2
, graphics
, &res
);
1164 ok(status
== Ok
, "status %08x\n", status
);
1165 ok(res
, "Expected to be equal.\n");
1168 status
= GdipDeleteRegion(region1
);
1169 ok(status
== Ok
, "status %08x\n", status
);
1170 status
= GdipDeleteRegion(region2
);
1171 ok(status
== Ok
, "status %08x\n", status
);
1172 status
= GdipDeleteGraphics(graphics
);
1173 ok(status
== Ok
, "status %08x\n", status
);
1177 static void test_translate(void)
1179 GpRegion
*region
, *region2
;
1180 GpGraphics
*graphics
;
1187 status
= GdipCreateFromHDC(hdc
, &graphics
);
1188 ok(status
== Ok
, "status %08x\n", status
);
1190 status
= GdipCreatePath(FillModeAlternate
, &path
);
1191 ok(status
== Ok
, "status %08x\n", status
);
1193 status
= GdipCreateRegion(®ion
);
1194 ok(status
== Ok
, "status %08x\n", status
);
1195 status
= GdipCreateRegion(®ion2
);
1196 ok(status
== Ok
, "status %08x\n", status
);
1199 status
= GdipTranslateRegion(NULL
, 0.0, 0.0);
1200 ok(status
== InvalidParameter
, "status %08x\n", status
);
1203 status
= GdipTranslateRegion(region
, 10.0, 10.0);
1204 ok(status
== Ok
, "status %08x\n", status
);
1206 status
= GdipSetEmpty(region
);
1207 ok(status
== Ok
, "status %08x\n", status
);
1208 status
= GdipTranslateRegion(region
, 10.0, 10.0);
1209 ok(status
== Ok
, "status %08x\n", status
);
1211 rectf
.X
= 10.0; rectf
.Y
= 0.0;
1212 rectf
.Width
= rectf
.Height
= 100.0;
1213 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1214 ok(status
== Ok
, "status %08x\n", status
);
1215 rectf
.X
= 15.0; rectf
.Y
= -2.0;
1216 rectf
.Width
= rectf
.Height
= 100.0;
1217 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1218 ok(status
== Ok
, "status %08x\n", status
);
1219 status
= GdipTranslateRegion(region
, 5.0, -2.0);
1220 ok(status
== Ok
, "status %08x\n", status
);
1222 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1223 ok(status
== Ok
, "status %08x\n", status
);
1224 ok(res
, "Expected to be equal.\n");
1226 status
= GdipAddPathEllipse(path
, 0.0, 10.0, 100.0, 150.0);
1227 ok(status
== Ok
, "status %08x\n", status
);
1228 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1229 ok(status
== Ok
, "status %08x\n", status
);
1230 status
= GdipResetPath(path
);
1231 ok(status
== Ok
, "status %08x\n", status
);
1232 status
= GdipAddPathEllipse(path
, 10.0, 21.0, 100.0, 150.0);
1233 ok(status
== Ok
, "status %08x\n", status
);
1234 status
= GdipCombineRegionPath(region2
, path
, CombineModeReplace
);
1235 ok(status
== Ok
, "status %08x\n", status
);
1236 status
= GdipTranslateRegion(region
, 10.0, 11.0);
1237 ok(status
== Ok
, "status %08x\n", status
);
1239 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1240 ok(status
== Ok
, "status %08x\n", status
);
1241 ok(res
, "Expected to be equal.\n");
1243 status
= GdipDeleteRegion(region
);
1244 ok(status
== Ok
, "status %08x\n", status
);
1245 status
= GdipDeleteRegion(region2
);
1246 ok(status
== Ok
, "status %08x\n", status
);
1247 status
= GdipDeleteGraphics(graphics
);
1248 ok(status
== Ok
, "status %08x\n", status
);
1249 status
= GdipDeletePath(path
);
1250 ok(status
== Ok
, "status %08x\n", status
);
1254 static void test_transform(void)
1256 GpRegion
*region
, *region2
;
1258 GpGraphics
*graphics
;
1265 status
= GdipCreateFromHDC(hdc
, &graphics
);
1268 status
= GdipCreatePath(FillModeAlternate
, &path
);
1271 status
= GdipCreateRegion(®ion
);
1273 status
= GdipCreateRegion(®ion2
);
1276 status
= GdipCreateMatrix(&matrix
);
1278 status
= GdipScaleMatrix(matrix
, 2.0, 3.0, MatrixOrderAppend
);
1282 status
= GdipTransformRegion(NULL
, matrix
);
1283 expect(InvalidParameter
, status
);
1285 status
= GdipTransformRegion(region
, NULL
);
1286 expect(InvalidParameter
, status
);
1289 status
= GdipTransformRegion(region
, matrix
);
1293 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1295 ok(res
, "Expected to be equal.\n");
1298 status
= GdipSetEmpty(region
);
1300 status
= GdipTransformRegion(region
, matrix
);
1303 status
= GdipSetEmpty(region2
);
1307 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1309 ok(res
, "Expected to be equal.\n");
1314 rectf
.Width
= rectf
.Height
= 100.0;
1315 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1319 rectf
.Width
= 200.0;
1320 rectf
.Height
= 300.0;
1321 status
= GdipCombineRegionRect(region2
, &rectf
, CombineModeReplace
);
1323 status
= GdipTransformRegion(region
, matrix
);
1326 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1328 ok(res
, "Expected to be equal.\n");
1331 status
= GdipAddPathEllipse(path
, 0.0, 10.0, 100.0, 150.0);
1333 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1335 status
= GdipResetPath(path
);
1337 status
= GdipAddPathEllipse(path
, 0.0, 30.0, 200.0, 450.0);
1339 status
= GdipCombineRegionPath(region2
, path
, CombineModeReplace
);
1341 status
= GdipTransformRegion(region
, matrix
);
1344 status
= GdipIsEqualRegion(region
, region2
, graphics
, &res
);
1346 ok(res
, "Expected to be equal.\n");
1348 status
= GdipDeleteRegion(region
);
1350 status
= GdipDeleteRegion(region2
);
1352 status
= GdipDeleteGraphics(graphics
);
1354 status
= GdipDeletePath(path
);
1356 status
= GdipDeleteMatrix(matrix
);
1361 static void test_scans(void)
1372 status
= GdipCreateRegion(®ion
);
1375 status
= GdipCreateMatrix(&matrix
);
1378 /* test NULL values */
1379 status
= GdipGetRegionScansCount(NULL
, &count
, matrix
);
1380 expect(InvalidParameter
, status
);
1382 status
= GdipGetRegionScansCount(region
, NULL
, matrix
);
1383 expect(InvalidParameter
, status
);
1385 status
= GdipGetRegionScansCount(region
, &count
, NULL
);
1386 expect(InvalidParameter
, status
);
1388 status
= GdipGetRegionScans(NULL
, scans
, &icount
, matrix
);
1389 expect(InvalidParameter
, status
);
1391 status
= GdipGetRegionScans(region
, scans
, NULL
, matrix
);
1392 expect(InvalidParameter
, status
);
1394 status
= GdipGetRegionScans(region
, scans
, &icount
, NULL
);
1395 expect(InvalidParameter
, status
);
1398 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1402 status
= GdipGetRegionScans(region
, NULL
, &icount
, matrix
);
1406 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1410 status
= GdipGetRegionScansI(region
, scansi
, &icount
, matrix
);
1413 expect(-0x400000, scansi
[0].X
);
1414 expect(-0x400000, scansi
[0].Y
);
1415 expect(0x800000, scansi
[0].Width
);
1416 expect(0x800000, scansi
[0].Height
);
1418 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1421 expectf((double)-0x400000, scans
[0].X
);
1422 expectf((double)-0x400000, scans
[0].Y
);
1423 expectf((double)0x800000, scans
[0].Width
);
1424 expectf((double)0x800000, scans
[0].Height
);
1427 status
= GdipSetEmpty(region
);
1430 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1434 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1438 /* single rectangle */
1439 rectf
.X
= rectf
.Y
= 0.0;
1440 rectf
.Width
= rectf
.Height
= 5.0;
1441 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1444 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1448 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1451 expectf(0.0, scans
[0].X
);
1452 expectf(0.0, scans
[0].Y
);
1453 expectf(5.0, scans
[0].Width
);
1454 expectf(5.0, scans
[0].Height
);
1456 /* two rectangles */
1457 rectf
.X
= rectf
.Y
= 5.0;
1458 rectf
.Width
= rectf
.Height
= 5.0;
1459 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeUnion
);
1462 status
= GdipGetRegionScansCount(region
, &count
, matrix
);
1466 /* Native ignores the initial value of count */
1467 scans
[1].X
= scans
[1].Y
= scans
[1].Width
= scans
[1].Height
= 8.0;
1469 status
= GdipGetRegionScans(region
, scans
, &icount
, matrix
);
1472 expectf(0.0, scans
[0].X
);
1473 expectf(0.0, scans
[0].Y
);
1474 expectf(5.0, scans
[0].Width
);
1475 expectf(5.0, scans
[0].Height
);
1476 expectf(5.0, scans
[1].X
);
1477 expectf(5.0, scans
[1].Y
);
1478 expectf(5.0, scans
[1].Width
);
1479 expectf(5.0, scans
[1].Height
);
1481 status
= GdipGetRegionScansI(region
, scansi
, &icount
, matrix
);
1484 expect(0, scansi
[0].X
);
1485 expect(0, scansi
[0].Y
);
1486 expect(5, scansi
[0].Width
);
1487 expect(5, scansi
[0].Height
);
1488 expect(5, scansi
[1].X
);
1489 expect(5, scansi
[1].Y
);
1490 expect(5, scansi
[1].Width
);
1491 expect(5, scansi
[1].Height
);
1493 status
= GdipDeleteRegion(region
);
1495 status
= GdipDeleteMatrix(matrix
);
1499 static void test_getbounds(void)
1502 GpGraphics
*graphics
;
1507 status
= GdipCreateFromHDC(hdc
, &graphics
);
1508 ok(status
== Ok
, "status %08x\n", status
);
1509 status
= GdipCreateRegion(®ion
);
1510 ok(status
== Ok
, "status %08x\n", status
);
1513 status
= GdipGetRegionBounds(NULL
, NULL
, NULL
);
1514 ok(status
== InvalidParameter
, "status %08x\n", status
);
1515 status
= GdipGetRegionBounds(region
, NULL
, NULL
);
1516 ok(status
== InvalidParameter
, "status %08x\n", status
);
1517 status
= GdipGetRegionBounds(region
, graphics
, NULL
);
1518 ok(status
== InvalidParameter
, "status %08x\n", status
);
1520 rectf
.X
= rectf
.Y
= 0.0;
1521 rectf
.Height
= rectf
.Width
= 100.0;
1522 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1523 ok(status
== Ok
, "status %08x\n", status
);
1524 ok(rectf
.X
== -(REAL
)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL
)(1 << 22), rectf
.X
);
1525 ok(rectf
.Y
== -(REAL
)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL
)(1 << 22), rectf
.Y
);
1526 ok(rectf
.Width
== (REAL
)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL
)(1 << 23), rectf
.Width
);
1527 ok(rectf
.Height
== (REAL
)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL
)(1 << 23), rectf
.Height
);
1529 rectf
.X
= rectf
.Y
= 0.0;
1530 rectf
.Height
= rectf
.Width
= 100.0;
1531 status
= GdipSetEmpty(region
);
1532 ok(status
== Ok
, "status %08x\n", status
);
1533 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1534 ok(status
== Ok
, "status %08x\n", status
);
1535 ok(rectf
.X
== 0.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1536 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1537 ok(rectf
.Width
== 0.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1538 ok(rectf
.Height
== 0.0, "Expected height = 0.0, got %.2f\n", rectf
.Height
);
1540 rectf
.X
= 10.0; rectf
.Y
= 0.0;
1541 rectf
.Width
= rectf
.Height
= 100.0;
1542 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1543 ok(status
== Ok
, "status %08x\n", status
);
1544 rectf
.X
= rectf
.Y
= 0.0;
1545 rectf
.Height
= rectf
.Width
= 0.0;
1546 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1547 ok(status
== Ok
, "status %08x\n", status
);
1548 ok(rectf
.X
== 10.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1549 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1550 ok(rectf
.Width
== 100.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1551 ok(rectf
.Height
== 100.0, "Expected height = 0.0, got %.2f\n", rectf
.Height
);
1553 /* the world and page transforms are ignored */
1554 GdipScaleWorldTransform(graphics
, 2.0, 2.0, MatrixOrderPrepend
);
1555 GdipSetPageUnit(graphics
, UnitInch
);
1556 GdipSetPageScale(graphics
, 2.0);
1557 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1558 ok(status
== Ok
, "status %08x\n", status
);
1559 ok(rectf
.X
== 10.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1560 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1561 ok(rectf
.Width
== 100.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1563 rectf
.X
= 10.0; rectf
.Y
= 0.0;
1564 rectf
.Width
= rectf
.Height
= 100.0;
1565 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1566 ok(status
== Ok
, "status %08x\n", status
);
1567 rectf
.X
= rectf
.Y
= 0.0;
1568 rectf
.Height
= rectf
.Width
= 0.0;
1569 status
= GdipGetRegionBounds(region
, graphics
, &rectf
);
1570 ok(status
== Ok
, "status %08x\n", status
);
1571 ok(rectf
.X
== 10.0, "Expected X = 0.0, got %.2f\n", rectf
.X
);
1572 ok(rectf
.Y
== 0.0, "Expected Y = 0.0, got %.2f\n", rectf
.Y
);
1573 ok(rectf
.Width
== 100.0, "Expected width = 0.0, got %.2f\n", rectf
.Width
);
1574 ok(rectf
.Height
== 100.0, "Expected height = 0.0, got %.2f\n", rectf
.Height
);
1576 status
= GdipDeleteRegion(region
);
1577 ok(status
== Ok
, "status %08x\n", status
);
1578 status
= GdipDeleteGraphics(graphics
);
1579 ok(status
== Ok
, "status %08x\n", status
);
1583 static void test_isvisiblepoint(void)
1586 GpGraphics
* graphics
;
1594 status
= GdipCreateFromHDC(hdc
, &graphics
);
1597 status
= GdipCreateRegion(®ion
);
1600 /* null parameters */
1601 status
= GdipIsVisibleRegionPoint(NULL
, 0, 0, graphics
, &res
);
1602 expect(InvalidParameter
, status
);
1603 status
= GdipIsVisibleRegionPointI(NULL
, 0, 0, graphics
, &res
);
1604 expect(InvalidParameter
, status
);
1606 status
= GdipIsVisibleRegionPoint(region
, 0, 0, NULL
, &res
);
1608 status
= GdipIsVisibleRegionPointI(region
, 0, 0, NULL
, &res
);
1611 status
= GdipIsVisibleRegionPoint(region
, 0, 0, graphics
, NULL
);
1612 expect(InvalidParameter
, status
);
1613 status
= GdipIsVisibleRegionPointI(region
, 0, 0, graphics
, NULL
);
1614 expect(InvalidParameter
, status
);
1616 /* infinite region */
1617 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
1619 ok(res
== TRUE
, "Region should be infinite\n");
1623 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1625 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1626 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1628 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1632 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1634 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1635 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1637 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1639 /* rectangular region */
1645 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeReplace
);
1650 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1652 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1653 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1655 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1659 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1661 ok(res
== FALSE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1665 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1667 ok(res
== FALSE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1671 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1673 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1677 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1679 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1683 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1685 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1689 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1691 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1692 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1694 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1698 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1700 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1701 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1703 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1705 /* translate into the center of the rectangle */
1706 status
= GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
1709 /* native ignores the world transform, so treat these as if
1710 * no transform exists */
1713 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1715 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1716 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1718 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1722 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1724 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1725 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1727 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1731 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1733 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1734 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1736 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1738 /* translate back to origin */
1739 status
= GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
1742 /* region from path */
1743 status
= GdipCreatePath(FillModeAlternate
, &path
);
1746 status
= GdipAddPathEllipse(path
, 10, 20, 30, 40);
1749 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1754 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1756 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1757 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1759 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1763 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1765 ok(res
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1766 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1768 ok(res
== TRUE
, "Expected (%d, %d) to be visible\n", (INT
)x
, (INT
)y
);
1772 status
= GdipIsVisibleRegionPoint(region
, x
, y
, graphics
, &res
);
1774 ok(res
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1775 status
= GdipIsVisibleRegionPointI(region
, (INT
)x
, (INT
)y
, graphics
, &res
);
1777 ok(res
== FALSE
, "Expected (%d, %d) not to be visible\n", (INT
)x
, (INT
)y
);
1779 GdipDeletePath(path
);
1781 GdipDeleteRegion(region
);
1782 GdipDeleteGraphics(graphics
);
1786 static void test_isvisiblerect(void)
1789 GpGraphics
* graphics
;
1797 status
= GdipCreateFromHDC(hdc
, &graphics
);
1800 status
= GdipCreateRegion(®ion
);
1803 /* null parameters */
1804 status
= GdipIsVisibleRegionRect(NULL
, 0, 0, 0, 0, graphics
, &res
);
1805 expect(InvalidParameter
, status
);
1806 status
= GdipIsVisibleRegionRectI(NULL
, 0, 0, 0, 0, graphics
, &res
);
1807 expect(InvalidParameter
, status
);
1809 status
= GdipIsVisibleRegionRect(region
, 0, 0, 0, 0, NULL
, &res
);
1811 status
= GdipIsVisibleRegionRectI(region
, 0, 0, 0, 0, NULL
, &res
);
1814 status
= GdipIsVisibleRegionRect(region
, 0, 0, 0, 0, graphics
, NULL
);
1815 expect(InvalidParameter
, status
);
1816 status
= GdipIsVisibleRegionRectI(region
, 0, 0, 0, 0, graphics
, NULL
);
1817 expect(InvalidParameter
, status
);
1819 /* infinite region */
1820 status
= GdipIsInfiniteRegion(region
, graphics
, &res
);
1822 ok(res
== TRUE
, "Region should be infinite\n");
1826 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1828 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1832 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1834 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1836 /* rectangular region */
1842 status
= GdipCombineRegionRect(region
, &rectf
, CombineModeIntersect
);
1845 /* entirely within the region */
1848 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1850 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1851 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1853 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1855 /* entirely outside of the region */
1858 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1860 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
1861 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1863 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1868 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1870 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
1874 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1876 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1880 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1882 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1886 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1888 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
1890 /* corners outside, but some intersection */
1893 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1895 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1899 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1901 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1905 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1907 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1909 /* translate into the center of the rectangle */
1910 status
= GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
1913 /* native ignores the world transform, so treat these as if
1914 * no transform exists */
1917 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1919 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
1920 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1922 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1926 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1928 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1929 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1931 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1933 /* translate back to origin */
1934 status
= GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
1937 /* region from path */
1938 status
= GdipCreatePath(FillModeAlternate
, &path
);
1941 status
= GdipAddPathEllipse(path
, 10, 20, 30, 40);
1944 status
= GdipCombineRegionPath(region
, path
, CombineModeReplace
);
1949 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1951 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
1952 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1954 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1958 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1960 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1961 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1963 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1967 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1969 ok(res
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, w
, h
);
1970 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1972 ok(res
== FALSE
, "Expected (%d, %d, %d, %d) not to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1976 status
= GdipIsVisibleRegionRect(region
, x
, y
, w
, h
, graphics
, &res
);
1978 ok(res
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, w
, h
);
1979 status
= GdipIsVisibleRegionRectI(region
, (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
, graphics
, &res
);
1981 ok(res
== TRUE
, "Expected (%d, %d, %d, %d) to be visible\n", (INT
)x
, (INT
)y
, (INT
)w
, (INT
)h
);
1983 GdipDeletePath(path
);
1985 GdipDeleteRegion(region
);
1986 GdipDeleteGraphics(graphics
);
1992 struct GdiplusStartupInput gdiplusStartupInput
;
1993 ULONG_PTR gdiplusToken
;
1995 gdiplusStartupInput
.GdiplusVersion
= 1;
1996 gdiplusStartupInput
.DebugEventCallback
= NULL
;
1997 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
1998 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2000 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2002 test_getregiondata();
2005 test_combinereplace();
2013 test_isvisiblepoint();
2014 test_isvisiblerect();
2016 GdiplusShutdown(gdiplusToken
);