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