- Sync gdiplus with wine head
[reactos.git] / reactos / dll / win32 / gdiplus / region.c
1 /*
2 * Copyright (C) 2008 Google (Lei Zhang)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include <stdarg.h>
20
21 #include "windef.h"
22 #include "winbase.h"
23 #include "wingdi.h"
24
25 #include "objbase.h"
26
27 #include "gdiplus.h"
28 #include "gdiplus_private.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
32
33 /**********************************************************
34 *
35 * Data returned by GdipGetRegionData looks something like this:
36 *
37 * struct region_data_header
38 * {
39 * DWORD size; size in bytes of the data - 8.
40 * DWORD magic1; probably a checksum.
41 * DWORD magic2; always seems to be 0xdbc01001 - version?
42 * DWORD num_ops; number of combining ops * 2
43 * };
44 *
45 * Then follows a sequence of combining ops and region elements.
46 *
47 * A region element is either a RECTF or some path data.
48 *
49 * Combining ops are just stored as their CombineMode value.
50 *
51 * Each RECTF is preceded by the DWORD 0x10000000. An empty rect is
52 * stored as 0x10000002 (with no following RECTF) and an infinite rect
53 * is stored as 0x10000003 (again with no following RECTF).
54 *
55 * Path data is preceded by the DWORD 0x10000001. Then follows a
56 * DWORD size and then size bytes of data.
57 *
58 * The combining ops are stored in the reverse order to the region
59 * elements and in the reverse order to which the region was
60 * constructed.
61 *
62 * When two or more complex regions (ie those with more than one
63 * element) are combined, the combining op for the two regions comes
64 * first, then the combining ops for the region elements in region 1,
65 * followed by the region elements for region 1, then follows the
66 * combining ops for region 2 and finally region 2's region elements.
67 * Presumably you're supposed to use the 0x1000000x header to find the
68 * end of the op list (the count of the elements in each region is not
69 * stored).
70 *
71 * When a simple region (1 element) is combined, it's treated as if a
72 * single rect/path is being combined.
73 *
74 */
75
76 #define FLAGS_NOFLAGS 0x0
77 #define FLAGS_INTPATH 0x4000
78
79 /* Header size as far as header->size is concerned. This doesn't include
80 * header->size or header->checksum
81 */
82 static const INT sizeheader_size = sizeof(DWORD) * 2;
83
84 typedef struct packed_point
85 {
86 short X;
87 short Y;
88 } packed_point;
89
90 /* Everything is measured in DWORDS; round up if there's a remainder */
91 static inline INT get_pathtypes_size(const GpPath* path)
92 {
93 INT needed = path->pathdata.Count / sizeof(DWORD);
94
95 if (path->pathdata.Count % sizeof(DWORD) > 0)
96 needed++;
97
98 return needed * sizeof(DWORD);
99 }
100
101 static inline INT get_element_size(const region_element* element)
102 {
103 INT needed = sizeof(DWORD); /* DWORD for the type */
104 switch(element->type)
105 {
106 case RegionDataRect:
107 return needed + sizeof(GpRect);
108 case RegionDataPath:
109 needed += element->elementdata.pathdata.pathheader.size;
110 needed += sizeof(DWORD); /* Extra DWORD for pathheader.size */
111 return needed;
112 case RegionDataEmptyRect:
113 case RegionDataInfiniteRect:
114 return needed;
115 default:
116 needed += get_element_size(element->elementdata.combine.left);
117 needed += get_element_size(element->elementdata.combine.right);
118 return needed;
119 }
120
121 return 0;
122 }
123
124 /* Does not check parameters, caller must do that */
125 static inline GpStatus init_region(GpRegion* region, const RegionType type)
126 {
127 region->node.type = type;
128 region->header.checksum = 0xdeadbeef;
129 region->header.magic = VERSION_MAGIC;
130 region->header.num_children = 0;
131 region->header.size = sizeheader_size + get_element_size(&region->node);
132
133 return Ok;
134 }
135
136 static inline GpStatus clone_element(const region_element* element,
137 region_element** element2)
138 {
139 GpStatus stat;
140
141 /* root node is allocated with GpRegion */
142 if(!*element2){
143 *element2 = GdipAlloc(sizeof(region_element));
144 if (!*element2)
145 return OutOfMemory;
146 }
147
148 (*element2)->type = element->type;
149
150 switch (element->type)
151 {
152 case RegionDataRect:
153 (*element2)->elementdata.rect = element->elementdata.rect;
154 break;
155 case RegionDataEmptyRect:
156 case RegionDataInfiniteRect:
157 break;
158 case RegionDataPath:
159 (*element2)->elementdata.pathdata.pathheader = element->elementdata.pathdata.pathheader;
160 stat = GdipClonePath(element->elementdata.pathdata.path,
161 &(*element2)->elementdata.pathdata.path);
162 if (stat != Ok) goto clone_out;
163 break;
164 default:
165 (*element2)->elementdata.combine.left = NULL;
166 (*element2)->elementdata.combine.right = NULL;
167
168 stat = clone_element(element->elementdata.combine.left,
169 &(*element2)->elementdata.combine.left);
170 if (stat != Ok) goto clone_out;
171 stat = clone_element(element->elementdata.combine.right,
172 &(*element2)->elementdata.combine.right);
173 if (stat != Ok) goto clone_out;
174 break;
175 }
176
177 return Ok;
178
179 clone_out:
180 delete_element(*element2);
181 *element2 = NULL;
182 return stat;
183 }
184
185 /* Common code for CombineRegion*
186 * All the caller has to do is get its format into an element
187 */
188 static inline void fuse_region(GpRegion* region, region_element* left,
189 region_element* right, const CombineMode mode)
190 {
191 region->node.type = mode;
192 region->node.elementdata.combine.left = left;
193 region->node.elementdata.combine.right = right;
194
195 region->header.size = sizeheader_size + get_element_size(&region->node);
196 region->header.num_children += 2;
197 }
198
199 /*****************************************************************************
200 * GdipCloneRegion [GDIPLUS.@]
201 *
202 * Creates a deep copy of the region
203 *
204 * PARAMS
205 * region [I] source region
206 * clone [O] resulting clone
207 *
208 * RETURNS
209 * SUCCESS: Ok
210 * FAILURE: InvalidParameter or OutOfMemory
211 */
212 GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
213 {
214 region_element *element;
215
216 TRACE("%p %p\n", region, clone);
217
218 if (!(region && clone))
219 return InvalidParameter;
220
221 *clone = GdipAlloc(sizeof(GpRegion));
222 if (!*clone)
223 return OutOfMemory;
224 element = &(*clone)->node;
225
226 (*clone)->header = region->header;
227 return clone_element(&region->node, &element);
228 }
229
230 /*****************************************************************************
231 * GdipCombineRegionPath [GDIPLUS.@]
232 */
233 GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, CombineMode mode)
234 {
235 GpRegion *path_region;
236 region_element *left, *right = NULL;
237 GpStatus stat;
238
239 TRACE("%p %p %d\n", region, path, mode);
240
241 if (!(region && path))
242 return InvalidParameter;
243
244 stat = GdipCreateRegionPath(path, &path_region);
245 if (stat != Ok)
246 return stat;
247
248 /* simply replace region data */
249 if(mode == CombineModeReplace){
250 delete_element(&region->node);
251 memcpy(region, path_region, sizeof(GpRegion));
252 return Ok;
253 }
254
255 left = GdipAlloc(sizeof(region_element));
256 if (!left)
257 goto out;
258 *left = region->node;
259
260 stat = clone_element(&path_region->node, &right);
261 if (stat != Ok)
262 goto out;
263
264 fuse_region(region, left, right, mode);
265
266 GdipDeleteRegion(path_region);
267 return Ok;
268
269 out:
270 GdipFree(left);
271 delete_element(right);
272 GdipDeleteRegion(path_region);
273 return stat;
274 }
275
276 /*****************************************************************************
277 * GdipCombineRegionRect [GDIPLUS.@]
278 */
279 GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
280 GDIPCONST GpRectF *rect, CombineMode mode)
281 {
282 GpRegion *rect_region;
283 region_element *left, *right = NULL;
284 GpStatus stat;
285
286 TRACE("%p %p %d\n", region, rect, mode);
287
288 if (!(region && rect))
289 return InvalidParameter;
290
291 stat = GdipCreateRegionRect(rect, &rect_region);
292 if (stat != Ok)
293 return stat;
294
295 /* simply replace region data */
296 if(mode == CombineModeReplace){
297 delete_element(&region->node);
298 memcpy(region, rect_region, sizeof(GpRegion));
299 return Ok;
300 }
301
302 left = GdipAlloc(sizeof(region_element));
303 if (!left)
304 goto out;
305 memcpy(left, &region->node, sizeof(region_element));
306
307 stat = clone_element(&rect_region->node, &right);
308 if (stat != Ok)
309 goto out;
310
311 fuse_region(region, left, right, mode);
312
313 GdipDeleteRegion(rect_region);
314 return Ok;
315
316 out:
317 GdipFree(left);
318 delete_element(right);
319 GdipDeleteRegion(rect_region);
320 return stat;
321 }
322
323 /*****************************************************************************
324 * GdipCombineRegionRectI [GDIPLUS.@]
325 */
326 GpStatus WINGDIPAPI GdipCombineRegionRectI(GpRegion *region,
327 GDIPCONST GpRect *rect, CombineMode mode)
328 {
329 GpRectF rectf;
330
331 TRACE("%p %p %d\n", region, rect, mode);
332
333 if (!rect)
334 return InvalidParameter;
335
336 rectf.X = (REAL)rect->X;
337 rectf.Y = (REAL)rect->Y;
338 rectf.Height = (REAL)rect->Height;
339 rectf.Width = (REAL)rect->Width;
340
341 return GdipCombineRegionRect(region, &rectf, mode);
342 }
343
344 GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
345 GpRegion *region2, CombineMode mode)
346 {
347 region_element *left, *right = NULL;
348 GpStatus stat;
349 GpRegion *reg2copy;
350
351 TRACE("%p %p %d\n", region1, region2, mode);
352
353 if(!(region1 && region2))
354 return InvalidParameter;
355
356 /* simply replace region data */
357 if(mode == CombineModeReplace){
358 stat = GdipCloneRegion(region2, &reg2copy);
359 if(stat != Ok) return stat;
360
361 delete_element(&region1->node);
362 memcpy(region1, reg2copy, sizeof(GpRegion));
363 return Ok;
364 }
365
366 left = GdipAlloc(sizeof(region_element));
367 if (!left)
368 return OutOfMemory;
369
370 *left = region1->node;
371 stat = clone_element(&region2->node, &right);
372 if (stat != Ok)
373 {
374 GdipFree(left);
375 delete_element(right);
376 return OutOfMemory;
377 }
378
379 fuse_region(region1, left, right, mode);
380 region1->header.num_children += region2->header.num_children;
381
382 return Ok;
383 }
384
385 /*****************************************************************************
386 * GdipCreateRegion [GDIPLUS.@]
387 */
388 GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
389 {
390 TRACE("%p\n", region);
391
392 if(!region)
393 return InvalidParameter;
394
395 *region = GdipAlloc(sizeof(GpRegion));
396 if(!*region)
397 return OutOfMemory;
398
399 return init_region(*region, RegionDataInfiniteRect);
400 }
401
402 /*****************************************************************************
403 * GdipCreateRegionPath [GDIPLUS.@]
404 *
405 * Creates a GpRegion from a GpPath
406 *
407 * PARAMS
408 * path [I] path to base the region on
409 * region [O] pointer to the newly allocated region
410 *
411 * RETURNS
412 * SUCCESS: Ok
413 * FAILURE: InvalidParameter
414 *
415 * NOTES
416 * If a path has no floating point points, its points will be stored as shorts
417 * (INTPATH)
418 *
419 * If a path is empty, it is considered to be an INTPATH
420 */
421 GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
422 {
423 region_element* element;
424 GpPoint *pointsi;
425 GpPointF *pointsf;
426
427 GpStatus stat;
428 DWORD flags = FLAGS_INTPATH;
429 INT count, i;
430
431 TRACE("%p, %p\n", path, region);
432
433 if (!(path && region))
434 return InvalidParameter;
435
436 *region = GdipAlloc(sizeof(GpRegion));
437 if(!*region)
438 return OutOfMemory;
439 stat = init_region(*region, RegionDataPath);
440 if (stat != Ok)
441 {
442 GdipDeleteRegion(*region);
443 return stat;
444 }
445 element = &(*region)->node;
446 count = path->pathdata.Count;
447
448 /* Test to see if the path is an Integer path */
449 if (count)
450 {
451 pointsi = GdipAlloc(sizeof(GpPoint) * count);
452 pointsf = GdipAlloc(sizeof(GpPointF) * count);
453 if (!(pointsi && pointsf))
454 {
455 GdipFree(pointsi);
456 GdipFree(pointsf);
457 GdipDeleteRegion(*region);
458 return OutOfMemory;
459 }
460
461 stat = GdipGetPathPointsI(path, pointsi, count);
462 if (stat != Ok)
463 {
464 GdipDeleteRegion(*region);
465 return stat;
466 }
467 stat = GdipGetPathPoints(path, pointsf, count);
468 if (stat != Ok)
469 {
470 GdipDeleteRegion(*region);
471 return stat;
472 }
473
474 for (i = 0; i < count; i++)
475 {
476 if (!(pointsi[i].X == pointsf[i].X &&
477 pointsi[i].Y == pointsf[i].Y ))
478 {
479 flags = FLAGS_NOFLAGS;
480 break;
481 }
482 }
483 GdipFree(pointsi);
484 GdipFree(pointsf);
485 }
486
487 stat = GdipClonePath(path, &element->elementdata.pathdata.path);
488 if (stat != Ok)
489 {
490 GdipDeleteRegion(*region);
491 return stat;
492 }
493
494 /* 3 for headers, once again size doesn't count itself */
495 element->elementdata.pathdata.pathheader.size = ((sizeof(DWORD) * 3));
496 switch(flags)
497 {
498 /* Floats, sent out as floats */
499 case FLAGS_NOFLAGS:
500 element->elementdata.pathdata.pathheader.size +=
501 (sizeof(DWORD) * count * 2);
502 break;
503 /* INTs, sent out as packed shorts */
504 case FLAGS_INTPATH:
505 element->elementdata.pathdata.pathheader.size +=
506 (sizeof(DWORD) * count);
507 break;
508 default:
509 FIXME("Unhandled flags (%08x). Expect wrong results.\n", flags);
510 }
511 element->elementdata.pathdata.pathheader.size += get_pathtypes_size(path);
512 element->elementdata.pathdata.pathheader.magic = VERSION_MAGIC;
513 element->elementdata.pathdata.pathheader.count = count;
514 element->elementdata.pathdata.pathheader.flags = flags;
515 (*region)->header.size = sizeheader_size + get_element_size(element);
516
517 return Ok;
518 }
519
520 /*****************************************************************************
521 * GdipCreateRegionRect [GDIPLUS.@]
522 */
523 GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect,
524 GpRegion **region)
525 {
526 GpStatus stat;
527
528 TRACE("%p, %p\n", rect, region);
529
530 if (!(rect && region))
531 return InvalidParameter;
532
533 *region = GdipAlloc(sizeof(GpRegion));
534 stat = init_region(*region, RegionDataRect);
535 if(stat != Ok)
536 {
537 GdipDeleteRegion(*region);
538 return stat;
539 }
540
541 (*region)->node.elementdata.rect.X = rect->X;
542 (*region)->node.elementdata.rect.Y = rect->Y;
543 (*region)->node.elementdata.rect.Width = rect->Width;
544 (*region)->node.elementdata.rect.Height = rect->Height;
545
546 return Ok;
547 }
548
549 GpStatus WINGDIPAPI GdipCreateRegionRectI(GDIPCONST GpRect *rect,
550 GpRegion **region)
551 {
552 GpRectF rectf;
553
554 TRACE("%p, %p\n", rect, region);
555
556 rectf.X = (REAL)rect->X;
557 rectf.Y = (REAL)rect->Y;
558 rectf.Width = (REAL)rect->Width;
559 rectf.Height = (REAL)rect->Height;
560
561 return GdipCreateRegionRect(&rectf, region);
562 }
563
564 GpStatus WINGDIPAPI GdipCreateRegionRgnData(GDIPCONST BYTE *data, INT size, GpRegion **region)
565 {
566 FIXME("(%p, %d, %p): stub\n", data, size, region);
567
568 *region = NULL;
569 return NotImplemented;
570 }
571
572 GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
573 {
574 FIXME("(%p, %p): stub\n", hrgn, region);
575
576 *region = NULL;
577 return NotImplemented;
578 }
579
580 GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
581 {
582 TRACE("%p\n", region);
583
584 if (!region)
585 return InvalidParameter;
586
587 delete_element(&region->node);
588 GdipFree(region);
589
590 return Ok;
591 }
592
593 GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
594 {
595 FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
596
597 return NotImplemented;
598 }
599
600 GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *region, GpGraphics *graphics, GpRect *rect)
601 {
602 FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
603
604 return NotImplemented;
605 }
606
607 static inline void write_dword(DWORD* location, INT* offset, const DWORD write)
608 {
609 location[*offset] = write;
610 (*offset)++;
611 }
612
613 static inline void write_float(DWORD* location, INT* offset, const FLOAT write)
614 {
615 ((FLOAT*)location)[*offset] = write;
616 (*offset)++;
617 }
618
619 static inline void write_packed_point(DWORD* location, INT* offset,
620 const GpPointF* write)
621 {
622 packed_point point;
623
624 point.X = write->X;
625 point.Y = write->Y;
626 memcpy(location + *offset, &point, sizeof(packed_point));
627 (*offset)++;
628 }
629
630 static inline void write_path_types(DWORD* location, INT* offset,
631 const GpPath* path)
632 {
633 memcpy(location + *offset, path->pathdata.Types, path->pathdata.Count);
634
635 /* The unwritten parts of the DWORD (if any) must be cleared */
636 if (path->pathdata.Count % sizeof(DWORD))
637 ZeroMemory(((BYTE*)location) + (*offset * sizeof(DWORD)) +
638 path->pathdata.Count,
639 sizeof(DWORD) - path->pathdata.Count % sizeof(DWORD));
640 *offset += (get_pathtypes_size(path) / sizeof(DWORD));
641 }
642
643 static void write_element(const region_element* element, DWORD *buffer,
644 INT* filled)
645 {
646 write_dword(buffer, filled, element->type);
647 switch (element->type)
648 {
649 case CombineModeReplace:
650 case CombineModeIntersect:
651 case CombineModeUnion:
652 case CombineModeXor:
653 case CombineModeExclude:
654 case CombineModeComplement:
655 write_element(element->elementdata.combine.left, buffer, filled);
656 write_element(element->elementdata.combine.right, buffer, filled);
657 break;
658 case RegionDataRect:
659 write_float(buffer, filled, element->elementdata.rect.X);
660 write_float(buffer, filled, element->elementdata.rect.Y);
661 write_float(buffer, filled, element->elementdata.rect.Width);
662 write_float(buffer, filled, element->elementdata.rect.Height);
663 break;
664 case RegionDataPath:
665 {
666 INT i;
667 const GpPath* path = element->elementdata.pathdata.path;
668
669 memcpy(buffer + *filled, &element->elementdata.pathdata.pathheader,
670 sizeof(element->elementdata.pathdata.pathheader));
671 *filled += sizeof(element->elementdata.pathdata.pathheader) / sizeof(DWORD);
672 switch (element->elementdata.pathdata.pathheader.flags)
673 {
674 case FLAGS_NOFLAGS:
675 for (i = 0; i < path->pathdata.Count; i++)
676 {
677 write_float(buffer, filled, path->pathdata.Points[i].X);
678 write_float(buffer, filled, path->pathdata.Points[i].Y);
679 }
680 break;
681 case FLAGS_INTPATH:
682 for (i = 0; i < path->pathdata.Count; i++)
683 {
684 write_packed_point(buffer, filled,
685 &path->pathdata.Points[i]);
686 }
687 }
688 write_path_types(buffer, filled, path);
689 break;
690 }
691 case RegionDataEmptyRect:
692 case RegionDataInfiniteRect:
693 break;
694 }
695 }
696
697 /*****************************************************************************
698 * GdipGetRegionData [GDIPLUS.@]
699 *
700 * Returns the header, followed by combining ops and region elements.
701 *
702 * PARAMS
703 * region [I] region to retrieve from
704 * buffer [O] buffer to hold the resulting data
705 * size [I] size of the buffer
706 * needed [O] (optional) how much data was written
707 *
708 * RETURNS
709 * SUCCESS: Ok
710 * FAILURE: InvalidParamter
711 *
712 * NOTES
713 * The header contains the size, a checksum, a version string, and the number
714 * of children. The size does not count itself or the checksum.
715 * Version is always something like 0xdbc01001 or 0xdbc01002
716 *
717 * An element is a RECT, or PATH; Combining ops are stored as their
718 * CombineMode value. Special regions (infinite, empty) emit just their
719 * op-code; GpRectFs emit their code followed by their points; GpPaths emit
720 * their code followed by a second header for the path followed by the actual
721 * path data. Followed by the flags for each point. The pathheader contains
722 * the size of the data to follow, a version number again, followed by a count
723 * of how many points, and any special flags which may apply. 0x4000 means its
724 * a path of shorts instead of FLOAT.
725 *
726 * Combining Ops are stored in reverse order from when they were constructed;
727 * the output is a tree where the left side combining area is always taken
728 * first.
729 */
730 GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *region, BYTE *buffer, UINT size,
731 UINT *needed)
732 {
733 INT filled = 0;
734
735 TRACE("%p, %p, %d, %p\n", region, buffer, size, needed);
736
737 if (!(region && buffer && size))
738 return InvalidParameter;
739
740 memcpy(buffer, &region->header, sizeof(region->header));
741 filled += sizeof(region->header) / sizeof(DWORD);
742 /* With few exceptions, everything written is DWORD aligned,
743 * so use that as our base */
744 write_element(&region->node, (DWORD*)buffer, &filled);
745
746 if (needed)
747 *needed = filled * sizeof(DWORD);
748
749 return Ok;
750 }
751
752 /*****************************************************************************
753 * GdipGetRegionDataSize [GDIPLUS.@]
754 */
755 GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *region, UINT *needed)
756 {
757 TRACE("%p, %p\n", region, needed);
758
759 if (!(region && needed))
760 return InvalidParameter;
761
762 /* header.size doesn't count header.size and header.checksum */
763 *needed = region->header.size + sizeof(DWORD) * 2;
764
765 return Ok;
766 }
767
768 /*****************************************************************************
769 * GdipGetRegionHRgn [GDIPLUS.@]
770 */
771 GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
772 {
773 FIXME("(%p, %p, %p): stub\n", region, graphics, hrgn);
774
775 *hrgn = NULL;
776 return NotImplemented;
777 }
778
779 GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
780 {
781 TRACE("(%p, %p, %p)\n", region, graphics, res);
782
783 if(!region || !graphics || !res)
784 return InvalidParameter;
785
786 *res = (region->node.type == RegionDataEmptyRect);
787
788 return Ok;
789 }
790
791 GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *region, GpRegion *region2, GpGraphics *graphics,
792 BOOL *res)
793 {
794 FIXME("(%p, %p, %p, %p): stub\n", region, region2, graphics, res);
795
796 return NotImplemented;
797 }
798
799 /*****************************************************************************
800 * GdipIsInfiniteRegion [GDIPLUS.@]
801 */
802 GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
803 {
804 /* I think graphics is ignored here */
805 TRACE("(%p, %p, %p)\n", region, graphics, res);
806
807 if(!region || !graphics || !res)
808 return InvalidParameter;
809
810 *res = (region->node.type == RegionDataInfiniteRect);
811
812 return Ok;
813 }
814
815 /*****************************************************************************
816 * GdipSetEmpty [GDIPLUS.@]
817 */
818 GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
819 {
820 GpStatus stat;
821
822 TRACE("%p\n", region);
823
824 if (!region)
825 return InvalidParameter;
826
827 delete_element(&region->node);
828 stat = init_region(region, RegionDataEmptyRect);
829
830 return stat;
831 }
832
833 GpStatus WINGDIPAPI GdipSetInfinite(GpRegion *region)
834 {
835 GpStatus stat;
836
837 TRACE("%p\n", region);
838
839 if (!region)
840 return InvalidParameter;
841
842 delete_element(&region->node);
843 stat = init_region(region, RegionDataInfiniteRect);
844
845 return stat;
846 }
847
848 GpStatus WINGDIPAPI GdipTransformRegion(GpRegion *region, GpMatrix *matrix)
849 {
850 FIXME("(%p, %p): stub\n", region, matrix);
851
852 return NotImplemented;
853 }
854
855 GpStatus WINGDIPAPI GdipTranslateRegion(GpRegion *region, REAL dx, REAL dy)
856 {
857 FIXME("(%p, %f, %f): stub\n", region, dx, dy);
858
859 return NotImplemented;
860 }
861
862 GpStatus WINGDIPAPI GdipTranslateRegionI(GpRegion *region, INT dx, INT dy)
863 {
864 FIXME("(%p, %d, %d): stub\n", region, dx, dy);
865
866 return NotImplemented;
867 }