rpcrt4: Make a server association when a bind packet is received in the server.
[wine] / dlls / gdiplus / pathiterator.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
30 GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
31 {
32     INT size;
33
34     if(!iterator || !path)
35         return InvalidParameter;
36
37     size = path->pathdata.Count;
38
39     *iterator = GdipAlloc(sizeof(GpPathIterator));
40     if(!*iterator)  return OutOfMemory;
41
42     (*iterator)->pathdata.Types = GdipAlloc(size);
43     (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
44
45     memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
46     memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
47            size * sizeof(PointF));
48     (*iterator)->pathdata.Count = size;
49
50     (*iterator)->subpath_pos = 0;
51     (*iterator)->marker_pos = 0;
52     (*iterator)->pathtype_pos = 0;
53
54     return Ok;
55 }
56
57 GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
58 {
59     if(!iter)
60         return InvalidParameter;
61
62     GdipFree(iter->pathdata.Types);
63     GdipFree(iter->pathdata.Points);
64     GdipFree(iter);
65
66     return Ok;
67 }
68
69 GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator* iterator,
70     INT* resultCount, GpPointF* points, BYTE* types, INT startIndex, INT endIndex)
71 {
72     if(!iterator || !types || !points)
73         return InvalidParameter;
74
75     if(endIndex > iterator->pathdata.Count - 1 || startIndex < 0 ||
76         endIndex < startIndex){
77         *resultCount = 0;
78         return Ok;
79     }
80
81     *resultCount = endIndex - startIndex + 1;
82
83     memcpy(types, &(iterator->pathdata.Types[startIndex]), *resultCount);
84     memcpy(points, &(iterator->pathdata.Points[startIndex]),
85         *resultCount * sizeof(PointF));
86
87     return Ok;
88 }
89
90 GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
91     INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed)
92 {
93     INT i, count;
94
95     if(!iterator)
96         return InvalidParameter;
97
98     count = iterator->pathdata.Count;
99
100     if(iterator->subpath_pos == count){
101         *startIndex = *endIndex = *resultCount = 0;
102         *isClosed = 1;
103         return Ok;
104     }
105
106     *startIndex = iterator->subpath_pos;
107
108     for(i = iterator->subpath_pos + 1; i < count &&
109         !(iterator->pathdata.Types[i] == PathPointTypeStart); i++);
110
111     *endIndex = i - 1;
112     iterator->subpath_pos = i;
113
114     *resultCount = *endIndex - *startIndex + 1;
115
116     if(iterator->pathdata.Types[*endIndex] & PathPointTypeCloseSubpath)
117         *isClosed = TRUE;
118     else
119         *isClosed = FALSE;
120
121     return Ok;
122 }
123 GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator *iterator)
124 {
125     if(!iterator)
126         return InvalidParameter;
127
128     iterator->subpath_pos = 0;
129     iterator->marker_pos = 0;
130     iterator->pathtype_pos = 0;
131
132     return Ok;
133 }