From 3d0a4eb77201fa8272f243cc34e45f0c05523652 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:33:51 -0700 Subject: [PATCH] [Impeller] made Vector3 naming match Vector2 naming. (flutter/engine#54396) Vector2 has `GetLength()` but Vector3 had `Length()`. This unifies the naming. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- engine/src/flutter/impeller/aiks/paint.cc | 3 ++- engine/src/flutter/impeller/geometry/matrix.cc | 6 +++--- engine/src/flutter/impeller/geometry/matrix.h | 8 ++++---- engine/src/flutter/impeller/geometry/vector.h | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/impeller/aiks/paint.cc b/engine/src/flutter/impeller/aiks/paint.cc index 12a5a0adc04..6cfad5d87f6 100644 --- a/engine/src/flutter/impeller/aiks/paint.cc +++ b/engine/src/flutter/impeller/aiks/paint.cc @@ -208,7 +208,8 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( const Matrix& ctm) const { Vector2 blur_sigma(sigma.sigma, sigma.sigma); if (!respect_ctm) { - blur_sigma /= Vector2(ctm.GetBasisX().Length(), ctm.GetBasisY().Length()); + blur_sigma /= + Vector2(ctm.GetBasisX().GetLength(), ctm.GetBasisY().GetLength()); } if (is_solid_color) { return FilterContents::MakeGaussianBlur(input, Sigma(blur_sigma.x), diff --git a/engine/src/flutter/impeller/geometry/matrix.cc b/engine/src/flutter/impeller/geometry/matrix.cc index 70ede5866ae..5f1c367c7be 100644 --- a/engine/src/flutter/impeller/geometry/matrix.cc +++ b/engine/src/flutter/impeller/geometry/matrix.cc @@ -290,7 +290,7 @@ std::optional Matrix::Decompose() const { /* * Compute X scale factor and normalize first row. */ - result.scale.x = row[0].Length(); + result.scale.x = row[0].GetLength(); row[0] = row[0].Normalize(); /* @@ -302,7 +302,7 @@ std::optional Matrix::Decompose() const { /* * Compute Y scale and normalize 2nd row. */ - result.scale.y = row[1].Length(); + result.scale.y = row[1].GetLength(); row[1] = row[1].Normalize(); result.shear.xy /= result.scale.y; @@ -317,7 +317,7 @@ std::optional Matrix::Decompose() const { /* * Next, get Z scale and normalize 3rd row. */ - result.scale.z = row[2].Length(); + result.scale.z = row[2].GetLength(); row[2] = row[2].Normalize(); result.shear.xz /= result.scale.z; diff --git a/engine/src/flutter/impeller/geometry/matrix.h b/engine/src/flutter/impeller/geometry/matrix.h index fd9a2163dd6..5e40c055575 100644 --- a/engine/src/flutter/impeller/geometry/matrix.h +++ b/engine/src/flutter/impeller/geometry/matrix.h @@ -309,13 +309,13 @@ struct Matrix { constexpr Vector3 GetBasisZ() const { return Vector3(m[8], m[9], m[10]); } constexpr Vector3 GetScale() const { - return Vector3(GetBasisX().Length(), GetBasisY().Length(), - GetBasisZ().Length()); + return Vector3(GetBasisX().GetLength(), GetBasisY().GetLength(), + GetBasisZ().GetLength()); } constexpr Scalar GetDirectionScale(Vector3 direction) const { - return 1.0f / (this->Basis().Invert() * direction.Normalize()).Length() * - direction.Length(); + return 1.0f / (this->Basis().Invert() * direction.Normalize()).GetLength() * + direction.GetLength(); } constexpr bool IsAffine() const { diff --git a/engine/src/flutter/impeller/geometry/vector.h b/engine/src/flutter/impeller/geometry/vector.h index d55136d5cef..31e894cb0a1 100644 --- a/engine/src/flutter/impeller/geometry/vector.h +++ b/engine/src/flutter/impeller/geometry/vector.h @@ -44,10 +44,10 @@ struct Vector3 { * * @return the calculated length. */ - constexpr Scalar Length() const { return sqrt(x * x + y * y + z * z); } + constexpr Scalar GetLength() const { return sqrt(x * x + y * y + z * z); } constexpr Vector3 Normalize() const { - const auto len = Length(); + const auto len = GetLength(); return {x / len, y / len, z / len}; }