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

[Impeller] handle fill polylines with zero area. #51945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions impeller/tessellator/tessellator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ std::vector<Point> Tessellator::TessellateConvex(const Path& path,
[this](Path::Polyline::PointBufferPtr point_buffer) {
point_buffer_ = std::move(point_buffer);
});
if (polyline.points->size() == 0) {
return output;
}

output.reserve(polyline.points->size() +
(4 * (polyline.contours.size() - 1)));
Expand Down
13 changes: 13 additions & 0 deletions impeller/tessellator/tessellator_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,19 @@ TEST(TessellatorTest, FilledRoundRectTessellationVertices) {
Rect::MakeXYWH(5000, 10000, 2000, 3000), {50, 70});
}

TEST(TessellatorTest, EarlyReturnEmptyConvexShape) {
// This path is not technically empty (it has a size in one dimension),
// but is otherwise completely flat.
auto tessellator = std::make_shared<Tessellator>();
PathBuilder builder;
builder.MoveTo({0, 0});
builder.MoveTo({10, 10}, /*relative=*/true);

auto points = tessellator->TessellateConvex(builder.TakePath(), 3.0);

EXPECT_TRUE(points.empty());
}

#if !NDEBUG
TEST(TessellatorTest, ChecksConcurrentPolylineUsage) {
auto tessellator = std::make_shared<Tessellator>();
Expand Down
Loading