mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Fix perspective interpolation.
It's not sound to insert random matrices in random positions in the transform operation list. I cannot make any sense of what the old code was trying to do. Bug: 1458715 Reviewed-by: hiro MozReview-Commit-ID: 5BtCiueEPlR
This commit is contained in:
parent
9d721072f5
commit
0ef70d52f2
2 changed files with 8 additions and 23 deletions
|
@ -1291,16 +1291,8 @@ impl Animate for ComputedTransformOperation {
|
||||||
&TransformOperation::Perspective(ref fd),
|
&TransformOperation::Perspective(ref fd),
|
||||||
&TransformOperation::Perspective(ref td),
|
&TransformOperation::Perspective(ref td),
|
||||||
) => {
|
) => {
|
||||||
let mut fd_matrix = Matrix3D::identity();
|
Ok(TransformOperation::Perspective(
|
||||||
let mut td_matrix = Matrix3D::identity();
|
fd.animate(td, procedure)?
|
||||||
if fd.px() > 0. {
|
|
||||||
fd_matrix.m34 = -1. / fd.px();
|
|
||||||
}
|
|
||||||
if td.px() > 0. {
|
|
||||||
td_matrix.m34 = -1. / td.px();
|
|
||||||
}
|
|
||||||
Ok(TransformOperation::Matrix3D(
|
|
||||||
fd_matrix.animate(&td_matrix, procedure)?,
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
_ if self.is_translate() && other.is_translate() => {
|
_ if self.is_translate() && other.is_translate() => {
|
||||||
|
@ -2640,16 +2632,7 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
|
||||||
&TransformOperation::Perspective(ref fd),
|
&TransformOperation::Perspective(ref fd),
|
||||||
&TransformOperation::Perspective(ref td),
|
&TransformOperation::Perspective(ref td),
|
||||||
) => {
|
) => {
|
||||||
let mut fd_matrix = Matrix3D::identity();
|
fd.compute_squared_distance(td)
|
||||||
let mut td_matrix = Matrix3D::identity();
|
|
||||||
if fd.px() > 0. {
|
|
||||||
fd_matrix.m34 = -1. / fd.px();
|
|
||||||
}
|
|
||||||
|
|
||||||
if td.px() > 0. {
|
|
||||||
td_matrix.m34 = -1. / td.px();
|
|
||||||
}
|
|
||||||
fd_matrix.compute_squared_distance(&td_matrix)
|
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
&TransformOperation::Perspective(ref p),
|
&TransformOperation::Perspective(ref p),
|
||||||
|
@ -2658,6 +2641,8 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
|
||||||
&TransformOperation::Matrix3D(ref m),
|
&TransformOperation::Matrix3D(ref m),
|
||||||
&TransformOperation::Perspective(ref p),
|
&TransformOperation::Perspective(ref p),
|
||||||
) => {
|
) => {
|
||||||
|
// FIXME(emilio): Is this right? Why interpolating this with
|
||||||
|
// Perspective but not with anything else?
|
||||||
let mut p_matrix = Matrix3D::identity();
|
let mut p_matrix = Matrix3D::identity();
|
||||||
if p.px() > 0. {
|
if p.px() > 0. {
|
||||||
p_matrix.m34 = -1. / p.px();
|
p_matrix.m34 = -1. / p.px();
|
||||||
|
|
|
@ -251,11 +251,11 @@ impl ToAnimatedZero for TransformOperation {
|
||||||
generic::TransformOperation::Rotate(_) => {
|
generic::TransformOperation::Rotate(_) => {
|
||||||
Ok(generic::TransformOperation::Rotate(Angle::zero()))
|
Ok(generic::TransformOperation::Rotate(Angle::zero()))
|
||||||
},
|
},
|
||||||
generic::TransformOperation::Perspective(..) |
|
generic::TransformOperation::Perspective(ref l) => {
|
||||||
|
Ok(generic::TransformOperation::Perspective(l.to_animated_zero()?))
|
||||||
|
},
|
||||||
generic::TransformOperation::AccumulateMatrix { .. } |
|
generic::TransformOperation::AccumulateMatrix { .. } |
|
||||||
generic::TransformOperation::InterpolateMatrix { .. } => {
|
generic::TransformOperation::InterpolateMatrix { .. } => {
|
||||||
// Perspective: We convert a perspective function into an equivalent
|
|
||||||
// ComputedMatrix, and then decompose/interpolate/recompose these matrices.
|
|
||||||
// AccumulateMatrix/InterpolateMatrix: We do interpolation on
|
// AccumulateMatrix/InterpolateMatrix: We do interpolation on
|
||||||
// AccumulateMatrix/InterpolateMatrix by reading it as a ComputedMatrix
|
// AccumulateMatrix/InterpolateMatrix by reading it as a ComputedMatrix
|
||||||
// (with layout information), and then do matrix interpolation.
|
// (with layout information), and then do matrix interpolation.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue