mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Reuse computed rotate animation.
I have the feeling this fixes a bug, but... Bug: 1464615 Reviewed-by: hiro MozReview-Commit-ID: Aj478qCbMV9
This commit is contained in:
parent
2e500d70ef
commit
92b856b70a
1 changed files with 4 additions and 41 deletions
|
@ -1300,18 +1300,10 @@ impl Animate for ComputedTransformOperation {
|
||||||
&TransformOperation::Rotate3D(fx, fy, fz, fa),
|
&TransformOperation::Rotate3D(fx, fy, fz, fa),
|
||||||
&TransformOperation::Rotate3D(tx, ty, tz, ta),
|
&TransformOperation::Rotate3D(tx, ty, tz, ta),
|
||||||
) => {
|
) => {
|
||||||
let (fx, fy, fz, fa) = transform::get_normalized_vector_and_angle(fx, fy, fz, fa);
|
let animated = Rotate::Rotate3D(fx, fy, fz, fa)
|
||||||
let (tx, ty, tz, ta) = transform::get_normalized_vector_and_angle(tx, ty, tz, ta);
|
.animate(&Rotate::Rotate3D(tx, ty, tz, ta), procedure)?;
|
||||||
if (fx, fy, fz) == (tx, ty, tz) {
|
let (fx, fy, fz, fa) = ComputedRotate::resolve(&animated);
|
||||||
let ia = fa.animate(&ta, procedure)?;
|
Ok(TransformOperation::Rotate3D(fx, fy, fz, fa))
|
||||||
Ok(TransformOperation::Rotate3D(fx, fy, fz, ia))
|
|
||||||
} else {
|
|
||||||
let matrix_f = rotate_to_matrix(fx, fy, fz, fa);
|
|
||||||
let matrix_t = rotate_to_matrix(tx, ty, tz, ta);
|
|
||||||
Ok(TransformOperation::Matrix3D(
|
|
||||||
matrix_f.animate(&matrix_t, procedure)?,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
&TransformOperation::RotateX(fa),
|
&TransformOperation::RotateX(fa),
|
||||||
|
@ -1416,35 +1408,6 @@ fn is_matched_operation(first: &ComputedTransformOperation, second: &ComputedTra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://www.w3.org/TR/css-transforms-1/#Rotate3dDefined>
|
|
||||||
fn rotate_to_matrix(x: f32, y: f32, z: f32, a: Angle) -> Matrix3D {
|
|
||||||
let half_rad = a.radians() / 2.0;
|
|
||||||
let sc = (half_rad).sin() * (half_rad).cos();
|
|
||||||
let sq = (half_rad).sin().powi(2);
|
|
||||||
|
|
||||||
Matrix3D {
|
|
||||||
m11: 1.0 - 2.0 * (y * y + z * z) * sq,
|
|
||||||
m12: 2.0 * (x * y * sq + z * sc),
|
|
||||||
m13: 2.0 * (x * z * sq - y * sc),
|
|
||||||
m14: 0.0,
|
|
||||||
|
|
||||||
m21: 2.0 * (x * y * sq - z * sc),
|
|
||||||
m22: 1.0 - 2.0 * (x * x + z * z) * sq,
|
|
||||||
m23: 2.0 * (y * z * sq + x * sc),
|
|
||||||
m24: 0.0,
|
|
||||||
|
|
||||||
m31: 2.0 * (x * z * sq + y * sc),
|
|
||||||
m32: 2.0 * (y * z * sq - x * sc),
|
|
||||||
m33: 1.0 - 2.0 * (x * x + y * y) * sq,
|
|
||||||
m34: 0.0,
|
|
||||||
|
|
||||||
m41: 0.0,
|
|
||||||
m42: 0.0,
|
|
||||||
m43: 0.0,
|
|
||||||
m44: 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A 2d matrix for interpolation.
|
/// A 2d matrix for interpolation.
|
||||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug)]
|
#[derive(Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue