Update the Simplify method for path geometries to handle cubic bezier curves.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d2d1/geometry.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c index 5e62ea8422..0e2ceb1875 100644 --- a/dlls/d2d1/geometry.c +++ b/dlls/d2d1/geometry.c @@ -3577,15 +3577,16 @@ static void d2d_geometry_flatten_cubic(ID2D1SimplifiedGeometrySink *sink, const ID2D1SimplifiedGeometrySink_SetSegmentFlags(sink, D2D1_PATH_SEGMENT_NONE); }
-static void d2d_geometry_simplify_quadratic(ID2D1SimplifiedGeometrySink *sink, +static void d2d_geometry_simplify_bezier(ID2D1SimplifiedGeometrySink *sink, D2D1_GEOMETRY_SIMPLIFICATION_OPTION option, const D2D1_POINT_2F *p0, - const D2D1_POINT_2F *p1, const D2D1_POINT_2F *p2, float tolerance) + const D2D1_POINT_2F *p1, const D2D1_POINT_2F *p2, + const D2D1_POINT_2F *p3, float tolerance) { D2D1_BEZIER_SEGMENT b;
- d2d_point_lerp(&b.point1, p0, p1, 2.0f / 3.0f); - d2d_point_lerp(&b.point2, p2, p1, 2.0f / 3.0f); - b.point3 = *p2; + b.point1 = *p1; + b.point2 = *p2; + b.point3 = *p3;
if (option == D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES) d2d_geometry_flatten_cubic(sink, p0, &b, tolerance); @@ -3601,7 +3602,7 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Simplify(ID2D1PathGeometry *i enum d2d_vertex_type type = D2D_VERTEX_TYPE_NONE; unsigned int i, j, bezier_idx; D2D1_FIGURE_BEGIN begin; - D2D1_POINT_2F p, p1, p2; + D2D1_POINT_2F p, p1, p2, p3; D2D1_FIGURE_END end;
TRACE("iface %p, option %#x, transform %p, tolerance %.8e, sink %p.\n", @@ -3642,14 +3643,17 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Simplify(ID2D1PathGeometry *i break;
case D2D_VERTEX_TYPE_BEZIER: - p1 = figure->original_bezier_controls[bezier_idx++].cq0; + p1 = figure->original_bezier_controls[bezier_idx].c0; if (transform) d2d_point_transform(&p1, transform, p1.x, p1.y); - p2 = figure->vertices[j]; + p2 = figure->original_bezier_controls[bezier_idx++].c1; if (transform) d2d_point_transform(&p2, transform, p2.x, p2.y); - d2d_geometry_simplify_quadratic(sink, option, &p, &p1, &p2, tolerance); - p = p2; + p3 = figure->vertices[j]; + if (transform) + d2d_point_transform(&p3, transform, p3.x, p3.y); + d2d_geometry_simplify_bezier(sink, option, &p, &p1, &p2, &p3, tolerance); + p = p3; break;
default: @@ -3666,13 +3670,16 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Simplify(ID2D1PathGeometry *i
if (type == D2D_VERTEX_TYPE_BEZIER) { - p1 = figure->original_bezier_controls[bezier_idx++].cq0; + p1 = figure->original_bezier_controls[bezier_idx].c0; if (transform) d2d_point_transform(&p1, transform, p1.x, p1.y); - p2 = figure->vertices[0]; + p2 = figure->original_bezier_controls[bezier_idx++].c1; if (transform) d2d_point_transform(&p2, transform, p2.x, p2.y); - d2d_geometry_simplify_quadratic(sink, option, &p, &p1, &p2, tolerance); + p3 = figure->vertices[0]; + if (transform) + d2d_point_transform(&p3, transform, p3.x, p3.y); + d2d_geometry_simplify_bezier(sink, option, &p, &p1, &p2, &p3, tolerance); }
end = figure->flags & D2D_FIGURE_FLAG_CLOSED ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN;