зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1272549 - Part 6: Use enum class for shear in decomposition functions. r=birtles
MozReview-Commit-ID: 4exovhbjHI3 --HG-- extra : rebase_source : 99705c1bb2c980be06f7c662698241dde5ee9ab9
This commit is contained in:
Родитель
c82cb7f0df
Коммит
17e5c4df16
|
@ -39,6 +39,7 @@ using namespace mozilla::css;
|
|||
using namespace mozilla::gfx;
|
||||
using nsStyleTransformMatrix::Decompose2DMatrix;
|
||||
using nsStyleTransformMatrix::Decompose3DMatrix;
|
||||
using nsStyleTransformMatrix::ShearType;
|
||||
|
||||
// HELPER METHODS
|
||||
// --------------
|
||||
|
@ -1609,16 +1610,21 @@ StyleAnimationValue::InterpolateTransformMatrix(const Matrix4x4 &aMatrix1,
|
|||
// Decompose both matrices
|
||||
|
||||
// TODO: What do we do if one of these returns false (singular matrix)
|
||||
|
||||
Point3D scale1(1, 1, 1), translate1;
|
||||
Point4D perspective1(0, 0, 0, 1);
|
||||
gfxQuaternion rotate1;
|
||||
float shear1[3] = { 0.0f, 0.0f, 0.0f};
|
||||
nsStyleTransformMatrix::ShearArray shear1;
|
||||
for (auto&& s : shear1) {
|
||||
s = 0.0f;
|
||||
}
|
||||
|
||||
Point3D scale2(1, 1, 1), translate2;
|
||||
Point4D perspective2(0, 0, 0, 1);
|
||||
gfxQuaternion rotate2;
|
||||
float shear2[3] = { 0.0f, 0.0f, 0.0f};
|
||||
nsStyleTransformMatrix::ShearArray shear2;
|
||||
for (auto&& s : shear2) {
|
||||
s = 0.0f;
|
||||
}
|
||||
|
||||
Matrix matrix2d1, matrix2d2;
|
||||
if (aMatrix1.Is2D(&matrix2d1) && aMatrix2.Is2D(&matrix2d2)) {
|
||||
|
@ -1651,19 +1657,25 @@ StyleAnimationValue::InterpolateTransformMatrix(const Matrix4x4 &aMatrix1,
|
|||
// TODO: Would it be better to interpolate these as angles?
|
||||
// How do we convert back to angles?
|
||||
float yzshear =
|
||||
InterpolateNumerically(shear1[YZSHEAR], shear2[YZSHEAR], aProgress);
|
||||
InterpolateNumerically(shear1[ShearType::YZSHEAR],
|
||||
shear2[ShearType::YZSHEAR],
|
||||
aProgress);
|
||||
if (yzshear != 0.0) {
|
||||
result.SkewYZ(yzshear);
|
||||
}
|
||||
|
||||
float xzshear =
|
||||
InterpolateNumerically(shear1[XZSHEAR], shear2[XZSHEAR], aProgress);
|
||||
InterpolateNumerically(shear1[ShearType::XZSHEAR],
|
||||
shear2[ShearType::XZSHEAR],
|
||||
aProgress);
|
||||
if (xzshear != 0.0) {
|
||||
result.SkewXZ(xzshear);
|
||||
}
|
||||
|
||||
float xyshear =
|
||||
InterpolateNumerically(shear1[XYSHEAR], shear2[XYSHEAR], aProgress);
|
||||
InterpolateNumerically(shear1[ShearType::XYSHEAR],
|
||||
shear2[ShearType::XYSHEAR],
|
||||
aProgress);
|
||||
if (xyshear != 0.0) {
|
||||
result.SkewXY(xyshear);
|
||||
}
|
||||
|
|
|
@ -876,7 +876,7 @@ ReadTransforms(const nsCSSValueList* aList,
|
|||
bool
|
||||
Decompose2DMatrix(const Matrix& aMatrix,
|
||||
Point3D& aScale,
|
||||
float aShear[3],
|
||||
ShearArray& aShear,
|
||||
gfxQuaternion& aRotate,
|
||||
Point3D& aTranslate)
|
||||
{
|
||||
|
@ -916,7 +916,7 @@ Decompose2DMatrix(const Matrix& aMatrix,
|
|||
|
||||
float rotate = atan2f(B, A);
|
||||
aRotate = gfxQuaternion(0, 0, sin(rotate/2), cos(rotate/2));
|
||||
aShear[XYSHEAR] = XYshear;
|
||||
aShear[ShearType::XYSHEAR] = XYshear;
|
||||
aScale.x = scaleX;
|
||||
aScale.y = scaleY;
|
||||
aTranslate.x = aMatrix._31;
|
||||
|
@ -937,7 +937,7 @@ Decompose2DMatrix(const Matrix& aMatrix,
|
|||
bool
|
||||
Decompose3DMatrix(const Matrix4x4& aMatrix,
|
||||
Point3D& aScale,
|
||||
float aShear[3],
|
||||
ShearArray& aShear,
|
||||
gfxQuaternion& aRotate,
|
||||
Point3D& aTranslate,
|
||||
Point4D& aPerspective)
|
||||
|
@ -994,26 +994,26 @@ Decompose3DMatrix(const Matrix4x4& aMatrix,
|
|||
local[0] /= aScale.x;
|
||||
|
||||
/* Compute XY shear factor and make 2nd local orthogonal to 1st. */
|
||||
aShear[XYSHEAR] = local[0].DotProduct(local[1]);
|
||||
local[1] -= local[0] * aShear[XYSHEAR];
|
||||
aShear[ShearType::XYSHEAR] = local[0].DotProduct(local[1]);
|
||||
local[1] -= local[0] * aShear[ShearType::XYSHEAR];
|
||||
|
||||
/* Now, compute Y scale and normalize 2nd local. */
|
||||
aScale.y = local[1].Length();
|
||||
local[1] /= aScale.y;
|
||||
aShear[XYSHEAR] /= aScale.y;
|
||||
aShear[ShearType::XYSHEAR] /= aScale.y;
|
||||
|
||||
/* Compute XZ and YZ shears, make 3rd local orthogonal */
|
||||
aShear[XZSHEAR] = local[0].DotProduct(local[2]);
|
||||
local[2] -= local[0] * aShear[XZSHEAR];
|
||||
aShear[YZSHEAR] = local[1].DotProduct(local[2]);
|
||||
local[2] -= local[1] * aShear[YZSHEAR];
|
||||
aShear[ShearType::XZSHEAR] = local[0].DotProduct(local[2]);
|
||||
local[2] -= local[0] * aShear[ShearType::XZSHEAR];
|
||||
aShear[ShearType::YZSHEAR] = local[1].DotProduct(local[2]);
|
||||
local[2] -= local[1] * aShear[ShearType::YZSHEAR];
|
||||
|
||||
/* Next, get Z scale and normalize 3rd local. */
|
||||
aScale.z = local[2].Length();
|
||||
local[2] /= aScale.z;
|
||||
|
||||
aShear[XZSHEAR] /= aScale.z;
|
||||
aShear[YZSHEAR] /= aScale.z;
|
||||
aShear[ShearType::XZSHEAR] /= aScale.z;
|
||||
aShear[ShearType::YZSHEAR] /= aScale.z;
|
||||
|
||||
/**
|
||||
* At this point, the matrix (in locals) is orthonormal.
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#ifndef nsStyleTransformMatrix_h_
|
||||
#define nsStyleTransformMatrix_h_
|
||||
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "nsCSSValue.h"
|
||||
|
||||
class nsIFrame;
|
||||
|
@ -174,16 +175,21 @@ namespace nsStyleTransformMatrix {
|
|||
bool* aContains3dTransform);
|
||||
|
||||
// Shear type for decomposition.
|
||||
#define XYSHEAR 0
|
||||
#define XZSHEAR 1
|
||||
#define YZSHEAR 2
|
||||
enum class ShearType {
|
||||
XYSHEAR,
|
||||
XZSHEAR,
|
||||
YZSHEAR,
|
||||
Count
|
||||
};
|
||||
using ShearArray =
|
||||
mozilla::EnumeratedArray<ShearType, ShearType::Count, float>;
|
||||
|
||||
/*
|
||||
* Implements the 2d transform matrix decomposition algorithm.
|
||||
*/
|
||||
bool Decompose2DMatrix(const mozilla::gfx::Matrix& aMatrix,
|
||||
mozilla::gfx::Point3D& aScale,
|
||||
float aShear[3],
|
||||
ShearArray& aShear,
|
||||
gfxQuaternion& aRotate,
|
||||
mozilla::gfx::Point3D& aTranslate);
|
||||
/*
|
||||
|
@ -191,7 +197,7 @@ namespace nsStyleTransformMatrix {
|
|||
*/
|
||||
bool Decompose3DMatrix(const mozilla::gfx::Matrix4x4& aMatrix,
|
||||
mozilla::gfx::Point3D& aScale,
|
||||
float aShear[3],
|
||||
ShearArray& aShear,
|
||||
gfxQuaternion& aRotate,
|
||||
mozilla::gfx::Point3D& aTranslate,
|
||||
mozilla::gfx::Point4D& aPerspective);
|
||||
|
|
Загрузка…
Ссылка в новой задаче