Bug 1480433 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 07 Aug 2018 14:46:40 -0400
changeset 430411 ec949bf303bdf21cc5d8d61fbada8285685c182e
parent 430410 d0eb4a82624b60c8b63b6f3cb7edf3de45ab9df7
child 430412 de67f1f28d06fd3212f8e0635b386cc75f6deee7
push id106162
push userkgupta@mozilla.com
push dateTue, 07 Aug 2018 20:32:43 +0000
treeherdermozilla-inbound@62e129cc3495 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1480433
milestone63.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 1480433 - Update Cargo lockfiles and re-vendor rust dependencies. r=jrmuizel MozReview-Commit-ID: FUDEEkJZeK
Cargo.lock
third_party/rust/plane-split/.cargo-checksum.json
third_party/rust/plane-split/Cargo.toml
third_party/rust/plane-split/src/bsp.rs
third_party/rust/plane-split/src/clip.rs
third_party/rust/plane-split/src/polygon.rs
third_party/rust/plane-split/tests/main.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1576,17 +1576,17 @@ dependencies = [
 
 [[package]]
 name = "pkg-config"
 version = "0.3.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "plane-split"
-version = "0.12.0"
+version = "0.12.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -2382,17 +2382,17 @@ dependencies = [
  "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "plane-split 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plane-split 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender_api 0.57.2",
 ]
@@ -2699,17 +2699,17 @@ dependencies = [
 "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
 "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356"
 "checksum petgraph 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "7a7e5234c228fbfa874c86a77f685886127f82e0aef602ad1d48333fcac6ad61"
 "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc"
 "checksum phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d62594c0bb54c464f633175d502038177e90309daf2e0158be42ed5f023ce88f"
 "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
 "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
 "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
-"checksum plane-split 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f0a0766225cf828672e97948dfa035bb2eae75110757359ae12fbb46509c8b66"
+"checksum plane-split 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3a4fc9e31d70eb6828e9a2d7a401a824d9f281686a39a8fc06f08796edb1bb"
 "checksum podio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e5422a1ee1bc57cc47ae717b0137314258138f38fd5f3cea083f43a9725383a0"
 "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
 "checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4"
 "checksum proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "effdb53b25cdad54f8f48843d67398f7ef2e14f12c1b4cb4effc549a6462a4d6"
 "checksum procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f566249236c6ca4340f7ca78968271f0ed2b0f234007a61b66f9ecd0af09260"
 "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
 "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
 "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
--- a/third_party/rust/plane-split/.cargo-checksum.json
+++ b/third_party/rust/plane-split/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{".travis.yml":"b76d49f66f842c652d40825c67791352364a6b6bbb7d8d1009f2ac79eb413e66","Cargo.toml":"19f5083a16929492a2e2123262e9dec955d67cc0ae49365857937846e2047bb6","LICENSE":"b946744aeda89b467929585fe8eeb5461847695220c1b168fb375d8abd4ea3d0","README.md":"a65ed5c817c867fe23bc2029f34baea4a645a07dd5d101a0027e796d2923be58","benches/split.rs":"632a011dfc6d8235dea853785061b7bbfe0362eb85b91b3b01fbf77a7f1c7f26","src/bsp.rs":"1dedfc48b79d767e28126cefd24af8ecf7eadd937bb5c7dc6b64e30b9c7d48c7","src/clip.rs":"aa4643264580fa55bc6a5cc02a8f9c0354a590e98545a132daf380603e4f0897","src/lib.rs":"3e9fb055066623b08be1abc06d0fd30f838d840ad13a6acab76d117f0c8bf5ff","src/polygon.rs":"3a37af114c44f531ad1565937ee473d4b21d286bbec11cfb351d8fcee6c5f4ce","tests/clip.rs":"0745faa4cb679c5eef4103a26a8714d6feb37ffd00b6c3dafad5937ec5392f10","tests/main.rs":"f782509823dfdba84de83dd36ba5ad5a468d8657950e74db697ee2e8886158a5","tests/split.rs":"0eb1afb1f26cdecd5fffbf32d57e889f8f69254c0a57eecb8ccbbdf38efcdf27"},"package":"f0a0766225cf828672e97948dfa035bb2eae75110757359ae12fbb46509c8b66"}
\ No newline at end of file
+{"files":{".travis.yml":"b76d49f66f842c652d40825c67791352364a6b6bbb7d8d1009f2ac79eb413e66","Cargo.toml":"9bffe8481e8672f72a85e3844627b35874b2f357ea7e7d91856268ce03f898a7","LICENSE":"b946744aeda89b467929585fe8eeb5461847695220c1b168fb375d8abd4ea3d0","README.md":"a65ed5c817c867fe23bc2029f34baea4a645a07dd5d101a0027e796d2923be58","benches/split.rs":"632a011dfc6d8235dea853785061b7bbfe0362eb85b91b3b01fbf77a7f1c7f26","src/bsp.rs":"60a306ecb7032a57bc5a7b7f094cb9669f7cd112894f85e6e2fc501a608a9404","src/clip.rs":"d1171933bea98c68440869d341d6f2ecdd672b2acb0a4408a011b7ef1c44b266","src/lib.rs":"3e9fb055066623b08be1abc06d0fd30f838d840ad13a6acab76d117f0c8bf5ff","src/polygon.rs":"c30e17aa88714b490f1cc9b7a9a388b37bc9af919ce1983e42f8b94555847118","tests/clip.rs":"0745faa4cb679c5eef4103a26a8714d6feb37ffd00b6c3dafad5937ec5392f10","tests/main.rs":"e299b33390fc486b45685eaef3af4fc67793b114dc0e63c873022dc1530ab672","tests/split.rs":"0eb1afb1f26cdecd5fffbf32d57e889f8f69254c0a57eecb8ccbbdf38efcdf27"},"package":"ff3a4fc9e31d70eb6828e9a2d7a401a824d9f281686a39a8fc06f08796edb1bb"}
\ No newline at end of file
--- a/third_party/rust/plane-split/Cargo.toml
+++ b/third_party/rust/plane-split/Cargo.toml
@@ -7,17 +7,17 @@
 #
 # If you believe there's an error in this file please file an
 # issue against the rust-lang/cargo repository. If you're
 # editing this file be aware that the upstream Cargo.toml
 # will likely look very different (and much more reasonable)
 
 [package]
 name = "plane-split"
