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

Commit

Permalink
[CP-beta][Impeller] handle fill polylines with zero area. (#51948)
Browse files Browse the repository at this point in the history
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:
What is the link to the issue this cherry-pick is addressing?

flutter/flutter#146362

### Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/wiki/Hotfix-Documentation-Best-Practices) for examples

Fixes Impeller crash when rendering zero area filled shapes.

### Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

Native crash in Impeller renderer.

### Workaround:
Is there a workaround for this issue?

No

### Risk:
What is the risk level of this cherry-pick?

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

### Validation Steps:
What are the steps to validate that this fix works?

Run the included test
  • Loading branch information
flutteractionsbot authored Apr 16, 2024
1 parent eac479f commit 41d578d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit 41d578d

Please sign in to comment.