mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[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:
parent
5ce93cf905
commit
3d0a4eb772
@ -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),
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user