Module: wine Branch: master Commit: 09c96907c1610396101f1317234b09ad4100c804 URL: https://gitlab.winehq.org/wine/wine/-/commit/09c96907c1610396101f1317234b09a...
Author: Bartosz Kosiorek gang65@poczta.onet.pl Date: Sat Oct 28 00:26:47 2023 +0200
gdiplus: Fix GdipAddPathCurve3 curve calculation with offset and nseg variables.
---
dlls/gdiplus/graphicspath.c | 28 ++++++++++++++++++++-------- dlls/gdiplus/tests/graphicspath.c | 8 ++++---- 2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index b65d574e73b..63f120a6aba 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -562,15 +562,23 @@ GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath *path, GDIPCONST GpPointF *points,
tension = tension * TENSION_CONST;
- calc_curve_bezier_endp(points[offset].X, points[offset].Y, points[offset + 1].X, points[offset + 1].Y, - tension, &x1, &y1); - pt[0].X = points[offset].X; pt[0].Y = points[offset].Y; - pt[1].X = x1; - pt[1].Y = y1; + if (offset > 0) + { + calc_curve_bezier(&(points[offset - 1]), tension, &x1, &y1, &x2, &y2); + pt[1].X = x2; + pt[1].Y = y2; + } + else + { + calc_curve_bezier_endp(points[offset].X, points[offset].Y, + points[offset + 1].X, points[offset + 1].Y, tension, &x1, &y1); + pt[1].X = x1; + pt[1].Y = y1; + }
- for(i = 0; i < nseg-1; i++){ + for (i = 0; i < nseg - 1; i++){ calc_curve_bezier(&(points[offset + i]), tension, &x1, &y1, &x2, &y2);
pt[3*i+2].X = x1; @@ -581,8 +589,12 @@ GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath *path, GDIPCONST GpPointF *points, pt[3*i+4].Y = y2; }
- calc_curve_bezier_endp(points[offset + nseg].X, points[offset + nseg].Y, - points[offset + nseg - 1].X, points[offset + nseg - 1].Y, tension, &x1, &y1); + if (offset + nseg + 1 < count) + /* If there are one more point in points table then use it for curve calculation */ + calc_curve_bezier(&(points[offset + nseg - 1]), tension, &x1, &y1, &x2, &y2); + else + calc_curve_bezier_endp(points[offset + nseg].X, points[offset + nseg].Y, + points[offset + nseg - 1].X, points[offset + nseg - 1].Y, tension, &x1, &y1);
pt[len_pt-2].X = x1; pt[len_pt-2].Y = y1; diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index f4099555dae..823e1cf38ed 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -947,7 +947,7 @@ static path_test_t addcurve_path2[] = { }; static path_test_t addcurve_path3[] = { {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ - {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/ + {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*1*/ {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/ {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/ @@ -957,13 +957,13 @@ static path_test_t addcurve_path3[] = { static path_test_t addcurve_path4[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ {3.33, 3.33, PathPointTypeBezier, 0, 0}, /*1*/ - {6.66, 3.33, PathPointTypeBezier, 0, 1}, /*2*/ + {6.66, 3.33, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ }; static path_test_t addcurve_path5[] = { {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ - {13.3, 16.6, PathPointTypeBezier, 0, 1}, /*1*/ - {3.33, 20.0, PathPointTypeBezier, 0, 1}, /*2*/ + {13.3, 16.6, PathPointTypeBezier, 0, 0}, /*1*/ + {3.33, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 20.0, PathPointTypeBezier, 0, 0} /*3*/ };