[GDIPLUS] Sync with Wine Staging 1.7.47. CORE-9924
[reactos.git] / rostests / winetests / gdiplus / region.c
1 /*
2 * Unit test suite for gdiplus regions
3 *
4 * Copyright (C) 2008 Huw Davies
5 * Copyright (C) 2013 Dmitry Timoshkov
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #define WIN32_NO_STATUS
23 #define _INC_WINDOWS
24 #define COM_NO_WINDOWS_H
25
26 //#include "windows.h"
27 #include <wine/test.h>
28 #include <wingdi.h>
29 #include <objbase.h>
30 #include <gdiplus.h>
31 #include <math.h>
32
33 #define RGNDATA_RECT 0x10000000
34 #define RGNDATA_PATH 0x10000001
35 #define RGNDATA_EMPTY_RECT 0x10000002
36 #define RGNDATA_INFINITE_RECT 0x10000003
37
38 #define RGNDATA_MAGIC 0xdbc01001
39 #define RGNDATA_MAGIC2 0xdbc01002
40
41 #define expect(expected, got) ok((got) == (expected), "Expected %.8x, got %.8x\n", (expected), (got))
42 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))
43 #define expectf(expected, got) expectf_((expected), (got), 0.001)
44
45 #define expect_magic(value) ok(*(value) == RGNDATA_MAGIC || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *(value))
46 #define expect_dword(value, expected) expect((expected), *(value))
47 #define expect_float(value, expected) expectf((expected), *(FLOAT *)(value))
48
49 /* We get shorts back, not INTs like a GpPoint */
50 typedef struct RegionDataPoint
51 {
52 short X, Y;
53 } RegionDataPoint;
54
55 static void verify_region(HRGN hrgn, const RECT *rc)
56 {
57 union
58 {
59 RGNDATA data;
60 char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
61 } rgn;
62 const RECT *rect;
63 DWORD ret;
64
65 ret = GetRegionData(hrgn, 0, NULL);
66 if (IsRectEmpty(rc))
67 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
68 else
69 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
70
71 if (!ret) return;
72
73 ret = GetRegionData(hrgn, sizeof(rgn), &rgn.data);
74 if (IsRectEmpty(rc))
75 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
76 else
77 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
78
79 trace("size %u, type %u, count %u, rgn size %u, bound (%d,%d-%d,%d)\n",
80 rgn.data.rdh.dwSize, rgn.data.rdh.iType,
81 rgn.data.rdh.nCount, rgn.data.rdh.nRgnSize,
82 rgn.data.rdh.rcBound.left, rgn.data.rdh.rcBound.top,
83 rgn.data.rdh.rcBound.right, rgn.data.rdh.rcBound.bottom);
84 if (rgn.data.rdh.nCount != 0)
85 {
86 rect = (const RECT *)rgn.data.Buffer;
87 trace("rect (%d,%d-%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom);
88 ok(EqualRect(rect, rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
89 rc->left, rc->top, rc->right, rc->bottom,
90 rect->left, rect->top, rect->right, rect->bottom);
91 }
92
93 ok(rgn.data.rdh.dwSize == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", rgn.data.rdh.dwSize);
94 ok(rgn.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn.data.rdh.iType);
95 if (IsRectEmpty(rc))
96 {
97 ok(rgn.data.rdh.nCount == 0, "expected 0, got %u\n", rgn.data.rdh.nCount);
98 ok(rgn.data.rdh.nRgnSize == 0, "expected 0, got %u\n", rgn.data.rdh.nRgnSize);
99 }
100 else
101 {
102 ok(rgn.data.rdh.nCount == 1, "expected 1, got %u\n", rgn.data.rdh.nCount);
103 ok(rgn.data.rdh.nRgnSize == sizeof(RECT), "expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
104 }
105 ok(EqualRect(&rgn.data.rdh.rcBound, rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
106 rc->left, rc->top, rc->right, rc->bottom,
107 rgn.data.rdh.rcBound.left, rgn.data.rdh.rcBound.top, rgn.data.rdh.rcBound.right, rgn.data.rdh.rcBound.bottom);
108 }
109
110 static void test_region_data(DWORD *data, UINT size, INT line)
111 {
112 GpStatus status;
113 GpRegion *region;
114 DWORD buf[256];
115 UINT needed, i;
116
117 status = GdipCreateRegionRgnData((BYTE *)data, size, &region);
118 /* Windows always fails to create an empty path in a region */
119 if (data[4] == RGNDATA_PATH)
120 {
121 struct _path_header
122 {
123 DWORD size;
124 DWORD magic;
125 DWORD count;
126 DWORD flags;
127 } *path_header = (struct _path_header *)(data + 5);
128 if (!path_header->count)
129 {
130 ok_(__FILE__, line)(status == GenericError, "expected GenericError, got %d\n", status);
131 return;
132 }
133 }
134
135 ok_(__FILE__, line)(status == Ok, "GdipCreateRegionRgnData error %d\n", status);
136 if (status != Ok) return;
137
138 needed = 0;
139 status = GdipGetRegionDataSize(region, &needed);
140 ok_(__FILE__, line)(status == Ok, "status %d\n", status);
141 ok_(__FILE__, line)(needed == size, "data size mismatch: %u != %u\n", needed, size);
142
143 memset(buf, 0xee, sizeof(buf));
144 needed = 0;
145 status = GdipGetRegionData(region, (BYTE *)buf, sizeof(buf), &needed);
146 ok_(__FILE__, line)(status == Ok, "status %08x\n", status);
147 ok_(__FILE__, line)(needed == size, "data size mismatch: %u != %u\n", needed, size);
148
149 size /= sizeof(DWORD);
150 for (i = 0; i < size - 1; i++)
151 {
152 if (i == 1) continue; /* data[1] never matches */
153 ok_(__FILE__, line)(data[i] == buf[i], "off %u: %#x != %#x\n", i, data[i], buf[i]);
154 }
155 /* some Windows versions fail to properly clear the aligned DWORD */
156 ok_(__FILE__, line)(data[size - 1] == buf[size - 1] || broken(data[size - 1] != buf[size - 1]),
157 "off %u: %#x != %#x\n", size - 1, data[size - 1], buf[size - 1]);
158 }
159
160 static void test_getregiondata(void)
161 {
162 GpStatus status;
163 GpRegion *region, *region2;
164 RegionDataPoint *point;
165 UINT needed;
166 DWORD buf[256];
167 GpRect rect;
168 GpPath *path;
169 GpMatrix *matrix;
170
171 status = GdipCreateRegion(&region);
172 ok(status == Ok, "status %08x\n", status);
173
174 needed = 0;
175 status = GdipGetRegionDataSize(region, &needed);
176 ok(status == Ok, "status %08x\n", status);
177 expect(20, needed);
178
179 needed = 0;
180 status = GdipGetRegionData(region, (BYTE*)buf, 0, &needed);
181 ok(status == InvalidParameter, "status %08x\n", status);
182
183 memset(buf, 0xee, sizeof(buf));
184 needed = 0;
185 status = GdipGetRegionData(region, (BYTE*)buf, 4, &needed);
186 ok(status == InsufficientBuffer, "status %08x\n", status);
187 expect(4, needed);
188 expect_dword(buf, 0xeeeeeeee);
189
190 memset(buf, 0xee, sizeof(buf));
191 needed = 0;
192 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
193 ok(status == Ok, "status %08x\n", status);
194 expect(20, needed);
195 expect_dword(buf, 12);
196 trace("buf[1] = %08x\n", buf[1]);
197 expect_magic(buf + 2);
198 expect_dword(buf + 3, 0);
199 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
200 expect_dword(buf + 6, 0xeeeeeeee);
201 test_region_data(buf, needed, __LINE__);
202
203 status = GdipSetEmpty(region);
204 ok(status == Ok, "status %08x\n", status);
205 status = GdipGetRegionDataSize(region, &needed);
206 ok(status == Ok, "status %08x\n", status);
207 expect(20, needed);
208 memset(buf, 0xee, sizeof(buf));
209 needed = 0;
210 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
211 ok(status == Ok, "status %08x\n", status);
212 expect(20, needed);
213 expect_dword(buf, 12);
214 trace("buf[1] = %08x\n", buf[1]);
215 expect_magic(buf + 2);
216 expect_dword(buf + 3, 0);
217 expect_dword(buf + 4, RGNDATA_EMPTY_RECT);
218 expect_dword(buf + 6, 0xeeeeeeee);
219 test_region_data(buf, needed, __LINE__);
220
221 status = GdipSetInfinite(region);
222 ok(status == Ok, "status %08x\n", status);
223 status = GdipGetRegionDataSize(region, &needed);
224 ok(status == Ok, "status %08x\n", status);
225 expect(20, needed);
226 memset(buf, 0xee, sizeof(buf));
227 needed = 0;
228 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
229 ok(status == Ok, "status %08x\n", status);
230 expect(20, needed);
231 expect_dword(buf, 12);
232 trace("buf[1] = %08x\n", buf[1]);
233 expect_magic(buf + 2);
234 expect_dword(buf + 3, 0);
235 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
236 expect_dword(buf + 6, 0xeeeeeeee);
237 test_region_data(buf, needed, __LINE__);
238
239 status = GdipDeleteRegion(region);
240 ok(status == Ok, "status %08x\n", status);
241
242 rect.X = 10;
243 rect.Y = 20;
244 rect.Width = 100;
245 rect.Height = 200;
246 status = GdipCreateRegionRectI(&rect, &region);
247 ok(status == Ok, "status %08x\n", status);
248 status = GdipGetRegionDataSize(region, &needed);
249 ok(status == Ok, "status %08x\n", status);
250 expect(36, needed);
251 memset(buf, 0xee, sizeof(buf));
252 needed = 0;
253 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
254 ok(status == Ok, "status %08x\n", status);
255 expect(36, needed);
256 expect_dword(buf, 28);
257 trace("buf[1] = %08x\n", buf[1]);
258 expect_magic(buf + 2);
259 expect_dword(buf + 3, 0);
260 expect_dword(buf + 4, RGNDATA_RECT);
261 expect_float(buf + 5, 10.0);
262 expect_float(buf + 6, 20.0);
263 expect_float(buf + 7, 100.0);
264 expect_float(buf + 8, 200.0);
265 expect_dword(buf + 10, 0xeeeeeeee);
266 test_region_data(buf, needed, __LINE__);
267
268 rect.X = 50;
269 rect.Y = 30;
270 rect.Width = 10;
271 rect.Height = 20;
272 status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
273 ok(status == Ok, "status %08x\n", status);
274 rect.X = 100;
275 rect.Y = 300;
276 rect.Width = 30;
277 rect.Height = 50;
278 status = GdipCombineRegionRectI(region, &rect, CombineModeXor);
279 ok(status == Ok, "status %08x\n", status);
280
281 rect.X = 200;
282 rect.Y = 100;
283 rect.Width = 133;
284 rect.Height = 266;
285 status = GdipCreateRegionRectI(&rect, &region2);
286 ok(status == Ok, "status %08x\n", status);
287 rect.X = 20;
288 rect.Y = 10;
289 rect.Width = 40;
290 rect.Height = 66;
291 status = GdipCombineRegionRectI(region2, &rect, CombineModeUnion);
292 ok(status == Ok, "status %08x\n", status);
293
294 status = GdipCombineRegionRegion(region, region2, CombineModeComplement);
295 ok(status == Ok, "status %08x\n", status);
296
297 rect.X = 400;
298 rect.Y = 500;
299 rect.Width = 22;
300 rect.Height = 55;
301 status = GdipCombineRegionRectI(region, &rect, CombineModeExclude);
302 ok(status == Ok, "status %08x\n", status);
303
304 status = GdipGetRegionDataSize(region, &needed);
305 ok(status == Ok, "status %08x\n", status);
306 expect(156, needed);
307 memset(buf, 0xee, sizeof(buf));
308 needed = 0;
309 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
310 ok(status == Ok, "status %08x\n", status);
311 expect(156, needed);
312 expect_dword(buf, 148);
313 trace("buf[1] = %08x\n", buf[1]);
314 expect_magic(buf + 2);
315 expect_dword(buf + 3, 10);
316 expect_dword(buf + 4, CombineModeExclude);
317 expect_dword(buf + 5, CombineModeComplement);
318 expect_dword(buf + 6, CombineModeXor);
319 expect_dword(buf + 7, CombineModeIntersect);
320 expect_dword(buf + 8, RGNDATA_RECT);
321 expect_float(buf + 9, 10.0);
322 expect_float(buf + 10, 20.0);
323 expect_float(buf + 11, 100.0);
324 expect_float(buf + 12, 200.0);
325 expect_dword(buf + 13, RGNDATA_RECT);
326 expect_float(buf + 14, 50.0);
327 expect_float(buf + 15, 30.0);
328 expect_float(buf + 16, 10.0);
329 expect_float(buf + 17, 20.0);
330 expect_dword(buf + 18, RGNDATA_RECT);
331 expect_float(buf + 19, 100.0);
332 expect_float(buf + 20, 300.0);
333 expect_float(buf + 21, 30.0);
334 expect_float(buf + 22, 50.0);
335 expect_dword(buf + 23, CombineModeUnion);
336 expect_dword(buf + 24, RGNDATA_RECT);
337 expect_float(buf + 25, 200.0);
338 expect_float(buf + 26, 100.0);
339 expect_float(buf + 27, 133.0);
340 expect_float(buf + 28, 266.0);
341 expect_dword(buf + 29, RGNDATA_RECT);
342 expect_float(buf + 30, 20.0);
343 expect_float(buf + 31, 10.0);
344 expect_float(buf + 32, 40.0);
345 expect_float(buf + 33, 66.0);
346 expect_dword(buf + 34, RGNDATA_RECT);
347 expect_float(buf + 35, 400.0);
348 expect_float(buf + 36, 500.0);
349 expect_float(buf + 37, 22.0);
350 expect_float(buf + 38, 55.0);
351 expect_dword(buf + 39, 0xeeeeeeee);
352 test_region_data(buf, needed, __LINE__);
353
354 status = GdipDeleteRegion(region2);
355 ok(status == Ok, "status %08x\n", status);
356 status = GdipDeleteRegion(region);
357 ok(status == Ok, "status %08x\n", status);
358
359 /* Try some paths */
360
361 status = GdipCreatePath(FillModeAlternate, &path);
362 ok(status == Ok, "status %08x\n", status);
363 GdipAddPathRectangle(path, 12.5, 13.0, 14.0, 15.0);
364
365 status = GdipCreateRegionPath(path, &region);
366 ok(status == Ok, "status %08x\n", status);
367 status = GdipGetRegionDataSize(region, &needed);
368 ok(status == Ok, "status %08x\n", status);
369 expect(72, needed);
370 memset(buf, 0xee, sizeof(buf));
371 needed = 0;
372 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
373 ok(status == Ok, "status %08x\n", status);
374 expect(72, needed);
375 expect_dword(buf, 64);
376 trace("buf[1] = %08x\n", buf[1]);
377 expect_magic(buf + 2);
378 expect_dword(buf + 3, 0);
379 expect_dword(buf + 4, RGNDATA_PATH);
380 expect_dword(buf + 5, 0x00000030);
381 expect_magic(buf + 6);
382 expect_dword(buf + 7, 0x00000004);
383 expect_dword(buf + 8, 0x00000000);
384 expect_float(buf + 9, 12.5);
385 expect_float(buf + 10, 13.0);
386 expect_float(buf + 11, 26.5);
387 expect_float(buf + 12, 13.0);
388 expect_float(buf + 13, 26.5);
389 expect_float(buf + 14, 28.0);
390 expect_float(buf + 15, 12.5);
391 expect_float(buf + 16, 28.0);
392 expect_dword(buf + 17, 0x81010100);
393 expect_dword(buf + 18, 0xeeeeeeee);
394 test_region_data(buf, needed, __LINE__);
395
396 rect.X = 50;
397 rect.Y = 30;
398 rect.Width = 10;
399 rect.Height = 20;
400 status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
401 ok(status == Ok, "status %08x\n", status);
402 status = GdipGetRegionDataSize(region, &needed);
403 ok(status == Ok, "status %08x\n", status);
404 expect(96, needed);
405 memset(buf, 0xee, sizeof(buf));
406 needed = 0;
407 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
408 ok(status == Ok, "status %08x\n", status);
409 expect(96, needed);
410 expect_dword(buf, 88);
411 trace("buf[1] = %08x\n", buf[1]);
412 expect_magic(buf + 2);
413 expect_dword(buf + 3, 2);
414 expect_dword(buf + 4, CombineModeIntersect);
415 expect_dword(buf + 5, RGNDATA_PATH);
416 expect_dword(buf + 6, 0x00000030);
417 expect_magic(buf + 7);
418 expect_dword(buf + 8, 0x00000004);
419 expect_dword(buf + 9, 0x00000000);
420 expect_float(buf + 10, 12.5);
421 expect_float(buf + 11, 13.0);
422 expect_float(buf + 12, 26.5);
423 expect_float(buf + 13, 13.0);
424 expect_float(buf + 14, 26.5);
425 expect_float(buf + 15, 28.0);
426 expect_float(buf + 16, 12.5);
427 expect_float(buf + 17, 28.0);
428 expect_dword(buf + 18, 0x81010100);
429 expect_dword(buf + 19, RGNDATA_RECT);
430 expect_float(buf + 20, 50.0);
431 expect_float(buf + 21, 30.0);
432 expect_float(buf + 22, 10.0);
433 expect_float(buf + 23, 20.0);
434 expect_dword(buf + 24, 0xeeeeeeee);
435 test_region_data(buf, needed, __LINE__);
436
437 status = GdipDeleteRegion(region);
438 ok(status == Ok, "status %08x\n", status);
439 status = GdipDeletePath(path);
440 ok(status == Ok, "status %08x\n", status);
441
442 /* Test an empty path */
443 status = GdipCreatePath(FillModeAlternate, &path);
444 expect(Ok, status);
445 status = GdipCreateRegionPath(path, &region);
446 expect(Ok, status);
447 status = GdipGetRegionDataSize(region, &needed);
448 expect(Ok, status);
449 expect(36, needed);
450 memset(buf, 0xee, sizeof(buf));
451 needed = 0;
452 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
453 expect(Ok, status);
454 expect(36, needed);
455 expect_dword(buf, 28);
456 trace("buf[1] = %08x\n", buf[1]);
457 expect_magic(buf + 2);
458 expect_dword(buf + 3, 0);
459 expect_dword(buf + 4, RGNDATA_PATH);
460 /* Second signature for pathdata */
461 expect_dword(buf + 5, 12);
462 expect_magic(buf + 6);
463 expect_dword(buf + 7, 0);
464 /* flags 0 means that a path is an array of FLOATs */
465 ok(*(buf + 8) == 0x4000 /* before win7 */ || *(buf + 8) == 0,
466 "expected 0x4000 or 0, got %08x\n", *(buf + 8));
467 expect_dword(buf + 10, 0xeeeeeeee);
468 test_region_data(buf, needed, __LINE__);
469
470 /* Transform an empty region */
471 status = GdipCreateMatrix(&matrix);
472 expect(Ok, status);
473 status = GdipTransformRegion(region, matrix);
474 expect(Ok, status);
475 GdipDeleteMatrix(matrix);
476
477 status = GdipDeleteRegion(region);
478 expect(Ok, status);
479
480 /* Test a simple triangle of INTs */
481 status = GdipAddPathLine(path, 5, 6, 7, 8);
482 expect(Ok, status);
483 status = GdipAddPathLine(path, 8, 1, 5, 6);
484 expect(Ok, status);
485 status = GdipClosePathFigure(path);
486 expect(Ok, status);
487 status = GdipCreateRegionPath(path, &region);
488 expect(Ok, status);
489 status = GdipGetRegionDataSize(region, &needed);
490 expect(Ok, status);
491 expect(56, needed);
492 memset(buf, 0xee, sizeof(buf));
493 needed = 0;
494 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
495 expect(Ok, status);
496 expect(56, needed);
497 expect_dword(buf, 48);
498 trace("buf[1] = %08x\n", buf[1]);
499 expect_magic(buf + 2);
500 expect_dword(buf + 3 , 0);
501 expect_dword(buf + 4 , RGNDATA_PATH);
502 expect_dword(buf + 5, 32);
503 expect_magic(buf + 6);
504 expect_dword(buf + 7, 4);
505 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
506 expect_dword(buf + 8, 0x4000);
507
508 point = (RegionDataPoint*)(buf + 9);
509 expect(5, point[0].X);
510 expect(6, point[0].Y);
511 expect(7, point[1].X); /* buf + 10 */
512 expect(8, point[1].Y);
513 expect(8, point[2].X); /* buf + 11 */
514 expect(1, point[2].Y);
515 expect(5, point[3].X); /* buf + 12 */
516 expect(6, point[3].Y);
517 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
518 expect_dword(buf + 14, 0xeeeeeeee);
519 test_region_data(buf, needed, __LINE__);
520
521 status = GdipTranslateRegion(region, 0.6, 0.8);
522 expect(Ok, status);
523 memset(buf, 0xee, sizeof(buf));
524 needed = 0;
525 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
526 expect(Ok, status);
527 expect(72, needed);
528 expect_dword(buf, 64);
529 expect_magic(buf + 2);
530 expect_dword(buf + 3 , 0);
531 expect_dword(buf + 4 , RGNDATA_PATH);
532 expect_dword(buf + 5, 48);
533 expect_magic(buf + 6);
534 expect_dword(buf + 7, 4);
535 /* flags 0 means that a path is an array of FLOATs */
536 expect_dword(buf + 8, 0);
537 expect_float(buf + 9, 5.6);
538 expect_float(buf + 10, 6.8);
539 expect_float(buf + 11, 7.6);
540 expect_float(buf + 12, 8.8);
541 expect_float(buf + 13, 8.6);
542 expect_float(buf + 14, 1.8);
543 expect_float(buf + 15, 5.6);
544 expect_float(buf + 16, 6.8);
545 expect_dword(buf + 17, 0x81010100); /* 0x01010100 if we don't close the path */
546 expect_dword(buf + 18, 0xeeeeeeee);
547 test_region_data(buf, needed, __LINE__);
548
549 status = GdipDeletePath(path);
550 expect(Ok, status);
551 status = GdipDeleteRegion(region);
552 expect(Ok, status);
553
554 /* Test a floating-point triangle */
555 status = GdipCreatePath(FillModeAlternate, &path);
556 expect(Ok, status);
557 status = GdipAddPathLine(path, 5.6, 6.2, 7.2, 8.9);
558 expect(Ok, status);
559 status = GdipAddPathLine(path, 8.1, 1.6, 5.6, 6.2);
560 expect(Ok, status);
561 status = GdipCreateRegionPath(path, &region);
562 expect(Ok, status);
563 status = GdipGetRegionDataSize(region, &needed);
564 expect(Ok, status);
565 expect(72, needed);
566 memset(buf, 0xee, sizeof(buf));
567 needed = 0;
568 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
569 expect(Ok, status);
570 expect(72, needed);
571 expect_dword(buf, 64);
572 trace("buf[1] = %08x\n", buf[1]);
573 expect_magic(buf + 2);
574 expect_dword(buf + 3, 0);
575 expect_dword(buf + 4, RGNDATA_PATH);
576 expect_dword(buf + 5, 48);
577 expect_magic(buf + 6);
578 expect_dword(buf + 7, 4);
579 expect_dword(buf + 8, 0);
580 expect_float(buf + 9, 5.6);
581 expect_float(buf + 10, 6.2);
582 expect_float(buf + 11, 7.2);
583 expect_float(buf + 12, 8.9);
584 expect_float(buf + 13, 8.1);
585 expect_float(buf + 14, 1.6);
586 expect_float(buf + 15, 5.6);
587 expect_float(buf + 16, 6.2);
588 expect_dword(buf + 17, 0x01010100);
589 expect_dword(buf + 18, 0xeeeeeeee);
590 test_region_data(buf, needed, __LINE__);
591
592 status = GdipDeletePath(path);
593 expect(Ok, status);
594 status = GdipDeleteRegion(region);
595 expect(Ok, status);
596
597 /* Test for a path with > 4 points, and CombineRegionPath */
598 GdipCreatePath(FillModeAlternate, &path);
599 status = GdipAddPathLine(path, 50, 70.2, 60, 102.8);
600 expect(Ok, status);
601 status = GdipAddPathLine(path, 55.4, 122.4, 40.4, 60.2);
602 expect(Ok, status);
603 status = GdipAddPathLine(path, 45.6, 20.2, 50, 70.2);
604 expect(Ok, status);
605 rect.X = 20;
606 rect.Y = 25;
607 rect.Width = 60;
608 rect.Height = 120;
609 status = GdipCreateRegionRectI(&rect, &region);
610 expect(Ok, status);
611 status = GdipCombineRegionPath(region, path, CombineModeUnion);
612 expect(Ok, status);
613
614 status = GdipGetRegionDataSize(region, &needed);
615 expect(Ok, status);
616 expect(116, needed);
617 memset(buf, 0xee, sizeof(buf));
618 needed = 0;
619 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
620 expect(Ok, status);
621 expect(116, needed);
622 expect_dword(buf, 108);
623 trace("buf[1] = %08x\n", buf[1]);
624 expect_magic(buf + 2);
625 expect_dword(buf + 3, 2);
626 expect_dword(buf + 4, CombineModeUnion);
627 expect_dword(buf + 5, RGNDATA_RECT);
628 expect_float(buf + 6, 20.0);
629 expect_float(buf + 7, 25.0);
630 expect_float(buf + 8, 60.0);
631 expect_float(buf + 9, 120.0);
632 expect_dword(buf + 10, RGNDATA_PATH);
633 expect_dword(buf + 11, 68);
634 expect_magic(buf + 12);
635 expect_dword(buf + 13, 6);
636 expect_float(buf + 14, 0.0);
637 expect_float(buf + 15, 50.0);
638 expect_float(buf + 16, 70.2);
639 expect_float(buf + 17, 60.0);
640 expect_float(buf + 18, 102.8);
641 expect_float(buf + 19, 55.4);
642 expect_float(buf + 20, 122.4);
643 expect_float(buf + 21, 40.4);
644 expect_float(buf + 22, 60.2);
645 expect_float(buf + 23, 45.6);
646 expect_float(buf + 24, 20.2);
647 expect_float(buf + 25, 50.0);
648 expect_float(buf + 26, 70.2);
649 expect_dword(buf + 27, 0x01010100);
650 ok(*(buf + 28) == 0x00000101 || *(buf + 28) == 0x43050101 /* Win 7 */,
651 "expected 00000101 or 43050101 got %08x\n", *(buf + 28));
652 expect_dword(buf + 29, 0xeeeeeeee);
653 test_region_data(buf, needed, __LINE__);
654
655 status = GdipDeletePath(path);
656 expect(Ok, status);
657 status = GdipDeleteRegion(region);
658 expect(Ok, status);
659
660 /* Test how shorts are stored in the region path data */
661 status = GdipCreatePath(FillModeAlternate, &path);
662 ok(status == Ok, "status %08x\n", status);
663 GdipAddPathRectangleI(path, -1969, -1974, 1995, 1997);
664
665 status = GdipCreateRegionPath(path, &region);
666 ok(status == Ok, "status %08x\n", status);
667 needed = 0;
668 status = GdipGetRegionDataSize(region, &needed);
669 ok(status == Ok, "status %08x\n", status);
670 expect(56, needed);
671 memset(buf, 0xee, sizeof(buf));
672 needed = 0;
673 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
674 ok(status == Ok, "status %08x\n", status);
675 expect(56, needed);
676 expect_dword(buf, 48);
677 trace("buf[1] = %08x\n", buf[1]);
678 expect_magic(buf + 2);
679 expect_dword(buf + 3, 0);
680 expect_dword(buf + 4, RGNDATA_PATH);
681 expect_dword(buf + 5, 32);
682 expect_magic(buf + 6);
683 expect_dword(buf + 7, 4);
684 /* flags 0x4000 means that a path is an array of shorts instead of FLOATs */
685 expect_dword(buf + 8, 0x4000);
686 point = (RegionDataPoint*)(buf + 9);
687 expect(-1969, point[0].X);
688 expect(-1974, point[0].Y);
689 expect(26, point[1].X); /* buf + 10 */
690 expect(-1974, point[1].Y);
691 expect(26, point[2].X); /* buf + 11 */
692 expect(23, point[2].Y);
693 expect(-1969, point[3].X); /* buf + 12 */
694 expect(23, point[3].Y);
695 expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */
696 expect_dword(buf + 14, 0xeeeeeeee);
697 test_region_data(buf, needed, __LINE__);
698
699 status = GdipDeletePath(path);
700 expect(Ok, status);
701 status = GdipDeleteRegion(region);
702 expect(Ok, status);
703
704 /* Test with integers that can't be stored as shorts */
705 status = GdipCreatePath(FillModeAlternate, &path);
706 ok(status == Ok, "status %08x\n", status);
707 GdipAddPathRectangleI(path, -196900, -197400, 199500, 199700);
708
709 status = GdipCreateRegionPath(path, &region);
710 ok(status == Ok, "status %08x\n", status);
711 needed = 0;
712 status = GdipGetRegionDataSize(region, &needed);
713 ok(status == Ok, "status %08x\n", status);
714 expect(72, needed);
715 memset(buf, 0xee, sizeof(buf));
716 needed = 0;
717 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
718 ok(status == Ok, "status %08x\n", status);
719 expect(72, needed);
720 expect_dword(buf, 64);
721 trace("buf[1] = %08x\n", buf[1]);
722 expect_magic(buf + 2);
723 expect_dword(buf + 3, 0);
724 expect_dword(buf + 4, RGNDATA_PATH);
725 expect_dword(buf + 5, 48);
726 expect_magic(buf + 6);
727 expect_dword(buf + 7, 4);
728 /* flags 0 means that a path is an array of FLOATs */
729 expect_dword(buf + 8, 0);
730 expect_float(buf + 9, -196900.0);
731 expect_float(buf + 10, -197400.0);
732 expect_float(buf + 11, 2600.0);
733 expect_float(buf + 12, -197400.0);
734 expect_float(buf + 13, 2600.0);
735 expect_float(buf + 14, 2300.0);
736 expect_float(buf + 15, -196900.0);
737 expect_float(buf + 16, 2300.0);
738 expect_dword(buf + 17, 0x81010100); /* 0x01010100 if we don't close the path */
739 expect_dword(buf + 18, 0xeeeeeeee);
740 test_region_data(buf, needed, __LINE__);
741
742 status = GdipDeletePath(path);
743 expect(Ok, status);
744 status = GdipDeleteRegion(region);
745 expect(Ok, status);
746
747 /* Test beziers */
748 GdipCreatePath(FillModeAlternate, &path);
749 /* Exactly 90 degrees */
750 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
751 expect(Ok, status);
752 /* Over 90 degrees */
753 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
754 expect(Ok, status);
755 status = GdipCreateRegionPath(path, &region);
756 ok(status == Ok, "status %08x\n", status);
757 needed = 0;
758 status = GdipGetRegionDataSize(region, &needed);
759 ok(status == Ok, "status %08x\n", status);
760 expect(136, needed);
761 memset(buf, 0xee, sizeof(buf));
762 needed = 0;
763 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
764 ok(status == Ok, "status %08x\n", status);
765 expect(136, needed);
766 expect_dword(buf, 128);
767 trace("buf[1] = %08x\n", buf[1]);
768 expect_magic(buf + 2);
769 expect_dword(buf + 3, 0);
770 expect_dword(buf + 4, RGNDATA_PATH);
771 expect_dword(buf + 5, 112);
772 expect_magic(buf + 6);
773 expect_dword(buf + 7, 11);
774 /* flags 0 means that a path is an array of FLOATs */
775 expect_dword(buf + 8, 0);
776 expect_float(buf + 9, 600.0);
777 expect_float(buf + 10, 450.0);
778 expect_float(buf + 11, 600.0);
779 expect_float(buf + 12, 643.299561);
780 expect_float(buf + 13, 488.071198);
781 expect_float(buf + 14, 800.0);
782 expect_float(buf + 15, 350.0);
783 expect_float(buf + 16, 800.0);
784 expect_float(buf + 17, 600.0);
785 expect_float(buf + 18, 450.0);
786 expect_float(buf + 19, 600.0);
787 expect_float(buf + 20, 643.299622);
788 expect_float(buf + 21, 488.071167);
789 expect_float(buf + 22, 800.0);
790 expect_float(buf + 23, 350.0);
791 expect_float(buf + 24, 800.0);
792 expect_float(buf + 25, 329.807129);
793 expect_float(buf + 26, 800.0);
794 expect_float(buf + 27, 309.688568);
795 expect_float(buf + 28, 796.574890);
796 expect_float(buf + 29, 290.084167);
797 expect_float(buf + 30, 789.799561);
798 expect_dword(buf + 31, 0x03030300);
799 expect_dword(buf + 32, 0x03030301);
800 ok(*(buf + 33) == 0x00030303 /* before win7 */ ||
801 *(buf + 33) == 0x43030303 /* 32-bit win7 */ || *(buf + 33) == 0x4c030303 /* 64-bit win7 */,
802 "expected 0x00030303 or 0x43030303 or 0x4c030303 got %08x\n", *(buf + 33));
803 expect_dword(buf + 34, 0xeeeeeeee);
804 test_region_data(buf, needed, __LINE__);
805
806 status = GdipDeletePath(path);
807 expect(Ok, status);
808 status = GdipDeleteRegion(region);
809 expect(Ok, status);
810 }
811
812 static void test_isinfinite(void)
813 {
814 GpStatus status;
815 GpRegion *region;
816 GpGraphics *graphics = NULL;
817 GpMatrix *m;
818 HDC hdc = GetDC(0);
819 BOOL res;
820
821 status = GdipCreateFromHDC(hdc, &graphics);
822 expect(Ok, status);
823 GdipCreateRegion(&region);
824
825 GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m);
826
827 /* NULL arguments */
828 status = GdipIsInfiniteRegion(NULL, NULL, NULL);
829 expect(InvalidParameter, status);
830 status = GdipIsInfiniteRegion(region, NULL, NULL);
831 expect(InvalidParameter, status);
832 status = GdipIsInfiniteRegion(NULL, graphics, NULL);
833 expect(InvalidParameter, status);
834 status = GdipIsInfiniteRegion(NULL, NULL, &res);
835 expect(InvalidParameter, status);
836 status = GdipIsInfiniteRegion(region, NULL, &res);
837 expect(InvalidParameter, status);
838
839 res = FALSE;
840 status = GdipIsInfiniteRegion(region, graphics, &res);
841 expect(Ok, status);
842 expect(TRUE, res);
843
844 /* after world transform */
845 status = GdipSetWorldTransform(graphics, m);
846 expect(Ok, status);
847
848 res = FALSE;
849 status = GdipIsInfiniteRegion(region, graphics, &res);
850 expect(Ok, status);
851 expect(TRUE, res);
852
853 GdipDeleteMatrix(m);
854 GdipDeleteRegion(region);
855 GdipDeleteGraphics(graphics);
856 ReleaseDC(0, hdc);
857 }
858
859 static void test_isempty(void)
860 {
861 GpStatus status;
862 GpRegion *region;
863 GpGraphics *graphics = NULL;
864 HDC hdc = GetDC(0);
865 BOOL res;
866
867 status = GdipCreateFromHDC(hdc, &graphics);
868 expect(Ok, status);
869 GdipCreateRegion(&region);
870
871 /* NULL arguments */
872 status = GdipIsEmptyRegion(NULL, NULL, NULL);
873 expect(InvalidParameter, status);
874 status = GdipIsEmptyRegion(region, NULL, NULL);
875 expect(InvalidParameter, status);
876 status = GdipIsEmptyRegion(NULL, graphics, NULL);
877 expect(InvalidParameter, status);
878 status = GdipIsEmptyRegion(NULL, NULL, &res);
879 expect(InvalidParameter, status);
880 status = GdipIsEmptyRegion(region, NULL, &res);
881 expect(InvalidParameter, status);
882
883 /* default is infinite */
884 res = TRUE;
885 status = GdipIsEmptyRegion(region, graphics, &res);
886 expect(Ok, status);
887 expect(FALSE, res);
888
889 status = GdipSetEmpty(region);
890 expect(Ok, status);
891
892 res = FALSE;
893 status = GdipIsEmptyRegion(region, graphics, &res);
894 expect(Ok, status);
895 expect(TRUE, res);
896
897 GdipDeleteRegion(region);
898 GdipDeleteGraphics(graphics);
899 ReleaseDC(0, hdc);
900 }
901
902 static void test_combinereplace(void)
903 {
904 GpStatus status;
905 GpRegion *region, *region2;
906 GpPath *path;
907 GpRectF rectf;
908 UINT needed;
909 DWORD buf[50];
910
911 rectf.X = rectf.Y = 0.0;
912 rectf.Width = rectf.Height = 100.0;
913
914 status = GdipCreateRegionRect(&rectf, &region);
915 expect(Ok, status);
916
917 /* replace with the same rectangle */
918 status = GdipCombineRegionRect(region, &rectf,CombineModeReplace);
919 expect(Ok, status);
920
921 status = GdipGetRegionDataSize(region, &needed);
922 expect(Ok, status);
923 expect(36, needed);
924 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
925 expect(Ok, status);
926 expect(36, needed);
927 expect_dword(buf, 28);
928 trace("buf[1] = %08x\n", buf[1]);
929 expect_magic(buf + 2);
930 expect_dword(buf + 3, 0);
931 expect_dword(buf + 4, RGNDATA_RECT);
932
933 /* replace with path */
934 status = GdipCreatePath(FillModeAlternate, &path);
935 expect(Ok, status);
936 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
937 expect(Ok, status);
938 status = GdipCombineRegionPath(region, path, CombineModeReplace);
939 expect(Ok, status);
940
941 status = GdipGetRegionDataSize(region, &needed);
942 expect(Ok, status);
943 expect(156, needed);
944 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
945 expect(Ok, status);
946 expect(156, needed);
947 expect_dword(buf, 148);
948 trace("buf[1] = %08x\n", buf[1]);
949 expect_magic(buf + 2);
950 expect_dword(buf + 3, 0);
951 expect_dword(buf + 4, RGNDATA_PATH);
952 GdipDeletePath(path);
953
954 /* replace with infinite rect */
955 status = GdipCreateRegion(&region2);
956 expect(Ok, status);
957 status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
958 expect(Ok, status);
959
960 status = GdipGetRegionDataSize(region, &needed);
961 expect(Ok, status);
962 expect(20, needed);
963 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
964 expect(Ok, status);
965 expect(20, needed);
966 expect_dword(buf, 12);
967 trace("buf[1] = %08x\n", buf[1]);
968 expect_magic(buf + 2);
969 expect_dword(buf + 3, 0);
970 expect_dword(buf + 4, RGNDATA_INFINITE_RECT);
971 GdipDeleteRegion(region2);
972
973 /* more complex case : replace with a combined region */
974 status = GdipCreateRegionRect(&rectf, &region2);
975 expect(Ok, status);
976 status = GdipCreatePath(FillModeAlternate, &path);
977 expect(Ok, status);
978 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 250.0);
979 expect(Ok, status);
980 status = GdipCombineRegionPath(region2, path, CombineModeUnion);
981 expect(Ok, status);
982 GdipDeletePath(path);
983 status = GdipCombineRegionRegion(region, region2, CombineModeReplace);
984 expect(Ok, status);
985 GdipDeleteRegion(region2);
986
987 status = GdipGetRegionDataSize(region, &needed);
988 expect(Ok, status);
989 expect(180, needed);
990 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
991 expect(Ok, status);
992 expect(180, needed);
993 expect_dword(buf, 172);
994 trace("buf[1] = %08x\n", buf[1]);
995 expect_magic(buf + 2);
996 expect_dword(buf + 3, 2);
997 expect_dword(buf + 4, CombineModeUnion);
998
999 GdipDeleteRegion(region);
1000 }
1001
1002 static void test_fromhrgn(void)
1003 {
1004 GpStatus status;
1005 GpRegion *region = (GpRegion*)0xabcdef01;
1006 HRGN hrgn;
1007 UINT needed;
1008 DWORD buf[220];
1009 RegionDataPoint *point;
1010 GpGraphics *graphics = NULL;
1011 HDC hdc;
1012 BOOL res;
1013
1014 /* NULL */
1015 status = GdipCreateRegionHrgn(NULL, NULL);
1016 expect(InvalidParameter, status);
1017 status = GdipCreateRegionHrgn(NULL, &region);
1018 expect(InvalidParameter, status);
1019 status = GdipCreateRegionHrgn((HRGN)0xdeadbeef, &region);
1020 expect(InvalidParameter, status);
1021 ok(region == (GpRegion*)0xabcdef01, "Expected region not to be created\n");
1022
1023 /* empty rectangle */
1024 hrgn = CreateRectRgn(0, 0, 0, 0);
1025 status = GdipCreateRegionHrgn(hrgn, &region);
1026 expect(Ok, status);
1027 if(status == Ok) {
1028
1029 hdc = GetDC(0);
1030 status = GdipCreateFromHDC(hdc, &graphics);
1031 expect(Ok, status);
1032 res = FALSE;
1033 status = GdipIsEmptyRegion(region, graphics, &res);
1034 expect(Ok, status);
1035 expect(TRUE, res);
1036 GdipDeleteGraphics(graphics);
1037 ReleaseDC(0, hdc);
1038 GdipDeleteRegion(region);
1039
1040 }
1041 DeleteObject(hrgn);
1042
1043 /* rectangle */
1044 hrgn = CreateRectRgn(0, 0, 100, 10);
1045 status = GdipCreateRegionHrgn(hrgn, &region);
1046 expect(Ok, status);
1047
1048 status = GdipGetRegionDataSize(region, &needed);
1049 expect(Ok, status);
1050 expect(56, needed);
1051
1052 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
1053 expect(Ok, status);
1054
1055 if(status == Ok){
1056
1057 expect(56, needed);
1058 expect_dword(buf, 48);
1059 expect_magic(buf + 2);
1060 expect_dword(buf + 3, 0);
1061 expect_dword(buf + 4, RGNDATA_PATH);
1062 expect_dword(buf + 5, 0x00000020);
1063 expect_magic(buf + 6);
1064 expect_dword(buf + 7, 0x00000004);
1065 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
1066
1067 point = (RegionDataPoint*)buf + 9;
1068
1069 expect(0, point[0].X);
1070 expect(0, point[0].Y);
1071
1072 expect(100,point[1].X); /* buf + 10 */
1073 expect(0, point[1].Y);
1074 expect(100,point[2].X); /* buf + 11 */
1075 expect(10, point[2].Y);
1076
1077 expect(0, point[3].X); /* buf + 12 */
1078
1079 expect(10, point[3].Y);
1080 expect_dword(buf + 13, 0x81010100); /* closed */
1081
1082 }
1083
1084 GdipDeleteRegion(region);
1085 DeleteObject(hrgn);
1086
1087 /* ellipse */
1088 hrgn = CreateEllipticRgn(0, 0, 100, 10);
1089 status = GdipCreateRegionHrgn(hrgn, &region);
1090 expect(Ok, status);
1091
1092 status = GdipGetRegionDataSize(region, &needed);
1093 expect(Ok, status);
1094 ok(needed == 216 ||
1095 needed == 196, /* win98 */
1096 "Got %.8x\n", needed);
1097
1098 status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
1099 expect(Ok, status);
1100
1101 if(status == Ok && needed == 216) /* Don't try to test win98 layout */
1102 {
1103 expect(Ok, status);
1104 expect(216, needed);
1105 expect_dword(buf, 208);
1106 expect_magic(buf + 2);
1107 expect_dword(buf + 3, 0);
1108 expect_dword(buf + 4, RGNDATA_PATH);
1109 expect_dword(buf + 5, 0x000000C0);
1110 expect_magic(buf + 6);
1111 expect_dword(buf + 7, 0x00000024);
1112 todo_wine expect_dword(buf + 8, 0x00006000); /* ?? */
1113 }
1114
1115 GdipDeleteRegion(region);
1116 DeleteObject(hrgn);
1117 }
1118
1119 static void test_gethrgn(void)
1120 {
1121 GpStatus status;
1122 GpRegion *region, *region2;
1123 GpPath *path;
1124 GpGraphics *graphics;
1125 HRGN hrgn;
1126 HDC hdc=GetDC(0);
1127 static const RECT empty_rect = {0,0,0,0};
1128 static const RECT test_rect = {10, 11, 20, 21};
1129 static const GpRectF test_rectF = {10.0, 11.0, 10.0, 10.0};
1130 static const RECT scaled_rect = {20, 22, 40, 42};
1131 static const RECT test_rect2 = {10, 21, 20, 31};
1132 static const GpRectF test_rect2F = {10.0, 21.0, 10.0, 10.0};
1133 static const RECT test_rect3 = {10, 11, 20, 31};
1134 static const GpRectF test_rect3F = {10.0, 11.0, 10.0, 20.0};
1135
1136 status = GdipCreateFromHDC(hdc, &graphics);
1137 ok(status == Ok, "status %08x\n", status);
1138
1139 status = GdipCreateRegion(&region);
1140 ok(status == Ok, "status %08x\n", status);
1141
1142 status = GdipGetRegionHRgn(NULL, graphics, &hrgn);
1143 ok(status == InvalidParameter, "status %08x\n", status);
1144 status = GdipGetRegionHRgn(region, graphics, NULL);
1145 ok(status == InvalidParameter, "status %08x\n", status);
1146
1147 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1148 ok(status == Ok, "status %08x\n", status);
1149 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
1150
1151 status = GdipGetRegionHRgn(region, graphics, &hrgn);
1152 ok(status == Ok, "status %08x\n", status);
1153 ok(hrgn == NULL, "hrgn=%p\n", hrgn);
1154
1155 status = GdipSetEmpty(region);
1156 ok(status == Ok, "status %08x\n", status);
1157 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1158 ok(status == Ok, "status %08x\n", status);
1159 verify_region(hrgn, &empty_rect);
1160 DeleteObject(hrgn);
1161
1162 status = GdipCreatePath(FillModeAlternate, &path);
1163 ok(status == Ok, "status %08x\n", status);
1164 status = GdipAddPathRectangle(path, 10.0, 11.0, 10.0, 10.0);
1165 ok(status == Ok, "status %08x\n", status);
1166
1167 status = GdipCreateRegionPath(path, &region2);
1168 ok(status == Ok, "status %08x\n", status);
1169 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
1170 ok(status == Ok, "status %08x\n", status);
1171 verify_region(hrgn, &test_rect);
1172 DeleteObject(hrgn);
1173
1174 /* resulting HRGN is in device coordinates */
1175 status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1176 ok(status == Ok, "status %08x\n", status);
1177 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
1178 ok(status == Ok, "status %08x\n", status);
1179 verify_region(hrgn, &scaled_rect);
1180 DeleteObject(hrgn);
1181
1182 status = GdipCombineRegionRect(region2, &test_rectF, CombineModeReplace);
1183 ok(status == Ok, "status %08x\n", status);
1184 status = GdipGetRegionHRgn(region2, NULL, &hrgn);
1185 ok(status == Ok, "status %08x\n", status);
1186 verify_region(hrgn, &test_rect);
1187 DeleteObject(hrgn);
1188
1189 status = GdipGetRegionHRgn(region2, graphics, &hrgn);
1190 ok(status == Ok, "status %08x\n", status);
1191 verify_region(hrgn, &scaled_rect);
1192 DeleteObject(hrgn);
1193
1194 status = GdipSetInfinite(region);
1195 ok(status == Ok, "status %08x\n", status);
1196 status = GdipCombineRegionRect(region, &test_rectF, CombineModeIntersect);
1197 ok(status == Ok, "status %08x\n", status);
1198 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1199 ok(status == Ok, "status %08x\n", status);
1200 verify_region(hrgn, &test_rect);
1201 DeleteObject(hrgn);
1202
1203 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
1204 ok(status == Ok, "status %08x\n", status);
1205 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeUnion);
1206 ok(status == Ok, "status %08x\n", status);
1207 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1208 ok(status == Ok, "status %08x\n", status);
1209 verify_region(hrgn, &test_rect3);
1210 DeleteObject(hrgn);
1211
1212 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
1213 ok(status == Ok, "status %08x\n", status);
1214 status = GdipCombineRegionRect(region, &test_rect2F, CombineModeXor);
1215 ok(status == Ok, "status %08x\n", status);
1216 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1217 ok(status == Ok, "status %08x\n", status);
1218 verify_region(hrgn, &test_rect);
1219 DeleteObject(hrgn);
1220
1221 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeReplace);
1222 ok(status == Ok, "status %08x\n", status);
1223 status = GdipCombineRegionRect(region, &test_rectF, CombineModeExclude);
1224 ok(status == Ok, "status %08x\n", status);
1225 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1226 ok(status == Ok, "status %08x\n", status);
1227 verify_region(hrgn, &test_rect2);
1228 DeleteObject(hrgn);
1229
1230 status = GdipCombineRegionRect(region, &test_rectF, CombineModeReplace);
1231 ok(status == Ok, "status %08x\n", status);
1232 status = GdipCombineRegionRect(region, &test_rect3F, CombineModeComplement);
1233 ok(status == Ok, "status %08x\n", status);
1234 status = GdipGetRegionHRgn(region, NULL, &hrgn);
1235 ok(status == Ok, "status %08x\n", status);
1236 verify_region(hrgn, &test_rect2);
1237 DeleteObject(hrgn);
1238
1239 status = GdipDeletePath(path);
1240 ok(status == Ok, "status %08x\n", status);
1241 status = GdipDeleteRegion(region);
1242 ok(status == Ok, "status %08x\n", status);
1243 status = GdipDeleteRegion(region2);
1244 ok(status == Ok, "status %08x\n", status);
1245 status = GdipDeleteGraphics(graphics);
1246 ok(status == Ok, "status %08x\n", status);
1247 ReleaseDC(0, hdc);
1248 }
1249
1250 static void test_isequal(void)
1251 {
1252 GpRegion *region1, *region2;
1253 GpGraphics *graphics;
1254 GpRectF rectf;
1255 GpStatus status;
1256 HDC hdc = GetDC(0);
1257 BOOL res;
1258
1259 status = GdipCreateFromHDC(hdc, &graphics);
1260 ok(status == Ok, "status %08x\n", status);
1261
1262 status = GdipCreateRegion(&region1);
1263 ok(status == Ok, "status %08x\n", status);
1264 status = GdipCreateRegion(&region2);
1265 ok(status == Ok, "status %08x\n", status);
1266
1267 /* NULL */
1268 status = GdipIsEqualRegion(NULL, NULL, NULL, NULL);
1269 ok(status == InvalidParameter, "status %08x\n", status);
1270 status = GdipIsEqualRegion(region1, region2, NULL, NULL);
1271 ok(status == InvalidParameter, "status %08x\n", status);
1272 status = GdipIsEqualRegion(region1, region2, graphics, NULL);
1273 ok(status == InvalidParameter, "status %08x\n", status);
1274 status = GdipIsEqualRegion(region1, region2, NULL, &res);
1275 ok(status == InvalidParameter, "status %08x\n", status);
1276
1277 /* infinite regions */
1278 res = FALSE;
1279 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1280 ok(status == Ok, "status %08x\n", status);
1281 ok(res, "Expected to be equal.\n");
1282 /* empty regions */
1283 status = GdipSetEmpty(region1);
1284 ok(status == Ok, "status %08x\n", status);
1285 status = GdipSetEmpty(region2);
1286 ok(status == Ok, "status %08x\n", status);
1287 res = FALSE;
1288 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1289 ok(status == Ok, "status %08x\n", status);
1290 ok(res, "Expected to be equal.\n");
1291 /* empty & infinite */
1292 status = GdipSetInfinite(region1);
1293 ok(status == Ok, "status %08x\n", status);
1294 res = TRUE;
1295 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1296 ok(status == Ok, "status %08x\n", status);
1297 ok(!res, "Expected to be unequal.\n");
1298 /* rect & (inf/empty) */
1299 rectf.X = rectf.Y = 0.0;
1300 rectf.Width = rectf.Height = 100.0;
1301 status = GdipCombineRegionRect(region1, &rectf, CombineModeReplace);
1302 ok(status == Ok, "status %08x\n", status);
1303 res = TRUE;
1304 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1305 ok(status == Ok, "status %08x\n", status);
1306 ok(!res, "Expected to be unequal.\n");
1307 status = GdipSetInfinite(region2);
1308 ok(status == Ok, "status %08x\n", status);
1309 res = TRUE;
1310 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1311 ok(status == Ok, "status %08x\n", status);
1312 ok(!res, "Expected to be unequal.\n");
1313 /* roughly equal rectangles */
1314 rectf.X = rectf.Y = 0.0;
1315 rectf.Width = rectf.Height = 100.001;
1316 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1317 ok(status == Ok, "status %08x\n", status);
1318 res = FALSE;
1319 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1320 ok(status == Ok, "status %08x\n", status);
1321 ok(res, "Expected to be equal.\n");
1322 /* equal rectangles */
1323 rectf.X = rectf.Y = 0.0;
1324 rectf.Width = rectf.Height = 100.0;
1325 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1326 ok(status == Ok, "status %08x\n", status);
1327 res = FALSE;
1328 status = GdipIsEqualRegion(region1, region2, graphics, &res);
1329 ok(status == Ok, "status %08x\n", status);
1330 ok(res, "Expected to be equal.\n");
1331
1332 /* cleanup */
1333 status = GdipDeleteRegion(region1);
1334 ok(status == Ok, "status %08x\n", status);
1335 status = GdipDeleteRegion(region2);
1336 ok(status == Ok, "status %08x\n", status);
1337 status = GdipDeleteGraphics(graphics);
1338 ok(status == Ok, "status %08x\n", status);
1339 ReleaseDC(0, hdc);
1340 }
1341
1342 static void test_translate(void)
1343 {
1344 GpRegion *region, *region2;
1345 GpGraphics *graphics;
1346 GpPath *path;
1347 GpRectF rectf;
1348 GpStatus status;
1349 HDC hdc = GetDC(0);
1350 BOOL res;
1351
1352 status = GdipCreateFromHDC(hdc, &graphics);
1353 ok(status == Ok, "status %08x\n", status);
1354
1355 status = GdipCreatePath(FillModeAlternate, &path);
1356 ok(status == Ok, "status %08x\n", status);
1357
1358 status = GdipCreateRegion(&region);
1359 ok(status == Ok, "status %08x\n", status);
1360 status = GdipCreateRegion(&region2);
1361 ok(status == Ok, "status %08x\n", status);
1362
1363 /* NULL */
1364 status = GdipTranslateRegion(NULL, 0.0, 0.0);
1365 ok(status == InvalidParameter, "status %08x\n", status);
1366
1367 /* infinite */
1368 status = GdipTranslateRegion(region, 10.0, 10.0);
1369 ok(status == Ok, "status %08x\n", status);
1370 /* empty */
1371 status = GdipSetEmpty(region);
1372 ok(status == Ok, "status %08x\n", status);
1373 status = GdipTranslateRegion(region, 10.0, 10.0);
1374 ok(status == Ok, "status %08x\n", status);
1375 /* rect */
1376 rectf.X = 10.0; rectf.Y = 0.0;
1377 rectf.Width = rectf.Height = 100.0;
1378 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1379 ok(status == Ok, "status %08x\n", status);
1380 rectf.X = 15.0; rectf.Y = -2.0;
1381 rectf.Width = rectf.Height = 100.0;
1382 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1383 ok(status == Ok, "status %08x\n", status);
1384 status = GdipTranslateRegion(region, 5.0, -2.0);
1385 ok(status == Ok, "status %08x\n", status);
1386 res = FALSE;
1387 status = GdipIsEqualRegion(region, region2, graphics, &res);
1388 ok(status == Ok, "status %08x\n", status);
1389 ok(res, "Expected to be equal.\n");
1390 /* path */
1391 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1392 ok(status == Ok, "status %08x\n", status);
1393 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1394 ok(status == Ok, "status %08x\n", status);
1395 status = GdipResetPath(path);
1396 ok(status == Ok, "status %08x\n", status);
1397 status = GdipAddPathEllipse(path, 10.0, 21.0, 100.0, 150.0);
1398 ok(status == Ok, "status %08x\n", status);
1399 status = GdipCombineRegionPath(region2, path, CombineModeReplace);
1400 ok(status == Ok, "status %08x\n", status);
1401 status = GdipTranslateRegion(region, 10.0, 11.0);
1402 ok(status == Ok, "status %08x\n", status);
1403 res = FALSE;
1404 status = GdipIsEqualRegion(region, region2, graphics, &res);
1405 ok(status == Ok, "status %08x\n", status);
1406 ok(res, "Expected to be equal.\n");
1407
1408 status = GdipDeleteRegion(region);
1409 ok(status == Ok, "status %08x\n", status);
1410 status = GdipDeleteRegion(region2);
1411 ok(status == Ok, "status %08x\n", status);
1412 status = GdipDeleteGraphics(graphics);
1413 ok(status == Ok, "status %08x\n", status);
1414 status = GdipDeletePath(path);
1415 ok(status == Ok, "status %08x\n", status);
1416 ReleaseDC(0, hdc);
1417 }
1418
1419 static void test_transform(void)
1420 {
1421 GpRegion *region, *region2;
1422 GpMatrix *matrix;
1423 GpGraphics *graphics;
1424 GpPath *path;
1425 GpRectF rectf;
1426 GpStatus status;
1427 HDC hdc = GetDC(0);
1428 BOOL res;
1429
1430 status = GdipCreateFromHDC(hdc, &graphics);
1431 expect(Ok, status);
1432
1433 status = GdipCreatePath(FillModeAlternate, &path);
1434 expect(Ok, status);
1435
1436 status = GdipCreateRegion(&region);
1437 expect(Ok, status);
1438 status = GdipCreateRegion(&region2);
1439 expect(Ok, status);
1440
1441 status = GdipCreateMatrix(&matrix);
1442 expect(Ok, status);
1443 status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
1444 expect(Ok, status);
1445
1446 /* NULL */
1447 status = GdipTransformRegion(NULL, matrix);
1448 expect(InvalidParameter, status);
1449
1450 status = GdipTransformRegion(region, NULL);
1451 expect(InvalidParameter, status);
1452
1453 /* infinite */
1454 status = GdipTransformRegion(region, matrix);
1455 expect(Ok, status);
1456
1457 res = FALSE;
1458 status = GdipIsEqualRegion(region, region2, graphics, &res);
1459 expect(Ok, status);
1460 ok(res, "Expected to be equal.\n");
1461
1462 /* empty */
1463 status = GdipSetEmpty(region);
1464 expect(Ok, status);
1465 status = GdipTransformRegion(region, matrix);
1466 expect(Ok, status);
1467
1468 status = GdipSetEmpty(region2);
1469 expect(Ok, status);
1470
1471 res = FALSE;
1472 status = GdipIsEqualRegion(region, region2, graphics, &res);
1473 expect(Ok, status);
1474 ok(res, "Expected to be equal.\n");
1475
1476 /* rect */
1477 rectf.X = 10.0;
1478 rectf.Y = 0.0;
1479 rectf.Width = rectf.Height = 100.0;
1480 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1481 expect(Ok, status);
1482 rectf.X = 20.0;
1483 rectf.Y = 0.0;
1484 rectf.Width = 200.0;
1485 rectf.Height = 300.0;
1486 status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
1487 expect(Ok, status);
1488 status = GdipTransformRegion(region, matrix);
1489 expect(Ok, status);
1490 res = FALSE;
1491 status = GdipIsEqualRegion(region, region2, graphics, &res);
1492 expect(Ok, status);
1493 ok(res, "Expected to be equal.\n");
1494
1495 /* path */
1496 status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
1497 expect(Ok, status);
1498 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1499 expect(Ok, status);
1500 status = GdipResetPath(path);
1501 expect(Ok, status);
1502 status = GdipAddPathEllipse(path, 0.0, 30.0, 200.0, 450.0);
1503 expect(Ok, status);
1504 status = GdipCombineRegionPath(region2, path, CombineModeReplace);
1505 expect(Ok, status);
1506 status = GdipTransformRegion(region, matrix);
1507 expect(Ok, status);
1508 res = FALSE;
1509 status = GdipIsEqualRegion(region, region2, graphics, &res);
1510 expect(Ok, status);
1511 ok(res, "Expected to be equal.\n");
1512
1513 status = GdipDeleteRegion(region);
1514 expect(Ok, status);
1515 status = GdipDeleteRegion(region2);
1516 expect(Ok, status);
1517 status = GdipDeleteGraphics(graphics);
1518 expect(Ok, status);
1519 status = GdipDeletePath(path);
1520 expect(Ok, status);
1521 status = GdipDeleteMatrix(matrix);
1522 expect(Ok, status);
1523 ReleaseDC(0, hdc);
1524 }
1525
1526 static void test_scans(void)
1527 {
1528 GpRegion *region;
1529 GpMatrix *matrix;
1530 GpRectF rectf;
1531 GpStatus status;
1532 ULONG count=80085;
1533 INT icount;
1534 GpRectF scans[2];
1535 GpRect scansi[2];
1536
1537 status = GdipCreateRegion(&region);
1538 expect(Ok, status);
1539
1540 status = GdipCreateMatrix(&matrix);
1541 expect(Ok, status);
1542
1543 /* test NULL values */
1544 status = GdipGetRegionScansCount(NULL, &count, matrix);
1545 expect(InvalidParameter, status);
1546
1547 status = GdipGetRegionScansCount(region, NULL, matrix);
1548 expect(InvalidParameter, status);
1549
1550 status = GdipGetRegionScansCount(region, &count, NULL);
1551 expect(InvalidParameter, status);
1552
1553 status = GdipGetRegionScans(NULL, scans, &icount, matrix);
1554 expect(InvalidParameter, status);
1555
1556 status = GdipGetRegionScans(region, scans, NULL, matrix);
1557 expect(InvalidParameter, status);
1558
1559 status = GdipGetRegionScans(region, scans, &icount, NULL);
1560 expect(InvalidParameter, status);
1561
1562 /* infinite */
1563 status = GdipGetRegionScansCount(region, &count, matrix);
1564 expect(Ok, status);
1565 expect(1, count);
1566
1567 status = GdipGetRegionScans(region, NULL, &icount, matrix);
1568 expect(Ok, status);
1569 expect(1, icount);
1570
1571 status = GdipGetRegionScans(region, scans, &icount, matrix);
1572 expect(Ok, status);
1573 expect(1, icount);
1574
1575 status = GdipGetRegionScansI(region, scansi, &icount, matrix);
1576 expect(Ok, status);
1577 expect(1, icount);
1578 expect(-0x400000, scansi[0].X);
1579 expect(-0x400000, scansi[0].Y);
1580 expect(0x800000, scansi[0].Width);
1581 expect(0x800000, scansi[0].Height);
1582
1583 status = GdipGetRegionScans(region, scans, &icount, matrix);
1584 expect(Ok, status);
1585 expect(1, icount);
1586 expectf((double)-0x400000, scans[0].X);
1587 expectf((double)-0x400000, scans[0].Y);
1588 expectf((double)0x800000, scans[0].Width);
1589 expectf((double)0x800000, scans[0].Height);
1590
1591 /* empty */
1592 status = GdipSetEmpty(region);
1593 expect(Ok, status);
1594
1595 status = GdipGetRegionScansCount(region, &count, matrix);
1596 expect(Ok, status);
1597 expect(0, count);
1598
1599 status = GdipGetRegionScans(region, scans, &icount, matrix);
1600 expect(Ok, status);
1601 expect(0, icount);
1602
1603 /* single rectangle */
1604 rectf.X = rectf.Y = 0.0;
1605 rectf.Width = rectf.Height = 5.0;
1606 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1607 expect(Ok, status);
1608
1609 status = GdipGetRegionScansCount(region, &count, matrix);
1610 expect(Ok, status);
1611 expect(1, count);
1612
1613 status = GdipGetRegionScans(region, scans, &icount, matrix);
1614 expect(Ok, status);
1615 expect(1, icount);
1616 expectf(0.0, scans[0].X);
1617 expectf(0.0, scans[0].Y);
1618 expectf(5.0, scans[0].Width);
1619 expectf(5.0, scans[0].Height);
1620
1621 /* two rectangles */
1622 rectf.X = rectf.Y = 5.0;
1623 rectf.Width = rectf.Height = 5.0;
1624 status = GdipCombineRegionRect(region, &rectf, CombineModeUnion);
1625 expect(Ok, status);
1626
1627 status = GdipGetRegionScansCount(region, &count, matrix);
1628 expect(Ok, status);
1629 expect(2, count);
1630
1631 /* Native ignores the initial value of count */
1632 scans[1].X = scans[1].Y = scans[1].Width = scans[1].Height = 8.0;
1633 icount = 1;
1634 status = GdipGetRegionScans(region, scans, &icount, matrix);
1635 expect(Ok, status);
1636 expect(2, icount);
1637 expectf(0.0, scans[0].X);
1638 expectf(0.0, scans[0].Y);
1639 expectf(5.0, scans[0].Width);
1640 expectf(5.0, scans[0].Height);
1641 expectf(5.0, scans[1].X);
1642 expectf(5.0, scans[1].Y);
1643 expectf(5.0, scans[1].Width);
1644 expectf(5.0, scans[1].Height);
1645
1646 status = GdipGetRegionScansI(region, scansi, &icount, matrix);
1647 expect(Ok, status);
1648 expect(2, icount);
1649 expect(0, scansi[0].X);
1650 expect(0, scansi[0].Y);
1651 expect(5, scansi[0].Width);
1652 expect(5, scansi[0].Height);
1653 expect(5, scansi[1].X);
1654 expect(5, scansi[1].Y);
1655 expect(5, scansi[1].Width);
1656 expect(5, scansi[1].Height);
1657
1658 status = GdipDeleteRegion(region);
1659 expect(Ok, status);
1660 status = GdipDeleteMatrix(matrix);
1661 expect(Ok, status);
1662 }
1663
1664 static void test_getbounds(void)
1665 {
1666 GpRegion *region;
1667 GpGraphics *graphics;
1668 GpStatus status;
1669 GpRectF rectf;
1670 HDC hdc = GetDC(0);
1671
1672 status = GdipCreateFromHDC(hdc, &graphics);
1673 ok(status == Ok, "status %08x\n", status);
1674 status = GdipCreateRegion(&region);
1675 ok(status == Ok, "status %08x\n", status);
1676
1677 /* NULL */
1678 status = GdipGetRegionBounds(NULL, NULL, NULL);
1679 ok(status == InvalidParameter, "status %08x\n", status);
1680 status = GdipGetRegionBounds(region, NULL, NULL);
1681 ok(status == InvalidParameter, "status %08x\n", status);
1682 status = GdipGetRegionBounds(region, graphics, NULL);
1683 ok(status == InvalidParameter, "status %08x\n", status);
1684 /* infinite */
1685 rectf.X = rectf.Y = 0.0;
1686 rectf.Height = rectf.Width = 100.0;
1687 status = GdipGetRegionBounds(region, graphics, &rectf);
1688 ok(status == Ok, "status %08x\n", status);
1689 ok(rectf.X == -(REAL)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.X);
1690 ok(rectf.Y == -(REAL)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.Y);
1691 ok(rectf.Width == (REAL)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL)(1 << 23), rectf.Width);
1692 ok(rectf.Height == (REAL)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL)(1 << 23), rectf.Height);
1693 /* empty */
1694 rectf.X = rectf.Y = 0.0;
1695 rectf.Height = rectf.Width = 100.0;
1696 status = GdipSetEmpty(region);
1697 ok(status == Ok, "status %08x\n", status);
1698 status = GdipGetRegionBounds(region, graphics, &rectf);
1699 ok(status == Ok, "status %08x\n", status);
1700 ok(rectf.X == 0.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1701 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1702 ok(rectf.Width == 0.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1703 ok(rectf.Height == 0.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1704 /* rect */
1705 rectf.X = 10.0; rectf.Y = 0.0;
1706 rectf.Width = rectf.Height = 100.0;
1707 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1708 ok(status == Ok, "status %08x\n", status);
1709 rectf.X = rectf.Y = 0.0;
1710 rectf.Height = rectf.Width = 0.0;
1711 status = GdipGetRegionBounds(region, graphics, &rectf);
1712 ok(status == Ok, "status %08x\n", status);
1713 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1714 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1715 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1716 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1717
1718 /* the world and page transforms are ignored */
1719 GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
1720 GdipSetPageUnit(graphics, UnitInch);
1721 GdipSetPageScale(graphics, 2.0);
1722 status = GdipGetRegionBounds(region, graphics, &rectf);
1723 ok(status == Ok, "status %08x\n", status);
1724 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1725 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1726 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1727
1728 rectf.X = 10.0; rectf.Y = 0.0;
1729 rectf.Width = rectf.Height = 100.0;
1730 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1731 ok(status == Ok, "status %08x\n", status);
1732 rectf.X = rectf.Y = 0.0;
1733 rectf.Height = rectf.Width = 0.0;
1734 status = GdipGetRegionBounds(region, graphics, &rectf);
1735 ok(status == Ok, "status %08x\n", status);
1736 ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
1737 ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
1738 ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
1739 ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
1740
1741 status = GdipDeleteRegion(region);
1742 ok(status == Ok, "status %08x\n", status);
1743 status = GdipDeleteGraphics(graphics);
1744 ok(status == Ok, "status %08x\n", status);
1745 ReleaseDC(0, hdc);
1746 }
1747
1748 static void test_isvisiblepoint(void)
1749 {
1750 HDC hdc = GetDC(0);
1751 GpGraphics* graphics;
1752 GpRegion* region;
1753 GpPath* path;
1754 GpRectF rectf;
1755 GpStatus status;
1756 BOOL res;
1757 REAL x, y;
1758
1759 status = GdipCreateFromHDC(hdc, &graphics);
1760 expect(Ok, status);
1761
1762 status = GdipCreateRegion(&region);
1763 expect(Ok, status);
1764
1765 /* null parameters */
1766 status = GdipIsVisibleRegionPoint(NULL, 0, 0, graphics, &res);
1767 expect(InvalidParameter, status);
1768 status = GdipIsVisibleRegionPointI(NULL, 0, 0, graphics, &res);
1769 expect(InvalidParameter, status);
1770
1771 status = GdipIsVisibleRegionPoint(region, 0, 0, NULL, &res);
1772 expect(Ok, status);
1773 status = GdipIsVisibleRegionPointI(region, 0, 0, NULL, &res);
1774 expect(Ok, status);
1775
1776 status = GdipIsVisibleRegionPoint(region, 0, 0, graphics, NULL);
1777 expect(InvalidParameter, status);
1778 status = GdipIsVisibleRegionPointI(region, 0, 0, graphics, NULL);
1779 expect(InvalidParameter, status);
1780
1781 /* infinite region */
1782 status = GdipIsInfiniteRegion(region, graphics, &res);
1783 expect(Ok, status);
1784 ok(res == TRUE, "Region should be infinite\n");
1785
1786 x = 10;
1787 y = 10;
1788 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1789 expect(Ok, status);
1790 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1791 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1792 expect(Ok, status);
1793 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1794
1795 x = -10;
1796 y = -10;
1797 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1798 expect(Ok, status);
1799 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1800 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1801 expect(Ok, status);
1802 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1803
1804 /* rectangular region */
1805 rectf.X = 10;
1806 rectf.Y = 20;
1807 rectf.Width = 30;
1808 rectf.Height = 40;
1809
1810 status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
1811 expect(Ok, status);
1812
1813 x = 0;
1814 y = 0;
1815 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1816 expect(Ok, status);
1817 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1818 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1819 expect(Ok, status);
1820 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1821
1822 x = 9;
1823 y = 19;
1824 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1825 expect(Ok, status);
1826 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1827
1828 x = 9.25;
1829 y = 19.25;
1830 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1831 expect(Ok, status);
1832 ok(res == FALSE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1833
1834 x = 9.5;
1835 y = 19.5;
1836 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1837 expect(Ok, status);
1838 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1839
1840 x = 9.75;
1841 y = 19.75;
1842 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1843 expect(Ok, status);
1844 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1845
1846 x = 10;
1847 y = 20;
1848 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1849 expect(Ok, status);
1850 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1851
1852 x = 25;
1853 y = 40;
1854 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1855 expect(Ok, status);
1856 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1857 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1858 expect(Ok, status);
1859 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1860
1861 x = 40;
1862 y = 60;
1863 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1864 expect(Ok, status);
1865 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1866 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1867 expect(Ok, status);
1868 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1869
1870 /* translate into the center of the rectangle */
1871 status = GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
1872 expect(Ok, status);
1873
1874 /* native ignores the world transform, so treat these as if
1875 * no transform exists */
1876 x = -20;
1877 y = -30;
1878 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1879 expect(Ok, status);
1880 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1881 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1882 expect(Ok, status);
1883 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1884
1885 x = 0;
1886 y = 0;
1887 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1888 expect(Ok, status);
1889 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1890 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1891 expect(Ok, status);
1892 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1893
1894 x = 25;
1895 y = 40;
1896 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1897 expect(Ok, status);
1898 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1899 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1900 expect(Ok, status);
1901 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1902
1903 /* translate back to origin */
1904 status = GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
1905 expect(Ok, status);
1906
1907 /* region from path */
1908 status = GdipCreatePath(FillModeAlternate, &path);
1909 expect(Ok, status);
1910
1911 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
1912 expect(Ok, status);
1913
1914 status = GdipCombineRegionPath(region, path, CombineModeReplace);
1915 expect(Ok, status);
1916
1917 x = 11;
1918 y = 21;
1919 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1920 expect(Ok, status);
1921 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1922 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1923 expect(Ok, status);
1924 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1925
1926 x = 25;
1927 y = 40;
1928 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1929 expect(Ok, status);
1930 ok(res == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
1931 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1932 expect(Ok, status);
1933 ok(res == TRUE, "Expected (%d, %d) to be visible\n", (INT)x, (INT)y);
1934
1935 x = 40;
1936 y = 60;
1937 status = GdipIsVisibleRegionPoint(region, x, y, graphics, &res);
1938 expect(Ok, status);
1939 ok(res == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
1940 status = GdipIsVisibleRegionPointI(region, (INT)x, (INT)y, graphics, &res);
1941 expect(Ok, status);
1942 ok(res == FALSE, "Expected (%d, %d) not to be visible\n", (INT)x, (INT)y);
1943
1944 GdipDeletePath(path);
1945
1946 GdipDeleteRegion(region);
1947 GdipDeleteGraphics(graphics);
1948 ReleaseDC(0, hdc);
1949 }
1950
1951 static void test_isvisiblerect(void)
1952 {
1953 HDC hdc = GetDC(0);
1954 GpGraphics* graphics;
1955 GpRegion* region;
1956 GpPath* path;
1957 GpRectF rectf;
1958 GpStatus status;
1959 BOOL res;
1960 REAL x, y, w, h;
1961
1962 status = GdipCreateFromHDC(hdc, &graphics);
1963 expect(Ok, status);
1964
1965 status = GdipCreateRegion(&region);
1966 expect(Ok, status);
1967
1968 /* null parameters */
1969 status = GdipIsVisibleRegionRect(NULL, 0, 0, 0, 0, graphics, &res);
1970 expect(InvalidParameter, status);
1971 status = GdipIsVisibleRegionRectI(NULL, 0, 0, 0, 0, graphics, &res);
1972 expect(InvalidParameter, status);
1973
1974 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, NULL, &res);
1975 expect(Ok, status);
1976 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, NULL, &res);
1977 expect(Ok, status);
1978
1979 status = GdipIsVisibleRegionRect(region, 0, 0, 0, 0, graphics, NULL);
1980 expect(InvalidParameter, status);
1981 status = GdipIsVisibleRegionRectI(region, 0, 0, 0, 0, graphics, NULL);
1982 expect(InvalidParameter, status);
1983
1984 /* infinite region */
1985 status = GdipIsInfiniteRegion(region, graphics, &res);
1986 expect(Ok, status);
1987 ok(res == TRUE, "Region should be infinite\n");
1988
1989 x = 10; w = 10;
1990 y = 10; h = 10;
1991 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1992 expect(Ok, status);
1993 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
1994
1995 x = -10; w = 5;
1996 y = -10; h = 5;
1997 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
1998 expect(Ok, status);
1999 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2000
2001 /* rectangular region */
2002 rectf.X = 10;
2003 rectf.Y = 20;
2004 rectf.Width = 30;
2005 rectf.Height = 40;
2006
2007 status = GdipCombineRegionRect(region, &rectf, CombineModeIntersect);
2008 expect(Ok, status);
2009
2010 /* entirely within the region */
2011 x = 11; w = 10;
2012 y = 12; h = 10;
2013 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2014 expect(Ok, status);
2015 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2016 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2017 expect(Ok, status);
2018 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2019
2020 /* entirely outside of the region */
2021 x = 0; w = 5;
2022 y = 0; h = 5;
2023 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2024 expect(Ok, status);
2025 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2026 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2027 expect(Ok, status);
2028 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2029
2030 /* corner cases */
2031 x = 0; w = 10;
2032 y = 0; h = 20;
2033 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2034 expect(Ok, status);
2035 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2036
2037 x = 0; w = 10.25;
2038 y = 0; h = 20.25;
2039 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2040 expect(Ok, status);
2041 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2042
2043 x = 39; w = 10;
2044 y = 59; h = 10;
2045 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2046 expect(Ok, status);
2047 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2048
2049 x = 39.25; w = 10;
2050 y = 59.25; h = 10;
2051 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2052 expect(Ok, status);
2053 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2054
2055 /* corners outside, but some intersection */
2056 x = 0; w = 100;
2057 y = 0; h = 100;
2058 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2059 expect(Ok, status);
2060 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2061
2062 x = 0; w = 100;
2063 y = 0; h = 40;
2064 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2065 expect(Ok, status);
2066 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2067
2068 x = 0; w = 25;
2069 y = 0; h = 100;
2070 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2071 expect(Ok, status);
2072 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2073
2074 /* translate into the center of the rectangle */
2075 status = GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2076 expect(Ok, status);
2077
2078 /* native ignores the world transform, so treat these as if
2079 * no transform exists */
2080 x = 0; w = 5;
2081 y = 0; h = 5;
2082 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2083 expect(Ok, status);
2084 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2085 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2086 expect(Ok, status);
2087 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2088
2089 x = 11; w = 10;
2090 y = 12; h = 10;
2091 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2092 expect(Ok, status);
2093 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2094 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2095 expect(Ok, status);
2096 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2097
2098 /* translate back to origin */
2099 status = GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2100 expect(Ok, status);
2101
2102 /* region from path */
2103 status = GdipCreatePath(FillModeAlternate, &path);
2104 expect(Ok, status);
2105
2106 status = GdipAddPathEllipse(path, 10, 20, 30, 40);
2107 expect(Ok, status);
2108
2109 status = GdipCombineRegionPath(region, path, CombineModeReplace);
2110 expect(Ok, status);
2111
2112 x = 0; w = 12;
2113 y = 0; h = 22;
2114 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2115 expect(Ok, status);
2116 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2117 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2118 expect(Ok, status);
2119 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2120
2121 x = 0; w = 25;
2122 y = 0; h = 40;
2123 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2124 expect(Ok, status);
2125 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2126 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2127 expect(Ok, status);
2128 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2129
2130 x = 38; w = 10;
2131 y = 55; h = 10;
2132 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2133 expect(Ok, status);
2134 ok(res == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, w, h);
2135 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2136 expect(Ok, status);
2137 ok(res == FALSE, "Expected (%d, %d, %d, %d) not to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2138
2139 x = 0; w = 100;
2140 y = 0; h = 100;
2141 status = GdipIsVisibleRegionRect(region, x, y, w, h, graphics, &res);
2142 expect(Ok, status);
2143 ok(res == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, w, h);
2144 status = GdipIsVisibleRegionRectI(region, (INT)x, (INT)y, (INT)w, (INT)h, graphics, &res);
2145 expect(Ok, status);
2146 ok(res == TRUE, "Expected (%d, %d, %d, %d) to be visible\n", (INT)x, (INT)y, (INT)w, (INT)h);
2147
2148 GdipDeletePath(path);
2149
2150 GdipDeleteRegion(region);
2151 GdipDeleteGraphics(graphics);
2152 ReleaseDC(0, hdc);
2153 }
2154
2155 static void test_excludeinfinite(void)
2156 {
2157 GpStatus status;
2158 GpRegion *region;
2159 UINT count=0xdeadbeef;
2160 GpRectF scans[4];
2161 GpMatrix *identity;
2162 static const RectF rect_exclude = {0.0, 0.0, 1.0, 1.0};
2163
2164 status = GdipCreateMatrix(&identity);
2165 expect(Ok, status);
2166
2167 status = GdipCreateRegion(&region);
2168 expect(Ok, status);
2169
2170 status = GdipCombineRegionRect(region, &rect_exclude, CombineModeExclude);
2171 expect(Ok, status);
2172
2173 status = GdipGetRegionScansCount(region, &count, identity);
2174 expect(Ok, status);
2175 expect(4, count);
2176
2177 count = 4;
2178 status = GdipGetRegionScans(region, scans, (INT*)&count, identity);
2179 expect(Ok, status);
2180
2181 expectf(-4194304.0, scans[0].X);
2182 expectf(-4194304.0, scans[0].Y);
2183 expectf(8388608.0, scans[0].Width);
2184 expectf(4194304.0, scans[0].Height);
2185
2186 expectf(-4194304.0, scans[1].X);
2187 expectf(0.0, scans[1].Y);
2188 expectf(4194304.0, scans[1].Width);
2189 expectf(1.0, scans[1].Height);
2190
2191 expectf(1.0, scans[2].X);
2192 expectf(0.0, scans[2].Y);
2193 expectf(4194303.0, scans[2].Width);
2194 expectf(1.0, scans[2].Height);
2195
2196 expectf(-4194304.0, scans[3].X);
2197 expectf(1.0, scans[3].Y);
2198 expectf(8388608.0, scans[3].Width);
2199 expectf(4194303.0, scans[3].Height);
2200
2201 GdipDeleteRegion(region);
2202 GdipDeleteMatrix(identity);
2203 }
2204
2205 START_TEST(region)
2206 {
2207 struct GdiplusStartupInput gdiplusStartupInput;
2208 ULONG_PTR gdiplusToken;
2209
2210 gdiplusStartupInput.GdiplusVersion = 1;
2211 gdiplusStartupInput.DebugEventCallback = NULL;
2212 gdiplusStartupInput.SuppressBackgroundThread = 0;
2213 gdiplusStartupInput.SuppressExternalCodecs = 0;
2214
2215 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2216
2217 test_getregiondata();
2218 test_isinfinite();
2219 test_isempty();
2220 test_combinereplace();
2221 test_fromhrgn();
2222 test_gethrgn();
2223 test_isequal();
2224 test_translate();
2225 test_transform();
2226 test_scans();
2227 test_getbounds();
2228 test_isvisiblepoint();
2229 test_isvisiblerect();
2230 test_excludeinfinite();
2231
2232 GdiplusShutdown(gdiplusToken);
2233 }