ReactOS 0.4.17-dev-243-g1369312
pathiterator.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "objbase.h"
#include "gdiplus.h"
#include "gdiplus_private.h"
#include "wine/debug.h"
Include dependency graph for pathiterator.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus)
 
GpStatus WINGDIPAPI GdipCreatePathIter (GpPathIterator **iterator, GpPath *path)
 
GpStatus WINGDIPAPI GdipDeletePathIter (GpPathIterator *iter)
 
GpStatus WINGDIPAPI GdipPathIterCopyData (GpPathIterator *iterator, INT *resultCount, GpPointF *points, BYTE *types, INT startIndex, INT endIndex)
 
GpStatus WINGDIPAPI GdipPathIterHasCurve (GpPathIterator *iterator, BOOL *hasCurve)
 
GpStatus WINGDIPAPI GdipPathIterGetSubpathCount (GpPathIterator *iterator, INT *count)
 
GpStatus WINGDIPAPI GdipPathIterNextMarker (GpPathIterator *iterator, INT *resultCount, INT *startIndex, INT *endIndex)
 
GpStatus WINGDIPAPI GdipPathIterNextMarkerPath (GpPathIterator *iterator, INT *result, GpPath *path)
 
GpStatus WINGDIPAPI GdipPathIterNextSubpath (GpPathIterator *iterator, INT *resultCount, INT *startIndex, INT *endIndex, BOOL *isClosed)
 
GpStatus WINGDIPAPI GdipPathIterRewind (GpPathIterator *iterator)
 
GpStatus WINGDIPAPI GdipPathIterGetCount (GpPathIterator *iterator, INT *count)
 
GpStatus WINGDIPAPI GdipPathIterEnumerate (GpPathIterator *iterator, INT *resultCount, GpPointF *points, BYTE *types, INT count)
 
GpStatus WINGDIPAPI GdipPathIterIsValid (GpPathIterator *iterator, BOOL *valid)
 
GpStatus WINGDIPAPI GdipPathIterNextPathType (GpPathIterator *iter, INT *result, BYTE *type, INT *start, INT *end)
 
GpStatus WINGDIPAPI GdipPathIterNextSubpathPath (GpPathIterator *iter, INT *result, GpPath *path, BOOL *closed)
 

Function Documentation

◆ GdipCreatePathIter()

GpStatus WINGDIPAPI GdipCreatePathIter ( GpPathIterator **  iterator,
GpPath path 
)

Definition at line 34 of file pathiterator.c.

35{
36 INT size;
37
38 TRACE("(%p, %p)\n", iterator, path);
39
40 if(!iterator)
41 return InvalidParameter;
42
43 *iterator = calloc(1, sizeof(GpPathIterator));
44 if(!*iterator) return OutOfMemory;
45
46 if(path){
47 size = path->pathdata.Count;
48
49 (*iterator)->pathdata.Types = malloc(size);
50 (*iterator)->pathdata.Points = malloc(size * sizeof(PointF));
51
52 memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
53 memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF));
54 (*iterator)->pathdata.Count = size;
55 }
56 else{
57 (*iterator)->pathdata.Types = NULL;
58 (*iterator)->pathdata.Points = NULL;
59 (*iterator)->pathdata.Count = 0;
60 }
61
62 (*iterator)->subpath_pos = 0;
63 (*iterator)->marker_pos = 0;
64 (*iterator)->pathtype_pos = 0;
65
66 return Ok;
67}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
@ Ok
Definition: gdiplustypes.h:25
@ InvalidParameter
Definition: gdiplustypes.h:27
@ OutOfMemory
Definition: gdiplustypes.h:28
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT
Definition: typedefs.h:58

Referenced by test_constructor_destructor(), test_getsubpathcount(), test_hascurve(), test_isvalid(), test_nextmarker(), test_nextmarkerpath(), test_nextpathtype(), test_nextsubpath(), and test_nextsubpathpath().

◆ GdipDeletePathIter()

GpStatus WINGDIPAPI GdipDeletePathIter ( GpPathIterator iter)

Definition at line 69 of file pathiterator.c.

