[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
This commit is contained in:
gaaclarke 2024-08-07 10:33:51 -07:00 committed by GitHub
parent 5ce93cf905
commit 3d0a4eb772
4 changed files with 11 additions and 10 deletions

View File

@ -208,7 +208,8 @@ std::shared_ptr<FilterContents> 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),

View File

@ -290,7 +290,7 @@ std::optional<MatrixDecomposition> 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<MatrixDecomposition> 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<MatrixDecomposition> 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;

View File

@ -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 {

View File

@ -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};
}