-version = "0.12.0"
+version = "0.12.1"
 authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
 description = "Plane splitting"
 documentation = "https://docs.rs/plane-split"
 keywords = ["geometry", "math"]
 license = "MPL-2.0"
 repository = "https://github.com/servo/plane-split"
 [dependencies.binary-space-partition]
 version = "0.1.2"
--- a/third_party/rust/plane-split/src/bsp.rs
+++ b/third_party/rust/plane-split/src/bsp.rs
@@ -1,16 +1,16 @@
 use {Intersection, Plane, Polygon, Splitter};
 
 use binary_space_partition::{BspNode, Plane as BspPlane, PlaneCut};
 use euclid::{TypedPoint3D, TypedVector3D};
 use euclid::approxeq::ApproxEq;
 use num_traits::{Float, One, Zero};
 
-use std::{fmt, ops};
+use std::{fmt, iter, ops};
 
 
 impl<T, U> BspPlane for Polygon<T, U> where
     T: Copy + fmt::Debug + ApproxEq<T> +
         ops::Sub<T, Output=T> + ops::Add<T, Output=T> +
         ops::Mul<T, Output=T> + ops::Div<T, Output=T> +
         Zero + One + Float,
     U: fmt::Debug,
@@ -38,29 +38,33 @@ impl<T, U> BspPlane for Polygon<T, U> wh
                     }
                 }
             }
             Intersection::Inside(line) => {
                 let (res_add1, res_add2) = plane.split(&line);
                 let mut front = Vec::new();
                 let mut back = Vec::new();
 
-                for sub in Some(plane).into_iter().chain(res_add1).chain(res_add2) {
+                for sub in iter::once(plane)
+                    .chain(res_add1)
+                    .chain(res_add2)
+                    .filter(|p| !p.is_empty())
+                {
                     if self.plane.signed_distance_sum_to(&sub) > T::zero() {
                         front.push(sub)
                     } else {
                         back.push(sub)
                     }
                 }
                 debug!("\t\tCut across {:?} by {} in front and {} in back",
                     line, front.len(), back.len());
 
                 PlaneCut::Cut {
-                    front: front,
-                    back: back,
+                    front,
+                    back,
                 }
             },
         }
     }
 
     fn is_aligned(&self, other: &Self) -> bool {
         self.plane.normal.dot(other.plane.normal) > T::zero()
     }
