diff --git a/engine/src/flutter/impeller/geometry/geometry_unittests.cc b/engine/src/flutter/impeller/geometry/geometry_unittests.cc index 705c54c4ca6..de6902c9d96 100644 --- a/engine/src/flutter/impeller/geometry/geometry_unittests.cc +++ b/engine/src/flutter/impeller/geometry/geometry_unittests.cc @@ -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); diff --git a/engine/src/flutter/impeller/geometry/path.cc b/engine/src/flutter/impeller/geometry/path.cc index 47a674ee15b..b71996e76d0 100644 --- a/engine/src/flutter/impeller/geometry/path.cc +++ b/engine/src/flutter/impeller/geometry/path.cc @@ -322,6 +322,10 @@ std::optional> Path::GetMinMaxCoveragePoints() const { clamp(cubic.Extrema()); } + if (!min.has_value() || !max.has_value()) { + return std::nullopt; + } + return std::make_pair(min.value(), max.value()); } diff --git a/engine/src/flutter/impeller/geometry/path_component.cc b/engine/src/flutter/impeller/geometry/path_component.cc index 70f83c3f1a1..b880f700060 100644 --- a/engine/src/flutter/impeller/geometry/path_component.cc +++ b/engine/src/flutter/impeller/geometry/path_component.cc @@ -408,7 +408,7 @@ std::vector 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 points; + std::vector points = {p1, p2}; for (const auto& value : values) { points.emplace_back(Solve(value));