diff --git a/display_list/geometry/dl_path.cc b/display_list/geometry/dl_path.cc index 38fea72130ccf..e0d708999560d 100644 --- a/display_list/geometry/dl_path.cc +++ b/display_list/geometry/dl_path.cc @@ -6,6 +6,7 @@ #include "flutter/display_list/geometry/dl_geometry_types.h" #include "flutter/impeller/geometry/path_builder.h" +#include "impeller/geometry/path.h" namespace flutter { @@ -81,6 +82,9 @@ using FillType = impeller::FillType; using Convexity = impeller::Convexity; Path DlPath::ConvertToImpellerPath(const SkPath& path, const DlPoint& shift) { + if (path.isEmpty()) { + return impeller::Path{}; + } auto iterator = SkPath::Iter(path, false); struct PathData { diff --git a/impeller/geometry/path.cc b/impeller/geometry/path.cc index 471f721e6ff86..7979f8399414e 100644 --- a/impeller/geometry/path.cc +++ b/impeller/geometry/path.cc @@ -53,7 +53,9 @@ bool Path::IsConvex() const { } bool Path::IsEmpty() const { - return data_->points.empty(); + return data_->points.empty() || + (data_->components.size() == 1 && + data_->components[0] == ComponentType::kContour); } void Path::WritePolyline(Scalar scale, VertexWriter& writer) const { diff --git a/impeller/geometry/path_unittests.cc b/impeller/geometry/path_unittests.cc index 8d1aed57892f7..f37689f5e8cf3 100644 --- a/impeller/geometry/path_unittests.cc +++ b/impeller/geometry/path_unittests.cc @@ -23,6 +23,13 @@ TEST(PathTest, CubicPathComponentPolylineDoesNotIncludePointOne) { ASSERT_EQ(polyline.back().y, 40); } +TEST(PathTest, EmptyPathWithContour) { + PathBuilder builder; + auto path = builder.TakePath(); + + EXPECT_TRUE(path.IsEmpty()); +} + TEST(PathTest, PathCreatePolyLineDoesNotDuplicatePoints) { PathBuilder builder; builder.MoveTo({10, 10});