Bug 1458927: Fix perspective squared distance computation. r=hiro
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 03 May 2018 17:43:30 +0200
changeset 470436 d42fb2ba68a48881c1ea0e1540767a515792379b
parent 470435 54bd7eb9c5efe65284eba06765b0e2c18f870224
child 470437 8b5bfccc85b1444d2edc7f90c95f9288e26013c2
push id9182
push usernerli@mozilla.com
push dateFri, 04 May 2018 15:39:56 +0000
treeherdermozilla-beta@01ab1ea4c55a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1458927
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1458927: Fix perspective squared distance computation. r=hiro MozReview-Commit-ID: YwjTheRonB
dom/animation/test/mozilla/test_distance_of_transform.html
servo/components/style/properties/helpers/animated_properties.mako.rs
--- a/dom/animation/test/mozilla/test_distance_of_transform.html
+++ b/dom/animation/test/mozilla/test_distance_of_transform.html
@@ -187,35 +187,35 @@ test(function(t) {
   assert_equals(dist, Math.sqrt(2 * 2 + 0.5 * 0.5), 'distance of skew');
 }, 'Test distance of skew functions');
 
 test(function(t) {
   var target = addDiv(t);
   var dist = getDistance(target, 'transform',
                          'perspective(128px)',
                          'none');
-  assert_equals(dist, 1/128, 'distance of perspective');
+  assert_equals(dist, 128, 'distance of perspective');
 }, 'Test distance of perspective function and none');
 
 test(function(t) {
   var target = addDiv(t);
   // perspective(0) is treated as perspective(inf) because perspective length
   // should be greater than or equal to zero.
   var dist = getDistance(target, 'transform',
                          'perspective(128px)',
                          'perspective(0)');
-  assert_equals(dist, 1/128, 'distance of perspective');
+  assert_equals(dist, 128, 'distance of perspective');
 }, 'Test distance of perspective function and an invalid perspective');
 
 test(function(t) {
   var target = addDiv(t);
   var dist = getDistance(target, 'transform',
                          'perspective(128px)',
                          'perspective(1024px)');
-  assert_equals(dist, 1/128 - 1/1024, 'distance of perspective');
+  assert_equals(dist, 1024 - 128, 'distance of perspective');
 }, 'Test distance of perspective functions');
 
 test(function(t) {
   var target = addDiv(t);
   var sin_30 = Math.sin(Math.PI / 6);
   var cos_30 = Math.cos(Math.PI / 6);
   // matrix => translate(100, 0) rotate(30deg).
   var matrix = createMatrixFromArray([ cos_30, sin_30,
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -2627,26 +2627,17 @@ impl ComputeSquaredDistance for Computed
                 &TransformOperation::Rotate(ta),
             ) => {
                 fa.compute_squared_distance(&ta)
             }
             (
                 &TransformOperation::Perspective(ref fd),
                 &TransformOperation::Perspective(ref td),
             ) => {
-                let mut fd_matrix = Matrix3D::identity();
-                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)
+                fd.compute_squared_distance(td)
             }
             (
                 &TransformOperation::Perspective(ref p),
                 &TransformOperation::Matrix3D(ref m),
             ) | (
                 &TransformOperation::Matrix3D(ref m),
                 &TransformOperation::Perspective(ref p),
             ) => {