gdiplus: Add a test for a floating-point triangle.
[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 GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
77 {
78     FIXME("(%p %p): stub\n", region, clone);
79
80     *clone = NULL;
81     return NotImplemented;
82 }
83
84 GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, CombineMode mode)
85 {
86     FIXME("(%p %p %d): stub\n", region, path, mode);
87     return NotImplemented;
88 }
89
90 GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region, GDIPCONST GpRectF *rect,
91                                           CombineMode mode)
92 {
93     FIXME("(%p %p %d): stub\n", region, rect, mode);
94     return NotImplemented;
95 }
96
97 GpStatus WINGDIPAPI GdipCombineRegionRectI(GpRegion *region, GDIPCONST GpRect *rect,
98                                            CombineMode mode)
99 {
100     FIXME("(%p %p %d): stub\n", region, rect, mode);
101     return NotImplemented;
102 }
103
104 GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1, GpRegion *region2,
105                                             CombineMode mode)
106 {
107     FIXME("(%p %p %d): stub\n", region1, region2, mode);
108     return NotImplemented;
109 }
110
111 GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
112 {
113     FIXME("(%p): stub\n", region);
114
115     *region = NULL;
116     return NotImplemented;
117 }
118
119 GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
120 {
121     FIXME("(%p, %p): stub\n", path, region);
122
123     *region = NULL;
124     return NotImplemented;
125 }
126
127 GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
128 {
129     FIXME("(%p, %p): stub\n", rect, region);
130
131     *region = NULL;
132     return NotImplemented;
133 }
134
135 GpStatus WINGDIPAPI GdipCreateRegionRectI(GDIPCONST GpRect *rect, GpRegion **region)
136 {
137     FIXME("(%p, %p): stub\n", rect, region);
138
139     *region = NULL;
140     return NotImplemented;
141 }
142
143 GpStatus WINGDIPAPI GdipCreateRegionRgnData(GDIPCONST BYTE *data, INT size, GpRegion **region)
144 {
145     FIXME("(%p, %d, %p): stub\n", data, size, region);
146
147     *region = NULL;
148     return NotImplemented;
149 }
150
151 GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
152 {
153     FIXME("(%p, %p): stub\n", hrgn, region);
154
155     *region = NULL;
156     return NotImplemented;
157 }
158
159 GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
160 {
161     FIXME("(%p): stub\n", region);
162     return NotImplemented;
163 }
164
165 GpStatus WINGDIPAPI GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
166         GpRegion* region)
167 {
168     if (!(graphics && brush && region))
169         return InvalidParameter;
170
171     FIXME("(%p, %p, %p): stub\n", graphics, brush, region);
172
173     return NotImplemented;
174 }
175
176 GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
177 {
178     FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
179
180     return NotImplemented;
181 }
182
183 GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *region, GpGraphics *graphics, GpRect *rect)
184 {
185     FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
186
187     return NotImplemented;
188 }
189
190 GpStatus WINGDIPAPI GdipGetRegionData(GpRegion *region, BYTE *buffer, UINT size, UINT *needed)
191 {
192     FIXME("(%p, %p, %d, %p): stub\n", region, buffer, size, needed);
193
194     return NotImplemented;
195 }
196
197 GpStatus WINGDIPAPI GdipGetRegionDataSize(GpRegion *region, UINT *needed)
198 {
199     FIXME("(%p, %p): stub\n", region, needed);
200
201     return NotImplemented;
202 }
203
204 GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
205 {
206     FIXME("(%p, %p, %p): stub\n", region, graphics, hrgn);
207
208     *hrgn = NULL;
209     return NotImplemented;
210 }
211
212 GpStatus WINGDIPAPI GdipIsEmptyRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
213 {
214     FIXME("(%p, %p, %p): stub\n", region, graphics, res);
215
216     return NotImplemented;
217 }
218
219 GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *region, GpRegion *region2, GpGraphics *graphics,
220                                       BOOL *res)
221 {
222     FIXME("(%p, %p, %p, %p): stub\n", region, region2, graphics, res);
223
224     return NotImplemented;
225 }
226
227 GpStatus WINGDIPAPI GdipIsInfiniteRegion(GpRegion *region, GpGraphics *graphics, BOOL *res)
228 {
229     FIXME("(%p, %p, %p): stub\n", region, graphics, res);
230
231     return NotImplemented;
232 }
233
234 GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
235 {
236     static int calls;
237
238     if(!(calls++))
239         FIXME("not implemented\n");
240
241     return NotImplemented;
242 }
243
244 GpStatus WINGDIPAPI GdipSetInfinite(GpRegion *region)
245 {
246     static int calls;
247
248     if(!(calls++))
249         FIXME("not implemented\n");
250
251     return NotImplemented;
252 }
253
254 GpStatus WINGDIPAPI GdipTransformRegion(GpRegion *region, GpMatrix *matrix)
255 {
256     FIXME("(%p, %p): stub\n", region, matrix);
257
258     return NotImplemented;
259 }
260
261 GpStatus WINGDIPAPI GdipTranslateRegion(GpRegion *region, REAL dx, REAL dy)
262 {
263     FIXME("(%p, %f, %f): stub\n", region, dx, dy);
264
265     return NotImplemented;
266 }
267
268 GpStatus WINGDIPAPI GdipTranslateRegionI(GpRegion *region, INT dx, INT dy)
269 {
270     FIXME("(%p, %d, %d): stub\n", region, dx, dy);
271
272     return NotImplemented;
273 }