Skip to content

Commit

Permalink
Fix MoveTo for fills (flutter#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield committed Apr 27, 2022
1 parent 4be3053 commit f0a7b4e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TEST_F(EntityTest, TriangleInsideASquare) {
ASSERT_TRUE(OpenPlaygroundHere(entity));
}

TEST_F(EntityTest, DISABLED_BadCubicCurveTest) {
TEST_F(EntityTest, CubicCurveTest) {
// Compare with https://fiddle.skia.org/c/b3625f26122c9de7afe7794fcf25ead3
Path path =
PathBuilder{}
Expand All @@ -88,7 +88,7 @@ TEST_F(EntityTest, DISABLED_BadCubicCurveTest) {
ASSERT_TRUE(OpenPlaygroundHere(entity));
}

TEST_F(EntityTest, DISABLED_BadCubicCurveAndOverlapTest) {
TEST_F(EntityTest, CubicCurveAndOverlapTest) {
// Compare with https://fiddle.skia.org/c/7a05a3e186c65a8dfb732f68020aae06
Path path =
PathBuilder{}
Expand Down
25 changes: 19 additions & 6 deletions impeller/renderer/tessellator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,25 @@ bool Tessellator::Tessellate(const Path::Polyline& contours,
/// Feed contour information to the tessellator.
///
static_assert(sizeof(Point) == 2 * sizeof(float));
::tessAddContour(tessellator.get(), // the C tessellator
kVertexSize, //
contours.points.data(), //
sizeof(Point), //
contours.points.size() //
);
size_t start_point_index = 0;
for (size_t end_point_index : contours.breaks) {
end_point_index = std::min(end_point_index, contours.points.size());
::tessAddContour(tessellator.get(), // the C tessellator
kVertexSize, //
contours.points.data() + start_point_index, //
sizeof(Point), //
end_point_index - start_point_index //
);
start_point_index = end_point_index;
}
if (start_point_index < contours.points.size()) {
::tessAddContour(tessellator.get(), // the C tessellator
kVertexSize, //
contours.points.data() + start_point_index, //
sizeof(Point), //
contours.points.size() - start_point_index //
);
}

//----------------------------------------------------------------------------
/// Let's tessellate.
Expand Down

0 comments on commit f0a7b4e

Please sign in to comment.