Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams committed Sep 24, 2024
1 parent 50dd210 commit 095fe34
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions display_list/geometry/dl_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion impeller/geometry/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions impeller/geometry/path_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down

0 comments on commit 095fe34

Please sign in to comment.