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

Commit ef08968

Browse files
committed
addressing comments
1 parent 87a0e2d commit ef08968

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

impeller/core/formats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ enum class PrimitiveType {
351351
/// [ABC].
352352
kLineStrip,
353353

354-
/// Draws a point at each input vertices.
354+
/// Draws a point at each input vertex.
355355
kPoint,
356356
// Triangle fans are implementation dependent and need extra extensions
357357
// checks. Hence, they are not supported here.

impeller/entity/geometry/stroke_path_geometry.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +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_section = 0;
256+
size_t contour_component_i = 0;
257257
size_t contour_start_point_i, contour_end_point_i;
258258
std::tie(contour_start_point_i, contour_end_point_i) =
259259
polyline.GetContourPointBounds(contour_i);
@@ -309,11 +309,11 @@ StrokePathGeometry::CreateSolidStrokeVertices(
309309
// Generate contour geometry.
310310
for (size_t point_i = contour_start_point_i + 1;
311311
point_i < contour_end_point_i; point_i++) {
312-
if ((contour_section + 1 >= contour.sections.size()) &&
313-
contour.sections[contour_section + 1].section_start_index <=
312+
if ((contour_component_i + 1 >= contour.components.size()) &&
313+
contour.components[contour_component_i + 1].component_start_index <=
314314
point_i) {
315-
// The point_i has entered the next section in this contour.
316-
contour_section += 1;
315+
// The point_i has entered the next component in this contour.
316+
contour_component_i += 1;
317317
}
318318
// Generate line rect.
319319
vtx.position = polyline.points[point_i - 1] + offset;
@@ -323,9 +323,9 @@ StrokePathGeometry::CreateSolidStrokeVertices(
323323

324324
auto is_end_of_contour = point_i == contour_end_point_i - 1;
325325

326-
if (!contour.sections[contour_section].is_curve) {
327-
/// Add two end points of the line rect to draw a solid
328-
/// straight line.
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.
329329
vtx.position = polyline.points[point_i] + offset;
330330
vtx_builder.AppendVertex(vtx);
331331
vtx.position = polyline.points[point_i] - offset;
@@ -338,9 +338,8 @@ StrokePathGeometry::CreateSolidStrokeVertices(
338338
offset, scaled_miter_limit, scale);
339339
}
340340
} else {
341-
// Curve sections don't require the two end points of the line rects
342-
// assuming the angles between of a continous two points are close
343-
// enough.
341+
// For curve components, the polyline is detailed enough such that
342+
// it can avoid worrying about joins altogether.
344343
if (!is_end_of_contour) {
345344
compute_offset(point_i + 1);
346345
} else {

impeller/geometry/path.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ Path::Polyline Path::CreatePolyline(Scalar scale) const {
324324
return Vector2(0, -1);
325325
};
326326

327-
std::vector<PolylineContour::Section> sections;
327+
std::vector<PolylineContour::Component> components;
328328
std::optional<size_t> previous_path_component_index;
329329
auto end_contour = [&polyline, &previous_path_component_index,
330-
&get_path_component, &sections]() {
330+
&get_path_component, &components]() {
331331
// Whenever a contour has ended, extract the exact end direction from the
332332
// last component.
333333
if (polyline.contours.empty()) {
@@ -340,8 +340,8 @@ Path::Polyline Path::CreatePolyline(Scalar scale) const {
340340

341341
auto& contour = polyline.contours.back();
342342
contour.end_direction = Vector2(0, 1);
343-
contour.sections = sections;
344-
sections.clear();
343+
contour.components = components;
344+
components.clear();
345345

346346
size_t previous_index = previous_path_component_index.value();
347347
while (!std::holds_alternative<std::monostate>(
@@ -366,24 +366,24 @@ Path::Polyline Path::CreatePolyline(Scalar scale) const {
366366
const auto& component = components_[component_i];
367367
switch (component.type) {
368368
case ComponentType::kLinear:
369-
sections.push_back({
370-
.section_start_index = polyline.points.size(),
369+
components.push_back({
370+
.component_start_index = polyline.points.size(),
371371
.is_curve = false,
372372
});
373373
collect_points(linears_[component.index].CreatePolyline());
374374
previous_path_component_index = component_i;
375375
break;
376376
case ComponentType::kQuadratic:
377-
sections.push_back({
378-
.section_start_index = polyline.points.size(),
377+
components.push_back({
378+
.component_start_index = polyline.points.size(),
379379
.is_curve = true,
380380
});
381381
collect_points(quads_[component.index].CreatePolyline(scale));
382382
previous_path_component_index = component_i;
383383
break;
384384
case ComponentType::kCubic:
385-
sections.push_back({
386-
.section_start_index = polyline.points.size(),
385+
components.push_back({
386+
.component_start_index = polyline.points.size(),
387387
.is_curve = true,
388388
});
389389
collect_points(cubics_[component.index].CreatePolyline(scale));
@@ -402,7 +402,7 @@ Path::Polyline Path::CreatePolyline(Scalar scale) const {
402402
polyline.contours.push_back({.start_index = polyline.points.size(),
403403
.is_closed = contour.is_closed,
404404
.start_direction = start_direction,
405-
.sections = sections});
405+
.components = components});
406406
previous_contour_point = std::nullopt;
407407
collect_points({contour.destination});
408408
break;

impeller/geometry/path.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class Path {
6161
};
6262

6363
struct PolylineContour {
64-
struct Section {
65-
size_t section_start_index;
66-
/// Denotes whether this section is a curve.
64+
struct Component {
65+
size_t component_start_index;
66+
/// Denotes whether this component is a curve.
6767
///
68-
/// This is set to true when this section is generated from
68+
/// This is set to true when this component is generated from
6969
/// QuadraticComponent or CubicPathComponent.
7070
bool is_curve;
7171
};
@@ -81,11 +81,11 @@ class Path {
8181
/// The direction of the contour's end cap.
8282
Vector2 end_direction;
8383

84-
/// Distinct sections in this contour.
84+
/// Distinct components in this contour.
8585
///
8686
/// If this contour is generated from multiple path components, each
87-
/// component forms a section.
88-
std::vector<Section> sections;
87+
/// path component forms a component in this vector.
88+
std::vector<Component> components;
8989
};
9090

9191
/// One or more contours represented as a series of points and indices in

impeller/geometry/path_component.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct LinearPathComponent {
4747
std::optional<Vector2> GetEndDirection() const;
4848
};
4949

50-
// A component represets a Quadratic Bézier curve.
50+
// A component that represets a Quadratic Bézier curve.
5151
struct QuadraticPathComponent {
5252
// Start point.
5353
Point p1;
@@ -91,7 +91,7 @@ struct QuadraticPathComponent {
9191
std::optional<Vector2> GetEndDirection() const;
9292
};
9393

94-
// A component represets a Cubic Bézier curve.
94+
// A component that represets a Cubic Bézier curve.
9595
struct CubicPathComponent {
9696
// Start point.
9797
Point p1;

0 commit comments

Comments
 (0)