Skip to content

Commit b26c6ac

Browse files
committed
Do not include the leading point for cubic polylines (#29)
This avoids having duplicated points present in the polyline.
1 parent e94acaa commit b26c6ac

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

impeller/geometry/geometry_unittests.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "flutter/testing/testing.h"
77
#include "impeller/geometry/path.h"
88
#include "impeller/geometry/path_builder.h"
9+
#include "impeller/geometry/path_component.h"
910
#include "impeller/geometry/point.h"
1011
#include "impeller/geometry/rect.h"
1112
#include "impeller/geometry/size.h"
@@ -524,5 +525,15 @@ TEST(GeometryTest, RectContainsRect) {
524525
}
525526
}
526527

528+
TEST(GeometryTest, CubicPathComponentPolylineDoesNotIncludePointOne) {
529+
CubicPathComponent component({10, 10}, {20,35}, {35, 20}, {40, 40});
530+
SmoothingApproximation approximation;
531+
auto polyline = component.CreatePolyline(approximation);
532+
ASSERT_NE(polyline.front().x, 10);
533+
ASSERT_NE(polyline.front().y, 10);
534+
ASSERT_EQ(polyline.back().x, 40);
535+
ASSERT_EQ(polyline.back().y, 40);
536+
}
537+
527538
} // namespace testing
528539
} // namespace impeller

impeller/geometry/path_component.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ static void CubicPathSmoothenRecursive(const SmoothingApproximation& approx,
339339
std::vector<Point> CubicPathComponent::CreatePolyline(
340340
const SmoothingApproximation& approximation) const {
341341
std::vector<Point> points;
342-
points.emplace_back(p1);
343342
CubicPathSmoothenRecursive(approximation, points, p1, cp1, cp2, p2, 0);
344343
points.emplace_back(p2);
345344
return points;

0 commit comments

Comments
 (0)