gdiplus: Initial custom line caps implementation.
[wine/wine64.git] / dlls / gdiplus / customlinecap.c
blob2a0cfb25876b81f370b0259329f851b1f4d3809a
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
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.
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.
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
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
24 #include "gdiplus.h"
25 #include "gdiplus_private.h"
27 GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath,
28 GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
30 GpPathData *pathdata;
32 if(!customCap || !(fillPath || strokePath))
33 return InvalidParameter;
35 *customCap = GdipAlloc(sizeof(GpCustomLineCap));
36 if(!*customCap) return OutOfMemory;
38 if(strokePath){
39 (*customCap)->fill = FALSE;
40 pathdata = &strokePath->pathdata;
42 else{
43 (*customCap)->fill = TRUE;
44 pathdata = &fillPath->pathdata;
47 (*customCap)->pathdata.Points = GdipAlloc(pathdata->Count * sizeof(PointF));
48 (*customCap)->pathdata.Types = GdipAlloc(pathdata->Count);
50 if((!(*customCap)->pathdata.Types || !(*customCap)->pathdata.Points) &&
51 pathdata->Count){
52 GdipFree((*customCap)->pathdata.Points);
53 GdipFree((*customCap)->pathdata.Types);
54 GdipFree(*customCap);
55 return OutOfMemory;
58 memcpy((*customCap)->pathdata.Points, pathdata->Points, pathdata->Count
59 * sizeof(PointF));
60 memcpy((*customCap)->pathdata.Types, pathdata->Types, pathdata->Count);
61 (*customCap)->pathdata.Count = pathdata->Count;
63 (*customCap)->inset = baseInset;
64 (*customCap)->cap = baseCap;
66 return Ok;
69 GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
71 if(!customCap)
72 return InvalidParameter;
74 GdipFree(customCap->pathdata.Points);
75 GdipFree(customCap->pathdata.Types);
76 GdipFree(customCap);
78 return Ok;