Use rewritten decomposition of 2d matrix to compute distance.

So we can align the result with interpolation.
This commit is contained in:
Boris Chiou 2017-08-21 14:58:41 +08:00
parent 9b76cd9d1c
commit 172b4aadda

View file

@ -1443,6 +1443,7 @@ impl Animate for ComputedMatrix {
impl ComputeSquaredDistance for ComputedMatrix {
#[inline]
#[cfg(feature = "servo")]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
if self.is_3d() || other.is_3d() {
let from = decompose_3d_matrix(*self)?;
@ -1454,6 +1455,17 @@ impl ComputeSquaredDistance for ComputedMatrix {
from.compute_squared_distance(&to)
}
}
#[inline]
#[cfg(feature = "gecko")]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
let (from, to) = if self.is_3d() || other.is_3d() {
(decompose_3d_matrix(*self)?, decompose_3d_matrix(*other)?)
} else {
(decompose_2d_matrix(self)?, decompose_2d_matrix(other)?)
};
from.compute_squared_distance(&to)
}
}
impl From<ComputedMatrix> for MatrixDecomposed2D {