From 43e50ac6b94d7b248160599f509b62251b4b7276 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 9 Nov 2023 13:15:59 -0800 Subject: [PATCH] [Impeller] Remove unused/untested Path APIs. (flutter/engine#47841) This will simplify the Path internals cleanup that I'd like to land as a part of https://github.com/flutter/flutter/issues/138004 --- engine/src/flutter/impeller/geometry/path.cc | 57 --------------- engine/src/flutter/impeller/geometry/path.h | 11 --- .../flutter/impeller/geometry/path_builder.cc | 70 ------------------- .../flutter/impeller/geometry/path_builder.h | 10 --- 4 files changed, 148 deletions(-) diff --git a/engine/src/flutter/impeller/geometry/path.cc b/engine/src/flutter/impeller/geometry/path.cc index 6158c06bd2..5bd197d039 100644 --- a/engine/src/flutter/impeller/geometry/path.cc +++ b/engine/src/flutter/impeller/geometry/path.cc @@ -212,63 +212,6 @@ bool Path::GetContourComponentAtIndex(size_t index, return true; } -bool Path::UpdateLinearComponentAtIndex(size_t index, - const LinearPathComponent& linear) { - if (index >= components_.size()) { - return false; - } - - if (components_[index].type != ComponentType::kLinear) { - return false; - } - - linears_[components_[index].index] = linear; - return true; -} - -bool Path::UpdateQuadraticComponentAtIndex( - size_t index, - const QuadraticPathComponent& quadratic) { - if (index >= components_.size()) { - return false; - } - - if (components_[index].type != ComponentType::kQuadratic) { - return false; - } - - quads_[components_[index].index] = quadratic; - return true; -} - -bool Path::UpdateCubicComponentAtIndex(size_t index, - CubicPathComponent& cubic) { - if (index >= components_.size()) { - return false; - } - - if (components_[index].type != ComponentType::kCubic) { - return false; - } - - cubics_[components_[index].index] = cubic; - return true; -} - -bool Path::UpdateContourComponentAtIndex(size_t index, - const ContourComponent& move) { - if (index >= components_.size()) { - return false; - } - - if (components_[index].type != ComponentType::kContour) { - return false; - } - - contours_[components_[index].index] = move; - return true; -} - Path::Polyline Path::CreatePolyline(Scalar scale) const { Polyline polyline; diff --git a/engine/src/flutter/impeller/geometry/path.h b/engine/src/flutter/impeller/geometry/path.h index bbbb207793..62c2d21cc9 100644 --- a/engine/src/flutter/impeller/geometry/path.h +++ b/engine/src/flutter/impeller/geometry/path.h @@ -173,17 +173,6 @@ class Path { void Shift(Point shift); - bool UpdateLinearComponentAtIndex(size_t index, - const LinearPathComponent& linear); - - bool UpdateQuadraticComponentAtIndex(size_t index, - const QuadraticPathComponent& quadratic); - - bool UpdateCubicComponentAtIndex(size_t index, CubicPathComponent& cubic); - - bool UpdateContourComponentAtIndex(size_t index, - const ContourComponent& contour); - struct ComponentIndexPair { ComponentType type = ComponentType::kLinear; size_t index = 0; diff --git a/engine/src/flutter/impeller/geometry/path_builder.cc b/engine/src/flutter/impeller/geometry/path_builder.cc index bad11f13f4..85544755f8 100644 --- a/engine/src/flutter/impeller/geometry/path_builder.cc +++ b/engine/src/flutter/impeller/geometry/path_builder.cc @@ -76,38 +76,6 @@ PathBuilder& PathBuilder::QuadraticCurveTo(Point controlPoint, return *this; } -Point PathBuilder::ReflectedQuadraticControlPoint1() const { - /* - * If there is no previous command or if the previous command was not a - * quadratic, assume the control point is coincident with the current point. - */ - if (prototype_.GetComponentCount() == 0) { - return current_; - } - - QuadraticPathComponent quad; - if (!prototype_.GetQuadraticComponentAtIndex( - prototype_.GetComponentCount() - 1, quad)) { - return current_; - } - - /* - * The control point is assumed to be the reflection of the control point on - * the previous command relative to the current point. - */ - return (current_ * 2.0) - quad.cp; -} - -PathBuilder& PathBuilder::SmoothQuadraticCurveTo(Point point, bool relative) { - point = relative ? current_ + point : point; - /* - * The reflected control point is absolute and we made the endpoint absolute - * too. So there the last argument is always false (i.e, not relative). - */ - QuadraticCurveTo(point, ReflectedQuadraticControlPoint1(), false); - return *this; -} - PathBuilder& PathBuilder::SetConvexity(Convexity value) { convexity_ = value; return *this; @@ -125,44 +93,6 @@ PathBuilder& PathBuilder::CubicCurveTo(Point controlPoint1, return *this; } -Point PathBuilder::ReflectedCubicControlPoint1() const { - /* - * If there is no previous command or if the previous command was not a - * cubic, assume the first control point is coincident with the current - * point. - */ - if (prototype_.GetComponentCount() == 0) { - return current_; - } - - CubicPathComponent cubic; - if (!prototype_.GetCubicComponentAtIndex(prototype_.GetComponentCount() - 1, - cubic)) { - return current_; - } - - /* - * The first control point is assumed to be the reflection of the second - * control point on the previous command relative to the current point. - */ - return (current_ * 2.0) - cubic.cp2; -} - -PathBuilder& PathBuilder::SmoothCubicCurveTo(Point controlPoint2, - Point point, - bool relative) { - auto controlPoint1 = ReflectedCubicControlPoint1(); - controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2; - auto endpoint = relative ? current_ + point : point; - - CubicCurveTo(endpoint, // endpoint - controlPoint1, // control point 1 - controlPoint2, // control point 2 - false // relative since all points are already absolute - ); - return *this; -} - PathBuilder& PathBuilder::AddQuadraticCurve(Point p1, Point cp, Point p2) { MoveTo(p1); prototype_.AddQuadraticComponent(p1, cp, p2); diff --git a/engine/src/flutter/impeller/geometry/path_builder.h b/engine/src/flutter/impeller/geometry/path_builder.h index fc72a502a8..e15b7e3abf 100644 --- a/engine/src/flutter/impeller/geometry/path_builder.h +++ b/engine/src/flutter/impeller/geometry/path_builder.h @@ -55,8 +55,6 @@ class PathBuilder { Point point, bool relative = false); - PathBuilder& SmoothQuadraticCurveTo(Point point, bool relative = false); - /// @brief Insert a cubic curve from the curren position to `point` using the /// control points `controlPoint1` and `controlPoint2`. /// @@ -67,10 +65,6 @@ class PathBuilder { Point point, bool relative = false); - PathBuilder& SmoothCubicCurveTo(Point controlPoint2, - Point point, - bool relative = false); - PathBuilder& AddRect(Rect rect); PathBuilder& AddCircle(const Point& center, Scalar radius); @@ -165,10 +159,6 @@ class PathBuilder { PathBuilder& AddRoundedRectBottomLeft(Rect rect, RoundingRadii radii); - Point ReflectedQuadraticControlPoint1() const; - - Point ReflectedCubicControlPoint1() const; - PathBuilder(const PathBuilder&) = delete; PathBuilder& operator=(const PathBuilder&&) = delete; };