--- a/third_party/rust/plane-split/src/clip.rs
+++ b/third_party/rust/plane-split/src/clip.rs
@@ -126,11 +126,11 @@ impl<
         self.add_frustum(transform, bounds);
         self.clip(polygon);
         // remove the frustum planes
         for _ in 0 .. num_planes {
             self.clips.pop();
         }
         self.results
             .drain(..)
-            .map(move |poly| poly.transform(transform).unwrap())
+            .flat_map(move |poly| poly.transform(transform))
     }
 }
--- a/third_party/rust/plane-split/src/polygon.rs
+++ b/third_party/rust/plane-split/src/polygon.rs
@@ -114,49 +114,64 @@ impl<T: Clone, U> Clone for Polygon<T, U
 impl<T, U> Polygon<T, U> where
     T: Copy + fmt::Debug + ApproxEq<T> +
         ops::Sub<T, Output=T> + ops::Add<T, Output=T> +
         ops::Mul<T, Output=T> + ops::Div<T, Output=T> +
         Zero + One + Float,
     U: fmt::Debug,
 {
     /// Construct a polygon from points that are already transformed.
+    #[deprecated(since = "0.12.1", note = "Use try_from_points instead")]
     pub fn from_points(
         points: [TypedPoint3D<T, U>; 4],
         anchor: usize,
     ) -> Self {
+        Self::try_from_points(points, anchor).unwrap()
+    }
+
+    /// Construct a polygon from points that are already transformed.
+    /// Return None if the polygon doesn't contain any space.
+    /// This method will be removed in `from_points` in the next breaking release.
+    pub fn try_from_points(
+        points: [TypedPoint3D<T, U>; 4],
+        anchor: usize,
+    ) -> Option<Self> {
         let edge1 = points[1] - points[0];
         let edge2 = points[2] - points[0];
         let edge3 = points[3] - points[0];
+        let edge4 = points[3] - points[1];
+
+        if edge2.square_length() < T::epsilon() || edge4.square_length() < T::epsilon() {
+            return None
+        }
 
         // one of them can be zero for redundant polygons produced by plane splitting
         //Note: this would be nicer if we used triangles instead of quads in the first place...
         // see https://github.com/servo/plane-split/issues/17
-        debug_assert!(edge2.square_length() > T::approx_epsilon());
         let normal_rough1 = edge1.cross(edge2);
         let normal_rough2 = edge2.cross(edge3);
         let square_length1 = normal_rough1.square_length();
         let square_length2 = normal_rough2.square_length();
         let normal = if square_length1 > square_length2 {
             normal_rough1 / square_length1.sqrt()
         } else {
             normal_rough2 / square_length2.sqrt()
         };
 
         let offset = -points[0].to_vector()
             .dot(normal);
 
-        Polygon {
+        Some(Polygon {
             points,
             plane: Plane {
                 normal,
                 offset,
             },
             anchor,
-        }
+        })
     }
 
     /// Construct a polygon from a non-transformed rectangle.
     pub fn from_rect(rect: TypedRect<T, U>, anchor: usize) -> Self {
         Self::from_points(
             [
                 rect.origin.to_3d(),
                 rect.top_right().to_3d(),
@@ -181,17 +196,17 @@ impl<T, U> Polygon<T, U> where
             transform.transform_point3d(&rect.top_right().to_3d())?,
             transform.transform_point3d(&rect.bottom_right().to_3d())?,
             transform.transform_point3d(&rect.bottom_left().to_3d())?,
         ];
 
         //Note: this code path could be more efficient if we had inverse-transpose
         //let n4 = transform.transform_point4d(&TypedPoint4D::new(T::zero(), T::zero(), T::one(), T::zero()));
         //let normal = TypedPoint3D::new(n4.x, n4.y, n4.z);
-        Some(Self::from_points(points, anchor))
+        Self::try_from_points(points, anchor)
     }
 
     /// Bring a point into the local coordinate space, returning
     /// the 2D normalized coordinates.
     pub fn untransform_point(&self, point: TypedPoint3D<T, U>) -> Point2D<T> {
         //debug_assert!(self.contains(point));
         // get axises and target vector
         let a = self.points[1] - self.points[0];
@@ -223,17 +238,17 @@ impl<T, U> Polygon<T, U> where
             let mut homo = transform.transform_point3d_homogeneous(point);
             homo.w = homo.w.max(T::approx_epsilon());
             *out = homo.to_point3d()?;
         }
 
         //Note: this code path could be more efficient if we had inverse-transpose
         //let n4 = transform.transform_point4d(&TypedPoint4D::new(T::zero(), T::zero(), T::one(), T::zero()));
         //let normal = TypedPoint3D::new(n4.x, n4.y, n4.z);
-        Some(Polygon::from_points(points, self.anchor))
+        Polygon::try_from_points(points, self.anchor)
     }
 
     /// Check if all the points are indeed placed on the plane defined by
     /// the normal and offset, and the winding order is consistent.
     pub fn is_valid(&self) -> bool {
         let is_planar = self.points
             .iter()
             .all(|p| is_zero(self.plane.signed_distance_to(p)));
@@ -246,23 +261,29 @@ impl<T, U> Polygon<T, U> where
         let anchor = edges[3].cross(edges[0]);
         let is_winding = edges
             .iter()
             .zip(edges[1..].iter())
             .all(|(a, &b)| a.cross(b).dot(anchor) >= T::zero());
         is_planar && is_winding
     }
 
+    /// Check if the polygon doesn't contain any space. This may happen
+    /// after a sequence of splits, and such polygons should be discarded.
+    pub fn is_empty(&self) -> bool {
+        (self.points[0] - self.points[2]).square_length() < T::epsilon() ||
+        (self.points[1] - self.points[3]).square_length() < T::epsilon()
+    }
+
     /// Check if this polygon contains another one.
     pub fn contains(&self, other: &Self) -> bool {
         //TODO: actually check for inside/outside
         self.plane.contains(&other.plane)
     }
 
-
     /// Project this polygon onto a 3D vector, returning a line projection.
     /// Note: we can think of it as a projection to a ray placed at the origin.
     pub fn project_on(&self, vector: &TypedVector3D<T, U>) -> LineProjection<T> {
         LineProjection {
             markers: [
                 vector.dot(self.points[0].to_vector()),
                 vector.dot(self.points[1].to_vector()),
                 vector.dot(self.points[2].to_vector()),
@@ -327,18 +348,18 @@ impl<T, U> Polygon<T, U> where
         for ((&b, &a), cut) in self.points
             .iter()
             .cycle()
             .skip(1)
             .zip(self.points.iter())
             .zip(cuts.iter_mut())
         {
             // intersecting line segment [a, b] with `line`
-            //a + (b-a) * t = r + k * d
-            //(a, d) + t * (b-a, d) - (r, d) = k
+            // a + (b-a) * t = r + k * d
+            // (a, d) + t * (b-a, d) - (r, d) = k
             // a + t * (b-a) = r + t * (b-a, d) * d + (a-r, d) * d
             // t * ((b-a) - (b-a, d)*d) = (r-a) - (r-a, d) * d
             let pr = line.origin - a - line.dir * line.dir.dot(line.origin - a);
             let pb = b - a - line.dir * line.dir.dot(b - a);
             let denom = pb.dot(pb);
             if !denom.approx_eq(&T::zero()) {
                 let t = pr.dot(pb) / denom;
                 if t > T::zero() && t < T::one() {
--- a/third_party/rust/plane-split/tests/main.rs
+++ b/third_party/rust/plane-split/tests/main.rs
@@ -54,16 +54,30 @@ fn valid() {
             offset: -1.0,
         },
         anchor: 0,
     };
     assert!(poly_c.is_valid());
 }
 
 #[test]
+fn empty() {
+    let poly = Polygon::<f32, ()>::try_from_points(
+        [
+            point3(0.0, 0.0, 1.0),
+            point3(0.0, 0.0, 1.0),
+            point3(0.0, 0.00001, 1.0),
+            point3(1.0, 0.0, 0.0),
+        ],
+        1,
+    );
+    assert_eq!(None, poly);
+}
+
+#[test]
 fn from_transformed_rect() {
     let rect: TypedRect<f32, ()> = TypedRect::new(point2(10.0, 10.0), TypedSize2D::new(20.0, 30.0));
     let transform: TypedTransform3D<f32, (), ()> =
         TypedTransform3D::create_rotation(0.5f32.sqrt(), 0.0, 0.5f32.sqrt(), Angle::radians(5.0))
         .pre_translate(vec3(0.0, 0.0, 10.0));
     let poly = Polygon::from_transformed_rect(rect, transform, 0);
     assert!(poly.is_some() && poly.unwrap().is_valid());
 }