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

Commit 41d578d

Browse files
[CP-beta][Impeller] handle fill polylines with zero area. (#51948)
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
1 parent eac479f commit 41d578d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

impeller/tessellator/tessellator.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ std::vector<Point> Tessellator::TessellateConvex(const Path& path,
187187
[this](Path::Polyline::PointBufferPtr point_buffer) {
188188
point_buffer_ = std::move(point_buffer);
189189
});
190+
if (polyline.points->size() == 0) {
191+
return output;
192+
}
190193

191194
output.reserve(polyline.points->size() +
192195
(4 * (polyline.contours.size() - 1)));

impeller/tessellator/tessellator_unittests.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,19 @@ TEST(TessellatorTest, FilledRoundRectTessellationVertices) {
480480
Rect::MakeXYWH(5000, 10000, 2000, 3000), {50, 70});
481481
}
482482

483+
TEST(TessellatorTest, EarlyReturnEmptyConvexShape) {
484+
// This path is not technically empty (it has a size in one dimension),
485+
// but is otherwise completely flat.
486+
auto tessellator = std::make_shared<Tessellator>();
487+
PathBuilder builder;
488+
builder.MoveTo({0, 0});
489+
builder.MoveTo({10, 10}, /*relative=*/true);
490+
491+
auto points = tessellator->TessellateConvex(builder.TakePath(), 3.0);
492+
493+
EXPECT_TRUE(points.empty());
494+
}
495+
483496
#if !NDEBUG
484497
TEST(TessellatorTest, ChecksConcurrentPolylineUsage) {
485498
auto tessellator = std::make_shared<Tessellator>();

0 commit comments

Comments
 (0)