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
31 #include "gdiplus_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus
);
36 typedef struct path_list_node_t path_list_node_t
;
37 struct path_list_node_t
{
39 BYTE type
; /* PathPointTypeStart or PathPointTypeLine */
40 path_list_node_t
*next
;
44 static BOOL
init_path_list(path_list_node_t
**node
, REAL x
, REAL y
)
46 *node
= heap_alloc_zero(sizeof(path_list_node_t
));
52 (*node
)->type
= PathPointTypeStart
;
58 /* free all nodes including argument */
59 static void free_path_list(path_list_node_t
*node
)
61 path_list_node_t
*n
= node
;
70 /* Add a node after 'node' */
74 * NULL on allocation problems
76 static path_list_node_t
* add_path_list_node(path_list_node_t
*node
, REAL x
, REAL y
, BOOL type
)
78 path_list_node_t
*new;
80 new = heap_alloc_zero(sizeof(path_list_node_t
));
87 new->next
= node
->next
;
93 /* returns element count */
94 static INT
path_list_count(path_list_node_t
*node
)
98 while((node
= node
->next
))
104 /* GdipFlattenPath helper */
106 * Used to recursively flatten single Bezier curve
108 * - start : pointer to start point node;
109 * - (x2, y2): first control point;
110 * - (x3, y3): second control point;
111 * - end : pointer to end point node
112 * - flatness: admissible error of linear approximation.
116 * FALSE: out of memory
118 * TODO: used quality criteria should be revised to match native as
119 * closer as possible.
121 static BOOL
flatten_bezier(path_list_node_t
*start
, REAL x2
, REAL y2
, REAL x3
, REAL y3
,
122 path_list_node_t
*end
, REAL flatness
)
124 /* this 5 middle points with start/end define to half-curves */
127 path_list_node_t
*node
;
129 /* calculate bezier curve middle points == new control points */
130 mp
[0].X
= (start
->pt
.X
+ x2
) / 2.0;
131 mp
[0].Y
= (start
->pt
.Y
+ y2
) / 2.0;
132 /* middle point between control points */
133 pt
.X
= (x2
+ x3
) / 2.0;
134 pt
.Y
= (y2
+ y3
) / 2.0;
135 mp
[1].X
= (mp
[0].X
+ pt
.X
) / 2.0;
136 mp
[1].Y
= (mp
[0].Y
+ pt
.Y
) / 2.0;
137 mp
[4].X
= (end
->pt
.X
+ x3
) / 2.0;
138 mp
[4].Y
= (end
->pt
.Y
+ y3
) / 2.0;
139 mp
[3].X
= (mp
[4].X
+ pt
.X
) / 2.0;
140 mp
[3].Y
= (mp
[4].Y
+ pt
.Y
) / 2.0;
142 mp
[2].X
= (mp
[1].X
+ mp
[3].X
) / 2.0;
143 mp
[2].Y
= (mp
[1].Y
+ mp
[3].Y
) / 2.0;
147 /* check flatness as a half of distance between middle point and a linearized path */
148 if(fabs(((pt
.Y
- pt_st
.Y
)*mp
[2].X
+ (pt_st
.X
- pt
.X
)*mp
[2].Y
+
149 (pt_st
.Y
*pt
.X
- pt_st
.X
*pt
.Y
))) <=
150 (0.5 * flatness
*sqrtf((powf(pt
.Y
- pt_st
.Y
, 2.0) + powf(pt_st
.X
- pt
.X
, 2.0))))){
154 /* add a middle point */
155 if(!(node
= add_path_list_node(start
, mp
[2].X
, mp
[2].Y
, PathPointTypeLine
)))
158 /* do the same with halves */
159 flatten_bezier(start
, mp
[0].X
, mp
[0].Y
, mp
[1].X
, mp
[1].Y
, node
, flatness
);
160 flatten_bezier(node
, mp
[3].X
, mp
[3].Y
, mp
[4].X
, mp
[4].Y
, end
, flatness
);
165 GpStatus WINGDIPAPI
GdipAddPathArc(GpPath
*path
, REAL x1
, REAL y1
, REAL x2
,
166 REAL y2
, REAL startAngle
, REAL sweepAngle
)
168 INT count
, old_count
, i
;
170 TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
171 path
, x1
, y1
, x2
, y2
, startAngle
, sweepAngle
);
174 return InvalidParameter
;
176 count
= arc2polybezier(NULL
, x1
, y1
, x2
, y2
, startAngle
, sweepAngle
);
180 if(!lengthen_path(path
, count
))
183 old_count
= path
->pathdata
.Count
;
184 arc2polybezier(&path
->pathdata
.Points
[old_count
], x1
, y1
, x2
, y2
,
185 startAngle
, sweepAngle
);
187 for(i
= 0; i
< count
; i
++){
188 path
->pathdata
.Types
[old_count
+ i
] = PathPointTypeBezier
;
191 path
->pathdata
.Types
[old_count
] =
192 (path
->newfigure
? PathPointTypeStart
: PathPointTypeLine
);
193 path
->newfigure
= FALSE
;
194 path
->pathdata
.Count
+= count
;
199 GpStatus WINGDIPAPI
GdipAddPathArcI(GpPath
*path
, INT x1
, INT y1
, INT x2
,
200 INT y2
, REAL startAngle
, REAL sweepAngle
)
202 TRACE("(%p, %d, %d, %d, %d, %.2f, %.2f)\n",
203 path
, x1
, y1
, x2
, y2
, startAngle
, sweepAngle
);
205 return GdipAddPathArc(path
,(REAL
)x1
,(REAL
)y1
,(REAL
)x2
,(REAL
)y2
,startAngle
,sweepAngle
);
208 GpStatus WINGDIPAPI
GdipAddPathBezier(GpPath
*path
, REAL x1
, REAL y1
, REAL x2
,
209 REAL y2
, REAL x3
, REAL y3
, REAL x4
, REAL y4
)
213 TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
214 path
, x1
, y1
, x2
, y2
, x3
, y3
, x4
, y4
);
217 return InvalidParameter
;
219 if(!lengthen_path(path
, 4))
222 old_count
= path
->pathdata
.Count
;
224 path
->pathdata
.Points
[old_count
].X
= x1
;
225 path
->pathdata
.Points
[old_count
].Y
= y1
;
226 path
->pathdata
.Points
[old_count
+ 1].X
= x2
;
227 path
->pathdata
.Points
[old_count
+ 1].Y
= y2
;
228 path
->pathdata
.Points
[old_count
+ 2].X
= x3
;
229 path
->pathdata
.Points
[old_count
+ 2].Y
= y3
;
230 path
->pathdata
.Points
[old_count
+ 3].X
= x4
;
231 path
->pathdata
.Points
[old_count
+ 3].Y
= y4
;
233 path
->pathdata
.Types
[old_count
] =
234 (path
->newfigure
? PathPointTypeStart
: PathPointTypeLine
);
235 path
->pathdata
.Types
[old_count
+ 1] = PathPointTypeBezier
;
236 path
->pathdata
.Types
[old_count
+ 2] = PathPointTypeBezier
;
237 path
->pathdata
.Types
[old_count
+ 3] = PathPointTypeBezier
;
239 path
->newfigure
= FALSE
;
240 path
->pathdata
.Count
+= 4;
245 GpStatus WINGDIPAPI
GdipAddPathBezierI(GpPath
*path
, INT x1
, INT y1
, INT x2
,
246 INT y2
, INT x3
, INT y3
, INT x4
, INT y4
)
248 TRACE("(%p, %d, %d, %d, %d, %d, %d, %d, %d)\n",
249 path
, x1
, y1
, x2
, y2
, x3
, y3
, x4
, y4
);
251 return GdipAddPathBezier(path
,(REAL
)x1
,(REAL
)y1
,(REAL
)x2
,(REAL
)y2
,(REAL
)x3
,(REAL
)y3
,
255 GpStatus WINGDIPAPI
GdipAddPathBeziers(GpPath
*path
, GDIPCONST GpPointF
*points
,
260 TRACE("(%p, %p, %d)\n", path
, points
, count
);
262 if(!path
|| !points
|| ((count
- 1) % 3))
263 return InvalidParameter
;
265 if(!lengthen_path(path
, count
))
268 old_count
= path
->pathdata
.Count
;
270 for(i
= 0; i
< count
; i
++){
271 path
->pathdata
.Points
[old_count
+ i
].X
= points
[i
].X
;
272 path
->pathdata
.Points
[old_count
+ i
].Y
= points
[i
].Y
;
273 path
->pathdata
.Types
[old_count
+ i
] = PathPointTypeBezier
;
276 path
->pathdata
.Types
[old_count
] =
277 (path
->newfigure
? PathPointTypeStart
: PathPointTypeLine
);
278 path
->newfigure
= FALSE
;
279 path
->pathdata
.Count
+= count
;
284 GpStatus WINGDIPAPI
GdipAddPathBeziersI(GpPath
*path
, GDIPCONST GpPoint
*points
,
291 TRACE("(%p, %p, %d)\n", path
, points
, count
);
293 if(!points
|| ((count
- 1) % 3))
294 return InvalidParameter
;
296 ptsF
= heap_alloc_zero(sizeof(GpPointF
) * count
);
300 for(i
= 0; i
< count
; i
++){
301 ptsF
[i
].X
= (REAL
)points
[i
].X
;
302 ptsF
[i
].Y
= (REAL
)points
[i
].Y
;
305 ret
= GdipAddPathBeziers(path
, ptsF
, count
);
311 GpStatus WINGDIPAPI
GdipAddPathClosedCurve(GpPath
*path
, GDIPCONST GpPointF
*points
,
314 TRACE("(%p, %p, %d)\n", path
, points
, count
);
316 return GdipAddPathClosedCurve2(path
, points
, count
, 1.0);
319 GpStatus WINGDIPAPI
GdipAddPathClosedCurveI(GpPath
*path
, GDIPCONST GpPoint
*points
,
322 TRACE("(%p, %p, %d)\n", path
, points
, count
);
324 return GdipAddPathClosedCurve2I(path
, points
, count
, 1.0);
327 GpStatus WINGDIPAPI
GdipAddPathClosedCurve2(GpPath
*path
, GDIPCONST GpPointF
*points
,
328 INT count
, REAL tension
)
330 INT i
, len_pt
= (count
+ 1)*3-2;
336 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
338 if(!path
|| !points
|| count
<= 1)
339 return InvalidParameter
;
341 pt
= heap_alloc_zero(len_pt
* sizeof(GpPointF
));
342 pts
= heap_alloc_zero((count
+ 1)*sizeof(GpPointF
));
349 /* copy source points to extend with the last one */
350 memcpy(pts
, points
, sizeof(GpPointF
)*count
);
353 tension
= tension
* TENSION_CONST
;
355 for(i
= 0; i
< count
-1; i
++){
356 calc_curve_bezier(&(pts
[i
]), tension
, &x1
, &y1
, &x2
, &y2
);
360 pt
[3*i
+3].X
= pts
[i
+1].X
;
361 pt
[3*i
+3].Y
= pts
[i
+1].Y
;
366 /* points [len_pt-2] and [0] are calculated
367 separately to connect splines properly */
368 pts
[0] = points
[count
-1];
369 pts
[1] = points
[0]; /* equals to start and end of a resulting path */
372 calc_curve_bezier(pts
, tension
, &x1
, &y1
, &x2
, &y2
);
380 pt
[len_pt
-1].X
= pt
[0].X
;
381 pt
[len_pt
-1].Y
= pt
[0].Y
;
383 stat
= GdipAddPathBeziers(path
, pt
, len_pt
);
387 path
->pathdata
.Types
[path
->pathdata
.Count
- 1] |= PathPointTypeCloseSubpath
;
388 path
->newfigure
= TRUE
;
397 GpStatus WINGDIPAPI
GdipAddPathClosedCurve2I(GpPath
*path
, GDIPCONST GpPoint
*points
,
398 INT count
, REAL tension
)
404 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
406 if(!path
|| !points
|| count
<= 1)
407 return InvalidParameter
;
409 ptf
= heap_alloc_zero(sizeof(GpPointF
)*count
);
413 for(i
= 0; i
< count
; i
++){
414 ptf
[i
].X
= (REAL
)points
[i
].X
;
415 ptf
[i
].Y
= (REAL
)points
[i
].Y
;
418 stat
= GdipAddPathClosedCurve2(path
, ptf
, count
, tension
);
425 GpStatus WINGDIPAPI
GdipAddPathCurve(GpPath
*path
, GDIPCONST GpPointF
*points
, INT count
)
427 TRACE("(%p, %p, %d)\n", path
, points
, count
);
429 if(!path
|| !points
|| count
<= 1)
430 return InvalidParameter
;
432 return GdipAddPathCurve2(path
, points
, count
, 1.0);
435 GpStatus WINGDIPAPI
GdipAddPathCurveI(GpPath
*path
, GDIPCONST GpPoint
*points
, INT count
)
437 TRACE("(%p, %p, %d)\n", path
, points
, count
);
439 if(!path
|| !points
|| count
<= 1)
440 return InvalidParameter
;
442 return GdipAddPathCurve2I(path
, points
, count
, 1.0);
445 GpStatus WINGDIPAPI
GdipAddPathCurve2(GpPath
*path
, GDIPCONST GpPointF
*points
, INT count
,
448 INT i
, len_pt
= count
*3-2;
453 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
455 if(!path
|| !points
|| count
<= 1)
456 return InvalidParameter
;
458 pt
= heap_alloc_zero(len_pt
* sizeof(GpPointF
));
462 tension
= tension
* TENSION_CONST
;
464 calc_curve_bezier_endp(points
[0].X
, points
[0].Y
, points
[1].X
, points
[1].Y
,
467 pt
[0].X
= points
[0].X
;
468 pt
[0].Y
= points
[0].Y
;
472 for(i
= 0; i
< count
-2; i
++){
473 calc_curve_bezier(&(points
[i
]), tension
, &x1
, &y1
, &x2
, &y2
);
477 pt
[3*i
+3].X
= points
[i
+1].X
;
478 pt
[3*i
+3].Y
= points
[i
+1].Y
;
483 calc_curve_bezier_endp(points
[count
-1].X
, points
[count
-1].Y
,
484 points
[count
-2].X
, points
[count
-2].Y
, tension
, &x1
, &y1
);
488 pt
[len_pt
-1].X
= points
[count
-1].X
;
489 pt
[len_pt
-1].Y
= points
[count
-1].Y
;
491 stat
= GdipAddPathBeziers(path
, pt
, len_pt
);
498 GpStatus WINGDIPAPI
GdipAddPathCurve2I(GpPath
*path
, GDIPCONST GpPoint
*points
,
499 INT count
, REAL tension
)
505 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
507 if(!path
|| !points
|| count
<= 1)
508 return InvalidParameter
;
510 ptf
= heap_alloc_zero(sizeof(GpPointF
)*count
);
514 for(i
= 0; i
< count
; i
++){
515 ptf
[i
].X
= (REAL
)points
[i
].X
;
516 ptf
[i
].Y
= (REAL
)points
[i
].Y
;
519 stat
= GdipAddPathCurve2(path
, ptf
, count
, tension
);
526 GpStatus WINGDIPAPI
GdipAddPathCurve3(GpPath
*path
, GDIPCONST GpPointF
*points
,
527 INT count
, INT offset
, INT nseg
, REAL tension
)
529 TRACE("(%p, %p, %d, %d, %d, %.2f)\n", path
, points
, count
, offset
, nseg
, tension
);
531 if(!path
|| !points
|| offset
+ 1 >= count
|| count
- offset
< nseg
+ 1)
532 return InvalidParameter
;
534 return GdipAddPathCurve2(path
, &points
[offset
], nseg
+ 1, tension
);
537 GpStatus WINGDIPAPI
GdipAddPathCurve3I(GpPath
*path
, GDIPCONST GpPoint
*points
,
538 INT count
, INT offset
, INT nseg
, REAL tension
)
540 TRACE("(%p, %p, %d, %d, %d, %.2f)\n", path
, points
, count
, offset
, nseg
, tension
);
542 if(!path
|| !points
|| offset
+ 1 >= count
|| count
- offset
< nseg
+ 1)
543 return InvalidParameter
;
545 return GdipAddPathCurve2I(path
, &points
[offset
], nseg
+ 1, tension
);
548 GpStatus WINGDIPAPI
GdipAddPathEllipse(GpPath
*path
, REAL x
, REAL y
, REAL width
,
551 INT old_count
, numpts
;
553 TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path
, x
, y
, width
, height
);
556 return InvalidParameter
;
558 if(!lengthen_path(path
, MAX_ARC_PTS
))
561 old_count
= path
->pathdata
.Count
;
562 if((numpts
= arc2polybezier(&path
->pathdata
.Points
[old_count
], x
, y
, width
,
563 height
, 0.0, 360.0)) != MAX_ARC_PTS
){
564 ERR("expected %d points but got %d\n", MAX_ARC_PTS
, numpts
);
568 memset(&path
->pathdata
.Types
[old_count
+ 1], PathPointTypeBezier
,
571 /* An ellipse is an intrinsic figure (always is its own subpath). */
572 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
573 path
->pathdata
.Types
[old_count
+ MAX_ARC_PTS
- 1] |= PathPointTypeCloseSubpath
;
574 path
->newfigure
= TRUE
;
575 path
->pathdata
.Count
+= MAX_ARC_PTS
;
580 GpStatus WINGDIPAPI
GdipAddPathEllipseI(GpPath
*path
, INT x
, INT y
, INT width
,
583 TRACE("(%p, %d, %d, %d, %d)\n", path
, x
, y
, width
, height
);
585 return GdipAddPathEllipse(path
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
);
588 GpStatus WINGDIPAPI
GdipAddPathLine2(GpPath
*path
, GDIPCONST GpPointF
*points
,
593 TRACE("(%p, %p, %d)\n", path
, points
, count
);
596 return InvalidParameter
;
598 if(!lengthen_path(path
, count
))
601 old_count
= path
->pathdata
.Count
;
603 for(i
= 0; i
< count
; i
++){
604 path
->pathdata
.Points
[old_count
+ i
].X
= points
[i
].X
;
605 path
->pathdata
.Points
[old_count
+ i
].Y
= points
[i
].Y
;
606 path
->pathdata
.Types
[old_count
+ i
] = PathPointTypeLine
;
610 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
611 path
->newfigure
= FALSE
;
614 path
->pathdata
.Count
+= count
;
619 GpStatus WINGDIPAPI
GdipAddPathLine2I(GpPath
*path
, GDIPCONST GpPoint
*points
, INT count
)
625 TRACE("(%p, %p, %d)\n", path
, points
, count
);
628 return InvalidParameter
;
630 pointsF
= heap_alloc_zero(sizeof(GpPointF
) * count
);
631 if(!pointsF
) return OutOfMemory
;
633 for(i
= 0;i
< count
; i
++){
634 pointsF
[i
].X
= (REAL
)points
[i
].X
;
635 pointsF
[i
].Y
= (REAL
)points
[i
].Y
;
638 stat
= GdipAddPathLine2(path
, pointsF
, count
);
645 GpStatus WINGDIPAPI
GdipAddPathLine(GpPath
*path
, REAL x1
, REAL y1
, REAL x2
, REAL y2
)
649 TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path
, x1
, y1
, x2
, y2
);
652 return InvalidParameter
;
654 if(!lengthen_path(path
, 2))
657 old_count
= path
->pathdata
.Count
;
659 path
->pathdata
.Points
[old_count
].X
= x1
;
660 path
->pathdata
.Points
[old_count
].Y
= y1
;
661 path
->pathdata
.Points
[old_count
+ 1].X
= x2
;
662 path
->pathdata
.Points
[old_count
+ 1].Y
= y2
;
664 path
->pathdata
.Types
[old_count
] =
665 (path
->newfigure
? PathPointTypeStart
: PathPointTypeLine
);
666 path
->pathdata
.Types
[old_count
+ 1] = PathPointTypeLine
;
668 path
->newfigure
= FALSE
;
669 path
->pathdata
.Count
+= 2;
674 GpStatus WINGDIPAPI
GdipAddPathLineI(GpPath
*path
, INT x1
, INT y1
, INT x2
, INT y2
)
676 TRACE("(%p, %d, %d, %d, %d)\n", path
, x1
, y1
, x2
, y2
);
678 return GdipAddPathLine(path
, (REAL
)x1
, (REAL
)y1
, (REAL
)x2
, (REAL
)y2
);
681 GpStatus WINGDIPAPI
GdipAddPathPath(GpPath
*path
, GDIPCONST GpPath
* addingPath
,
684 INT old_count
, count
;
686 TRACE("(%p, %p, %d)\n", path
, addingPath
, connect
);
688 if(!path
|| !addingPath
)
689 return InvalidParameter
;
691 old_count
= path
->pathdata
.Count
;
692 count
= addingPath
->pathdata
.Count
;
694 if(!lengthen_path(path
, count
))
697 memcpy(&path
->pathdata
.Points
[old_count
], addingPath
->pathdata
.Points
,
698 count
* sizeof(GpPointF
));
699 memcpy(&path
->pathdata
.Types
[old_count
], addingPath
->pathdata
.Types
, count
);
701 if(path
->newfigure
|| !connect
)
702 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
704 path
->pathdata
.Types
[old_count
] = PathPointTypeLine
;
706 path
->newfigure
= FALSE
;
707 path
->pathdata
.Count
+= count
;
712 GpStatus WINGDIPAPI
GdipAddPathPie(GpPath
*path
, REAL x
, REAL y
, REAL width
, REAL height
,
713 REAL startAngle
, REAL sweepAngle
)
719 TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
720 path
, x
, y
, width
, height
, startAngle
, sweepAngle
);
723 return InvalidParameter
;
725 /* on zero width/height only start point added */
726 if(width
<= 1e-7 || height
<= 1e-7){
727 if(!lengthen_path(path
, 1))
729 path
->pathdata
.Points
[0].X
= x
+ width
/ 2.0;
730 path
->pathdata
.Points
[0].Y
= y
+ height
/ 2.0;
731 path
->pathdata
.Types
[0] = PathPointTypeStart
| PathPointTypeCloseSubpath
;
732 path
->pathdata
.Count
= 1;
733 return InvalidParameter
;
736 count
= arc2polybezier(NULL
, x
, y
, width
, height
, startAngle
, sweepAngle
);
741 ptf
= heap_alloc_zero(sizeof(GpPointF
)*count
);
745 arc2polybezier(ptf
, x
, y
, width
, height
, startAngle
, sweepAngle
);
747 status
= GdipAddPathLine(path
, x
+ width
/2, y
+ height
/2, ptf
[0].X
, ptf
[0].Y
);
752 /* one spline is already added as a line endpoint */
753 if(!lengthen_path(path
, count
- 1)){
758 memcpy(&(path
->pathdata
.Points
[path
->pathdata
.Count
]), &(ptf
[1]),sizeof(GpPointF
)*(count
-1));
759 for(i
= 0; i
< count
-1; i
++)
760 path
->pathdata
.Types
[path
->pathdata
.Count
+i
] = PathPointTypeBezier
;
762 path
->pathdata
.Count
+= count
-1;
764 GdipClosePathFigure(path
);
771 GpStatus WINGDIPAPI
GdipAddPathPieI(GpPath
*path
, INT x
, INT y
, INT width
, INT height
,
772 REAL startAngle
, REAL sweepAngle
)
774 TRACE("(%p, %d, %d, %d, %d, %.2f, %.2f)\n",
775 path
, x
, y
, width
, height
, startAngle
, sweepAngle
);
777 return GdipAddPathPie(path
, (REAL
)x
, (REAL
)y
, (REAL
)width
, (REAL
)height
, startAngle
, sweepAngle
);
780 GpStatus WINGDIPAPI
GdipAddPathPolygon(GpPath
*path
, GDIPCONST GpPointF
*points
, INT count
)
784 TRACE("(%p, %p, %d)\n", path
, points
, count
);
786 if(!path
|| !points
|| count
< 3)
787 return InvalidParameter
;
789 if(!lengthen_path(path
, count
))
792 old_count
= path
->pathdata
.Count
;
794 memcpy(&path
->pathdata
.Points
[old_count
], points
, count
*sizeof(GpPointF
));
795 memset(&path
->pathdata
.Types
[old_count
+ 1], PathPointTypeLine
, count
- 1);
797 /* A polygon is an intrinsic figure */
798 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
799 path
->pathdata
.Types
[old_count
+ count
- 1] |= PathPointTypeCloseSubpath
;
800 path
->newfigure
= TRUE
;
801 path
->pathdata
.Count
+= count
;
806 GpStatus WINGDIPAPI
GdipAddPathPolygonI(GpPath
*path
, GDIPCONST GpPoint
*points
, INT count
)
812 TRACE("(%p, %p, %d)\n", path
, points
, count
);
814 if(!points
|| count
< 3)
815 return InvalidParameter
;
817 ptf
= heap_alloc_zero(sizeof(GpPointF
) * count
);
821 for(i
= 0; i
< count
; i
++){
822 ptf
[i
].X
= (REAL
)points
[i
].X
;
823 ptf
[i
].Y
= (REAL
)points
[i
].Y
;
826 status
= GdipAddPathPolygon(path
, ptf
, count
);
833 static float fromfixedpoint(const FIXED v
)
835 float f
= ((float)v
.fract
) / (1<<(sizeof(v
.fract
)*8));
840 struct format_string_args
848 static GpStatus
format_string_callback(HDC dc
,
849 GDIPCONST WCHAR
*string
, INT index
, INT length
, GDIPCONST GpFont
*font
,
850 GDIPCONST RectF
*rect
, GDIPCONST GpStringFormat
*format
,
851 INT lineno
, const RectF
*bounds
, INT
*underlined_indexes
,
852 INT underlined_index_count
, void *priv
)
854 static const MAT2 identity
= { {0,1}, {0,0}, {0,0}, {0,1} };
855 struct format_string_args
*args
= priv
;
856 GpPath
*path
= args
->path
;
857 GpStatus status
= Ok
;
858 float x
= rect
->X
+ (bounds
->X
- rect
->X
) * args
->scale
;
859 float y
= rect
->Y
+ (bounds
->Y
- rect
->Y
) * args
->scale
;
862 if (underlined_index_count
)
863 FIXME("hotkey underlines not drawn yet\n");
865 if (y
+ bounds
->Height
* args
->scale
> args
->maxY
)
866 args
->maxY
= y
+ bounds
->Height
* args
->scale
;
868 for (i
= index
; i
< length
; ++i
)
871 TTPOLYGONHEADER
*ph
= NULL
, *origph
;
874 len
= GetGlyphOutlineW(dc
, string
[i
], GGO_BEZIER
, &gm
, 0, NULL
, &identity
);
875 if (len
== GDI_ERROR
)
877 status
= GenericError
;
880 origph
= ph
= heap_alloc_zero(len
);
882 if (!ph
|| !lengthen_path(path
, len
/ sizeof(POINTFX
)))
884 status
= OutOfMemory
;
887 GetGlyphOutlineW(dc
, string
[i
], GGO_BEZIER
, &gm
, len
, start
, &identity
);
892 DWORD ofs_start
= ofs
;
893 ph
= (TTPOLYGONHEADER
*)&start
[ofs
];
894 path
->pathdata
.Types
[path
->pathdata
.Count
] = PathPointTypeStart
;
895 path
->pathdata
.Points
[path
->pathdata
.Count
].X
= x
+ fromfixedpoint(ph
->pfxStart
.x
) * args
->scale
;
896 path
->pathdata
.Points
[path
->pathdata
.Count
++].Y
= y
+ args
->ascent
- fromfixedpoint(ph
->pfxStart
.y
) * args
->scale
;
897 TRACE("Starting at count %i with pos %f, %f)\n", path
->pathdata
.Count
, x
, y
);
899 while (ofs
- ofs_start
< ph
->cb
)
901 TTPOLYCURVE
*curve
= (TTPOLYCURVE
*)&start
[ofs
];
903 ofs
+= sizeof(TTPOLYCURVE
) + (curve
->cpfx
- 1) * sizeof(POINTFX
);
905 switch (curve
->wType
)
908 for (j
= 0; j
< curve
->cpfx
; ++j
)
910 path
->pathdata
.Types
[path
->pathdata
.Count
] = PathPointTypeLine
;
911 path
->pathdata
.Points
[path
->pathdata
.Count
].X
= x
+ fromfixedpoint(curve
->apfx
[j
].x
) * args
->scale
;
912 path
->pathdata
.Points
[path
->pathdata
.Count
++].Y
= y
+ args
->ascent
- fromfixedpoint(curve
->apfx
[j
].y
) * args
->scale
;
915 case TT_PRIM_CSPLINE
:
916 for (j
= 0; j
< curve
->cpfx
; ++j
)
918 path
->pathdata
.Types
[path
->pathdata
.Count
] = PathPointTypeBezier
;
919 path
->pathdata
.Points
[path
->pathdata
.Count
].X
= x
+ fromfixedpoint(curve
->apfx
[j
].x
) * args
->scale
;
920 path
->pathdata
.Points
[path
->pathdata
.Count
++].Y
= y
+ args
->ascent
- fromfixedpoint(curve
->apfx
[j
].y
) * args
->scale
;
924 ERR("Unhandled type: %u\n", curve
->wType
);
925 status
= GenericError
;
928 path
->pathdata
.Types
[path
->pathdata
.Count
- 1] |= PathPointTypeCloseSubpath
;
930 path
->newfigure
= TRUE
;
931 x
+= gm
.gmCellIncX
* args
->scale
;
932 y
+= gm
.gmCellIncY
* args
->scale
;
942 GpStatus WINGDIPAPI
GdipAddPathString(GpPath
* path
, GDIPCONST WCHAR
* string
, INT length
, GDIPCONST GpFontFamily
* family
, INT style
, REAL emSize
, GDIPCONST RectF
* layoutRect
, GDIPCONST GpStringFormat
* format
)
949 GpGraphics
*graphics
;
951 struct format_string_args args
;
953 UINT16 native_height
;
954 RectF scaled_layout_rect
;
955 TEXTMETRICW textmetric
;
957 TRACE("(%p, %s, %d, %p, %d, %f, %p, %p)\n", path
, debugstr_w(string
), length
, family
, style
, emSize
, layoutRect
, format
);
958 if (!path
|| !string
|| !family
|| !emSize
|| !layoutRect
|| !format
)
959 return InvalidParameter
;
961 status
= GdipGetEmHeight(family
, style
, &native_height
);
965 scaled_layout_rect
.X
= layoutRect
->X
;
966 scaled_layout_rect
.Y
= layoutRect
->Y
;
967 scaled_layout_rect
.Width
= layoutRect
->Width
* native_height
/ emSize
;
968 scaled_layout_rect
.Height
= layoutRect
->Height
* native_height
/ emSize
;
970 if ((status
= GdipClonePath(path
, &backup
)) != Ok
)
973 dc
= CreateCompatibleDC(0);
974 status
= GdipCreateFromHDC(dc
, &graphics
);
978 GdipDeletePath(backup
);
982 status
= GdipCreateFont(family
, native_height
, style
, UnitPixel
, &font
);
985 GdipDeleteGraphics(graphics
);
987 GdipDeletePath(backup
);
991 get_log_fontW(font
, graphics
, &lfw
);
992 GdipDeleteFont(font
);
993 GdipDeleteGraphics(graphics
);
995 hfont
= CreateFontIndirectW(&lfw
);
998 WARN("Failed to create font\n");
1000 GdipDeletePath(backup
);
1001 return GenericError
;
1004 SelectObject(dc
, hfont
);
1006 GetTextMetricsW(dc
, &textmetric
);
1010 args
.scale
= emSize
/ native_height
;
1011 args
.ascent
= textmetric
.tmAscent
* args
.scale
;
1012 status
= gdip_format_string(dc
, string
, length
, NULL
, &scaled_layout_rect
,
1013 format
, TRUE
, format_string_callback
, &args
);
1016 DeleteObject(hfont
);
1018 if (status
!= Ok
) /* free backup */
1020 heap_free(path
->pathdata
.Points
);
1021 heap_free(path
->pathdata
.Types
);
1026 if (format
&& format
->vertalign
== StringAlignmentCenter
&& layoutRect
->Y
+ args
.maxY
< layoutRect
->Height
)
1028 float inc
= layoutRect
->Height
+ layoutRect
->Y
- args
.maxY
;
1030 for (i
= backup
->pathdata
.Count
; i
< path
->pathdata
.Count
; ++i
)
1031 path
->pathdata
.Points
[i
].Y
+= inc
;
1032 } else if (format
&& format
->vertalign
== StringAlignmentFar
) {
1033 float inc
= layoutRect
->Height
+ layoutRect
->Y
- args
.maxY
;
1034 for (i
= backup
->pathdata
.Count
; i
< path
->pathdata
.Count
; ++i
)
1035 path
->pathdata
.Points
[i
].Y
+= inc
;
1037 GdipDeletePath(backup
);
1041 GpStatus WINGDIPAPI
GdipAddPathStringI(GpPath
* path
, GDIPCONST WCHAR
* string
, INT length
, GDIPCONST GpFontFamily
* family
, INT style
, REAL emSize
, GDIPCONST Rect
* layoutRect
, GDIPCONST GpStringFormat
* format
)
1045 RectF layoutRectF
= {
1046 (REAL
)layoutRect
->X
,
1047 (REAL
)layoutRect
->Y
,
1048 (REAL
)layoutRect
->Width
,
1049 (REAL
)layoutRect
->Height
1051 return GdipAddPathString(path
, string
, length
, family
, style
, emSize
, &layoutRectF
, format
);
1053 return InvalidParameter
;
1056 GpStatus WINGDIPAPI
GdipClonePath(GpPath
* path
, GpPath
**clone
)
1058 TRACE("(%p, %p)\n", path
, clone
);
1061 return InvalidParameter
;
1063 *clone
= heap_alloc_zero(sizeof(GpPath
));
1064 if(!*clone
) return OutOfMemory
;
1068 (*clone
)->pathdata
.Points
= heap_alloc_zero(path
->datalen
* sizeof(PointF
));
1069 (*clone
)->pathdata
.Types
= heap_alloc_zero(path
->datalen
);
1070 if(!(*clone
)->pathdata
.Points
|| !(*clone
)->pathdata
.Types
){
1071 heap_free((*clone
)->pathdata
.Points
);
1072 heap_free((*clone
)->pathdata
.Types
);
1077 memcpy((*clone
)->pathdata
.Points
, path
->pathdata
.Points
,
1078 path
->datalen
* sizeof(PointF
));
1079 memcpy((*clone
)->pathdata
.Types
, path
->pathdata
.Types
, path
->datalen
);
1084 GpStatus WINGDIPAPI
GdipClosePathFigure(GpPath
* path
)
1086 TRACE("(%p)\n", path
);
1089 return InvalidParameter
;
1091 if(path
->pathdata
.Count
> 0){
1092 path
->pathdata
.Types
[path
->pathdata
.Count
- 1] |= PathPointTypeCloseSubpath
;
1093 path
->newfigure
= TRUE
;
1099 GpStatus WINGDIPAPI
GdipClosePathFigures(GpPath
* path
)
1103 TRACE("(%p)\n", path
);
1106 return InvalidParameter
;
1108 for(i
= 1; i
< path
->pathdata
.Count
; i
++){
1109 if(path
->pathdata
.Types
[i
] == PathPointTypeStart
)
1110 path
->pathdata
.Types
[i
-1] |= PathPointTypeCloseSubpath
;
1113 path
->newfigure
= TRUE
;
1118 GpStatus WINGDIPAPI
GdipCreatePath(GpFillMode fill
, GpPath
**path
)
1120 TRACE("(%d, %p)\n", fill
, path
);
1123 return InvalidParameter
;
1125 *path
= heap_alloc_zero(sizeof(GpPath
));
1126 if(!*path
) return OutOfMemory
;
1128 (*path
)->fill
= fill
;
1129 (*path
)->newfigure
= TRUE
;
1134 GpStatus WINGDIPAPI
GdipCreatePath2(GDIPCONST GpPointF
* points
,
1135 GDIPCONST BYTE
* types
, INT count
, GpFillMode fill
, GpPath
**path
)
1137 TRACE("(%p, %p, %d, %d, %p)\n", points
, types
, count
, fill
, path
);
1140 return InvalidParameter
;
1142 *path
= heap_alloc_zero(sizeof(GpPath
));
1143 if(!*path
) return OutOfMemory
;
1145 (*path
)->pathdata
.Points
= heap_alloc_zero(count
* sizeof(PointF
));
1146 (*path
)->pathdata
.Types
= heap_alloc_zero(count
);
1148 if(!(*path
)->pathdata
.Points
|| !(*path
)->pathdata
.Types
){
1149 heap_free((*path
)->pathdata
.Points
);
1150 heap_free((*path
)->pathdata
.Types
);
1155 memcpy((*path
)->pathdata
.Points
, points
, count
* sizeof(PointF
));
1156 memcpy((*path
)->pathdata
.Types
, types
, count
);
1157 (*path
)->pathdata
.Count
= count
;
1158 (*path
)->datalen
= count
;
1160 (*path
)->fill
= fill
;
1161 (*path
)->newfigure
= TRUE
;
1166 GpStatus WINGDIPAPI
GdipCreatePath2I(GDIPCONST GpPoint
* points
,
1167 GDIPCONST BYTE
* types
, INT count
, GpFillMode fill
, GpPath
**path
)
1173 TRACE("(%p, %p, %d, %d, %p)\n", points
, types
, count
, fill
, path
);
1175 ptF
= heap_alloc_zero(sizeof(GpPointF
)*count
);
1177 for(i
= 0;i
< count
; i
++){
1178 ptF
[i
].X
= (REAL
)points
[i
].X
;
1179 ptF
[i
].Y
= (REAL
)points
[i
].Y
;
1182 ret
= GdipCreatePath2(ptF
, types
, count
, fill
, path
);
1189 GpStatus WINGDIPAPI
GdipDeletePath(GpPath
*path
)
1191 TRACE("(%p)\n", path
);
1194 return InvalidParameter
;
1196 heap_free(path
->pathdata
.Points
);
1197 heap_free(path
->pathdata
.Types
);
1203 GpStatus WINGDIPAPI
GdipFlattenPath(GpPath
*path
, GpMatrix
* matrix
, REAL flatness
)
1205 path_list_node_t
*list
, *node
;
1211 TRACE("(%p, %p, %.2f)\n", path
, matrix
, flatness
);
1214 return InvalidParameter
;
1216 if(path
->pathdata
.Count
== 0)
1219 stat
= GdipTransformPath(path
, matrix
);
1223 pt
= path
->pathdata
.Points
[0];
1224 if(!init_path_list(&list
, pt
.X
, pt
.Y
))
1229 while(i
< path
->pathdata
.Count
){
1231 BYTE type
= path
->pathdata
.Types
[i
] & PathPointTypePathTypeMask
;
1232 path_list_node_t
*start
;
1234 pt
= path
->pathdata
.Points
[i
];
1236 /* save last start point index */
1237 if(type
== PathPointTypeStart
)
1240 /* always add line points and start points */
1241 if((type
== PathPointTypeStart
) || (type
== PathPointTypeLine
)){
1242 if(!add_path_list_node(node
, pt
.X
, pt
.Y
, path
->pathdata
.Types
[i
]))
1252 /* test for closed figure */
1253 if(path
->pathdata
.Types
[i
+1] & PathPointTypeCloseSubpath
){
1254 pt
= path
->pathdata
.Points
[startidx
];
1260 pt
= path
->pathdata
.Points
[i
];
1264 /* add Bezier end point */
1265 type
= (path
->pathdata
.Types
[i
] & ~PathPointTypePathTypeMask
) | PathPointTypeLine
;
1266 if(!add_path_list_node(node
, pt
.X
, pt
.Y
, type
))
1271 if(!flatten_bezier(start
, path
->pathdata
.Points
[i
-2].X
, path
->pathdata
.Points
[i
-2].Y
,
1272 path
->pathdata
.Points
[i
-1].X
, path
->pathdata
.Points
[i
-1].Y
,
1279 /* store path data back */
1280 i
= path_list_count(list
);
1281 if(!lengthen_path(path
, i
))
1283 path
->pathdata
.Count
= i
;
1286 for(i
= 0; i
< path
->pathdata
.Count
; i
++){
1287 path
->pathdata
.Points
[i
] = node
->pt
;
1288 path
->pathdata
.Types
[i
] = node
->type
;
1292 free_path_list(list
);
1296 free_path_list(list
);
1300 GpStatus WINGDIPAPI
GdipGetPathData(GpPath
*path
, GpPathData
* pathData
)
1302 TRACE("(%p, %p)\n", path
, pathData
);
1304 if(!path
|| !pathData
)
1305 return InvalidParameter
;
1307 /* Only copy data. pathData allocation/freeing controlled by wrapper class.
1308 Assumed that pathData is enough wide to get all data - controlled by wrapper too. */
1309 memcpy(pathData
->Points
, path
->pathdata
.Points
, sizeof(PointF
) * pathData
->Count
);
1310 memcpy(pathData
->Types
, path
->pathdata
.Types
, pathData
->Count
);
1315 GpStatus WINGDIPAPI
GdipGetPathFillMode(GpPath
*path
, GpFillMode
*fillmode
)
1317 TRACE("(%p, %p)\n", path
, fillmode
);
1319 if(!path
|| !fillmode
)
1320 return InvalidParameter
;
1322 *fillmode
= path
->fill
;
1327 GpStatus WINGDIPAPI
GdipGetPathLastPoint(GpPath
* path
, GpPointF
* lastPoint
)
1331 TRACE("(%p, %p)\n", path
, lastPoint
);
1333 if(!path
|| !lastPoint
)
1334 return InvalidParameter
;
1336 count
= path
->pathdata
.Count
;
1338 *lastPoint
= path
->pathdata
.Points
[count
-1];
1343 GpStatus WINGDIPAPI
GdipGetPathPoints(GpPath
*path
, GpPointF
* points
, INT count
)
1345 TRACE("(%p, %p, %d)\n", path
, points
, count
);
1348 return InvalidParameter
;
1350 if(count
< path
->pathdata
.Count
)
1351 return InsufficientBuffer
;
1353 memcpy(points
, path
->pathdata
.Points
, path
->pathdata
.Count
* sizeof(GpPointF
));
1358 GpStatus WINGDIPAPI
GdipGetPathPointsI(GpPath
*path
, GpPoint
* points
, INT count
)
1364 TRACE("(%p, %p, %d)\n", path
, points
, count
);
1367 return InvalidParameter
;
1369 ptf
= heap_alloc_zero(sizeof(GpPointF
)*count
);
1370 if(!ptf
) return OutOfMemory
;
1372 ret
= GdipGetPathPoints(path
,ptf
,count
);
1374 for(i
= 0;i
< count
;i
++){
1375 points
[i
].X
= gdip_round(ptf
[i
].X
);
1376 points
[i
].Y
= gdip_round(ptf
[i
].Y
);
1383 GpStatus WINGDIPAPI
GdipGetPathTypes(GpPath
*path
, BYTE
* types
, INT count
)
1385 TRACE("(%p, %p, %d)\n", path
, types
, count
);
1388 return InvalidParameter
;
1390 if(count
< path
->pathdata
.Count
)
1391 return InsufficientBuffer
;
1393 memcpy(types
, path
->pathdata
.Types
, path
->pathdata
.Count
);
1398 /* Windows expands the bounding box to the maximum possible bounding box
1399 * for a given pen. For example, if a line join can extend past the point
1400 * it's joining by x units, the bounding box is extended by x units in every
1401 * direction (even though this is too conservative for most cases). */
1402 GpStatus WINGDIPAPI
GdipGetPathWorldBounds(GpPath
* path
, GpRectF
* bounds
,
1403 GDIPCONST GpMatrix
*matrix
, GDIPCONST GpPen
*pen
)
1405 GpPointF
* points
, temp_pts
[4];
1407 REAL path_width
= 1.0, width
, height
, temp
, low_x
, low_y
, high_x
, high_y
;
1409 TRACE("(%p, %p, %p, %p)\n", path
, bounds
, matrix
, pen
);
1411 /* Matrix and pen can be null. */
1412 if(!path
|| !bounds
)
1413 return InvalidParameter
;
1415 /* If path is empty just return. */
1416 count
= path
->pathdata
.Count
;
1418 bounds
->X
= bounds
->Y
= bounds
->Width
= bounds
->Height
= 0.0;
1422 points
= path
->pathdata
.Points
;
1424 low_x
= high_x
= points
[0].X
;
1425 low_y
= high_y
= points
[0].Y
;
1427 for(i
= 1; i
< count
; i
++){
1428 low_x
= min(low_x
, points
[i
].X
);
1429 low_y
= min(low_y
, points
[i
].Y
);
1430 high_x
= max(high_x
, points
[i
].X
);
1431 high_y
= max(high_y
, points
[i
].Y
);
1434 width
= high_x
- low_x
;
1435 height
= high_y
- low_y
;
1437 /* This looks unusual but it's the only way I can imitate windows. */
1439 temp_pts
[0].X
= low_x
;
1440 temp_pts
[0].Y
= low_y
;
1441 temp_pts
[1].X
= low_x
;
1442 temp_pts
[1].Y
= high_y
;
1443 temp_pts
[2].X
= high_x
;
1444 temp_pts
[2].Y
= high_y
;
1445 temp_pts
[3].X
= high_x
;
1446 temp_pts
[3].Y
= low_y
;
1448 GdipTransformMatrixPoints((GpMatrix
*)matrix
, temp_pts
, 4);
1449 low_x
= temp_pts
[0].X
;
1450 low_y
= temp_pts
[0].Y
;
1452 for(i
= 1; i
< 4; i
++){
1453 low_x
= min(low_x
, temp_pts
[i
].X
);
1454 low_y
= min(low_y
, temp_pts
[i
].Y
);
1458 width
= height
* fabs(matrix
->matrix
[2]) + width
* fabs(matrix
->matrix
[0]);
1459 height
= height
* fabs(matrix
->matrix
[3]) + temp
* fabs(matrix
->matrix
[1]);
1463 path_width
= pen
->width
/ 2.0;
1466 path_width
= max(path_width
, pen
->width
* pen
->miterlimit
/ 2.0);
1467 /* FIXME: this should probably also check for the startcap */
1468 if(pen
->endcap
& LineCapNoAnchor
)
1469 path_width
= max(path_width
, pen
->width
* 2.2);
1471 low_x
-= path_width
;
1472 low_y
-= path_width
;
1473 width
+= 2.0 * path_width
;
1474 height
+= 2.0 * path_width
;
1479 bounds
->Width
= width
;
1480 bounds
->Height
= height
;
1485 GpStatus WINGDIPAPI
GdipGetPathWorldBoundsI(GpPath
* path
, GpRect
* bounds
,
1486 GDIPCONST GpMatrix
*matrix
, GDIPCONST GpPen
*pen
)
1491 TRACE("(%p, %p, %p, %p)\n", path
, bounds
, matrix
, pen
);
1493 ret
= GdipGetPathWorldBounds(path
,&boundsF
,matrix
,pen
);
1496 bounds
->X
= gdip_round(boundsF
.X
);
1497 bounds
->Y
= gdip_round(boundsF
.Y
);
1498 bounds
->Width
= gdip_round(boundsF
.Width
);
1499 bounds
->Height
= gdip_round(boundsF
.Height
);
1505 GpStatus WINGDIPAPI
GdipGetPointCount(GpPath
*path
, INT
*count
)
1507 TRACE("(%p, %p)\n", path
, count
);
1510 return InvalidParameter
;
1512 *count
= path
->pathdata
.Count
;
1517 GpStatus WINGDIPAPI
GdipReversePath(GpPath
* path
)
1520 INT start
= 0; /* position in reversed path */
1523 TRACE("(%p)\n", path
);
1526 return InvalidParameter
;
1528 count
= path
->pathdata
.Count
;
1530 if(count
== 0) return Ok
;
1532 revpath
.Points
= heap_alloc_zero(sizeof(GpPointF
)*count
);
1533 revpath
.Types
= heap_alloc_zero(sizeof(BYTE
)*count
);
1534 revpath
.Count
= count
;
1535 if(!revpath
.Points
|| !revpath
.Types
){
1536 heap_free(revpath
.Points
);
1537 heap_free(revpath
.Types
);
1541 for(i
= 0; i
< count
; i
++){
1543 /* find next start point */
1544 if(path
->pathdata
.Types
[count
-i
-1] == PathPointTypeStart
){
1546 for(j
= start
; j
<= i
; j
++){
1547 revpath
.Points
[j
] = path
->pathdata
.Points
[count
-j
-1];
1548 revpath
.Types
[j
] = path
->pathdata
.Types
[count
-j
-1];
1550 /* mark start point */
1551 revpath
.Types
[start
] = PathPointTypeStart
;
1552 /* set 'figure' endpoint type */
1554 revpath
.Types
[i
] = path
->pathdata
.Types
[count
-start
-1] & ~PathPointTypePathTypeMask
;
1555 revpath
.Types
[i
] |= revpath
.Types
[i
-1];
1558 revpath
.Types
[i
] = path
->pathdata
.Types
[start
];
1564 memcpy(path
->pathdata
.Points
, revpath
.Points
, sizeof(GpPointF
)*count
);
1565 memcpy(path
->pathdata
.Types
, revpath
.Types
, sizeof(BYTE
)*count
);
1567 heap_free(revpath
.Points
);
1568 heap_free(revpath
.Types
);
1573 GpStatus WINGDIPAPI
GdipIsOutlineVisiblePathPointI(GpPath
* path
, INT x
, INT y
,
1574 GpPen
*pen
, GpGraphics
*graphics
, BOOL
*result
)
1576 TRACE("(%p, %d, %d, %p, %p, %p)\n", path
, x
, y
, pen
, graphics
, result
);
1578 return GdipIsOutlineVisiblePathPoint(path
, x
, y
, pen
, graphics
, result
);
1581 GpStatus WINGDIPAPI
GdipIsOutlineVisiblePathPoint(GpPath
* path
, REAL x
, REAL y
,
1582 GpPen
*pen
, GpGraphics
*graphics
, BOOL
*result
)
1586 TRACE("(%p,%0.2f,%0.2f,%p,%p,%p)\n", path
, x
, y
, pen
, graphics
, result
);
1589 return InvalidParameter
;
1592 FIXME("not implemented\n");
1594 return NotImplemented
;
1597 GpStatus WINGDIPAPI
GdipIsVisiblePathPointI(GpPath
* path
, INT x
, INT y
, GpGraphics
*graphics
, BOOL
*result
)
1599 TRACE("(%p, %d, %d, %p, %p)\n", path
, x
, y
, graphics
, result
);
1601 return GdipIsVisiblePathPoint(path
, x
, y
, graphics
, result
);
1604 /*****************************************************************************
1605 * GdipIsVisiblePathPoint [GDIPLUS.@]
1607 GpStatus WINGDIPAPI
GdipIsVisiblePathPoint(GpPath
* path
, REAL x
, REAL y
, GpGraphics
*graphics
, BOOL
*result
)
1613 if(!path
|| !result
) return InvalidParameter
;
1615 status
= GdipCreateRegionPath(path
, ®ion
);
1619 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
1621 GdipDeleteRegion(region
);
1625 *result
= PtInRegion(hrgn
, gdip_round(x
), gdip_round(y
));
1628 GdipDeleteRegion(region
);
1633 GpStatus WINGDIPAPI
GdipStartPathFigure(GpPath
*path
)
1635 TRACE("(%p)\n", path
);
1638 return InvalidParameter
;
1640 path
->newfigure
= TRUE
;
1645 GpStatus WINGDIPAPI
GdipResetPath(GpPath
*path
)
1647 TRACE("(%p)\n", path
);
1650 return InvalidParameter
;
1652 path
->pathdata
.Count
= 0;
1653 path
->newfigure
= TRUE
;
1654 path
->fill
= FillModeAlternate
;
1659 GpStatus WINGDIPAPI
GdipSetPathFillMode(GpPath
*path
, GpFillMode fill
)
1661 TRACE("(%p, %d)\n", path
, fill
);
1664 return InvalidParameter
;
1671 GpStatus WINGDIPAPI
GdipTransformPath(GpPath
*path
, GpMatrix
*matrix
)
1673 TRACE("(%p, %p)\n", path
, matrix
);
1676 return InvalidParameter
;
1678 if(path
->pathdata
.Count
== 0 || !matrix
)
1681 return GdipTransformMatrixPoints(matrix
, path
->pathdata
.Points
,
1682 path
->pathdata
.Count
);
1685 GpStatus WINGDIPAPI
GdipWarpPath(GpPath
*path
, GpMatrix
* matrix
,
1686 GDIPCONST GpPointF
*points
, INT count
, REAL x
, REAL y
, REAL width
,
1687 REAL height
, WarpMode warpmode
, REAL flatness
)
1689 FIXME("(%p,%p,%p,%i,%0.2f,%0.2f,%0.2f,%0.2f,%i,%0.2f)\n", path
, matrix
,
1690 points
, count
, x
, y
, width
, height
, warpmode
, flatness
);
1692 return NotImplemented
;
1695 static void add_bevel_point(const GpPointF
*endpoint
, const GpPointF
*nextpoint
,
1696 GpPen
*pen
, int right_side
, path_list_node_t
**last_point
)
1698 REAL segment_dy
= nextpoint
->Y
-endpoint
->Y
;
1699 REAL segment_dx
= nextpoint
->X
-endpoint
->X
;
1700 REAL segment_length
= sqrtf(segment_dy
*segment_dy
+ segment_dx
*segment_dx
);
1701 REAL distance
= pen
->width
/2.0;
1702 REAL bevel_dx
, bevel_dy
;
1704 if (segment_length
== 0.0)
1706 *last_point
= add_path_list_node(*last_point
, endpoint
->X
,
1707 endpoint
->Y
, PathPointTypeLine
);
1713 bevel_dx
= -distance
* segment_dy
/ segment_length
;
1714 bevel_dy
= distance
* segment_dx
/ segment_length
;
1718 bevel_dx
= distance
* segment_dy
/ segment_length
;
1719 bevel_dy
= -distance
* segment_dx
/ segment_length
;
1722 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ bevel_dx
,
1723 endpoint
->Y
+ bevel_dy
, PathPointTypeLine
);
1726 static void widen_joint(const GpPointF
*p1
, const GpPointF
*p2
, const GpPointF
*p3
,
1727 GpPen
* pen
, path_list_node_t
**last_point
)
1732 case LineJoinMiterClipped
:
1733 if ((p2
->X
- p1
->X
) * (p3
->Y
- p1
->Y
) > (p2
->Y
- p1
->Y
) * (p3
->X
- p1
->X
))
1735 float distance
= pen
->width
/2.0;
1736 float length_0
= sqrtf((p2
->X
-p1
->X
)*(p2
->X
-p1
->X
)+(p2
->Y
-p1
->Y
)*(p2
->Y
-p1
->Y
));
1737 float length_1
= sqrtf((p3
->X
-p2
->X
)*(p3
->X
-p2
->X
)+(p3
->Y
-p2
->Y
)*(p3
->Y
-p2
->Y
));
1738 float dx0
= distance
* (p2
->X
- p1
->X
) / length_0
;
1739 float dy0
= distance
* (p2
->Y
- p1
->Y
) / length_0
;
1740 float dx1
= distance
* (p3
->X
- p2
->X
) / length_1
;
1741 float dy1
= distance
* (p3
->Y
- p2
->Y
) / length_1
;
1742 float det
= (dy0
*dx1
- dx0
*dy1
);
1743 float dx
= (dx0
*dx1
*(dx0
-dx1
) + dy0
*dy0
*dx1
- dy1
*dy1
*dx0
)/det
;
1744 float dy
= (dy0
*dy1
*(dy0
-dy1
) + dx0
*dx0
*dy1
- dx1
*dx1
*dy0
)/det
;
1745 if (dx
*dx
+ dy
*dy
< pen
->miterlimit
*pen
->miterlimit
* distance
*distance
)
1747 *last_point
= add_path_list_node(*last_point
, p2
->X
+ dx
,
1748 p2
->Y
+ dy
, PathPointTypeLine
);
1751 else if (pen
->join
== LineJoinMiter
)
1755 FIXME("should add a clipped corner\n");
1757 /* else fall-through */
1759 /* else fall-through */
1762 add_bevel_point(p2
, p1
, pen
, 1, last_point
);
1763 add_bevel_point(p2
, p3
, pen
, 0, last_point
);
1768 static void widen_cap(const GpPointF
*endpoint
, const GpPointF
*nextpoint
,
1769 GpPen
*pen
, GpLineCap cap
, GpCustomLineCap
*custom
, int add_first_points
,
1770 int add_last_point
, path_list_node_t
**last_point
)
1776 if (add_first_points
)
1777 add_bevel_point(endpoint
, nextpoint
, pen
, 1, last_point
);
1779 add_bevel_point(endpoint
, nextpoint
, pen
, 0, last_point
);
1783 REAL segment_dy
= nextpoint
->Y
-endpoint
->Y
;
1784 REAL segment_dx
= nextpoint
->X
-endpoint
->X
;
1785 REAL segment_length
= sqrtf(segment_dy
*segment_dy
+ segment_dx
*segment_dx
);
1786 REAL distance
= pen
->width
/2.0;
1787 REAL bevel_dx
, bevel_dy
;
1788 REAL extend_dx
, extend_dy
;
1790 extend_dx
= -distance
* segment_dx
/ segment_length
;
1791 extend_dy
= -distance
* segment_dy
/ segment_length
;
1793 bevel_dx
= -distance
* segment_dy
/ segment_length
;
1794 bevel_dy
= distance
* segment_dx
/ segment_length
;
1796 if (add_first_points
)
1797 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ extend_dx
+ bevel_dx
,
1798 endpoint
->Y
+ extend_dy
+ bevel_dy
, PathPointTypeLine
);
1801 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ extend_dx
- bevel_dx
,
1802 endpoint
->Y
+ extend_dy
- bevel_dy
, PathPointTypeLine
);
1808 REAL segment_dy
= nextpoint
->Y
-endpoint
->Y
;
1809 REAL segment_dx
= nextpoint
->X
-endpoint
->X
;
1810 REAL segment_length
= sqrtf(segment_dy
*segment_dy
+ segment_dx
*segment_dx
);
1811 REAL distance
= pen
->width
/2.0;
1812 REAL dx
, dy
, dx2
, dy2
;
1813 const REAL control_point_distance
= 0.5522847498307935; /* 4/3 * (sqrt(2) - 1) */
1815 if (add_first_points
)
1817 dx
= -distance
* segment_dx
/ segment_length
;
1818 dy
= -distance
* segment_dy
/ segment_length
;
1820 dx2
= dx
* control_point_distance
;
1821 dy2
= dy
* control_point_distance
;
1823 /* first 90-degree arc */
1824 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ dy
,
1825 endpoint
->Y
- dx
, PathPointTypeLine
);
1827 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ dy
+ dx2
,
1828 endpoint
->Y
- dx
+ dy2
, PathPointTypeBezier
);
1830 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ dx
+ dy2
,
1831 endpoint
->Y
+ dy
- dx2
, PathPointTypeBezier
);
1834 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ dx
,
1835 endpoint
->Y
+ dy
, PathPointTypeBezier
);
1837 /* second 90-degree arc */
1838 *last_point
= add_path_list_node(*last_point
, endpoint
->X
+ dx
- dy2
,
1839 endpoint
->Y
+ dy
+ dx2
, PathPointTypeBezier
);
1841 *last_point
= add_path_list_node(*last_point
, endpoint
->X
- dy
+ dx2
,
1842 endpoint
->Y
+ dx
+ dy2
, PathPointTypeBezier
);
1844 *last_point
= add_path_list_node(*last_point
, endpoint
->X
- dy
,
1845 endpoint
->Y
+ dx
, PathPointTypeBezier
);
1852 static void widen_open_figure(const GpPointF
*points
, GpPen
*pen
, int start
, int end
,
1853 GpLineCap start_cap
, GpCustomLineCap
*start_custom
, GpLineCap end_cap
,
1854 GpCustomLineCap
*end_custom
, path_list_node_t
**last_point
)
1857 path_list_node_t
*prev_point
;
1862 prev_point
= *last_point
;
1864 widen_cap(&points
[start
], &points
[start
+1],
1865 pen
, start_cap
, start_custom
, FALSE
, TRUE
, last_point
);
1867 for (i
=start
+1; i
<end
; i
++)
1868 widen_joint(&points
[i
-1], &points
[i
],
1869 &points
[i
+1], pen
, last_point
);
1871 widen_cap(&points
[end
], &points
[end
-1],
1872 pen
, end_cap
, end_custom
, TRUE
, TRUE
, last_point
);
1874 for (i
=end
-1; i
>start
; i
--)
1875 widen_joint(&points
[i
+1], &points
[i
],
1876 &points
[i
-1], pen
, last_point
);
1878 widen_cap(&points
[start
], &points
[start
+1],
1879 pen
, start_cap
, start_custom
, TRUE
, FALSE
, last_point
);
1881 prev_point
->next
->type
= PathPointTypeStart
;
1882 (*last_point
)->type
|= PathPointTypeCloseSubpath
;
1885 static void widen_closed_figure(GpPath
*path
, GpPen
*pen
, int start
, int end
,
1886 path_list_node_t
**last_point
)
1889 path_list_node_t
*prev_point
;
1895 prev_point
= *last_point
;
1897 widen_joint(&path
->pathdata
.Points
[end
], &path
->pathdata
.Points
[start
],
1898 &path
->pathdata
.Points
[start
+1], pen
, last_point
);
1900 for (i
=start
+1; i
<end
; i
++)
1901 widen_joint(&path
->pathdata
.Points
[i
-1], &path
->pathdata
.Points
[i
],
1902 &path
->pathdata
.Points
[i
+1], pen
, last_point
);
1904 widen_joint(&path
->pathdata
.Points
[end
-1], &path
->pathdata
.Points
[end
],
1905 &path
->pathdata
.Points
[start
], pen
, last_point
);
1907 prev_point
->next
->type
= PathPointTypeStart
;
1908 (*last_point
)->type
|= PathPointTypeCloseSubpath
;
1911 prev_point
= *last_point
;
1913 widen_joint(&path
->pathdata
.Points
[start
], &path
->pathdata
.Points
[end
],
1914 &path
->pathdata
.Points
[end
-1], pen
, last_point
);
1916 for (i
=end
-1; i
>start
; i
--)
1917 widen_joint(&path
->pathdata
.Points
[i
+1], &path
->pathdata
.Points
[i
],
1918 &path
->pathdata
.Points
[i
-1], pen
, last_point
);
1920 widen_joint(&path
->pathdata
.Points
[start
+1], &path
->pathdata
.Points
[start
],
1921 &path
->pathdata
.Points
[end
], pen
, last_point
);
1923 prev_point
->next
->type
= PathPointTypeStart
;
1924 (*last_point
)->type
|= PathPointTypeCloseSubpath
;
1927 static void widen_dashed_figure(GpPath
*path
, GpPen
*pen
, int start
, int end
,
1928 int closed
, path_list_node_t
**last_point
)
1933 const REAL
*dash_pattern
;
1935 GpPointF
*tmp_points
;
1938 REAL segment_length
;
1940 int num_tmp_points
=0;
1941 int draw_start_cap
=0;
1942 static const REAL dash_dot_dot
[6] = { 3.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
1951 dash_pattern
= dash_dot_dot
;
1955 dash_pattern
= &dash_dot_dot
[2];
1958 case DashStyleDashDot
:
1959 dash_pattern
= dash_dot_dot
;
1962 case DashStyleDashDotDot
:
1963 dash_pattern
= dash_dot_dot
;
1966 case DashStyleCustom
:
1967 dash_pattern
= pen
->dashes
;
1968 dash_count
= pen
->numdashes
;
1972 tmp_points
= heap_alloc_zero((end
- start
+ 2) * sizeof(GpPoint
));
1973 if (!tmp_points
) return; /* FIXME */
1978 for (j
=start
; j
<= end
; j
++)
1990 segment_dy
= path
->pathdata
.Points
[j
].Y
- path
->pathdata
.Points
[i
].Y
;
1991 segment_dx
= path
->pathdata
.Points
[j
].X
- path
->pathdata
.Points
[i
].X
;
1992 segment_length
= sqrtf(segment_dy
*segment_dy
+ segment_dx
*segment_dx
);
1997 if (dash_pos
== 0.0)
1999 if ((dash_index
% 2) == 0)
2003 tmp_points
[0].X
= path
->pathdata
.Points
[i
].X
+ segment_dx
* segment_pos
/ segment_length
;
2004 tmp_points
[0].Y
= path
->pathdata
.Points
[i
].Y
+ segment_dy
* segment_pos
/ segment_length
;
2009 tmp_points
[num_tmp_points
].X
= path
->pathdata
.Points
[i
].X
+ segment_dx
* segment_pos
/ segment_length
;
2010 tmp_points
[num_tmp_points
].Y
= path
->pathdata
.Points
[i
].Y
+ segment_dy
* segment_pos
/ segment_length
;
2012 widen_open_figure(tmp_points
, pen
, 0, num_tmp_points
,
2013 draw_start_cap
? pen
->startcap
: LineCapFlat
, pen
->customstart
,
2014 LineCapFlat
, NULL
, last_point
);
2020 if (dash_pattern
[dash_index
] - dash_pos
> segment_length
- segment_pos
)
2022 /* advance to next segment */
2023 if ((dash_index
% 2) == 0)
2025 tmp_points
[num_tmp_points
] = path
->pathdata
.Points
[j
];
2028 dash_pos
+= segment_length
- segment_pos
;
2033 /* advance to next dash in pattern */
2034 segment_pos
+= dash_pattern
[dash_index
] - dash_pos
;
2036 if (++dash_index
== dash_count
)
2043 if (dash_index
% 2 == 0 && num_tmp_points
!= 0)
2045 /* last dash overflows last segment */
2046 tmp_points
[num_tmp_points
] = path
->pathdata
.Points
[end
];
2047 widen_open_figure(tmp_points
, pen
, 0, num_tmp_points
,
2048 draw_start_cap
? pen
->startcap
: LineCapFlat
, pen
->customstart
,
2049 closed
? LineCapFlat
: pen
->endcap
, pen
->customend
, last_point
);
2052 heap_free(tmp_points
);
2055 GpStatus WINGDIPAPI
GdipWidenPath(GpPath
*path
, GpPen
*pen
, GpMatrix
*matrix
,
2058 GpPath
*flat_path
=NULL
;
2060 path_list_node_t
*points
=NULL
, *last_point
=NULL
;
2061 int i
, subpath_start
=0, new_length
;
2064 TRACE("(%p,%p,%p,%0.2f)\n", path
, pen
, matrix
, flatness
);
2067 return InvalidParameter
;
2069 if (path
->pathdata
.Count
<= 1)
2072 status
= GdipClonePath(path
, &flat_path
);
2075 status
= GdipFlattenPath(flat_path
, pen
->unit
== UnitPixel
? matrix
: NULL
, flatness
);
2077 if (status
== Ok
&& !init_path_list(&points
, 314.0, 22.0))
2078 status
= OutOfMemory
;
2082 last_point
= points
;
2084 if (pen
->endcap
> LineCapRound
)
2085 FIXME("unimplemented end cap %x\n", pen
->endcap
);
2087 if (pen
->startcap
> LineCapRound
)
2088 FIXME("unimplemented start cap %x\n", pen
->startcap
);
2090 if (pen
->dashcap
!= DashCapFlat
)
2091 FIXME("unimplemented dash cap %d\n", pen
->dashcap
);
2093 if (pen
->join
== LineJoinRound
)
2094 FIXME("unimplemented line join %d\n", pen
->join
);
2096 if (pen
->align
!= PenAlignmentCenter
)
2097 FIXME("unimplemented pen alignment %d\n", pen
->align
);
2099 for (i
=0; i
< flat_path
->pathdata
.Count
; i
++)
2101 type
= flat_path
->pathdata
.Types
[i
];
2103 if ((type
&PathPointTypePathTypeMask
) == PathPointTypeStart
)
2106 if ((type
&PathPointTypeCloseSubpath
) == PathPointTypeCloseSubpath
)
2108 if (pen
->dash
!= DashStyleSolid
)
2109 widen_dashed_figure(flat_path
, pen
, subpath_start
, i
, 1, &last_point
);
2111 widen_closed_figure(flat_path
, pen
, subpath_start
, i
, &last_point
);
2113 else if (i
== flat_path
->pathdata
.Count
-1 ||
2114 (flat_path
->pathdata
.Types
[i
+1]&PathPointTypePathTypeMask
) == PathPointTypeStart
)
2116 if (pen
->dash
!= DashStyleSolid
)
2117 widen_dashed_figure(flat_path
, pen
, subpath_start
, i
, 0, &last_point
);
2119 widen_open_figure(flat_path
->pathdata
.Points
, pen
, subpath_start
, i
, pen
->startcap
, pen
->customstart
, pen
->endcap
, pen
->customend
, &last_point
);
2123 new_length
= path_list_count(points
)-1;
2125 if (!lengthen_path(path
, new_length
))
2126 status
= OutOfMemory
;
2131 path
->pathdata
.Count
= new_length
;
2133 last_point
= points
->next
;
2134 for (i
= 0; i
< new_length
; i
++)
2136 path
->pathdata
.Points
[i
] = last_point
->pt
;
2137 path
->pathdata
.Types
[i
] = last_point
->type
;
2138 last_point
= last_point
->next
;
2141 path
->fill
= FillModeWinding
;
2144 free_path_list(points
);
2146 GdipDeletePath(flat_path
);
2148 if (status
== Ok
&& pen
->unit
!= UnitPixel
)
2149 status
= GdipTransformPath(path
, matrix
);
2154 GpStatus WINGDIPAPI
GdipAddPathRectangle(GpPath
*path
, REAL x
, REAL y
,
2155 REAL width
, REAL height
)
2162 TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path
, x
, y
, width
, height
);
2165 return InvalidParameter
;
2167 /* make a backup copy of path data */
2168 if((retstat
= GdipClonePath(path
, &backup
)) != Ok
)
2171 /* rectangle should start as new path */
2172 old_new
= path
->newfigure
;
2173 path
->newfigure
= TRUE
;
2174 if((retstat
= GdipAddPathLine(path
,x
,y
,x
+width
,y
)) != Ok
){
2175 path
->newfigure
= old_new
;
2180 ptf
[0].Y
= y
+height
;
2182 ptf
[1].Y
= y
+height
;
2184 if((retstat
= GdipAddPathLine2(path
, ptf
, 2)) != Ok
) goto fail
;
2185 path
->pathdata
.Types
[path
->pathdata
.Count
-1] |= PathPointTypeCloseSubpath
;
2188 GdipDeletePath(backup
);
2193 heap_free(path
->pathdata
.Points
);
2194 heap_free(path
->pathdata
.Types
);
2195 memcpy(path
, backup
, sizeof(*path
));
2201 GpStatus WINGDIPAPI
GdipAddPathRectangleI(GpPath
*path
, INT x
, INT y
,
2202 INT width
, INT height
)
2204 TRACE("(%p, %d, %d, %d, %d)\n", path
, x
, y
, width
, height
);
2206 return GdipAddPathRectangle(path
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
);
2209 GpStatus WINGDIPAPI
GdipAddPathRectangles(GpPath
*path
, GDIPCONST GpRectF
*rects
, INT count
)
2215 TRACE("(%p, %p, %d)\n", path
, rects
, count
);
2217 /* count == 0 - verified condition */
2218 if(!path
|| !rects
|| count
== 0)
2219 return InvalidParameter
;
2224 /* make a backup copy */
2225 if((retstat
= GdipClonePath(path
, &backup
)) != Ok
)
2228 for(i
= 0; i
< count
; i
++){
2229 if((retstat
= GdipAddPathRectangle(path
,rects
[i
].X
,rects
[i
].Y
,rects
[i
].Width
,rects
[i
].Height
)) != Ok
)
2234 GdipDeletePath(backup
);
2239 heap_free(path
->pathdata
.Points
);
2240 heap_free(path
->pathdata
.Types
);
2241 memcpy(path
, backup
, sizeof(*path
));
2247 GpStatus WINGDIPAPI
GdipAddPathRectanglesI(GpPath
*path
, GDIPCONST GpRect
*rects
, INT count
)
2253 TRACE("(%p, %p, %d)\n", path
, rects
, count
);
2255 if(!rects
|| count
== 0)
2256 return InvalidParameter
;
2261 rectsF
= heap_alloc_zero(sizeof(GpRectF
)*count
);
2263 for(i
= 0;i
< count
;i
++){
2264 rectsF
[i
].X
= (REAL
)rects
[i
].X
;
2265 rectsF
[i
].Y
= (REAL
)rects
[i
].Y
;
2266 rectsF
[i
].Width
= (REAL
)rects
[i
].Width
;
2267 rectsF
[i
].Height
= (REAL
)rects
[i
].Height
;
2270 retstat
= GdipAddPathRectangles(path
, rectsF
, count
);
2276 GpStatus WINGDIPAPI
GdipSetPathMarker(GpPath
* path
)
2280 TRACE("(%p)\n", path
);
2283 return InvalidParameter
;
2285 count
= path
->pathdata
.Count
;
2287 /* set marker flag */
2289 path
->pathdata
.Types
[count
-1] |= PathPointTypePathMarker
;
2294 GpStatus WINGDIPAPI
GdipClearPathMarkers(GpPath
* path
)
2299 TRACE("(%p)\n", path
);
2302 return InvalidParameter
;
2304 count
= path
->pathdata
.Count
;
2306 for(i
= 0; i
< count
- 1; i
++){
2307 path
->pathdata
.Types
[i
] &= ~PathPointTypePathMarker
;
2313 GpStatus WINGDIPAPI
GdipWindingModeOutline(GpPath
*path
, GpMatrix
*matrix
, REAL flatness
)
2315 FIXME("stub: %p, %p, %.2f\n", path
, matrix
, flatness
);
2316 return NotImplemented
;