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
28 #include "gdiplus_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
33 /* make sure path has enough space for len more points */
34 static BOOL lengthen_path(GpPath *path, INT len)
36 /* initial allocation */
37 if(path->datalen == 0){
38 path->datalen = len * 2;
40 path->pathdata.Points = GdipAlloc(path->datalen * sizeof(PointF));
41 if(!path->pathdata.Points) return FALSE;
43 path->pathdata.Types = GdipAlloc(path->datalen);
44 if(!path->pathdata.Types){
45 GdipFree(path->pathdata.Points);
49 /* reallocation, double size of arrays */
50 else if(path->datalen - path->pathdata.Count < len){
51 while(path->datalen - path->pathdata.Count < len)
54 path->pathdata.Points = HeapReAlloc(GetProcessHeap(), 0,
55 path->pathdata.Points, path->datalen * sizeof(PointF));
56 if(!path->pathdata.Points) return FALSE;
58 path->pathdata.Types = HeapReAlloc(GetProcessHeap(), 0,
59 path->pathdata.Types, path->datalen);
60 if(!path->pathdata.Types) return FALSE;
66 GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points,
69 INT i, old_count = path->pathdata.Count;
72 return InvalidParameter;
74 if(!lengthen_path(path, count + (path->newfigure ? 1 : 0)))
77 for(i = 0; i < count; i++){
78 path->pathdata.Points[old_count + i].X = points[i].X;
79 path->pathdata.Points[old_count + i].Y = points[i].Y;
80 path->pathdata.Types[old_count + i] = PathPointTypeLine;
84 path->pathdata.Types[old_count] = PathPointTypeStart;
85 path->newfigure = FALSE;
88 path->pathdata.Count += count;
93 GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
96 return InvalidParameter;
98 *path = GdipAlloc(sizeof(GpPath));
99 if(!*path) return OutOfMemory;
101 (*path)->fill = fill;
102 (*path)->newfigure = TRUE;
107 GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
110 return InvalidParameter;