winhttp: Implement WinHttpOpenRequest.
[wine] / dlls / 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 typedef enum RegionType
77 {
78     RegionDataRect          = 0x10000000,
79     RegionDataPath          = 0x10000001,
80     RegionDataEmptyRect     = 0x10000002,
81     RegionDataInfiniteRect  = 0x10000003,
82 } RegionType;
83
84 #define FLAGS_NOFLAGS   0x0
85 #define FLAGS_INTPATH   0x4000
86
87 /* Header size as far as header->size is concerned. This doesn't include
88  * header->size or header->checksum
89  */
90 static const INT sizeheader_size = sizeof(DWORD) * 2;
91
92 typedef struct packed_point
93 {
94     short X;
95     short Y;
96 } packed_point;
97
98 /* Everything is measured in DWORDS; round up if there's a remainder */
99 static inline INT get_pathtypes_size(const GpPath* path)
100 {
101     INT needed = path->pathdata.Count / sizeof(DWORD);
102
103     if (path->pathdata.Count % sizeof(DWORD) > 0)
104         needed++;
105
106     return needed * sizeof(DWORD);
107 }
108
109 static inline INT get_element_size(const region_element* element)
110 {
111     INT needed = sizeof(DWORD); /* DWORD for the type */
112     switch(element->type)
113     {
114         case RegionDataRect:
115             return needed + sizeof(GpRect);
116         case RegionDataPath:
117              needed += element->elementdata.pathdata.pathheader.size;
118              needed += sizeof(DWORD); /* Extra DWORD for pathheader.size */
119              return needed;
120         case RegionDataEmptyRect:
121         case RegionDataInfiniteRect:
122             return needed;
123         default:
124             needed += get_element_size(element->elementdata.combine.left);
125             needed += get_element_size(element->elementdata.combine.right);
126             return needed;
127     }
128
129     return 0;
130 }
131
132 /* Does not check parameters, caller must do that */
133 static inline GpStatus init_region(GpRegion* region, const RegionType type)
134 {
135     region->node.type       = type;
136     region->header.checksum = 0xdeadbeef;
137     region->header.magic    = VERSION_MAGIC;
138     region->header.num_children  = 0;
139     region->header.size     = sizeheader_size + get_element_size(&region->node);
140
141     return Ok;
142 }
143
144 static inline void delete_element(region_element* element)
145 {
146     switch(element->type)
147     {
148         case RegionDataRect:
149             break;
150         case RegionDataPath:
151             GdipDeletePath(element->elementdata.pathdata.path);
152             break;
153         case RegionDataEmptyRect:
154         case RegionDataInfiniteRect:
155             break;
156         default:
157             delete_element(element->elementdata.combine.left);
158             delete_element(element->elementdata.combine.right);
159             GdipFree(element->elementdata.combine.left);
160             GdipFree(element->elementdata.combine.right);
161             break;
162     }
163 }
164
165 static inline GpStatus clone_element(const region_element* element,
166         region_element** element2)
167 {
168     GpStatus stat;
169
170     *element2 = GdipAlloc(sizeof(region_element));
171     if (!*element2)
172         return OutOfMemory;
173
174     (*element2)->type = element->type;
175
176     switch (element->type)
177     {
178         case RegionDataRect:
179             (*element2)->elementdata.rect = element->elementdata.rect;
180             break;
181         case RegionDataEmptyRect:
182         case RegionDataInfiniteRect:
183             break;
184         case RegionDataPath:
185             (*element2)->elementdata.pathdata.pathheader = element->elementdata.pathdata.pathheader;
186             stat = GdipClonePath(element->elementdata.pathdata.path,
187                     &(*element2)->elementdata.pathdata.path);
188             if (stat != Ok) goto clone_out;
189             break;
190         default:
191             stat = clone_element(element->elementdata.combine.left,
192                     &(*element2)->elementdata.combine.left);
193             if (stat != Ok) goto clone_out;
194             stat = clone_element(element->elementdata.combine.right,
195                     &(*element2)->elementdata.combine.right);
196             if (stat != Ok) goto clone_out;
197             break;
198     }
199
200     return Ok;
201
202 clone_out:
203     delete_element(*element2);
204     *element2 = NULL;
205     return stat;
206 }
207
208 /* Common code for CombineRegion*
209  * All the caller has to do is get its format into an element
210  */
211 static inline void fuse_region(GpRegion* region, region_element* left,
212         region_element* right, const CombineMode mode)
213 {
214     region->node.type = mode;
215     region->node.elementdata.combine.left = left;
216     region->node.elementdata.combine.right = right;
217
218     region->header.size = sizeheader_size + get_element_size(&region->node);
219     region->header.num_children += 2;
220 }
221
222 /*****************************************************************************
223  * GdipCloneRegion [GDIPLUS.@]
224  *
225  * Creates a deep copy of the region
226  *
227  * PARAMS
228  *  region  [I] source region
229  *  clone   [O] resulting clone
230  *
231  * RETURNS
232  *  SUCCESS: Ok
233  *  FAILURE: InvalidParameter or OutOfMemory
234  */
235 GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
236 {
237     region_element *element;
238
239     TRACE("%p %p\n", region, clone);
240
241     if (!(region && clone))
242         return InvalidParameter;
243
244     *clone = GdipAlloc(sizeof(GpRegion));
245     if (!*clone)
246         return OutOfMemory;
247     element = &(*clone)->node;
248
249     (*clone)->header = region->header;
250     return clone_element(&region->node, &element);
251 }
252
253 GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, CombineMode mode)
254 {
255     GpRegion *path_region;
256     region_element *left, *right = NULL;
257     GpStatus stat;
258
259     TRACE("%p %p %d\n", region, path, mode);
260
261     if (!(region && path))
262         return InvalidParameter;
263
264     stat = GdipCreateRegionPath(path, &path_region);
265     if (stat != Ok)
266         return stat;
267
268     left = GdipAlloc(sizeof(region_element));
269     if (!left)
270         goto out;
271     *left = region->node;
272
273     stat = clone_element(&path_region->node, &right);
274     if (stat != Ok)
275         goto out;
276
277     fuse_region(region, left, right, mode);
278
279     GdipDeleteRegion(path_region);
280     return Ok;
281
282 out:
283     GdipFree(left);
284     delete_element(right);
285     GdipDeleteRegion(path_region);
286     return stat;
287 }
288
289 GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
290         GDIPCONST GpRectF *rect, CombineMode mode)
291 {
292     GpRegion *rect_region;
293     region_element *left, *right = NULL;
294     GpStatus stat;
295
296     TRACE("%p %p %d\n", region, rect, mode);
297
298     if (!(region && rect))
299         return InvalidParameter;
300
301     stat = GdipCreateRegionRect(rect, &rect_region);
302     if (stat != Ok)
303         return stat;
304
305     left = GdipAlloc(sizeof(region_element));
306     if (!left)
307         goto out;
308     memcpy(left, &region->node, sizeof(region_element));
309
310     stat = clone_element(&rect_region->node, &right);
311     if (stat != Ok)
312         goto out;
313
314     fuse_region(region, left, right, mode);
315
316     GdipDeleteRegion(rect_region);
317     return Ok;
318
319 out:
320     GdipFree(left);
321     delete_element(right);
322     GdipDeleteRegion(rect_region);
323     return stat;
324 }
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;
348     GpStatus stat;
349
350     TRACE("%p %p %d\n", region1, region2, mode);
351
352     if(!(region1 && region2))
353         return InvalidParameter;
354
355     left  = GdipAlloc(sizeof(region_element));
356     if (!left)
357         return OutOfMemory;
358
359     *left = region1->node;
360     stat = clone_element(&region2->node, &right);
361     if (stat != Ok)
362     {
363         GdipFree(left);
364         delete_element(right);
365         return OutOfMemory;
366     }
367
368     fuse_region(region1, left, right, mode);
369     region1->header.num_children += region2->header.num_children;
370
371     return Ok;
372 }
373
374 GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
375 {
376     if(!region)
377         return InvalidParameter;
378
379     TRACE("%p\n", region);
380
381     *region = GdipAlloc(sizeof(GpRegion));
382     if(!*region)
383         return OutOfMemory;
384
385     return init_region(*region, RegionDataInfiniteRect);
386 }
387
388 /*****************************************************************************
389  * GdipCreateRegionPath [GDIPLUS.@]
390  *
391  * Creates a GpRegion from a GpPath
392  *
393  * PARAMS
394  *  path    [I] path to base the region on
395  *  region  [O] pointer to the newly allocated region
396  *
397  * RETURNS
398  *  SUCCESS: Ok
399  *  FAILURE: InvalidParameter
400  *
401  * NOTES
402  *  If a path has no floating point points, its points will be stored as shorts
403  *  (INTPATH)
404  *
405  *  If a path is empty, it is considered to be an INTPATH
406  */
407 GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
408 {
409     region_element* element;
410     GpPoint  *pointsi;
411     GpPointF *pointsf;
412
413     GpStatus stat;
414     DWORD flags = FLAGS_INTPATH;
415     INT count, i;
416
417     TRACE("%p, %p\n", path, region);
418
419     if (!(path && region))
420         return InvalidParameter;
421
422     *region = GdipAlloc(sizeof(GpRegion));
423     if(!*region)
424         return OutOfMemory;
425     stat = init_region(*region, RegionDataPath);
426     if (stat != Ok)
427     {
428         GdipDeleteRegion(*region);
429         return stat;
430     }
431     element = &(*region)->node;
432     count = path->pathdata.Count;
433
434     /* Test to see if the path is an Integer path */
435     if (count)
436     {
437         pointsi = GdipAlloc(sizeof(GpPoint) * count);
438         pointsf = GdipAlloc(sizeof(GpPointF) * count);
439         if (!(pointsi && pointsf))
440         {
441             GdipFree(pointsi);
442             GdipFree(pointsf);
443             GdipDeleteRegion(*region);
444             return OutOfMemory;
445         }
446
447         stat = GdipGetPathPointsI(path, pointsi, count);
448         if (stat != Ok)
449         {
450             GdipDeleteRegion(*region);
451             return stat;
452         }
453         stat = GdipGetPathPoints(path, pointsf, count);
454         if (stat != Ok)
455         {
456             GdipDeleteRegion(*region);
457             return stat;
458         }
459
460         for (i = 0; i < count; i++)
461         {
462             if (!(pointsi[i].X == pointsf[i].X &&
463                   pointsi[i].Y == pointsf[i].Y ))
464             {
465                 flags = FLAGS_NOFLAGS;
466                 break;
467             }
468         }
469         GdipFree(pointsi);
470         GdipFree(pointsf);
471     }
472
473     stat = GdipClonePath(path, &element->elementdata.pathdata.path);
474     if (stat != Ok)
475     {
476         GdipDeleteRegion(*region);
477         return stat;
478     }
479
480     /* 3 for headers, once again size doesn't count itself */
481     element->elementdata.pathdata.pathheader.size = ((sizeof(DWORD) * 3));
482     switch(flags)
483     {
484         /* Floats, sent out as floats */
485         case FLAGS_NOFLAGS:
486             element->elementdata.pathdata.pathheader.size +=
487                 (sizeof(DWORD) * count * 2);
488             break;
489         /* INTs, sent out as packed shorts */
490         case FLAGS_INTPATH:
491             element->elementdata.pathdata.pathheader.size +=
492                 (sizeof(DWORD) * count);
493             break;
494         default:
495             FIXME("Unhandled flags (%08x). Expect wrong results.\n", flags);
496     }
497     element->elementdata.pathdata.pathheader.size += get_pathtypes_size(path);
498     element->elementdata.pathdata.pathheader.magic = VERSION_MAGIC;
499     element->elementdata.pathdata.pathheader.count = count;
500     element->elementdata.pathdata.pathheader.flags = flags;
501     (*region)->header.size = sizeheader_size + get_element_size(element);
502
503     return Ok;
504 }
505
506 GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect,
507         GpRegion **region)
508 {
509     GpStatus stat;
510
511     TRACE("%p, %p\n", rect, region);
512
513     if (!(rect && region))
514         return InvalidParameter;
515
516     *region = GdipAlloc(sizeof(GpRegion));
517     stat = init_region(*region, RegionDataRect);
518     if(stat != Ok)
519     {
520         GdipDeleteRegion(*region);
521         return stat;
522     }
523
524     (*region)->node.elementdata.rect.X = rect->X;
525     (*region)->node.elementdata.rect.Y = rect->Y;
526     (*region)->node.elementdata.rect.Width = rect->Width;
527     (*region)->node.elementdata.rect.Height = rect->Height;
528
529     return Ok;
530 }
531
532 GpStatus WINGDIPAPI GdipCreateRegionRectI(GDIPCONST GpRect *rect,
533         GpRegion **region)
534 {
535     GpRectF rectf;
536
537     TRACE("%p, %p\n", rect, region);
538
539     rectf.X = (REAL)rect->X;
540     rectf.Y = (REAL)rect->Y;
541     rectf.Width = (REAL)rect->Width;
542     rectf.Height = (REAL)rect->Height;
543
544     return GdipCreateRegionRect(&rectf, region);
545 }
546
547 GpStatus WINGDIPAPI GdipCreateRegionRgnData(GDIPCONST BYTE *data, INT size, GpRegion **region)
548 {
549     FIXME("(%p, %d, %p): stub\n", data, size, region);
550
551     *region = NULL;
552     return NotImplemented;
553 }
554
555 GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
556 {
557     FIXME("(%p, %p): stub\n", hrgn, region);
558
559     *region = NULL;
560     return NotImplemented;
561 }
562
563 GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
564 {
565     TRACE("%p\n", region);
566
567     if (!region)
568         return InvalidParameter;
569
570     delete_element(&region->node);
571     GdipFree(region);
572
573     return Ok;
574 }
575
576 GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
577 {
578     FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
579
580     return NotImplemented;
581 }
582
583 GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *region, GpGraphics *graphics, GpRect *rect)
584 {
585     FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
586
587     return NotImplemented;
588 }
589
590 static inline void write_dword(DWORD* location, INT* offset, const DWORD write)
591 {
592     location[*offset] = write;
593     (*offset)++;
594 }
595
596 static inline void write_float(DWORD* location, INT* offset, const FLOAT write)
597 {
598     ((FLOAT*)location)[*offset] = write;
599     (*offset)++;
600 }
601
602 static inline void write_packed_point(DWORD* location, INT* offset,
603         const GpPointF* write)
604 {
605     packed_point point;
606
607     point.X = write->X;
608     point.Y = write->Y;
609     memcpy(location + *offset, &point, sizeof(packed_point));
610     (*offset)++;
611 }
612
613 static inline void write_path_types(DWORD* location, INT* offset,
614         const GpPath* path)
615 {
616     memcpy(location + *offset, path->pathdata.Types, path->pathdata.Count);
617
618     /* The unwritten parts of the DWORD (if any) must be cleared */
619     if (path->pathdata.Count % sizeof(DWORD))
620         ZeroMemory(((BYTE*)location) + (*offset * sizeof(DWORD)) +
621                 path->pathdata.Count,
622                 sizeof(DWORD) - path->pathdata.Count % sizeof(DWORD));
623     *offset += (get_pathtypes_size(path) / sizeof(DWORD));
624 }
625
626 static void write_element(const region_element* element, DWORD *buffer,
627         INT* filled)
628 {
629     write_dword(buffer, filled, element->type);
630     switch (element->type)
631     {
632         case CombineModeReplace:
633         case CombineModeIntersect:
634         case CombineModeUnion:
635         case CombineModeXor:
636         case CombineModeExclude:
637         case CombineModeComplement:
638             write_element(element->elementdata.combine.left, buffer, filled);
639             write_element(element->elementdata.combine.right, buffer, filled);
640             break;
641         case RegionDataRect:
642             write_float(buffer, filled, element->elementdata.rect.X);
643             write_float(buffer, filled, element->elementdata.rect.Y);
644             write_float(buffer, filled, element->elementdata.rect.Width);
645             write_float(buffer, filled, element->elementdata.rect.Height);
646             break;
647         case RegionDataPath:
648         {
649             INT i;
650             const GpPath* path = element->elementdata.pathdata.path;
651
652             memcpy(buffer + *filled, &element->elementdata.pathdata.pathheader,
653                     sizeof(element->elementdata.pathdata.pathheader));
654             *filled += sizeof(element->elementdata.pathdata.pathheader) / sizeof(DWORD);
655             switch (element->elementdata.pathdata.pathheader.flags)
656             {
657                 case FLAGS_NOFLAGS:
658                     for (i = 0; i < path->pathdata.Count; i++)
659                     {
660                         write_float(buffer, filled, path->pathdata.Points[i].X);
661                         write_float(buffer, filled, path->pathdata.Points[i].Y);
662                     }
663                     break;
664                 case FLAGS_INTPATH:
665                     for (i = 0; i < path->pathdata.Count; i++)
666                     {
667                         write_packed_point(buffer, filled,
668                                 &path->pathdata.Points[i]);
669                     }
670             }
671             write_path_types(buffer, filled, path);
672             break;
673         }
674         case RegionDataEmptyRect:
675         case RegionDataInfiniteRect:
676             break;
677     }
678 }
679
680 /*****************************************************************************
681  * GdipGetRegionData [GDIPLUS.@]
682  *
683  * Returns the header, followed by combining ops and region elements.
684  *
685  * PARAMS
686  *  region  [I] region to retrieve from
687  *  buffer  [O] buffer to hold the resulting data
688  *  size    [I] size of the buffer
689  *  needed  [O] (optional) how much data was written
690  *
691  * RETURNS
692  *  SUCCESS: Ok
693  *  FAILURE: InvalidParamter
694  *
695  * NOTES
696  *  The header contains the size, a checksum, a version string, and the number
697  *  of children. The size does not count itself or the checksum.
698  *  Version is always something like 0xdbc01001 or 0xdbc01002
699  *
700  *  An element is a RECT, or PATH; Combining ops are stored as their
701  *  CombineMode value. Special regions (infinite, empty) emit just their
702  *  op-code; GpRectFs emit their code followed by their points; GpPaths emit
703  *  their code followed by a second header for the path followed by the actual
704  *  path data. Followed by the flags for each point. The pathheader contains
705  *  the size of the data to follow, a version number again, followed by a count
706  *  of how many points, and any special flags which may apply. 0x4000 means its
707  *  a path of shorts instead of FLOAT.
708  *
709  *  Combining Ops are stored in reverse order from when they were constructed;
710  *  the output is a tree where the left side combining area is always taken
711  *  first.
712  */
713 GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *region, BYTE *buffer, UINT size,
714         UINT *needed)
715 {
716     INT filled = 0;
717
718     if (!(region && buffer && size))
719         return InvalidParameter;
720
721     TRACE("%p, %p, %d, %p\n", region, buffer, size, needed);
722     memcpy(buffer, &region->header, sizeof(region->header));
723     filled += sizeof(region->header) / sizeof(DWORD);
724     /* With few exceptions, everything written is DWORD aligned,
725      * so use that as our base */
726     write_element(&region->node, (DWORD*)buffer, &filled);
727
728     if (needed)
729         *needed = filled * sizeof(DWORD);
730
731     return Ok;
732 }
733
734 GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *region, UINT *needed)
735 {
736     if (!(region && needed))
737         return InvalidParameter;
738
739     TRACE("%p, %p\n", region, needed);
740
741     /* header.size doesn't count header.size and header.checksum */
742     *needed = region->header.size + sizeof(DWORD) * 2;
743
744     return Ok;
745 }
746
747 /*****************************************************************************
748  * GdipGetRegionHRgn [GDIPLUS.@]
749  */
750 GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
751 {
752     FIXME("(%p, %p, %p): stub\n", region, graphics, hrgn);
753
754     *hrgn = NULL;
755     return NotImplemented;
756 }
757
758 GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
759 {
760     FIXME("(%p, %p, %p): stub\n", region, graphics, res);
761
762     return NotImplemented;
763 }
764
765 GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *region, GpRegion *region2, GpGraphics *graphics,
766                                       BOOL *res)
767 {
768     FIXME("(%p, %p, %p, %p): stub\n", region, region2, graphics, res);
769
770     return NotImplemented;
771 }
772
773 GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
774 {
775     FIXME("(%p, %p, %p): stub\n", region, graphics, res);
776
777     return NotImplemented;
778 }
779
780 GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
781 {
782     GpStatus stat;
783
784     TRACE("%p\n", region);
785
786     if (!region)
787         return InvalidParameter;
788
789     delete_element(&region->node);
790     stat = init_region(region, RegionDataEmptyRect);
791
792     return stat;
793 }
794
795 GpStatus WINGDIPAPI GdipSetInfinite(GpRegion *region)
796 {
797     GpStatus stat;
798
799     if (!region)
800         return InvalidParameter;
801
802     TRACE("%p\n", region);
803
804     delete_element(&region->node);
805     stat = init_region(region, RegionDataInfiniteRect);
806
807     return stat;
808 }
809
810 GpStatus WINGDIPAPI GdipTransformRegion(GpRegion *region, GpMatrix *matrix)
811 {
812     FIXME("(%p, %p): stub\n", region, matrix);
813
814     return NotImplemented;
815 }
816
817 GpStatus WINGDIPAPI GdipTranslateRegion(GpRegion *region, REAL dx, REAL dy)
818 {
819     FIXME("(%p, %f, %f): stub\n", region, dx, dy);
820
821     return NotImplemented;
822 }
823
824 GpStatus WINGDIPAPI GdipTranslateRegionI(GpRegion *region, INT dx, INT dy)
825 {
826     FIXME("(%p, %d, %d): stub\n", region, dx, dy);
827
828     return NotImplemented;
829 }