[Impeller] Apply the transform to PointFieldGeometry coverage (flutter/engine#46428)

Fixes https://github.com/flutter/flutter/issues/134068
This commit is contained in:
Jason Simmons
2023-09-29 18:53:23 -07:00
committed by GitHub
parent 3e7ec67048
commit 50a17ba824
2 changed files with 11 additions and 2 deletions

View File

@@ -2417,6 +2417,14 @@ TEST_P(EntityTest, PointFieldGeometryDivisions) {
ASSERT_EQ(PointFieldGeometry::ComputeCircleDivisions(20000.0, true), 140u);
}
TEST_P(EntityTest, PointFieldGeometryCoverage) {
std::vector<Point> points = {{10, 20}, {100, 200}};
auto geometry = Geometry::MakePointField(points, 5.0, false);
ASSERT_EQ(*geometry->GetCoverage(Matrix()), Rect::MakeLTRB(5, 15, 105, 205));
ASSERT_EQ(*geometry->GetCoverage(Matrix::MakeTranslation({30, 0, 0})),
Rect::MakeLTRB(35, 15, 135, 205));
}
TEST_P(EntityTest, ColorFilterContentsWithLargeGeometry) {
Entity entity;
entity.SetTransformation(Matrix::MakeScale(GetContentScale()));

View File

@@ -287,8 +287,9 @@ std::optional<Rect> PointFieldGeometry::GetCoverage(
right = std::max(right, it->x);
bottom = std::max(bottom, it->y);
}
return Rect::MakeLTRB(left - radius_, top - radius_, right + radius_,
bottom + radius_);
auto coverage = Rect::MakeLTRB(left - radius_, top - radius_,
right + radius_, bottom + radius_);
return coverage.TransformBounds(transform);
}
return std::nullopt;
}