70{
71 TRACE("(%p)\n", iter);
72
73 if(!iter)
74 return InvalidParameter;
75
76 free(iter->pathdata.Types);
77 free(iter->pathdata.Points);
78 free(iter);
79
80 return Ok;
81}
#define free
Definition: debug_ros.c:5
GpPathData pathdata
PointF * Points
Definition: gdiplustypes.h:650
BYTE * Types
Definition: gdiplustypes.h:651

Referenced by test_constructor_destructor(), test_getsubpathcount(), test_hascurve(), test_isvalid(), test_nextmarker(), test_nextmarkerpath(), test_nextpathtype(), test_nextsubpath(), and test_nextsubpathpath().

◆ GdipPathIterCopyData()

GpStatus WINGDIPAPI GdipPathIterCopyData ( GpPathIterator iterator,
INT resultCount,
GpPointF points,
BYTE types,
INT  startIndex,
INT  endIndex 
)

Definition at line 83 of file pathiterator.c.

85{
86 TRACE("(%p, %p, %p, %p, %d, %d)\n", iterator, resultCount, points, types,
87 startIndex, endIndex);
88
89 if(!iterator || !types || !points)
90 return InvalidParameter;
91
92 if(endIndex > iterator->pathdata.Count - 1 || startIndex < 0 ||
93 endIndex < startIndex){
94 *resultCount = 0;
95 return Ok;
96 }
97
98 *resultCount = endIndex - startIndex + 1;
99
100 memcpy(types, &(iterator->pathdata.Types[startIndex]), *resultCount);
101 memcpy(points, &(iterator->pathdata.Points[startIndex]),
102 *resultCount * sizeof(PointF));
103
104 return Ok;
105}
GLsizei const GLfloat * points
Definition: glext.h:8112
Definition: cmds.c:130

Referenced by GdipPathIterEnumerate().

◆ GdipPathIterEnumerate()

GpStatus WINGDIPAPI GdipPathIterEnumerate ( GpPathIterator iterator,
INT resultCount,
GpPointF points,
BYTE types,
INT  count 
)

Definition at line 270 of file pathiterator.c.

272{
273 TRACE("(%p, %p, %p, %p, %d)\n", iterator, resultCount, points, types, count);
274
275 if((count < 0) || !resultCount)
276 return InvalidParameter;
277
278 if(count == 0){
279 *resultCount = 0;
280 return Ok;
281 }
282
283 return GdipPathIterCopyData(iterator, resultCount, points, types, 0, count-1);
284}
GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator *iterator, INT *resultCount, GpPointF *points, BYTE *types, INT startIndex, INT endIndex)
Definition: pathiterator.c:83
GLuint GLuint GLsizei count
Definition: gl.h:1545

◆ GdipPathIterGetCount()

GpStatus WINGDIPAPI GdipPathIterGetCount ( GpPathIterator iterator,
INT count 
)

Definition at line 258 of file pathiterator.c.

259{
260 TRACE("(%p, %p)\n", iterator, count);
261
262 if(!iterator || !count)
263 return InvalidParameter;
264
265 *count = iterator->pathdata.Count;
266
267 return Ok;
268}

Referenced by test_nextpathtype().

◆ GdipPathIterGetSubpathCount()

GpStatus WINGDIPAPI GdipPathIterGetSubpathCount ( GpPathIterator iterator,
INT count 
)

Definition at line 127 of file pathiterator.c.

128{
129 INT i;
130
131 TRACE("(%p, %p)\n", iterator, count);
132
133 if(!iterator || !count)
134 return InvalidParameter;
135
136 *count = 0;
137 for(i = 0; i < iterator->pathdata.Count; i++){
138 if(iterator->pathdata.Types[i] == PathPointTypeStart)
139 (*count)++;
140 }
141
142 return Ok;
143}
@ PathPointTypeStart
Definition: gdiplusenums.h:83
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by test_getsubpathcount().

◆ GdipPathIterHasCurve()

GpStatus WINGDIPAPI GdipPathIterHasCurve ( GpPathIterator iterator,
BOOL hasCurve 
)

Definition at line 107 of file pathiterator.c.

