@@ -253,6 +253,7 @@ StrokePathGeometry::CreateSolidStrokeVertices(
253253 for (size_t contour_i = 0 ; contour_i < polyline.contours .size ();
254254 contour_i++) {
255255 auto contour = polyline.contours [contour_i];
256+ size_t contour_component_i = 0 ;
256257 size_t contour_start_point_i, contour_end_point_i;
257258 std::tie (contour_start_point_i, contour_end_point_i) =
258259 polyline.GetContourPointBounds (contour_i);
@@ -308,27 +309,55 @@ StrokePathGeometry::CreateSolidStrokeVertices(
308309 // Generate contour geometry.
309310 for (size_t point_i = contour_start_point_i + 1 ;
310311 point_i < contour_end_point_i; point_i++) {
312+ if ((contour_component_i + 1 >= contour.components .size ()) &&
313+ contour.components [contour_component_i + 1 ].component_start_index <=
314+ point_i) {
315+ // The point_i has entered the next component in this contour.
316+ contour_component_i += 1 ;
317+ }
311318 // Generate line rect.
312319 vtx.position = polyline.points [point_i - 1 ] + offset;
313320 vtx_builder.AppendVertex (vtx);
314321 vtx.position = polyline.points [point_i - 1 ] - offset;
315322 vtx_builder.AppendVertex (vtx);
316- vtx.position = polyline.points [point_i] + offset;
317- vtx_builder.AppendVertex (vtx);
318- vtx.position = polyline.points [point_i] - offset;
319- vtx_builder.AppendVertex (vtx);
320323
321- if (point_i < contour_end_point_i - 1 ) {
322- compute_offset (point_i + 1 );
324+ auto is_end_of_contour = point_i == contour_end_point_i - 1 ;
325+
326+ if (!contour.components [contour_component_i].is_curve ) {
327+ // For line components, two additional points need to be appended prior
328+ // to appending a join connecting the next component.
329+ vtx.position = polyline.points [point_i] + offset;
330+ vtx_builder.AppendVertex (vtx);
331+ vtx.position = polyline.points [point_i] - offset;
332+ vtx_builder.AppendVertex (vtx);
323333
324- // Generate join from the current line to the next line.
325- join_proc (vtx_builder, polyline.points [point_i], previous_offset,
326- offset, scaled_miter_limit, scale);
334+ if (!is_end_of_contour) {
335+ compute_offset (point_i + 1 );
336+ // Generate join from the current line to the next line.
337+ join_proc (vtx_builder, polyline.points [point_i], previous_offset,
338+ offset, scaled_miter_limit, scale);
339+ }
340+ } else {
341+ // For curve components, the polyline is detailed enough such that
342+ // it can avoid worrying about joins altogether.
343+ if (!is_end_of_contour) {
344+ compute_offset (point_i + 1 );
345+ } else {
346+ // If this is a curve and is the end of the contour, two end points
347+ // need to be drawn with the contour end_direction.
348+ auto end_offset =
349+ Vector2 (-contour.end_direction .y , contour.end_direction .x ) *
350+ stroke_width * 0.5 ;
351+ vtx.position = polyline.points [contour_end_point_i - 1 ] + end_offset;
352+ vtx_builder.AppendVertex (vtx);
353+ vtx.position = polyline.points [contour_end_point_i - 1 ] - end_offset;
354+ vtx_builder.AppendVertex (vtx);
355+ }
327356 }
328357 }
329358
330359 // Generate end cap or join.
331- if (!polyline. contours [contour_i] .is_closed ) {
360+ if (!contour .is_closed ) {
332361 auto cap_offset =
333362 Vector2 (-contour.end_direction .y , contour.end_direction .x ) *
334363 stroke_width * 0.5 ; // Clockwise normal
0 commit comments