Bug 1656236 - Update euclid in stylo. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D85762
This commit is contained in:
Nicolas Silva 2020-08-18 16:06:19 +00:00
Родитель fc87bc960e
Коммит 0473064210
6 изменённых файлов: 51 добавлений и 43 удалений

31
Cargo.lock сгенерированный
Просмотреть файл

@ -1334,6 +1334,15 @@ name = "euclid"
version = "0.20.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bb7ef65b3777a325d1eeefefab5b6d4959da54747e33bd6258e789640f307ad"
dependencies = [
"num-traits",
]
[[package]]
name = "euclid"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ab0e07e345fb061928646949fdf5fb888e5d75a57385e7f5856e45be289e745"
dependencies = [
"num-traits",
"serde",
@ -2827,7 +2836,7 @@ version = "0.0.1"
dependencies = [
"app_units",
"cssparser",
"euclid",
"euclid 0.22.0",
"hashglobe",
"selectors",
"servo_arc",
@ -3577,7 +3586,7 @@ dependencies = [
name = "peek-poke"
version = "0.2.0"
dependencies = [
"euclid",
"euclid 0.22.0",
"peek-poke-derive 0.2.1",
]
@ -3736,12 +3745,12 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "plane-split"
version = "0.15.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe16a646a08f4b4dd74035b9ff8e378eb1a4012a74f14f5889e7001cdbece33"
checksum = "2211e7ccc9b6260779dd9bad59f7b10889d6361974623b9e405afd7e7e764654"
dependencies = [
"binary-space-partition",
"euclid",
"euclid 0.22.0",
"log",
"num-traits",
]
@ -4690,7 +4699,7 @@ dependencies = [
"byteorder",
"cssparser",
"derive_more",
"euclid",
"euclid 0.22.0",
"fallible",
"fxhash",
"hashbrown",
@ -4753,7 +4762,7 @@ dependencies = [
"app_units",
"bitflags",
"cssparser",
"euclid",
"euclid 0.20.14",
"lazy_static",
"malloc_size_of",
"malloc_size_of_derive",
@ -5609,7 +5618,7 @@ dependencies = [
"core-text",
"cstr",
"dwrote",
"euclid",
"euclid 0.22.0",
"freetype",
"fxhash",
"gleam",
@ -5647,7 +5656,7 @@ dependencies = [
"core-graphics",
"crossbeam-channel",
"derive_more",
"euclid",
"euclid 0.22.0",
"malloc_size_of_derive",
"peek-poke 0.2.0",
"serde",
@ -5667,7 +5676,7 @@ dependencies = [
"core-graphics",
"dirs",
"dwrote",
"euclid",
"euclid 0.22.0",
"foreign-types",
"fxhash",
"gleam",
@ -5844,7 +5853,7 @@ name = "wr_malloc_size_of"
version = "0.0.1"
dependencies = [
"app_units",
"euclid",
"euclid 0.22.0",
]
[[package]]

Просмотреть файл

@ -37,7 +37,7 @@ cssparser = "0.27"
derive_more = "0.99"
new_debug_unreachable = "1.0"
encoding_rs = {version = "0.8", optional = true}
euclid = "0.20"
euclid = "0.22"
fallible = { path = "../fallible" }
fxhash = "0.2"
hashbrown = "0.7"

Просмотреть файл

@ -76,7 +76,7 @@ pub use self::GenericMatrix3D as Matrix3D;
impl<T: Into<f64>> From<Matrix<T>> for Transform3D<f64> {
#[inline]
fn from(m: Matrix<T>) -> Self {
Transform3D::row_major(
Transform3D::new(
m.a.into(), m.b.into(), 0.0, 0.0,
m.c.into(), m.d.into(), 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
@ -89,7 +89,7 @@ impl<T: Into<f64>> From<Matrix<T>> for Transform3D<f64> {
impl<T: Into<f64>> From<Matrix3D<T>> for Transform3D<f64> {
#[inline]
fn from(m: Matrix3D<T>) -> Self {
Transform3D::row_major(
Transform3D::new(
m.m11.into(), m.m12.into(), m.m13.into(), m.m14.into(),
m.m21.into(), m.m22.into(), m.m23.into(), m.m24.into(),
m.m31.into(), m.m32.into(), m.m33.into(), m.m34.into(),
@ -443,15 +443,14 @@ where
use self::TransformOperation::*;
use std::f64;
const TWO_PI: f64 = 2.0f64 * f64::consts::PI;
let reference_width = reference_box.map(|v| v.size.width);
let reference_height = reference_box.map(|v| v.size.height);
let matrix = match *self {
Rotate3D(ax, ay, az, theta) => {
let theta = TWO_PI - theta.radians64();
let theta = theta.radians64();
let (ax, ay, az, theta) =
get_normalized_vector_and_angle(ax.into(), ay.into(), az.into(), theta);
Transform3D::create_rotation(
Transform3D::rotation(
ax as f64,
ay as f64,
az as f64,
@ -459,56 +458,56 @@ where
)
},
RotateX(theta) => {
let theta = euclid::Angle::radians(TWO_PI - theta.radians64());
Transform3D::create_rotation(1., 0., 0., theta)
let theta = euclid::Angle::radians(theta.radians64());
Transform3D::rotation(1., 0., 0., theta)
},
RotateY(theta) => {
let theta = euclid::Angle::radians(TWO_PI - theta.radians64());
Transform3D::create_rotation(0., 1., 0., theta)
let theta = euclid::Angle::radians(theta.radians64());
Transform3D::rotation(0., 1., 0., theta)
},
RotateZ(theta) | Rotate(theta) => {
let theta = euclid::Angle::radians(TWO_PI - theta.radians64());
Transform3D::create_rotation(0., 0., 1., theta)
let theta = euclid::Angle::radians(theta.radians64());
Transform3D::rotation(0., 0., 1., theta)
},
Perspective(ref d) => {
let m = create_perspective_matrix(d.to_pixel_length(None)?);
m.cast()
},
Scale3D(sx, sy, sz) => Transform3D::create_scale(sx.into(), sy.into(), sz.into()),
Scale(sx, sy) => Transform3D::create_scale(sx.into(), sy.into(), 1.),
ScaleX(s) => Transform3D::create_scale(s.into(), 1., 1.),
ScaleY(s) => Transform3D::create_scale(1., s.into(), 1.),
ScaleZ(s) => Transform3D::create_scale(1., 1., s.into()),
Scale3D(sx, sy, sz) => Transform3D::scale(sx.into(), sy.into(), sz.into()),
Scale(sx, sy) => Transform3D::scale(sx.into(), sy.into(), 1.),
ScaleX(s) => Transform3D::scale(s.into(), 1., 1.),
ScaleY(s) => Transform3D::scale(1., s.into(), 1.),
ScaleZ(s) => Transform3D::scale(1., 1., s.into()),
Translate3D(ref tx, ref ty, ref tz) => {
let tx = tx.to_pixel_length(reference_width)? as f64;
let ty = ty.to_pixel_length(reference_height)? as f64;
Transform3D::create_translation(tx, ty, tz.to_pixel_length(None)? as f64)
Transform3D::translation(tx, ty, tz.to_pixel_length(None)? as f64)
},
Translate(ref tx, ref ty) => {
let tx = tx.to_pixel_length(reference_width)? as f64;
let ty = ty.to_pixel_length(reference_height)? as f64;
Transform3D::create_translation(tx, ty, 0.)
Transform3D::translation(tx, ty, 0.)
},
TranslateX(ref t) => {
let t = t.to_pixel_length(reference_width)? as f64;
Transform3D::create_translation(t, 0., 0.)
Transform3D::translation(t, 0., 0.)
},
TranslateY(ref t) => {
let t = t.to_pixel_length(reference_height)? as f64;
Transform3D::create_translation(0., t, 0.)
Transform3D::translation(0., t, 0.)
},
TranslateZ(ref z) => {
Transform3D::create_translation(0., 0., z.to_pixel_length(None)? as f64)
Transform3D::translation(0., 0., z.to_pixel_length(None)? as f64)
},
Skew(theta_x, theta_y) => Transform3D::create_skew(
Skew(theta_x, theta_y) => Transform3D::skew(
euclid::Angle::radians(theta_x.radians64()),
euclid::Angle::radians(theta_y.radians64()),
),
SkewX(theta) => Transform3D::create_skew(
SkewX(theta) => Transform3D::skew(
euclid::Angle::radians(theta.radians64()),
euclid::Angle::radians(0.),
),
SkewY(theta) => Transform3D::create_skew(
SkewY(theta) => Transform3D::skew(
euclid::Angle::radians(0.),
euclid::Angle::radians(theta.radians64()),
),
@ -547,7 +546,7 @@ impl<T: ToMatrix> Transform<T> {
let cast_3d_transform = |m: Transform3D<f64>| -> Transform3D<CSSFloat> {
use std::{f32, f64};
let cast = |v: f64| { v.min(f32::MAX as f64).max(f32::MIN as f64) as f32 };
Transform3D::row_major(
Transform3D::new(
cast(m.m11), cast(m.m12), cast(m.m13), cast(m.m14),
cast(m.m21), cast(m.m22), cast(m.m23), cast(m.m24),
cast(m.m31), cast(m.m32), cast(m.m33), cast(m.m34),
@ -565,7 +564,7 @@ impl<T: ToMatrix> Transform<T> {
reference_box: Option<&Rect<ComputedLength>>,
) -> Result<(Transform3D<f64>, bool), ()> {
// We intentionally use Transform3D<f64> during computation to avoid error propagation
// because using f32 to compute triangle functions (e.g. in create_rotation()) is not
// because using f32 to compute triangle functions (e.g. in rotation()) is not
// accurate enough. In Gecko, we also use "double" to compute the triangle functions.
// Therefore, let's use Transform3D<f64> during matrix computation and cast it into f32
// in the end.
@ -575,7 +574,7 @@ impl<T: ToMatrix> Transform<T> {
for operation in &*self.0 {
let matrix = operation.to_3d_matrix(reference_box)?;
contain_3d |= operation.is_3d();
transform = transform.pre_transform(&matrix);
transform = matrix.then(&transform);
}
Ok((transform, contain_3d))
@ -595,7 +594,7 @@ pub fn create_perspective_matrix(d: CSSFloat) -> Transform3D<CSSFloat> {
if d <= 0.0 {
Transform3D::identity()
} else {
Transform3D::create_perspective(d)
Transform3D::perspective(d)
}
}

Просмотреть файл

@ -17,7 +17,7 @@ gecko = []
app_units = "0.7"
bitflags = "1.0"
cssparser = "0.27"
euclid = "0.20"
euclid = "0.22"
lazy_static = "1"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = "0.1"

Просмотреть файл

@ -6598,7 +6598,7 @@ pub extern "C" fn Servo_ParseTransformIntoMatrix(
Err(..) => return false,
};
*result = m.to_row_major_array();
*result = m.to_array();
*contain_3d = is_3d;
true
}

Просмотреть файл

@ -13,7 +13,7 @@ doctest = false
byteorder = "1.0"
app_units = "0.7"
cssparser = "0.27"
euclid = "0.20"
euclid = "0.22"
html5ever = "0.22"
parking_lot = "0.10"
rayon = "1"