From b199ca864ac44c6fc131bb4fb43a3d8ce4626962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 26 May 2018 23:48:55 +0200 Subject: [PATCH] style: Move skew and rotation application to their own scope for clarity. The skew resetting of temp I think fixes a bug in presence of skew in every direction, but again haven't double-checked. Bug: 1459403 Reviewed-by: hiro MozReview-Commit-ID: Bn93CoaG8Bu --- .../helpers/animated_properties.mako.rs | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 1071671968a..673ba86f8b3 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -2161,43 +2161,47 @@ impl From for Matrix3D { % endfor // Apply rotation - let x = decomposed.quaternion.0; - let y = decomposed.quaternion.1; - let z = decomposed.quaternion.2; - let w = decomposed.quaternion.3; + { + let x = decomposed.quaternion.0; + let y = decomposed.quaternion.1; + let z = decomposed.quaternion.2; + let w = decomposed.quaternion.3; - // Construct a composite rotation matrix from the quaternion values - // rotationMatrix is a identity 4x4 matrix initially - let mut rotation_matrix = Matrix3D::identity(); - rotation_matrix.m11 = 1.0 - 2.0 * (y * y + z * z) as f32; - rotation_matrix.m12 = 2.0 * (x * y + z * w) as f32; - rotation_matrix.m13 = 2.0 * (x * z - y * w) as f32; - rotation_matrix.m21 = 2.0 * (x * y - z * w) as f32; - rotation_matrix.m22 = 1.0 - 2.0 * (x * x + z * z) as f32; - rotation_matrix.m23 = 2.0 * (y * z + x * w) as f32; - rotation_matrix.m31 = 2.0 * (x * z + y * w) as f32; - rotation_matrix.m32 = 2.0 * (y * z - x * w) as f32; - rotation_matrix.m33 = 1.0 - 2.0 * (x * x + y * y) as f32; + // Construct a composite rotation matrix from the quaternion values + // rotationMatrix is a identity 4x4 matrix initially + let mut rotation_matrix = Matrix3D::identity(); + rotation_matrix.m11 = 1.0 - 2.0 * (y * y + z * z) as f32; + rotation_matrix.m12 = 2.0 * (x * y + z * w) as f32; + rotation_matrix.m13 = 2.0 * (x * z - y * w) as f32; + rotation_matrix.m21 = 2.0 * (x * y - z * w) as f32; + rotation_matrix.m22 = 1.0 - 2.0 * (x * x + z * z) as f32; + rotation_matrix.m23 = 2.0 * (y * z + x * w) as f32; + rotation_matrix.m31 = 2.0 * (x * z + y * w) as f32; + rotation_matrix.m32 = 2.0 * (y * z - x * w) as f32; + rotation_matrix.m33 = 1.0 - 2.0 * (x * x + y * y) as f32; - matrix = multiply(rotation_matrix, matrix); + matrix = multiply(rotation_matrix, matrix); + } // Apply skew - let mut temp = Matrix3D::identity(); - if decomposed.skew.2 != 0.0 { - temp.m32 = decomposed.skew.2; - matrix = multiply(temp, matrix); - } + { + let mut temp = Matrix3D::identity(); + if decomposed.skew.2 != 0.0 { + temp.m32 = decomposed.skew.2; + matrix = multiply(temp, matrix); + temp.m32 = 0.0; + } - if decomposed.skew.1 != 0.0 { - temp.m32 = 0.0; - temp.m31 = decomposed.skew.1; - matrix = multiply(temp, matrix); - } + if decomposed.skew.1 != 0.0 { + temp.m31 = decomposed.skew.1; + matrix = multiply(temp, matrix); + temp.m31 = 0.0; + } - if decomposed.skew.0 != 0.0 { - temp.m31 = 0.0; - temp.m21 = decomposed.skew.0; - matrix = multiply(temp, matrix); + if decomposed.skew.0 != 0.0 { + temp.m21 = decomposed.skew.0; + matrix = multiply(temp, matrix); + } } // Apply scale