mshtml.idl: Added some missing attributes.
[wine.git] / dlls / gdiplus / pathiterator.c
bloba9e1d3fe4d07dec1dd5bbfd9307309271e0744b5
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 GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
29 INT size;
31 if(!iterator || !path)
32 return InvalidParameter;
34 size = path->pathdata.Count;
36 *iterator = GdipAlloc(sizeof(GpPathIterator));
37 if(!*iterator) return OutOfMemory;
39 (*iterator)->pathdata.Types = GdipAlloc(size);
40 (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
42 memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
43 memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
44 size * sizeof(PointF));
45 (*iterator)->pathdata.Count = size;
47 (*iterator)->subpath_pos = 0;
48 (*iterator)->marker_pos = 0;
49 (*iterator)->pathtype_pos = 0;
51 return Ok;
54 GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
56 if(!iter)
57 return InvalidParameter;
59 GdipFree(iter->pathdata.Types);
60 GdipFree(iter->pathdata.Points);
61 GdipFree(iter);
63 return Ok;
66 GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator* iterator,
67 INT* resultCount, GpPointF* points, BYTE* types, INT startIndex, INT endIndex)
69 if(!iterator || !types || !points)
70 return InvalidParameter;
72 if(endIndex > iterator->pathdata.Count - 1 || startIndex < 0 ||
73 endIndex < startIndex){
74 *resultCount = 0;
75 return Ok;
78 *resultCount = endIndex - startIndex + 1;
80 memcpy(types, &(iterator->pathdata.Types[startIndex]), *resultCount);
81 memcpy(points, &(iterator->pathdata.Points[startIndex]),
82 *resultCount * sizeof(PointF));
84 return Ok;
87 GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
88 INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed)
90 INT i, count;
92 if(!iterator)
93 return InvalidParameter;
95 count = iterator->pathdata.Count;
97 if(iterator->subpath_pos == count){
98 *startIndex = *endIndex = *resultCount = 0;
99 *isClosed = 1;
100 return Ok;
103 *startIndex = iterator->subpath_pos;
105 for(i = iterator->subpath_pos + 1; i < count &&
106 !(iterator->pathdata.Types[i] == PathPointTypeStart); i++);
108 *endIndex = i - 1;
109 iterator->subpath_pos = i;
111 *resultCount = *endIndex - *startIndex + 1;
113 if(iterator->pathdata.Types[*endIndex] & PathPointTypeCloseSubpath)
114 *isClosed = TRUE;
115 else
116 *isClosed = FALSE;
118 return Ok;
120 GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator *iterator)
122 if(!iterator)
123 return InvalidParameter;
125 iterator->subpath_pos = 0;
126 iterator->marker_pos = 0;
127 iterator->pathtype_pos = 0;
129 return Ok;