diff --git a/impeller/geometry/geometry_unittests.cc b/impeller/geometry/geometry_unittests.cc index ca3e02e7eafa8..aa0b66b19771f 100644 --- a/impeller/geometry/geometry_unittests.cc +++ b/impeller/geometry/geometry_unittests.cc @@ -1580,7 +1580,7 @@ TEST(GeometryTest, RectGetPositive) { TEST(GeometryTest, CubicPathComponentPolylineDoesNotIncludePointOne) { CubicPathComponent component({10, 10}, {20, 35}, {35, 20}, {40, 40}); - auto polyline = component.CreatePolyline(); + auto polyline = component.CreatePolyline(1.0f); ASSERT_NE(polyline.front().x, 10); ASSERT_NE(polyline.front().y, 10); ASSERT_EQ(polyline.back().x, 40); diff --git a/impeller/geometry/path.cc b/impeller/geometry/path.cc index b5f26937cb325..e018b0ff38e55 100644 --- a/impeller/geometry/path.cc +++ b/impeller/geometry/path.cc @@ -224,7 +224,6 @@ bool Path::UpdateContourComponentAtIndex(size_t index, Path::Polyline Path::CreatePolyline(Scalar scale) const { Polyline polyline; - auto tolerance = kDefaultCurveTolerance / scale; std::optional previous_contour_point; auto collect_points = [&polyline, &previous_contour_point]( @@ -287,11 +286,11 @@ Path::Polyline Path::CreatePolyline(Scalar scale) const { previous_path_component = &linears_[component.index]; break; case ComponentType::kQuadratic: - collect_points(quads_[component.index].CreatePolyline(tolerance)); + collect_points(quads_[component.index].CreatePolyline(scale)); previous_path_component = &quads_[component.index]; break; case ComponentType::kCubic: - collect_points(cubics_[component.index].CreatePolyline(tolerance)); + collect_points(cubics_[component.index].CreatePolyline(scale)); previous_path_component = &cubics_[component.index]; break; case ComponentType::kContour: diff --git a/impeller/geometry/path_component.cc b/impeller/geometry/path_component.cc index 669fa4eaee0ff..de5ca44b200f0 100644 --- a/impeller/geometry/path_component.cc +++ b/impeller/geometry/path_component.cc @@ -96,15 +96,15 @@ static Scalar ApproximateParabolaIntegral(Scalar x) { return x / (1.0 - d + sqrt(sqrt(pow(d, 4) + 0.25 * x * x))); } -std::vector QuadraticPathComponent::CreatePolyline( - Scalar tolerance) const { +std::vector QuadraticPathComponent::CreatePolyline(Scalar scale) const { std::vector points; - FillPointsForPolyline(points, tolerance); + FillPointsForPolyline(points, scale); return points; } void QuadraticPathComponent::FillPointsForPolyline(std::vector& points, - Scalar tolerance) const { + Scalar scale_factor) const { + auto tolerance = kDefaultCurveTolerance / scale_factor; auto sqrt_tolerance = sqrt(tolerance); auto d01 = cp - p1; @@ -171,11 +171,11 @@ Point CubicPathComponent::SolveDerivative(Scalar time) const { }; } -std::vector CubicPathComponent::CreatePolyline(Scalar tolerance) const { +std::vector CubicPathComponent::CreatePolyline(Scalar scale) const { auto quads = ToQuadraticPathComponents(.1); std::vector points; for (const auto& quad : quads) { - quad.FillPointsForPolyline(points, tolerance); + quad.FillPointsForPolyline(points, scale); } return points; } diff --git a/impeller/geometry/path_component.h b/impeller/geometry/path_component.h index 2871192cc618a..3c339ee013cee 100644 --- a/impeller/geometry/path_component.h +++ b/impeller/geometry/path_component.h @@ -76,11 +76,10 @@ struct QuadraticPathComponent : public PathComponent { // making it trivially parallelizable. // // See also the implementation in kurbo: https://github.com/linebender/kurbo. - std::vector CreatePolyline( - Scalar tolerance = kDefaultCurveTolerance) const; + std::vector CreatePolyline(Scalar scale) const; void FillPointsForPolyline(std::vector& points, - Scalar tolerance = kDefaultCurveTolerance) const; + Scalar scale_factor) const; std::vector Extrema() const; @@ -118,8 +117,7 @@ struct CubicPathComponent : public PathComponent { // generates a polyline from those quadratics. // // See the note on QuadraticPathComponent::CreatePolyline for references. - std::vector CreatePolyline( - Scalar tolerance = kDefaultCurveTolerance) const; + std::vector CreatePolyline(Scalar scale) const; std::vector Extrema() const;