From 297125158edf46c6c8657bcf03bf8e089c6e23ef Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Thu, 6 Jun 2024 13:06:16 -0700 Subject: [PATCH] Golden txt --- .../entity/geometry/stroke_path_geometry.cc | 48 ++++--------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/impeller/entity/geometry/stroke_path_geometry.cc b/impeller/entity/geometry/stroke_path_geometry.cc index c4220a21ef674..166fefebe4bc2 100644 --- a/impeller/entity/geometry/stroke_path_geometry.cc +++ b/impeller/entity/geometry/stroke_path_geometry.cc @@ -163,45 +163,13 @@ class StrokeGenerator { } } - /// @brief Represents a ray in 2D space. - /// - /// This is a simple convenience struct for handling polyline offset - /// values when generating stroke geometry. For performance reasons, - /// it's sometimes adventageous to track the direction and magnitude - /// for offsets separately. - struct Ray { - /// The normalized direction of the ray. - Vector2 direction; - - /// The magnitude of the ray. - Scalar magnitude = 0.0; - - /// Returns the vector representation of the ray. - Vector2 GetVector() const { return direction * magnitude; } - - /// Returns the scalar alignment of the two rays. - /// - /// Domain: [-1, 1] - /// A value of 1 indicates the rays are parallel and pointing in the same - /// direction. A value of -1 indicates the rays are parallel and pointing in - /// opposite directions. A value of 0 indicates the rays are perpendicular. - Scalar GetAlignment(const Ray& other) const { - return direction.Dot(other.direction); - } - - /// Returns the scalar angle between the two rays. - Radians AngleTo(const Ray& other) const { - return direction.AngleTo(other.direction); - } - }; - /// Computes offset by calculating the direction from point_i - 1 to point_i /// if point_i is within `contour_start_point_i` and `contour_end_point_i`; /// Otherwise, it uses direction from contour. - Ray ComputeOffset(const size_t point_i, - const size_t contour_start_point_i, - const size_t contour_end_point_i, - const Path::PolylineContour& contour) const { + SeparatedVector2 ComputeOffset(const size_t point_i, + const size_t contour_start_point_i, + const size_t contour_end_point_i, + const Path::PolylineContour& contour) const { Point direction; if (point_i >= contour_end_point_i) { direction = contour.end_direction; @@ -211,8 +179,8 @@ class StrokeGenerator { direction = (polyline.GetPoint(point_i) - polyline.GetPoint(point_i - 1)) .Normalize(); } - return {.direction = Vector2{-direction.y, direction.x}, - .magnitude = stroke_width * 0.5f}; + return SeparatedVector2(Vector2{-direction.y, direction.x}, + stroke_width * 0.5f); } void AddVerticesForLinearComponent(VertexWriter& vtx_builder, @@ -338,8 +306,8 @@ class StrokeGenerator { const CapProc& cap_proc; const Scalar scale; - Ray previous_offset; - Ray offset; + SeparatedVector2 previous_offset; + SeparatedVector2 offset; SolidFillVertexShader::PerVertexData vtx; };