Skip to content

Commit ada4f75

Browse files
jonahwilliamsGitHub Actions Bot
authored and
GitHub Actions Bot
committed
[Impeller] handle fill polylines with zero area. (flutter#51945)
Fixes flutter/flutter#146362 Sometimes we can have effectively zero area in a way that doesn't seem to register with the Skia bounding box logic we're using. Add a sanity check for zero points in the polyline.
1 parent 82478f3 commit ada4f75

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)