gdiplus: Add TRACE(..) to CustomLineCap.
[wine] / dlls / gdiplus / customlinecap.c
1 /*
2  * Copyright (C) 2007 Google (Evan Stade)
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 GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
34     GpCustomLineCap** to)
35 {
36     TRACE("(%p, %p)\n", from, to);
37
38     if(!from || !to)
39         return InvalidParameter;
40
41     *to = GdipAlloc(sizeof(GpCustomLineCap));
42     if(!*to)   return OutOfMemory;
43
44     memcpy(*to, from, sizeof(GpCustomLineCap));
45
46     (*to)->pathdata.Points = GdipAlloc(from->pathdata.Count * sizeof(PointF));
47     (*to)->pathdata.Types = GdipAlloc(from->pathdata.Count);
48
49     if((!(*to)->pathdata.Types  || !(*to)->pathdata.Points) && (*to)->pathdata.Count){
50         GdipFree((*to)->pathdata.Points);
51         GdipFree((*to)->pathdata.Types);
52         GdipFree(*to);
53         return OutOfMemory;
54     }
55
56     memcpy((*to)->pathdata.Points, from->pathdata.Points, from->pathdata.Count
57            * sizeof(PointF));
58     memcpy((*to)->pathdata.Types, from->pathdata.Types, from->pathdata.Count);
59
60     return Ok;
61 }
62
63 /* FIXME: Sometimes when fillPath is non-null and stroke path is null, the native
64  * version of this function returns NotImplemented. I cannot figure out why. */
65 GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath,
66     GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
67 {
68     GpPathData *pathdata;
69
70     TRACE("%p %p %d %f %p\n", fillPath, strokePath, baseCap, baseInset, customCap);
71
72     if(!customCap || !(fillPath || strokePath))
73         return InvalidParameter;
74
75     *customCap = GdipAlloc(sizeof(GpCustomLineCap));
76     if(!*customCap)    return OutOfMemory;
77
78     if(strokePath){
79         (*customCap)->fill = FALSE;
80         pathdata = &strokePath->pathdata;
81     }
82     else{
83         (*customCap)->fill = TRUE;
84         pathdata = &fillPath->pathdata;
85     }
86
87     (*customCap)->pathdata.Points = GdipAlloc(pathdata->Count * sizeof(PointF));
88     (*customCap)->pathdata.Types = GdipAlloc(pathdata->Count);
89
90     if((!(*customCap)->pathdata.Types || !(*customCap)->pathdata.Points) &&
91         pathdata->Count){
92         GdipFree((*customCap)->pathdata.Points);
93         GdipFree((*customCap)->pathdata.Types);
94         GdipFree(*customCap);
95         return OutOfMemory;
96     }
97
98     memcpy((*customCap)->pathdata.Points, pathdata->Points, pathdata->Count
99            * sizeof(PointF));
100     memcpy((*customCap)->pathdata.Types, pathdata->Types, pathdata->Count);
101     (*customCap)->pathdata.Count = pathdata->Count;
102
103     (*customCap)->inset = baseInset;
104     (*customCap)->cap = baseCap;
105     (*customCap)->join = LineJoinMiter;
106     (*customCap)->scale = 1.0;
107
108     return Ok;
109 }
110
111 GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
112 {
113     TRACE("(%p)\n", customCap);
114
115     if(!customCap)
116         return InvalidParameter;
117
118     GdipFree(customCap->pathdata.Points);
119     GdipFree(customCap->pathdata.Types);
120     GdipFree(customCap);
121
122     return Ok;
123 }
124
125 GpStatus WINGDIPAPI GdipGetCustomLineCapStrokeJoin(GpCustomLineCap* customCap,
126     GpLineJoin* lineJoin)
127 {
128     TRACE("(%p, %p)\n", customCap, lineJoin);
129
130     if(!customCap || !lineJoin)
131         return InvalidParameter;
132
133     *lineJoin = customCap->join;
134
135     return Ok;
136 }
137
138 GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap* custom,
139     REAL* widthScale)
140 {
141     TRACE("(%p, %p)\n", custom, widthScale);
142
143     if(!custom || !widthScale)
144         return InvalidParameter;
145
146     *widthScale = custom->scale;
147
148     return Ok;
149 }
150
151 GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap* custom,
152     GpLineCap start, GpLineCap end)
153 {
154     static int calls;
155
156     if(!custom)
157         return InvalidParameter;
158
159     if(!(calls++))
160         FIXME("not implemented\n");
161
162     return NotImplemented;
163 }
164
165 GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap* custom,
166     GpLineCap base)
167 {
168     static int calls;
169
170     if(!(calls++))
171         FIXME("not implemented\n");
172
173     return NotImplemented;
174 }
175
176 GpStatus WINGDIPAPI GdipGetCustomLineCapBaseInset(GpCustomLineCap* custom,
177     REAL* inset)
178 {
179     TRACE("(%p, %p)\n", custom, inset);
180
181     if(!custom || !inset)
182         return InvalidParameter;
183
184     *inset = custom->inset;
185
186     return Ok;
187 }
188
189 GpStatus WINGDIPAPI GdipSetCustomLineCapBaseInset(GpCustomLineCap* custom,
190     REAL inset)
191 {
192     static int calls;
193
194     if(!(calls++))
195         FIXME("not implemented\n");
196
197     return NotImplemented;
198 }
199
200 /*FIXME: LineJoin completely ignored now */
201 GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeJoin(GpCustomLineCap* custom,
202     GpLineJoin join)
203 {
204     TRACE("(%p, %d)\n", custom, join);
205
206     if(!custom)
207         return InvalidParameter;
208
209     custom->join = join;
210
211     return Ok;
212 }
213
214 GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap* custom,
215     REAL width)
216 {
217     static int calls;
218
219     if(!(calls++))
220         FIXME("not implemented\n");
221
222     return NotImplemented;
223 }
224
225 GpStatus WINGDIPAPI GdipGetCustomLineCapBaseCap(GpCustomLineCap *customCap, GpLineCap *baseCap)
226 {
227     TRACE("(%p, %p)\n", customCap, baseCap);
228
229     if(!customCap || !baseCap)
230         return InvalidParameter;
231
232     *baseCap = customCap->cap;
233
234     return Ok;
235 }