Skip to content

Commit f0a7b4e

Browse files
committed
Fix MoveTo for fills (#32)
1 parent 4be3053 commit f0a7b4e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

impeller/entity/entity_unittests.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ TEST_F(EntityTest, TriangleInsideASquare) {
6666
ASSERT_TRUE(OpenPlaygroundHere(entity));
6767
}
6868

69-
TEST_F(EntityTest, DISABLED_BadCubicCurveTest) {
69+
TEST_F(EntityTest, CubicCurveTest) {
7070
// Compare with https://fiddle.skia.org/c/b3625f26122c9de7afe7794fcf25ead3
7171
Path path =
7272
PathBuilder{}
@@ -88,7 +88,7 @@ TEST_F(EntityTest, DISABLED_BadCubicCurveTest) {
8888
ASSERT_TRUE(OpenPlaygroundHere(entity));
8989
}
9090

91-
TEST_F(EntityTest, DISABLED_BadCubicCurveAndOverlapTest) {
91+
TEST_F(EntityTest, CubicCurveAndOverlapTest) {
9292
// Compare with https://fiddle.skia.org/c/7a05a3e186c65a8dfb732f68020aae06
9393
Path path =
9494
PathBuilder{}

impeller/renderer/tessellator.cc

+19-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,25 @@ bool Tessellator::Tessellate(const Path::Polyline& contours,
6161
/// Feed contour information to the tessellator.
6262
///
6363
static_assert(sizeof(Point) == 2 * sizeof(float));
64-
::tessAddContour(tessellator.get(), // the C tessellator
65-
kVertexSize, //
66-
contours.points.data(), //
67-
sizeof(Point), //
68-
contours.points.size() //
69-
);
64+
size_t start_point_index = 0;
65+
for (size_t end_point_index : contours.breaks) {
66+
end_point_index = std::min(end_point_index, contours.points.size());
67+
::tessAddContour(tessellator.get(), // the C tessellator
68+
kVertexSize, //
69+
contours.points.data() + start_point_index, //
70+
sizeof(Point), //
71+
end_point_index - start_point_index //
72+
);
73+
start_point_index = end_point_index;
74+
}
75+
if (start_point_index < contours.points.size()) {
76+
::tessAddContour(tessellator.get(), // the C tessellator
77+
kVertexSize, //
78+
contours.points.data() + start_point_index, //
79+
sizeof(Point), //
80+
contours.points.size() - start_point_index //
81+
);
82+
}
7083

7184
//----------------------------------------------------------------------------
7285
/// Let's tessellate.

0 commit comments

Comments
 (0)