108{
109 INT i;
110
111 TRACE("(%p, %p)\n", iterator, hasCurve);
112
113 if(!iterator)
114 return InvalidParameter;
115
116 *hasCurve = FALSE;
117
118 for(i = 0; i < iterator->pathdata.Count; i++)
119 if((iterator->pathdata.Types[i] & PathPointTypePathTypeMask) == PathPointTypeBezier){
120 *hasCurve = TRUE;
121 break;
122 }
123
124 return Ok;
125}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ PathPointTypePathTypeMask
Definition: gdiplusenums.h:86
@ PathPointTypeBezier
Definition: gdiplusenums.h:85

Referenced by test_hascurve().

◆ GdipPathIterIsValid()

GpStatus WINGDIPAPI GdipPathIterIsValid ( GpPathIterator iterator,
BOOL valid 
)

Definition at line 286 of file pathiterator.c.

287{
288 TRACE("(%p, %p)\n", iterator, valid);
289
290 if(!iterator || !valid)
291 return InvalidParameter;
292
293 *valid = TRUE;
294
295 return Ok;
296}
BOOLEAN valid

Referenced by test_isvalid().

◆ GdipPathIterNextMarker()

GpStatus WINGDIPAPI GdipPathIterNextMarker ( GpPathIterator iterator,
INT resultCount,
INT startIndex,
INT endIndex 
)

Definition at line 145 of file pathiterator.c.

147{
148 INT i;
149
150 TRACE("(%p, %p, %p, %p)\n", iterator, resultCount, startIndex, endIndex);
151
152 if(!iterator || !startIndex || !endIndex)
153 return InvalidParameter;
154
155 *resultCount = 0;
156
157 /* first call could start with second point as all subsequent, cause
158 path couldn't contain only one */
159 for(i = iterator->marker_pos + 1; i < iterator->pathdata.Count; i++){
160 if((iterator->pathdata.Types[i] & PathPointTypePathMarker) ||
161 (i == iterator->pathdata.Count - 1)){
162 *startIndex = iterator->marker_pos;
163 if(iterator->marker_pos > 0) (*startIndex)++;
164 *endIndex = iterator->marker_pos = i;
165 *resultCount= *endIndex - *startIndex + 1;
166 break;
167 }
168 }
169
170 return Ok;
171}
@ PathPointTypePathMarker
Definition: gdiplusenums.h:88

Referenced by GdipPathIterNextMarkerPath(), test_isvalid(), and test_nextmarker().

◆ GdipPathIterNextMarkerPath()

GpStatus WINGDIPAPI GdipPathIterNextMarkerPath ( GpPathIterator iterator,
INT result,
GpPath path 
)

Definition at line 173 of file pathiterator.c.

175{
176 INT start, end;
177
178 TRACE("(%p, %p, %p)\n", iterator, result, path);
179
180 if(!iterator || !result)
181 return InvalidParameter;
182
184 /* return path */
185 if(((*result) > 0) && path){
187
189 return OutOfMemory;
190
191 memcpy(path->pathdata.Points, &(iterator->pathdata.Points[start]), sizeof(GpPointF)*(*result));
192 memcpy(path->pathdata.Types, &(iterator->pathdata.Types[start]), sizeof(BYTE)*(*result));
193 path->pathdata.Count = *result;
194 }
195
196 return Ok;
197}
GpStatus WINGDIPAPI GdipResetPath(GpPath *path)
GpStatus WINGDIPAPI GdipPathIterNextMarker(GpPathIterator *iterator, INT *resultCount, INT *startIndex, INT *endIndex)
Definition: pathiterator.c:145
BOOL lengthen_path(GpPath *path, INT len)
Definition: gdiplus.c:415
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_nextmarkerpath().

◆ GdipPathIterNextPathType()

GpStatus WINGDIPAPI GdipPathIterNextPathType ( GpPathIterator iter,
INT result,
BYTE type,
INT start,
INT end 
)

Definition at line 298 of file pathiterator.c.

