Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 14f262d

Browse files
committed
update
1 parent 45ace04 commit 14f262d

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

impeller/entity/geometry/stroke_path_geometry.cc

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,22 @@ StrokePathGeometry::CreateSolidStrokeVertices(
242242
Point offset;
243243
Point previous_offset; // Used for computing joins.
244244

245-
// Computes offset by calculating the direction from point_i - 1 to point_i if point_i
246-
// is within `contour_start_point_i` and `contour_end_point_i`; Otherwise, it uses direction
247-
// from contour.
248-
auto compute_offset = [&polyline, &offset, &previous_offset,
249-
&stroke_width](const size_t point_i, const size_t contour_start_point_i, const size_t contour_end_point_i, const Path::PolylineContour& contour) {
245+
// Computes offset by calculating the direction from point_i - 1 to point_i if
246+
// point_i is within `contour_start_point_i` and `contour_end_point_i`;
247+
// Otherwise, it uses direction from contour.
248+
auto compute_offset = [&polyline, &offset, &previous_offset, &stroke_width](
249+
const size_t point_i,
250+
const size_t contour_start_point_i,
251+
const size_t contour_end_point_i,
252+
const Path::PolylineContour& contour) {
250253
Point direction;
251254
if (point_i >= contour_end_point_i) {
252255
direction = contour.end_direction;
253256
} else if (point_i <= contour_start_point_i) {
254-
direction = - contour.start_direction;
257+
direction = -contour.start_direction;
255258
} else {
256259
direction =
257-
(polyline.points[point_i] - polyline.points[point_i - 1]).Normalize();
260+
(polyline.points[point_i] - polyline.points[point_i - 1]).Normalize();
258261
}
259262
previous_offset = offset;
260263
offset = Vector2{-direction.y, direction.x} * stroke_width * 0.5;
@@ -263,7 +266,8 @@ StrokePathGeometry::CreateSolidStrokeVertices(
263266
auto add_vertices_for_linear_compoent =
264267
[&vtx_builder, &offset, &previous_offset, &vtx, &polyline,
265268
&compute_offset, scaled_miter_limit, scale, &join_proc](
266-
const size_t component_start_index, const size_t component_end_index, const size_t contour_start_point_i, const size_t contour_end_point_i,
269+
const size_t component_start_index, const size_t component_end_index,
270+
const size_t contour_start_point_i, const size_t contour_end_point_i,
267271
const Path::PolylineContour& contour) {
268272
auto is_last_component =
269273
component_start_index ==
@@ -275,27 +279,30 @@ StrokePathGeometry::CreateSolidStrokeVertices(
275279
vtx.position = polyline.points[point_i] + offset;
276280
vtx_builder.AppendVertex(vtx);
277281
vtx.position = polyline.points[point_i] - offset;
278-
vtx_builder.AppendVertex(vtx);
282+
vtx_builder.AppendVertex(vtx);
279283

280284
// For line components, two additional points need to be appended
281285
// prior to appending a join connecting the next component.
282286
vtx.position = polyline.points[point_i + 1] + offset;
283287
vtx_builder.AppendVertex(vtx);
284288
vtx.position = polyline.points[point_i + 1] - offset;
285289
vtx_builder.AppendVertex(vtx);
286-
287-
compute_offset(point_i + 2, contour_start_point_i, contour_end_point_i, contour);
290+
291+
compute_offset(point_i + 2, contour_start_point_i,
292+
contour_end_point_i, contour);
288293
if (!is_last_component && is_end_of_component) {
289294
// Generate join from the current line to the next line.
290-
join_proc(vtx_builder, polyline.points[point_i + 1], previous_offset,
291-
offset, scaled_miter_limit, scale);
295+
join_proc(vtx_builder, polyline.points[point_i + 1],
296+
previous_offset, offset, scaled_miter_limit, scale);
292297
}
293298
}
294299
};
295300

296301
auto add_vertices_for_curve_compoent =
297-
[&vtx_builder, &offset, &previous_offset, &vtx, &polyline, &compute_offset, scaled_miter_limit, scale, &join_proc](
298-
const size_t component_start_index, const size_t component_end_index, const size_t contour_start_point_i, const size_t contour_end_point_i,
302+
[&vtx_builder, &offset, &previous_offset, &vtx, &polyline,
303+
&compute_offset, scaled_miter_limit, scale, &join_proc](
304+
const size_t component_start_index, const size_t component_end_index,
305+
const size_t contour_start_point_i, const size_t contour_end_point_i,
299306
const Path::PolylineContour& contour) {
300307
auto is_last_component =
301308
component_start_index ==
@@ -310,7 +317,8 @@ StrokePathGeometry::CreateSolidStrokeVertices(
310317
vtx.position = polyline.points[point_i] - offset;
311318
vtx_builder.AppendVertex(vtx);
312319

313-
compute_offset(point_i + 2, contour_start_point_i, contour_end_point_i, contour);
320+
compute_offset(point_i + 2, contour_start_point_i,
321+
contour_end_point_i, contour);
314322
// For curve components, the polyline is detailed enough such that
315323
// it can avoid worrying about joins altogether.
316324
if (is_end_of_component) {
@@ -320,8 +328,8 @@ StrokePathGeometry::CreateSolidStrokeVertices(
320328
vtx_builder.AppendVertex(vtx);
321329
// Generate join from the current line to the next line.
322330
if (!is_last_component) {
323-
join_proc(vtx_builder, polyline.points[point_i + 1], previous_offset,
324-
offset, scaled_miter_limit, scale);
331+
join_proc(vtx_builder, polyline.points[point_i + 1],
332+
previous_offset, offset, scaled_miter_limit, scale);
325333
}
326334
}
327335
}
@@ -347,7 +355,8 @@ StrokePathGeometry::CreateSolidStrokeVertices(
347355
break;
348356
}
349357

350-
compute_offset(contour_start_point_i, contour_start_point_i, contour_end_point_i, contour);
358+
compute_offset(contour_start_point_i, contour_start_point_i,
359+
contour_end_point_i, contour);
351360
const Point contour_first_offset = offset;
352361

353362
if (contour_i > 0) {
@@ -394,11 +403,13 @@ StrokePathGeometry::CreateSolidStrokeVertices(
394403
: contour.components[contour_component_i + 1]
395404
.component_start_index;
396405
if (component.is_curve) {
397-
add_vertices_for_curve_compoent(component_start_index,
398-
component_end_index, contour_start_point_i, contour_end_point_i, contour);
406+
add_vertices_for_curve_compoent(
407+
component_start_index, component_end_index, contour_start_point_i,
408+
contour_end_point_i, contour);
399409
} else {
400-
add_vertices_for_linear_compoent(component_start_index,
401-
component_end_index, contour_start_point_i, contour_end_point_i,contour);
410+
add_vertices_for_linear_compoent(
411+
component_start_index, component_end_index, contour_start_point_i,
412+
contour_end_point_i, contour);
402413
}
403414
}
404415

0 commit comments

Comments
 (0)