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
= GdipAlloc(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 = GdipAlloc(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 halfs */
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
= GdipAlloc(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
= GdipAlloc(len_pt
* sizeof(GpPointF
));
342 pts
= GdipAlloc((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 INT count
= path
->pathdata
.Count
;
388 path
->pathdata
.Types
[count
- 1] |= PathPointTypeCloseSubpath
;
389 path
->newfigure
= TRUE
;
398 GpStatus WINGDIPAPI
GdipAddPathClosedCurve2I(GpPath
*path
, GDIPCONST GpPoint
*points
,
399 INT count
, REAL tension
)
405 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
407 if(!path
|| !points
|| count
<= 1)
408 return InvalidParameter
;
410 ptf
= GdipAlloc(sizeof(GpPointF
)*count
);
414 for(i
= 0; i
< count
; i
++){
415 ptf
[i
].X
= (REAL
)points
[i
].X
;
416 ptf
[i
].Y
= (REAL
)points
[i
].Y
;
419 stat
= GdipAddPathClosedCurve2(path
, ptf
, count
, tension
);
426 GpStatus WINGDIPAPI
GdipAddPathCurve(GpPath
*path
, GDIPCONST GpPointF
*points
, INT count
)
428 TRACE("(%p, %p, %d)\n", path
, points
, count
);
430 if(!path
|| !points
|| count
<= 1)
431 return InvalidParameter
;
433 return GdipAddPathCurve2(path
, points
, count
, 1.0);
436 GpStatus WINGDIPAPI
GdipAddPathCurveI(GpPath
*path
, GDIPCONST GpPoint
*points
, INT count
)
438 TRACE("(%p, %p, %d)\n", path
, points
, count
);
440 if(!path
|| !points
|| count
<= 1)
441 return InvalidParameter
;
443 return GdipAddPathCurve2I(path
, points
, count
, 1.0);
446 GpStatus WINGDIPAPI
GdipAddPathCurve2(GpPath
*path
, GDIPCONST GpPointF
*points
, INT count
,
449 INT i
, len_pt
= count
*3-2;
454 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
456 if(!path
|| !points
|| count
<= 1)
457 return InvalidParameter
;
459 pt
= GdipAlloc(len_pt
* sizeof(GpPointF
));
463 tension
= tension
* TENSION_CONST
;
465 calc_curve_bezier_endp(points
[0].X
, points
[0].Y
, points
[1].X
, points
[1].Y
,
468 pt
[0].X
= points
[0].X
;
469 pt
[0].Y
= points
[0].Y
;
473 for(i
= 0; i
< count
-2; i
++){
474 calc_curve_bezier(&(points
[i
]), tension
, &x1
, &y1
, &x2
, &y2
);
478 pt
[3*i
+3].X
= points
[i
+1].X
;
479 pt
[3*i
+3].Y
= points
[i
+1].Y
;
484 calc_curve_bezier_endp(points
[count
-1].X
, points
[count
-1].Y
,
485 points
[count
-2].X
, points
[count
-2].Y
, tension
, &x1
, &y1
);
489 pt
[len_pt
-1].X
= points
[count
-1].X
;
490 pt
[len_pt
-1].Y
= points
[count
-1].Y
;
492 stat
= GdipAddPathBeziers(path
, pt
, len_pt
);
499 GpStatus WINGDIPAPI
GdipAddPathCurve2I(GpPath
*path
, GDIPCONST GpPoint
*points
,
500 INT count
, REAL tension
)
506 TRACE("(%p, %p, %d, %.2f)\n", path
, points
, count
, tension
);
508 if(!path
|| !points
|| count
<= 1)
509 return InvalidParameter
;
511 ptf
= GdipAlloc(sizeof(GpPointF
)*count
);
515 for(i
= 0; i
< count
; i
++){
516 ptf
[i
].X
= (REAL
)points
[i
].X
;
517 ptf
[i
].Y
= (REAL
)points
[i
].Y
;
520 stat
= GdipAddPathCurve2(path
, ptf
, count
, tension
);
527 GpStatus WINGDIPAPI
GdipAddPathCurve3(GpPath
*path
, GDIPCONST GpPointF
*points
,
528 INT count
, INT offset
, INT nseg
, REAL tension
)
530 TRACE("(%p, %p, %d, %d, %d, %.2f)\n", path
, points
, count
, offset
, nseg
, tension
);
532 if(!path
|| !points
|| offset
+ 1 >= count
|| count
- offset
< nseg
+ 1)
533 return InvalidParameter
;
535 return GdipAddPathCurve2(path
, &points
[offset
], nseg
+ 1, tension
);
538 GpStatus WINGDIPAPI
GdipAddPathCurve3I(GpPath
*path
, GDIPCONST GpPoint
*points
,
539 INT count
, INT offset
, INT nseg
, REAL tension
)
541 TRACE("(%p, %p, %d, %d, %d, %.2f)\n", path
, points
, count
, offset
, nseg
, tension
);
543 if(!path
|| !points
|| offset
+ 1 >= count
|| count
- offset
< nseg
+ 1)
544 return InvalidParameter
;
546 return GdipAddPathCurve2I(path
, &points
[offset
], nseg
+ 1, tension
);
549 GpStatus WINGDIPAPI
GdipAddPathEllipse(GpPath
*path
, REAL x
, REAL y
, REAL width
,
552 INT old_count
, numpts
;
554 TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path
, x
, y
, width
, height
);
557 return InvalidParameter
;
559 if(!lengthen_path(path
, MAX_ARC_PTS
))
562 old_count
= path
->pathdata
.Count
;
563 if((numpts
= arc2polybezier(&path
->pathdata
.Points
[old_count
], x
, y
, width
,
564 height
, 0.0, 360.0)) != MAX_ARC_PTS
){
565 ERR("expected %d points but got %d\n", MAX_ARC_PTS
, numpts
);
569 memset(&path
->pathdata
.Types
[old_count
+ 1], PathPointTypeBezier
,
572 /* An ellipse is an intrinsic figure (always is its own subpath). */
573 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
574 path
->pathdata
.Types
[old_count
+ MAX_ARC_PTS
- 1] |= PathPointTypeCloseSubpath
;
575 path
->newfigure
= TRUE
;
576 path
->pathdata
.Count
+= MAX_ARC_PTS
;
581 GpStatus WINGDIPAPI
GdipAddPathEllipseI(GpPath
*path
, INT x
, INT y
, INT width
,
584 TRACE("(%p, %d, %d, %d, %d)\n", path
, x
, y
, width
, height
);
586 return GdipAddPathEllipse(path
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
);
589 GpStatus WINGDIPAPI
GdipAddPathLine2(GpPath
*path
, GDIPCONST GpPointF
*points
,
594 TRACE("(%p, %p, %d)\n", path
, points
, count
);
597 return InvalidParameter
;
599 if(!lengthen_path(path
, count
))
602 old_count
= path
->pathdata
.Count
;
604 for(i
= 0; i
< count
; i
++){
605 path
->pathdata
.Points
[old_count
+ i
].X
= points
[i
].X
;
606 path
->pathdata
.Points
[old_count
+ i
].Y
= points
[i
].Y
;
607 path
->pathdata
.Types
[old_count
+ i
] = PathPointTypeLine
;
611 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
612 path
->newfigure
= FALSE
;
615 path
->pathdata
.Count
+= count
;
620 GpStatus WINGDIPAPI
GdipAddPathLine2I(GpPath
*path
, GDIPCONST GpPoint
*points
, INT count
)
626 TRACE("(%p, %p, %d)\n", path
, points
, count
);
629 return InvalidParameter
;
631 pointsF
= GdipAlloc(sizeof(GpPointF
) * count
);
632 if(!pointsF
) return OutOfMemory
;
634 for(i
= 0;i
< count
; i
++){
635 pointsF
[i
].X
= (REAL
)points
[i
].X
;
636 pointsF
[i
].Y
= (REAL
)points
[i
].Y
;
639 stat
= GdipAddPathLine2(path
, pointsF
, count
);
646 GpStatus WINGDIPAPI
GdipAddPathLine(GpPath
*path
, REAL x1
, REAL y1
, REAL x2
, REAL y2
)
650 TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path
, x1
, y1
, x2
, y2
);
653 return InvalidParameter
;
655 if(!lengthen_path(path
, 2))
658 old_count
= path
->pathdata
.Count
;
660 path
->pathdata
.Points
[old_count
].X
= x1
;
661 path
->pathdata
.Points
[old_count
].Y
= y1
;
662 path
->pathdata
.Points
[old_count
+ 1].X
= x2
;
663 path
->pathdata
.Points
[old_count
+ 1].Y
= y2
;
665 path
->pathdata
.Types
[old_count
] =
666 (path
->newfigure
? PathPointTypeStart
: PathPointTypeLine
);
667 path
->pathdata
.Types
[old_count
+ 1] = PathPointTypeLine
;
669 path
->newfigure
= FALSE
;
670 path
->pathdata
.Count
+= 2;
675 GpStatus WINGDIPAPI
GdipAddPathLineI(GpPath
*path
, INT x1
, INT y1
, INT x2
, INT y2
)
677 TRACE("(%p, %d, %d, %d, %d)\n", path
, x1
, y1
, x2
, y2
);
679 return GdipAddPathLine(path
, (REAL
)x1
, (REAL
)y1
, (REAL
)x2
, (REAL
)y2
);
682 GpStatus WINGDIPAPI
GdipAddPathPath(GpPath
*path
, GDIPCONST GpPath
* addingPath
,
685 INT old_count
, count
;
687 TRACE("(%p, %p, %d)\n", path
, addingPath
, connect
);
689 if(!path
|| !addingPath
)
690 return InvalidParameter
;
692 old_count
= path
->pathdata
.Count
;
693 count
= addingPath
->pathdata
.Count
;
695 if(!lengthen_path(path
, count
))
698 memcpy(&path
->pathdata
.Points
[old_count
], addingPath
->pathdata
.Points
,
699 count
* sizeof(GpPointF
));
700 memcpy(&path
->pathdata
.Types
[old_count
], addingPath
->pathdata
.Types
, count
);
702 if(path
->newfigure
|| !connect
)
703 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
705 path
->pathdata
.Types
[old_count
] = PathPointTypeLine
;
707 path
->newfigure
= FALSE
;
708 path
->pathdata
.Count
+= count
;
713 GpStatus WINGDIPAPI
GdipAddPathPie(GpPath
*path
, REAL x
, REAL y
, REAL width
, REAL height
,
714 REAL startAngle
, REAL sweepAngle
)
720 TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
721 path
, x
, y
, width
, height
, startAngle
, sweepAngle
);
724 return InvalidParameter
;
726 /* on zero width/height only start point added */
727 if(width
<= 1e-7 || height
<= 1e-7){
728 if(!lengthen_path(path
, 1))
730 path
->pathdata
.Points
[0].X
= x
+ width
/ 2.0;
731 path
->pathdata
.Points
[0].Y
= y
+ height
/ 2.0;
732 path
->pathdata
.Types
[0] = PathPointTypeStart
| PathPointTypeCloseSubpath
;
733 path
->pathdata
.Count
= 1;
734 return InvalidParameter
;
737 count
= arc2polybezier(NULL
, x
, y
, width
, height
, startAngle
, sweepAngle
);
742 ptf
= GdipAlloc(sizeof(GpPointF
)*count
);
746 arc2polybezier(ptf
, x
, y
, width
, height
, startAngle
, sweepAngle
);
748 status
= GdipAddPathLine(path
, (width
- x
)/2, (height
- y
)/2, ptf
[0].X
, ptf
[0].Y
);
753 /* one spline is already added as a line endpoint */
754 if(!lengthen_path(path
, count
- 1)){
759 memcpy(&(path
->pathdata
.Points
[path
->pathdata
.Count
]), &(ptf
[1]),sizeof(GpPointF
)*(count
-1));
760 for(i
= 0; i
< count
-1; i
++)
761 path
->pathdata
.Types
[path
->pathdata
.Count
+i
] = PathPointTypeBezier
;
763 path
->pathdata
.Count
+= count
-1;
765 GdipClosePathFigure(path
);
772 GpStatus WINGDIPAPI
GdipAddPathPieI(GpPath
*path
, INT x
, INT y
, INT width
, INT height
,
773 REAL startAngle
, REAL sweepAngle
)
775 TRACE("(%p, %d, %d, %d, %d, %.2f, %.2f)\n",
776 path
, x
, y
, width
, height
, startAngle
, sweepAngle
);
778 return GdipAddPathPie(path
, (REAL
)x
, (REAL
)y
, (REAL
)width
, (REAL
)height
, startAngle
, sweepAngle
);
781 GpStatus WINGDIPAPI
GdipAddPathPolygon(GpPath
*path
, GDIPCONST GpPointF
*points
, INT count
)
785 TRACE("(%p, %p, %d)\n", path
, points
, count
);
787 if(!path
|| !points
|| count
< 3)
788 return InvalidParameter
;
790 if(!lengthen_path(path
, count
))
793 old_count
= path
->pathdata
.Count
;
795 memcpy(&path
->pathdata
.Points
[old_count
], points
, count
*sizeof(GpPointF
));
796 memset(&path
->pathdata
.Types
[old_count
+ 1], PathPointTypeLine
, count
- 1);
798 /* A polygon is an intrinsic figure */
799 path
->pathdata
.Types
[old_count
] = PathPointTypeStart
;
800 path
->pathdata
.Types
[old_count
+ count
- 1] |= PathPointTypeCloseSubpath
;
801 path
->newfigure
= TRUE
;
802 path
->pathdata
.Count
+= count
;
807 GpStatus WINGDIPAPI
GdipAddPathPolygonI(GpPath
*path
, GDIPCONST GpPoint
*points
, INT count
)
813 TRACE("(%p, %p, %d)\n", path
, points
, count
);
815 if(!points
|| count
< 3)
816 return InvalidParameter
;
818 ptf
= GdipAlloc(sizeof(GpPointF
) * count
);
822 for(i
= 0; i
< count
; i
++){
823 ptf
[i
].X
= (REAL
)points
[i
].X
;
824 ptf
[i
].Y
= (REAL
)points
[i
].Y
;
827 status
= GdipAddPathPolygon(path
, ptf
, count
);
834 static float fromfixedpoint(const FIXED v
)
836 float f
= ((float)v
.fract
) / (1<<(sizeof(v
.fract
)*8));
841 struct format_string_args
847 static GpStatus
format_string_callback(HDC dc
,
848 GDIPCONST WCHAR
*string
, INT index
, INT length
, GDIPCONST GpFont
*font
,
849 GDIPCONST RectF
*rect
, GDIPCONST GpStringFormat
*format
,
850 INT lineno
, const RectF
*bounds
, void *priv
)
852 static const MAT2 identity
= { {0,1}, {0,0}, {0,0}, {0,1} };
853 struct format_string_args
*args
= priv
;
854 GpPath
*path
= args
->path
;
855 GpStatus status
= Ok
;
860 for (i
= index
; i
< length
; ++i
)
863 TTPOLYGONHEADER
*ph
= NULL
;
867 len
= GetGlyphOutlineW(dc
, string
[i
], GGO_BEZIER
, &gm
, 0, NULL
, &identity
);
868 if (len
== GDI_ERROR
)
870 status
= GenericError
;
875 if (!ph
|| !lengthen_path(path
, len
/ sizeof(POINTFX
)))
877 status
= OutOfMemory
;
880 GetGlyphOutlineW(dc
, string
[i
], GGO_BEZIER
, &gm
, len
, start
, &identity
);
881 bb_end
= gm
.gmBlackBoxY
+ gm
.gmptGlyphOrigin
.y
;
882 if (bb_end
+ y
> args
->maxY
)
883 args
->maxY
= bb_end
+ y
;
888 DWORD ofs_start
= ofs
;
889 ph
= (TTPOLYGONHEADER
*)&start
[ofs
];
890 path
->pathdata
.Types
[path
->pathdata
.Count
] = PathPointTypeStart
;
891 path
->pathdata
.Points
[path
->pathdata
.Count
].X
= x
+ fromfixedpoint(ph
->pfxStart
.x
);
892 path
->pathdata
.Points
[path
->pathdata
.Count
++].Y
= y
+ bb_end
- fromfixedpoint(ph
->pfxStart
.y
);
893 TRACE("Starting at count %i with pos %f, %f)\n", path
->pathdata
.Count
, x
, y
);
895 while (ofs
- ofs_start
< ph
->cb
)
897 TTPOLYCURVE
*curve
= (TTPOLYCURVE
*)&start
[ofs
];
899 ofs
+= sizeof(TTPOLYCURVE
) + (curve
->cpfx
- 1) * sizeof(POINTFX
);
901 switch (curve
->wType
)
904 for (j
= 0; j
< curve
->cpfx
; ++j
)
906 path
->pathdata
.Types
[path
->pathdata
.Count
] = PathPointTypeLine
;
907 path
->pathdata
.Points
[path
->pathdata
.Count
].X
= x
+ fromfixedpoint(curve
->apfx
[j
].x
);
908 path
->pathdata
.Points
[path
->pathdata
.Count
++].Y
= y
+ bb_end
- fromfixedpoint(curve
->apfx
[j
].y
);
911 case TT_PRIM_CSPLINE
:
912 for (j
= 0; j
< curve
->cpfx
; ++j
)
914 path
->pathdata
.Types
[path
->pathdata
.Count
] = PathPointTypeBezier
;
915 path
->pathdata
.Points
[path
->pathdata
.Count
].X
= x
+ fromfixedpoint(curve
->apfx
[j
].x
);
916 path
->pathdata
.Points
[path
->pathdata
.Count
++].Y
= y
+ bb_end
- fromfixedpoint(curve
->apfx
[j
].y
);
920 ERR("Unhandled type: %u\n", curve
->wType
);
921 status
= GenericError
;
924 path
->pathdata
.Types
[path
->pathdata
.Count
- 1] |= PathPointTypeCloseSubpath
;
926 path
->newfigure
= TRUE
;
938 GpStatus WINGDIPAPI
GdipAddPathString(GpPath
* path
, GDIPCONST WCHAR
* string
, INT length
, GDIPCONST GpFontFamily
* family
, INT style
, REAL emSize
, GDIPCONST RectF
* layoutRect
, GDIPCONST GpStringFormat
* format
)
945 struct format_string_args args
;
948 FIXME("(%p, %s, %d, %p, %d, %f, %p, %p): stub\n", path
, debugstr_w(string
), length
, family
, style
, emSize
, layoutRect
, format
);
949 if (!path
|| !string
|| !family
|| !emSize
|| !layoutRect
|| !format
)
950 return InvalidParameter
;
952 status
= GdipCreateFont(family
, emSize
, style
, UnitPixel
, &font
);
956 hfont
= CreateFontIndirectW(&font
->lfw
);
959 WARN("Failed to create font\n");
963 if ((status
= GdipClonePath(path
, &backup
)) != Ok
)
969 dc
= CreateCompatibleDC(0);
970 SelectObject(dc
, hfont
);
974 status
= gdip_format_string(dc
, string
, length
, NULL
, layoutRect
, format
, format_string_callback
, &args
);
979 if (status
!= Ok
) /* free backup */
981 GdipFree(path
->pathdata
.Points
);
982 GdipFree(path
->pathdata
.Types
);
987 if (format
&& format
->vertalign
== StringAlignmentCenter
&& layoutRect
->Y
+ args
.maxY
< layoutRect
->Height
)
989 float inc
= layoutRect
->Height
- args
.maxY
- layoutRect
->Y
;
991 for (i
= backup
->pathdata
.Count
; i
< path
->pathdata
.Count
; ++i
)
992 path
->pathdata
.Points
[i
].Y
+= inc
;
993 } else if (format
&& format
->vertalign
== StringAlignmentFar
) {
994 float inc
= layoutRect
->Height
- args
.maxY
- layoutRect
->Y
;
995 for (i
= backup
->pathdata
.Count
; i
< path
->pathdata
.Count
; ++i
)
996 path
->pathdata
.Points
[i
].Y
+= inc
;
998 GdipDeletePath(backup
);
1002 GpStatus WINGDIPAPI
GdipAddPathStringI(GpPath
* path
, GDIPCONST WCHAR
* string
, INT length
, GDIPCONST GpFontFamily
* family
, INT style
, REAL emSize
, GDIPCONST Rect
* layoutRect
, GDIPCONST GpStringFormat
* format
)
1006 RectF layoutRectF
= {
1007 (REAL
)layoutRect
->X
,
1008 (REAL
)layoutRect
->Y
,
1009 (REAL
)layoutRect
->Width
,
1010 (REAL
)layoutRect
->Height
1012 return GdipAddPathString(path
, string
, length
, family
, style
, emSize
, &layoutRectF
, format
);
1014 return InvalidParameter
;
1017 GpStatus WINGDIPAPI
GdipClonePath(GpPath
* path
, GpPath
**clone
)
1019 TRACE("(%p, %p)\n", path
, clone
);
1022 return InvalidParameter
;
1024 *clone
= GdipAlloc(sizeof(GpPath
));
1025 if(!*clone
) return OutOfMemory
;
1029 (*clone
)->pathdata
.Points
= GdipAlloc(path
->datalen
* sizeof(PointF
));
1030 (*clone
)->pathdata
.Types
= GdipAlloc(path
->datalen
);
1031 if(!(*clone
)->pathdata
.Points
|| !(*clone
)->pathdata
.Types
){
1033 GdipFree((*clone
)->pathdata
.Points
);
1034 GdipFree((*clone
)->pathdata
.Types
);
1038 memcpy((*clone
)->pathdata
.Points
, path
->pathdata
.Points
,
1039 path
->datalen
* sizeof(PointF
));
1040 memcpy((*clone
)->pathdata
.Types
, path
->pathdata
.Types
, path
->datalen
);
1045 GpStatus WINGDIPAPI
GdipClosePathFigure(GpPath
* path
)
1047 TRACE("(%p)\n", path
);
1050 return InvalidParameter
;
1052 if(path
->pathdata
.Count
> 0){
1053 path
->pathdata
.Types
[path
->pathdata
.Count
- 1] |= PathPointTypeCloseSubpath
;
1054 path
->newfigure
= TRUE
;
1060 GpStatus WINGDIPAPI
GdipClosePathFigures(GpPath
* path
)
1064 TRACE("(%p)\n", path
);
1067 return InvalidParameter
;
1069 for(i
= 1; i
< path
->pathdata
.Count
; i
++){
1070 if(path
->pathdata
.Types
[i
] == PathPointTypeStart
)
1071 path
->pathdata
.Types
[i
-1] |= PathPointTypeCloseSubpath
;
1074 path
->newfigure
= TRUE
;
1079 GpStatus WINGDIPAPI
GdipCreatePath(GpFillMode fill
, GpPath
**path
)
1081 TRACE("(%d, %p)\n", fill
, path
);
1084 return InvalidParameter
;
1086 *path
= GdipAlloc(sizeof(GpPath
));
1087 if(!*path
) return OutOfMemory
;
1089 (*path
)->fill
= fill
;
1090 (*path
)->newfigure
= TRUE
;
1095 GpStatus WINGDIPAPI
GdipCreatePath2(GDIPCONST GpPointF
* points
,
1096 GDIPCONST BYTE
* types
, INT count
, GpFillMode fill
, GpPath
**path
)
1098 TRACE("(%p, %p, %d, %d, %p)\n", points
, types
, count
, fill
, path
);
1101 return InvalidParameter
;
1103 *path
= GdipAlloc(sizeof(GpPath
));
1104 if(!*path
) return OutOfMemory
;
1106 (*path
)->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
1107 (*path
)->pathdata
.Types
= GdipAlloc(count
);
1109 if(!(*path
)->pathdata
.Points
|| !(*path
)->pathdata
.Types
){
1110 GdipFree((*path
)->pathdata
.Points
);
1111 GdipFree((*path
)->pathdata
.Types
);
1116 memcpy((*path
)->pathdata
.Points
, points
, count
* sizeof(PointF
));
1117 memcpy((*path
)->pathdata
.Types
, types
, count
);
1118 (*path
)->pathdata
.Count
= count
;
1119 (*path
)->datalen
= count
;
1121 (*path
)->fill
= fill
;
1122 (*path
)->newfigure
= TRUE
;
1127 GpStatus WINGDIPAPI
GdipCreatePath2I(GDIPCONST GpPoint
* points
,
1128 GDIPCONST BYTE
* types
, INT count
, GpFillMode fill
, GpPath
**path
)
1134 TRACE("(%p, %p, %d, %d, %p)\n", points
, types
, count
, fill
, path
);
1136 ptF
= GdipAlloc(sizeof(GpPointF
)*count
);
1138 for(i
= 0;i
< count
; i
++){
1139 ptF
[i
].X
= (REAL
)points
[i
].X
;
1140 ptF
[i
].Y
= (REAL
)points
[i
].Y
;
1143 ret
= GdipCreatePath2(ptF
, types
, count
, fill
, path
);
1150 GpStatus WINGDIPAPI
GdipDeletePath(GpPath
*path
)
1152 TRACE("(%p)\n", path
);
1155 return InvalidParameter
;
1157 GdipFree(path
->pathdata
.Points
);
1158 GdipFree(path
->pathdata
.Types
);
1164 GpStatus WINGDIPAPI
GdipFlattenPath(GpPath
*path
, GpMatrix
* matrix
, REAL flatness
)
1166 path_list_node_t
*list
, *node
;
1171 TRACE("(%p, %p, %.2f)\n", path
, matrix
, flatness
);
1174 return InvalidParameter
;
1177 WARN("transformation not supported yet!\n");
1178 return NotImplemented
;
1181 if(path
->pathdata
.Count
== 0)
1184 pt
= path
->pathdata
.Points
[0];
1185 if(!init_path_list(&list
, pt
.X
, pt
.Y
))
1190 while(i
< path
->pathdata
.Count
){
1192 BYTE type
= path
->pathdata
.Types
[i
] & PathPointTypePathTypeMask
;
1193 path_list_node_t
*start
;
1195 pt
= path
->pathdata
.Points
[i
];
1197 /* save last start point index */
1198 if(type
== PathPointTypeStart
)
1201 /* always add line points and start points */
1202 if((type
== PathPointTypeStart
) || (type
== PathPointTypeLine
)){
1203 if(!add_path_list_node(node
, pt
.X
, pt
.Y
, path
->pathdata
.Types
[i
]))
1211 /* Bezier curve always stored as 4 points */
1212 if((path
->pathdata
.Types
[i
-1] & PathPointTypePathTypeMask
) != PathPointTypeStart
){
1213 type
= (path
->pathdata
.Types
[i
] & ~PathPointTypePathTypeMask
) | PathPointTypeLine
;
1214 if(!add_path_list_node(node
, pt
.X
, pt
.Y
, type
))
1220 /* test for closed figure */
1221 if(path
->pathdata
.Types
[i
+1] & PathPointTypeCloseSubpath
){
1222 pt
= path
->pathdata
.Points
[startidx
];
1228 pt
= path
->pathdata
.Points
[i
];
1232 /* add Bezier end point */
1233 type
= (path
->pathdata
.Types
[i
] & ~PathPointTypePathTypeMask
) | PathPointTypeLine
;
1234 if(!add_path_list_node(node
, pt
.X
, pt
.Y
, type
))
1239 if(!flatten_bezier(start
, path
->pathdata
.Points
[i
-2].X
, path
->pathdata
.Points
[i
-2].Y
,
1240 path
->pathdata
.Points
[i
-1].X
, path
->pathdata
.Points
[i
-1].Y
,
1247 /* store path data back */
1248 i
= path_list_count(list
);
1249 if(!lengthen_path(path
, i
))
1251 path
->pathdata
.Count
= i
;
1254 for(i
= 0; i
< path
->pathdata
.Count
; i
++){
1255 path
->pathdata
.Points
[i
] = node
->pt
;
1256 path
->pathdata
.Types
[i
] = node
->type
;
1260 free_path_list(list
);
1264 free_path_list(list
);
1268 GpStatus WINGDIPAPI
GdipGetPathData(GpPath
*path
, GpPathData
* pathData
)
1270 TRACE("(%p, %p)\n", path
, pathData
);
1272 if(!path
|| !pathData
)
1273 return InvalidParameter
;
1275 /* Only copy data. pathData allocation/freeing controlled by wrapper class.
1276 Assumed that pathData is enough wide to get all data - controlled by wrapper too. */
1277 memcpy(pathData
->Points
, path
->pathdata
.Points
, sizeof(PointF
) * pathData
->Count
);
1278 memcpy(pathData
->Types
, path
->pathdata
.Types
, pathData
->Count
);
1283 GpStatus WINGDIPAPI
GdipGetPathFillMode(GpPath
*path
, GpFillMode
*fillmode
)
1285 TRACE("(%p, %p)\n", path
, fillmode
);
1287 if(!path
|| !fillmode
)
1288 return InvalidParameter
;
1290 *fillmode
= path
->fill
;
1295 GpStatus WINGDIPAPI
GdipGetPathLastPoint(GpPath
* path
, GpPointF
* lastPoint
)
1299 TRACE("(%p, %p)\n", path
, lastPoint
);
1301 if(!path
|| !lastPoint
)
1302 return InvalidParameter
;
1304 count
= path
->pathdata
.Count
;
1306 *lastPoint
= path
->pathdata
.Points
[count
-1];
1311 GpStatus WINGDIPAPI
GdipGetPathPoints(GpPath
*path
, GpPointF
* points
, INT count
)
1313 TRACE("(%p, %p, %d)\n", path
, points
, count
);
1316 return InvalidParameter
;
1318 if(count
< path
->pathdata
.Count
)
1319 return InsufficientBuffer
;
1321 memcpy(points
, path
->pathdata
.Points
, path
->pathdata
.Count
* sizeof(GpPointF
));
1326 GpStatus WINGDIPAPI
GdipGetPathPointsI(GpPath
*path
, GpPoint
* points
, INT count
)
1332 TRACE("(%p, %p, %d)\n", path
, points
, count
);
1335 return InvalidParameter
;
1337 ptf
= GdipAlloc(sizeof(GpPointF
)*count
);
1338 if(!ptf
) return OutOfMemory
;
1340 ret
= GdipGetPathPoints(path
,ptf
,count
);
1342 for(i
= 0;i
< count
;i
++){
1343 points
[i
].X
= roundr(ptf
[i
].X
);
1344 points
[i
].Y
= roundr(ptf
[i
].Y
);
1351 GpStatus WINGDIPAPI
GdipGetPathTypes(GpPath
*path
, BYTE
* types
, INT count
)
1353 TRACE("(%p, %p, %d)\n", path
, types
, count
);
1356 return InvalidParameter
;
1358 if(count
< path
->pathdata
.Count
)
1359 return InsufficientBuffer
;
1361 memcpy(types
, path
->pathdata
.Types
, path
->pathdata
.Count
);
1366 /* Windows expands the bounding box to the maximum possible bounding box
1367 * for a given pen. For example, if a line join can extend past the point
1368 * it's joining by x units, the bounding box is extended by x units in every
1369 * direction (even though this is too conservative for most cases). */
1370 GpStatus WINGDIPAPI
GdipGetPathWorldBounds(GpPath
* path
, GpRectF
* bounds
,
1371 GDIPCONST GpMatrix
*matrix
, GDIPCONST GpPen
*pen
)
1373 GpPointF
* points
, temp_pts
[4];
1375 REAL path_width
= 1.0, width
, height
, temp
, low_x
, low_y
, high_x
, high_y
;
1377 TRACE("(%p, %p, %p, %p)\n", path
, bounds
, matrix
, pen
);
1379 /* Matrix and pen can be null. */
1380 if(!path
|| !bounds
)
1381 return InvalidParameter
;
1383 /* If path is empty just return. */
1384 count
= path
->pathdata
.Count
;
1386 bounds
->X
= bounds
->Y
= bounds
->Width
= bounds
->Height
= 0.0;
1390 points
= path
->pathdata
.Points
;
1392 low_x
= high_x
= points
[0].X
;
1393 low_y
= high_y
= points
[0].Y
;
1395 for(i
= 1; i
< count
; i
++){
1396 low_x
= min(low_x
, points
[i
].X
);
1397 low_y
= min(low_y
, points
[i
].Y
);
1398 high_x
= max(high_x
, points
[i
].X
);
1399 high_y
= max(high_y
, points
[i
].Y
);
1402 width
= high_x
- low_x
;
1403 height
= high_y
- low_y
;
1405 /* This looks unusual but it's the only way I can imitate windows. */
1407 temp_pts
[0].X
= low_x
;
1408 temp_pts
[0].Y
= low_y
;
1409 temp_pts
[1].X
= low_x
;
1410 temp_pts
[1].Y
= high_y
;
1411 temp_pts
[2].X
= high_x
;
1412 temp_pts
[2].Y
= high_y
;
1413 temp_pts
[3].X
= high_x
;
1414 temp_pts
[3].Y
= low_y
;
1416 GdipTransformMatrixPoints((GpMatrix
*)matrix
, temp_pts
, 4);
1417 low_x
= temp_pts
[0].X
;
1418 low_y
= temp_pts
[0].Y
;
1420 for(i
= 1; i
< 4; i
++){
1421 low_x
= min(low_x
, temp_pts
[i
].X
);
1422 low_y
= min(low_y
, temp_pts
[i
].Y
);
1426 width
= height
* fabs(matrix
->matrix
[2]) + width
* fabs(matrix
->matrix
[0]);
1427 height
= height
* fabs(matrix
->matrix
[3]) + temp
* fabs(matrix
->matrix
[1]);
1431 path_width
= pen
->width
/ 2.0;
1434 path_width
= max(path_width
, pen
->width
* pen
->miterlimit
/ 2.0);
1435 /* FIXME: this should probably also check for the startcap */
1436 if(pen
->endcap
& LineCapNoAnchor
)
1437 path_width
= max(path_width
, pen
->width
* 2.2);
1439 low_x
-= path_width
;
1440 low_y
-= path_width
;
1441 width
+= 2.0 * path_width
;
1442 height
+= 2.0 * path_width
;
1447 bounds
->Width
= width
;
1448 bounds
->Height
= height
;
1453 GpStatus WINGDIPAPI
GdipGetPathWorldBoundsI(GpPath
* path
, GpRect
* bounds
,
1454 GDIPCONST GpMatrix
*matrix
, GDIPCONST GpPen
*pen
)
1459 TRACE("(%p, %p, %p, %p)\n", path
, bounds
, matrix
, pen
);
1461 ret
= GdipGetPathWorldBounds(path
,&boundsF
,matrix
,pen
);
1464 bounds
->X
= roundr(boundsF
.X
);
1465 bounds
->Y
= roundr(boundsF
.Y
);
1466 bounds
->Width
= roundr(boundsF
.Width
);
1467 bounds
->Height
= roundr(boundsF
.Height
);
1473 GpStatus WINGDIPAPI
GdipGetPointCount(GpPath
*path
, INT
*count
)
1475 TRACE("(%p, %p)\n", path
, count
);
1478 return InvalidParameter
;
1480 *count
= path
->pathdata
.Count
;
1485 GpStatus WINGDIPAPI
GdipReversePath(GpPath
* path
)
1488 INT start
= 0; /* position in reversed path */
1491 TRACE("(%p)\n", path
);
1494 return InvalidParameter
;
1496 count
= path
->pathdata
.Count
;
1498 if(count
== 0) return Ok
;
1500 revpath
.Points
= GdipAlloc(sizeof(GpPointF
)*count
);
1501 revpath
.Types
= GdipAlloc(sizeof(BYTE
)*count
);
1502 revpath
.Count
= count
;
1503 if(!revpath
.Points
|| !revpath
.Types
){
1504 GdipFree(revpath
.Points
);
1505 GdipFree(revpath
.Types
);
1509 for(i
= 0; i
< count
; i
++){
1511 /* find next start point */
1512 if(path
->pathdata
.Types
[count
-i
-1] == PathPointTypeStart
){
1514 for(j
= start
; j
<= i
; j
++){
1515 revpath
.Points
[j
] = path
->pathdata
.Points
[count
-j
-1];
1516 revpath
.Types
[j
] = path
->pathdata
.Types
[count
-j
-1];
1518 /* mark start point */
1519 revpath
.Types
[start
] = PathPointTypeStart
;
1520 /* set 'figure' endpoint type */
1522 revpath
.Types
[i
] = path
->pathdata
.Types
[count
-start
-1] & ~PathPointTypePathTypeMask
;
1523 revpath
.Types
[i
] |= revpath
.Types
[i
-1];
1526 revpath
.Types
[i
] = path
->pathdata
.Types
[start
];
1532 memcpy(path
->pathdata
.Points
, revpath
.Points
, sizeof(GpPointF
)*count
);
1533 memcpy(path
->pathdata
.Types
, revpath
.Types
, sizeof(BYTE
)*count
);
1535 GdipFree(revpath
.Points
);
1536 GdipFree(revpath
.Types
);
1541 GpStatus WINGDIPAPI
GdipIsOutlineVisiblePathPointI(GpPath
* path
, INT x
, INT y
,
1542 GpPen
*pen
, GpGraphics
*graphics
, BOOL
*result
)
1544 TRACE("(%p, %d, %d, %p, %p, %p)\n", path
, x
, y
, pen
, graphics
, result
);
1546 return GdipIsOutlineVisiblePathPoint(path
, x
, y
, pen
, graphics
, result
);
1549 GpStatus WINGDIPAPI
GdipIsOutlineVisiblePathPoint(GpPath
* path
, REAL x
, REAL y
,
1550 GpPen
*pen
, GpGraphics
*graphics
, BOOL
*result
)
1554 TRACE("(%p,%0.2f,%0.2f,%p,%p,%p)\n", path
, x
, y
, pen
, graphics
, result
);
1557 return InvalidParameter
;
1560 FIXME("not implemented\n");
1562 return NotImplemented
;
1565 GpStatus WINGDIPAPI
GdipIsVisiblePathPointI(GpPath
* path
, INT x
, INT y
, GpGraphics
*graphics
, BOOL
*result
)
1567 TRACE("(%p, %d, %d, %p, %p)\n", path
, x
, y
, graphics
, result
);
1569 return GdipIsVisiblePathPoint(path
, x
, y
, graphics
, result
);
1572 /*****************************************************************************
1573 * GdipIsVisiblePathPoint [GDIPLUS.@]
1575 GpStatus WINGDIPAPI
GdipIsVisiblePathPoint(GpPath
* path
, REAL x
, REAL y
, GpGraphics
*graphics
, BOOL
*result
)
1581 if(!path
|| !result
) return InvalidParameter
;
1583 status
= GdipCreateRegionPath(path
, ®ion
);
1587 status
= GdipGetRegionHRgn(region
, graphics
, &hrgn
);
1589 GdipDeleteRegion(region
);
1593 *result
= PtInRegion(hrgn
, roundr(x
), roundr(y
));
1596 GdipDeleteRegion(region
);
1601 GpStatus WINGDIPAPI
GdipStartPathFigure(GpPath
*path
)
1603 TRACE("(%p)\n", path
);
1606 return InvalidParameter
;
1608 path
->newfigure
= TRUE
;
1613 GpStatus WINGDIPAPI
GdipResetPath(GpPath
*path
)
1615 TRACE("(%p)\n", path
);
1618 return InvalidParameter
;
1620 path
->pathdata
.Count
= 0;
1621 path
->newfigure
= TRUE
;
1622 path
->fill
= FillModeAlternate
;
1627 GpStatus WINGDIPAPI
GdipSetPathFillMode(GpPath
*path
, GpFillMode fill
)
1629 TRACE("(%p, %d)\n", path
, fill
);
1632 return InvalidParameter
;
1639 GpStatus WINGDIPAPI
GdipTransformPath(GpPath
*path
, GpMatrix
*matrix
)
1641 TRACE("(%p, %p)\n", path
, matrix
);
1644 return InvalidParameter
;
1646 if(path
->pathdata
.Count
== 0)
1649 return GdipTransformMatrixPoints(matrix
, path
->pathdata
.Points
,
1650 path
->pathdata
.Count
);
1653 GpStatus WINGDIPAPI
GdipWarpPath(GpPath
*path
, GpMatrix
* matrix
,
1654 GDIPCONST GpPointF
*points
, INT count
, REAL x
, REAL y
, REAL width
,
1655 REAL height
, WarpMode warpmode
, REAL flatness
)
1657 FIXME("(%p,%p,%p,%i,%0.2f,%0.2f,%0.2f,%0.2f,%i,%0.2f)\n", path
, matrix
,
1658 points
, count
, x
, y
, width
, height
, warpmode
, flatness
);
1660 return NotImplemented
;
1663 GpStatus WINGDIPAPI
GdipWidenPath(GpPath
*path
, GpPen
*pen
, GpMatrix
*matrix
,
1666 FIXME("(%p,%p,%p,%0.2f)\n", path
, pen
, matrix
, flatness
);
1668 return NotImplemented
;
1671 GpStatus WINGDIPAPI
GdipAddPathRectangle(GpPath
*path
, REAL x
, REAL y
,
1672 REAL width
, REAL height
)
1679 TRACE("(%p, %.2f, %.2f, %.2f, %.2f)\n", path
, x
, y
, width
, height
);
1682 return InvalidParameter
;
1684 /* make a backup copy of path data */
1685 if((retstat
= GdipClonePath(path
, &backup
)) != Ok
)
1688 /* rectangle should start as new path */
1689 old_new
= path
->newfigure
;
1690 path
->newfigure
= TRUE
;
1691 if((retstat
= GdipAddPathLine(path
,x
,y
,x
+width
,y
)) != Ok
){
1692 path
->newfigure
= old_new
;
1697 ptf
[0].Y
= y
+height
;
1699 ptf
[1].Y
= y
+height
;
1701 if((retstat
= GdipAddPathLine2(path
, ptf
, 2)) != Ok
) goto fail
;
1702 path
->pathdata
.Types
[path
->pathdata
.Count
-1] |= PathPointTypeCloseSubpath
;
1705 GdipDeletePath(backup
);
1710 GdipFree(path
->pathdata
.Points
);
1711 GdipFree(path
->pathdata
.Types
);
1712 memcpy(path
, backup
, sizeof(*path
));
1718 GpStatus WINGDIPAPI
GdipAddPathRectangleI(GpPath
*path
, INT x
, INT y
,
1719 INT width
, INT height
)
1721 TRACE("(%p, %d, %d, %d, %d)\n", path
, x
, y
, width
, height
);
1723 return GdipAddPathRectangle(path
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
);
1726 GpStatus WINGDIPAPI
GdipAddPathRectangles(GpPath
*path
, GDIPCONST GpRectF
*rects
, INT count
)
1732 TRACE("(%p, %p, %d)\n", path
, rects
, count
);
1734 /* count == 0 - verified condition */
1735 if(!path
|| !rects
|| count
== 0)
1736 return InvalidParameter
;
1741 /* make a backup copy */
1742 if((retstat
= GdipClonePath(path
, &backup
)) != Ok
)
1745 for(i
= 0; i
< count
; i
++){
1746 if((retstat
= GdipAddPathRectangle(path
,rects
[i
].X
,rects
[i
].Y
,rects
[i
].Width
,rects
[i
].Height
)) != Ok
)
1751 GdipDeletePath(backup
);
1756 GdipFree(path
->pathdata
.Points
);
1757 GdipFree(path
->pathdata
.Types
);
1758 memcpy(path
, backup
, sizeof(*path
));
1764 GpStatus WINGDIPAPI
GdipAddPathRectanglesI(GpPath
*path
, GDIPCONST GpRect
*rects
, INT count
)
1770 TRACE("(%p, %p, %d)\n", path
, rects
, count
);
1772 if(!rects
|| count
== 0)
1773 return InvalidParameter
;
1778 rectsF
= GdipAlloc(sizeof(GpRectF
)*count
);
1780 for(i
= 0;i
< count
;i
++){
1781 rectsF
[i
].X
= (REAL
)rects
[i
].X
;
1782 rectsF
[i
].Y
= (REAL
)rects
[i
].Y
;
1783 rectsF
[i
].Width
= (REAL
)rects
[i
].Width
;
1784 rectsF
[i
].Height
= (REAL
)rects
[i
].Height
;
1787 retstat
= GdipAddPathRectangles(path
, rectsF
, count
);
1793 GpStatus WINGDIPAPI
GdipSetPathMarker(GpPath
* path
)
1797 TRACE("(%p)\n", path
);
1800 return InvalidParameter
;
1802 count
= path
->pathdata
.Count
;
1804 /* set marker flag */
1806 path
->pathdata
.Types
[count
-1] |= PathPointTypePathMarker
;
1811 GpStatus WINGDIPAPI
GdipClearPathMarkers(GpPath
* path
)
1816 TRACE("(%p)\n", path
);
1819 return InvalidParameter
;
1821 count
= path
->pathdata
.Count
;
1823 for(i
= 0; i
< count
- 1; i
++){
1824 path
->pathdata
.Types
[i
] &= ~PathPointTypePathMarker
;
1830 GpStatus WINGDIPAPI
GdipWindingModeOutline(GpPath
*path
, GpMatrix
*matrix
, REAL flatness
)
1832 FIXME("stub: %p, %p, %.2f\n", path
, matrix
, flatness
);
1833 return NotImplemented
;