diff --git a/impeller/geometry/path.cc b/impeller/geometry/path.cc index 6b2ecf847b614..68115f06533e5 100644 --- a/impeller/geometry/path.cc +++ b/impeller/geometry/path.cc @@ -299,33 +299,37 @@ std::optional> Path::GetMinMaxCoveragePoints() const { std::optional min, max; - auto clamp = [&min, &max](const std::vector& extrema) { - for (const auto& extremum : extrema) { - if (!min.has_value()) { - min = extremum; - } - - if (!max.has_value()) { - max = extremum; - } + auto clamp = [&min, &max](const Point& point) { + if (min.has_value()) { + min->x = std::min(min->x, point.x); + min->y = std::min(min->y, point.y); + } else { + min = point; + } - min->x = std::min(min->x, extremum.x); - min->y = std::min(min->y, extremum.y); - max->x = std::max(max->x, extremum.x); - max->y = std::max(max->y, extremum.y); + if (max.has_value()) { + max->x = std::max(max->x, point.x); + max->y = std::max(max->y, point.y); + } else { + max = point; } }; for (const auto& linear : linears_) { - clamp(linear.Extrema()); + clamp(linear.p1); + clamp(linear.p2); } for (const auto& quad : quads_) { - clamp(quad.Extrema()); + for (const Point& point : quad.Extrema()) { + clamp(point); + } } for (const auto& cubic : cubics_) { - clamp(cubic.Extrema()); + for (const Point& point : cubic.Extrema()) { + clamp(point); + } } if (!min.has_value() || !max.has_value()) {