mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix Path::GetBoundingBox crash for cubics with no local min/max (flutter/engine#126)
This commit is contained in:
parent
f48865ec86
commit
2e41cfc501
@ -315,6 +315,17 @@ TEST(GeometryTest, BoundingBoxOfCompositePathIsCorrect) {
|
||||
ASSERT_RECT_NEAR(actual.value(), expected);
|
||||
}
|
||||
|
||||
TEST(GeometryTest, PathGetBoundingBoxForCubicWithNoDerivativeRootsIsCorrect) {
|
||||
PathBuilder builder;
|
||||
// Straight diagonal line.
|
||||
builder.AddCubicCurve({0, 1}, {2, 3}, {4, 5}, {6, 7});
|
||||
auto path = builder.TakePath();
|
||||
auto actual = path.GetBoundingBox();
|
||||
auto expected = Rect::MakeLTRB(0, 1, 6, 7);
|
||||
ASSERT_TRUE(actual.has_value());
|
||||
ASSERT_RECT_NEAR(actual.value(), expected);
|
||||
}
|
||||
|
||||
TEST(GeometryTest, CanGenerateMipCounts) {
|
||||
ASSERT_EQ((Size{128, 128}.MipCount()), 7u);
|
||||
ASSERT_EQ((Size{128, 256}.MipCount()), 8u);
|
||||
|
||||
@ -322,6 +322,10 @@ std::optional<std::pair<Point, Point>> Path::GetMinMaxCoveragePoints() const {
|
||||
clamp(cubic.Extrema());
|
||||
}
|
||||
|
||||
if (!min.has_value() || !max.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return std::make_pair(min.value(), max.value());
|
||||
}
|
||||
|
||||
|
||||
@ -408,7 +408,7 @@ std::vector<Point> CubicPathComponent::Extrema() const {
|
||||
CubicPathBoundingPopulateValues(values, p1.x, cp1.x, cp2.x, p2.x);
|
||||
CubicPathBoundingPopulateValues(values, p1.y, cp1.y, cp2.y, p2.y);
|
||||
|
||||
std::vector<Point> points;
|
||||
std::vector<Point> points = {p1, p2};
|
||||
|
||||
for (const auto& value : values) {
|
||||
points.emplace_back(Solve(value));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user