Fix MoveTo for fills (flutter/engine#32)

This commit is contained in:
Dan Field
2022-02-25 10:54:21 -08:00
committed by Dan Field
parent 8f32a7d961
commit 2132a0a1b9
2 changed files with 21 additions and 8 deletions

View File

@@ -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{}
@@ -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{}

View File

@@ -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.