300{
301 INT i, stopIndex;
302 TRACE("(%p, %p, %p, %p, %p)\n", iter, result, type, start, end);
303
304 if (!iter || !result || !type || !start || !end)
305 return InvalidParameter;
306
307 i = iter->pathtype_pos;
308 stopIndex = iter->subpath_pos;
309 if (i >= stopIndex) {
310 *result = 0;
311 return Ok;
312 }
314 i++;
315
316 *start = i - 1;
317 if ((i < stopIndex) &&
319 {
321 i++;
322 for ( ; i < stopIndex; i++) {
323 if ((iter->pathdata.Types[i] & PathPointTypePathTypeMask) != *type)
324 break;
325 }
326 }
327 iter->pathtype_pos = i;
328 *end = i - 1;
329 *result = *end - *start + 1;
330 return Ok;
331}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by test_nextpathtype().

◆ GdipPathIterNextSubpath()

GpStatus WINGDIPAPI GdipPathIterNextSubpath ( GpPathIterator iterator,
INT resultCount,
INT startIndex,
INT endIndex,
BOOL isClosed 
)

Definition at line 199 of file pathiterator.c.

201{
202 INT i, count;
203
204 TRACE("(%p, %p, %p, %p, %p)\n", iterator, resultCount, startIndex,
205 endIndex, isClosed);
206
207 if(!iterator || !startIndex || !endIndex || !isClosed || !resultCount)
208 return InvalidParameter;
209
210 count = iterator->pathdata.Count;
211
212 /* iterator created with NULL path */
213 if(count == 0){
214 *resultCount = 0;
215 return Ok;
216 }
217
218 if(iterator->subpath_pos == count){
219 *startIndex = *endIndex = *resultCount = 0;
220 *isClosed = TRUE;
221 return Ok;
222 }
223
224 *startIndex = iterator->subpath_pos;
225 /* Set new pathtype position */
226 iterator->pathtype_pos = iterator->subpath_pos;
227
228 for(i = iterator->subpath_pos + 1; i < count &&
229 !(iterator->pathdata.Types[i] == PathPointTypeStart); i++);
230
231 *endIndex = i - 1;
232 iterator->subpath_pos = i;
233
234 *resultCount = *endIndex - *startIndex + 1;
235
236 if(iterator->pathdata.Types[*endIndex] & PathPointTypeCloseSubpath)
237 *isClosed = TRUE;
238 else
239 *isClosed = FALSE;
240
241 return Ok;
242}
@ PathPointTypeCloseSubpath
Definition: gdiplusenums.h:89

Referenced by GdipPathIterNextSubpathPath(), test_nextpathtype(), and test_nextsubpath().

◆ GdipPathIterNextSubpathPath()

GpStatus WINGDIPAPI GdipPathIterNextSubpathPath ( GpPathIterator iter,
INT result,
GpPath path,
BOOL closed 
)

Definition at line 333 of file pathiterator.c.

335{
336 INT start, end;
337
338 TRACE("(%p, %p, %p, %p)\n", iter, result, path, closed);
339
340 if(!iter || !result || !closed)
341 return InvalidParameter;
342
343 GdipPathIterNextSubpath(iter, result, &start, &end, closed);
344 /* return path */
345 if(((*result) > 0) && path){
347
349 return OutOfMemory;
350
351 memcpy(path->pathdata.Points, &(iter->pathdata.Points[start]), sizeof(GpPointF)*(*result));
352 memcpy(path->pathdata.Types, &(iter->pathdata.Types[start]), sizeof(BYTE)*(*result));
353 path->pathdata.Count = *result;
354 }
355
356 return Ok;
357}
GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator *iterator, INT *resultCount, INT *startIndex, INT *endIndex, BOOL *isClosed)
Definition: pathiterator.c:199

Referenced by test_nextsubpathpath().

◆ GdipPathIterRewind()

GpStatus WINGDIPAPI GdipPathIterRewind ( GpPathIterator iterator)

Definition at line 244 of file pathiterator.c.

245{
246 TRACE("(%p)\n", iterator);
247
248 if(!iterator)
249 return InvalidParameter;
250
251 iterator->subpath_pos = 0;
252 iterator->marker_pos = 0;
253 iterator->pathtype_pos = 0;
254
255 return Ok;
256}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( gdiplus  )