diff options
Diffstat (limited to 'components')
44 files changed, 165 insertions, 169 deletions
diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index 1d51ab6e7ea..96872adeda8 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -21,7 +21,7 @@ byteorder = "1" canvas_traits = { path = "../canvas_traits" } crossbeam-channel = "0.4" cssparser = "0.29" -euclid = "0.20" +euclid = "0.22" font-kit = "0.11" fnv = "1.0" gfx = { path = "../gfx" } @@ -29,7 +29,7 @@ gleam = "0.12" half = "1" ipc-channel = "0.14" log = "0.4" -lyon_geom = "0.14" +lyon_geom = "1.0.4" num-traits = "0.2" pathfinder_geometry = "0.5" pixels = { path = "../pixels" } @@ -40,8 +40,8 @@ sparkle = "0.1.25" style = { path = "../style" } style_traits = { path = "../style_traits" } # NOTE: the sm-angle feature only enables angle on windows, not other platforms! -surfman = { version = "0.4", features = ["sm-angle","sm-angle-default"] } -surfman-chains = "0.6" +surfman = { version = "0.5", features = ["sm-angle","sm-angle-default"] } +surfman-chains = "0.7" surfman-chains-api = "0.2" time = { version = "0.1.41", optional = true } webrender = { git = "https://github.com/servo/webrender" } diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 875d8a23b2f..31c74f1e7a4 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -1213,9 +1213,9 @@ impl<'a> CanvasData<'a> { ), self.drawtarget.get_format(), ); - let matrix = Transform2D::identity() - .pre_translate(-source_rect.origin.to_vector().cast::<f32>()) - .pre_transform(&self.state.transform); + let matrix = self.state.transform.then( + &Transform2D::identity().pre_translate(-source_rect.origin.to_vector().cast::<f32>()), + ); draw_target.set_transform(&matrix); draw_target } @@ -1224,7 +1224,7 @@ impl<'a> CanvasData<'a> { where F: FnOnce(&mut dyn GenericDrawTarget), { - let shadow_src_rect = self.state.transform.transform_rect(rect); + let shadow_src_rect = self.state.transform.outer_transformed_rect(rect); let mut new_draw_target = self.create_draw_target_for_shadow(&shadow_src_rect); draw_shadow_source(&mut *new_draw_target); self.drawtarget.draw_surface_with_shadow( diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 1ef1bc54dab..da14d3b1673 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -445,8 +445,8 @@ impl GenericDrawTarget for raqote::DrawTarget { Repetition::NoRepeat, )); let transform = - raqote::Transform::create_translation(-dest.origin.x as f32, -dest.origin.y as f32) - .post_scale( + raqote::Transform::translation(-dest.origin.x as f32, -dest.origin.y as f32) + .then_scale( image.width as f32 / dest.size.width as f32, image.height as f32 / dest.size.height as f32, ); diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 423d799e27f..c764fc69b77 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -606,7 +606,7 @@ impl WebGLThread { let size = clamp_viewport(&gl, requested_size); if safe_size != size { - debug!("Resizing swap chain from {} to {}", safe_size, size); + debug!("Resizing swap chain from {:?} to {:?}", safe_size, size); swap_chain .resize(&mut self.device, &mut ctx, size.to_i32()) .map_err(|err| format!("Failed to resize swap chain: {:?}", err))?; diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 499d8c43399..8eb6aa9ee66 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -17,7 +17,7 @@ xr-profile = ["webxr-api/profile", "time"] [dependencies] crossbeam-channel = "0.4" cssparser = "0.29" -euclid = "0.20" +euclid = "0.22" ipc-channel = "0.14" lazy_static = "1" malloc_size_of = { path = "../malloc_size_of" } diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 972b3bdeffc..a89643b07f9 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -19,7 +19,7 @@ gl = ["gleam", "pixels"] canvas = { path = "../canvas" } crossbeam-channel = "0.4" embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" gfx_traits = { path = "../gfx_traits" } gleam = { version = "0.12", optional = true } image = "0.24" diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 831de6646f6..34660ea8338 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -15,7 +15,7 @@ path = "lib.rs" [dependencies] embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" getopts = "0.2.11" lazy_static = "1" log = "0.4" diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index 79f7a927f9d..bf9e4f579f0 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -19,7 +19,7 @@ compositing = { path = "../compositing" } crossbeam-channel = "0.4" devtools_traits = { path = "../devtools_traits" } embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" gfx = { path = "../gfx" } gfx_traits = { path = "../gfx_traits" } http = "0.2" diff --git a/components/geometry/Cargo.toml b/components/geometry/Cargo.toml index e1bbbadbea5..fe9195d96b5 100644 --- a/components/geometry/Cargo.toml +++ b/components/geometry/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] app_units = "0.7" -euclid = "0.20" +euclid = "0.22" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = "0.1" webrender_api = { git = "https://github.com/servo/webrender" } diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index b6c9a00df1d..dfb1888f37f 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -16,7 +16,7 @@ doctest = false [dependencies] app_units = "0.7" bitflags = "1.0" -euclid = "0.20" +euclid = "0.22" fnv = "1.0" fontsan = { git = "https://github.com/servo/fontsan" } gfx_traits = { path = "../gfx_traits" } diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 1c9cddfac1a..82956ad5eb7 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -18,7 +18,7 @@ atomic_refcell = "0.1" bitflags = "1.0" canvas_traits = { path = "../canvas_traits" } embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" fnv = "1.0" gfx = { path = "../gfx" } gfx_traits = { path = "../gfx_traits" } diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 5fb9f89a77d..7dc85fec830 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -834,7 +834,7 @@ impl Fragment { index, ); - if placement.tile_size.is_empty_or_negative() { + if placement.tile_size.is_empty() { return; } @@ -2321,7 +2321,7 @@ impl BlockFlow { .fragment .perspective_matrix(&border_box) .unwrap_or(LayoutTransform::identity()); - let transform = transform.pre_transform(&perspective).inverse(); + let transform = perspective.then(&transform).inverse(); let origin = border_box.origin; let transform_clip = |clip: Rect<Au>| { @@ -2346,7 +2346,7 @@ impl BlockFlow { clip.size.height.to_f32_px(), ); - let clip = transform.transform_rect(&clip).unwrap(); + let clip = transform.outer_transformed_rect(&clip).unwrap(); rect( Au::from_f32_px(clip.origin.x), diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs index 9495b2ab166..fddd3002166 100644 --- a/components/layout/display_list/webrender_helpers.rs +++ b/components/layout/display_list/webrender_helpers.rs @@ -204,7 +204,7 @@ impl DisplayItem { ), (Some(t), None) => (t, ReferenceFrameKind::Transform), (Some(t), Some(p)) => ( - t.pre_transform(&p), + p.then(&t), ReferenceFrameKind::Perspective { scrolling_relative_to: None, }, diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 074f0ad273a..01aa77043f1 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -355,10 +355,10 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static { .to_untyped(); let transformed_overflow = Overflow { paint: f32_rect_to_au_rect( - transform_2d.transform_rect(&au_rect_to_f32_rect(overflow.paint)), + transform_2d.outer_transformed_rect(&au_rect_to_f32_rect(overflow.paint)), ), scroll: f32_rect_to_au_rect( - transform_2d.transform_rect(&au_rect_to_f32_rect(overflow.scroll)), + transform_2d.outer_transformed_rect(&au_rect_to_f32_rect(overflow.scroll)), ), }; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 9b28aa5dfe9..843a7caebbd 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -3205,22 +3205,18 @@ impl Fragment { .to_f32_px(); let transform_origin_z = transform_origin.depth.px(); - let pre_transform = LayoutTransform::create_translation( + let pre_transform = LayoutTransform::translation( transform_origin_x, transform_origin_y, transform_origin_z, ); - let post_transform = LayoutTransform::create_translation( + let post_transform = LayoutTransform::translation( -transform_origin_x, -transform_origin_y, -transform_origin_z, ); - Some( - pre_transform - .pre_transform(&transform) - .pre_transform(&post_transform), - ) + Some(post_transform.then(&transform).then(&pre_transform)) } /// Returns the 4D matrix representing this fragment's perspective. @@ -3241,25 +3237,19 @@ impl Fragment { ) .to_layout(); - let pre_transform = LayoutTransform::create_translation( - perspective_origin.x, - perspective_origin.y, - 0.0, - ); - let post_transform = LayoutTransform::create_translation( - -perspective_origin.x, - -perspective_origin.y, - 0.0, - ); + let pre_transform = + LayoutTransform::translation(perspective_origin.x, perspective_origin.y, 0.0); + let post_transform = + LayoutTransform::translation(-perspective_origin.x, -perspective_origin.y, 0.0); let perspective_matrix = LayoutTransform::from_untyped( &transform::create_perspective_matrix(length.px()), ); Some( - pre_transform - .pre_transform(&perspective_matrix) - .pre_transform(&post_transform), + post_transform + .then(&perspective_matrix) + .then(&pre_transform), ) }, Perspective::None => None, diff --git a/components/layout/query.rs b/components/layout/query.rs index 10d652f3b12..ec3dd555ffc 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -15,7 +15,7 @@ use crate::opaque_node::OpaqueNodeMethods; use crate::sequential; use crate::wrapper::LayoutNodeLayoutData; use app_units::Au; -use euclid::default::{Point2D, Rect, Size2D, Vector2D}; +use euclid::default::{Box2D, Point2D, Rect, Size2D, Vector2D}; use euclid::Size2D as TypedSize2D; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; @@ -532,7 +532,35 @@ impl FragmentBorderBoxIterator for UnioningFragmentScrollAreaIterator { Point2D::new(left_margin, top_margin), Size2D::new(right_margin, bottom_margin), ); - self.union_rect = self.union_rect.union(&margin).union(&padding); + + // This is a workaround because euclid does not support unioning empty + // rectangles. + // TODO: The way that this iterator is calculating scroll area is very + // suspect and the code below is a workaround until it can be written + // in a better way. + self.union_rect = Box2D::new( + Point2D::new( + min( + padding.min_x(), + min(margin.min_x(), self.union_rect.min_x()), + ), + min( + padding.min_y(), + min(margin.min_y(), self.union_rect.min_y()), + ), + ), + Point2D::new( + max( + padding.max_x(), + max(margin.max_x(), self.union_rect.max_x()), + ), + max( + padding.max_y(), + max(margin.max_y(), self.union_rect.max_y()), + ), + ), + ) + .to_rect(); }, None => { self.level = Some(level); diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index dad13222760..57184c47ef4 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -18,7 +18,7 @@ atomic_refcell = "0.1.6" canvas_traits = { path = "../canvas_traits" } cssparser = "0.29" embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" fnv = "1.0" fxhash = "0.2" gfx = { path = "../gfx" } diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs index a76b607fa6d..7fa1fa770ae 100644 --- a/components/layout_2020/display_list/stacking_context.rs +++ b/components/layout_2020/display_list/stacking_context.rs @@ -802,7 +802,7 @@ impl BoxFragment { ), (Some(transform), None) => (transform, wr::ReferenceFrameKind::Transform), (Some(transform), Some(perspective)) => ( - transform.pre_transform(&perspective), + perspective.then(&transform), wr::ReferenceFrameKind::Perspective { scrolling_relative_to: None, }, @@ -861,11 +861,7 @@ impl BoxFragment { -transform_origin_z, ); - Some( - pre_transform - .pre_transform(&transform) - .pre_transform(&post_transform), - ) + Some(post_transform.then(&transform).then(&pre_transform)) } /// Returns the 4D matrix representing this fragment's perspective. @@ -903,9 +899,9 @@ impl BoxFragment { ); Some( - pre_transform - .pre_transform(&perspective_matrix) - .pre_transform(&post_transform), + post_transform + .then(&perspective_matrix) + .then(&pre_transform), ) }, Perspective::None => None, diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index d43884d4d9f..73939ab4872 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -15,7 +15,7 @@ app_units = "0.7" atomic_refcell = "0.1" crossbeam-channel = "0.4" embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" fnv = "1.0" fxhash = "0.2" gfx = { path = "../gfx" } diff --git a/components/layout_thread_2020/Cargo.toml b/components/layout_thread_2020/Cargo.toml index 387ac63786c..0ed1585c0a0 100644 --- a/components/layout_thread_2020/Cargo.toml +++ b/components/layout_thread_2020/Cargo.toml @@ -15,7 +15,7 @@ app_units = "0.7" atomic_refcell = "0.1" crossbeam-channel = "0.4" embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" fnv = "1.0" fxhash = "0.2" gfx = { path = "../gfx" } diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index d1968a188b6..d931d15a01c 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -32,7 +32,7 @@ app_units = "0.7" content-security-policy = { version = "0.4.0", features = ["serde"], optional = true } crossbeam-channel = { version = "0.4", optional = true } cssparser = "0.29" -euclid = "0.20" +euclid = "0.22" hashglobe = { path = "../hashglobe" } http = { version = "0.2", optional = true } hyper_serde = { version = "0.13", optional = true } diff --git a/components/media/Cargo.toml b/components/media/Cargo.toml index 6ef931ca4cc..a76b3ee754c 100644 --- a/components/media/Cargo.toml +++ b/components/media/Cargo.toml @@ -11,7 +11,7 @@ name = "media" path = "lib.rs" [dependencies] -euclid = "0.20" +euclid = "0.22" fnv = "1.0" ipc-channel = "0.14" lazy_static = "1" diff --git a/components/pixels/Cargo.toml b/components/pixels/Cargo.toml index cfd7d0e6051..ffcfaf54d49 100644 --- a/components/pixels/Cargo.toml +++ b/components/pixels/Cargo.toml @@ -11,7 +11,7 @@ name = "pixels" path = "lib.rs" [dependencies] -euclid = "0.20" +euclid = "0.22" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = "0.1" serde = { version = "1", features = ["derive"] } diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index b6aabb0d88d..1b6eece505b 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -51,7 +51,7 @@ domobject_derive = { path = "../domobject_derive" } embedder_traits = { path = "../embedder_traits" } encoding_rs = "0.8" enum-iterator = "0.3" -euclid = "0.20" +euclid = "0.22" fnv = "1.0" fxhash = "0.2" headers = "0.3" diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs index 0a6fba842e4..3dacd34ec48 100644 --- a/components/script/canvas_state.rs +++ b/components/script/canvas_state.rs @@ -1495,14 +1495,9 @@ impl CanvasState { let (sin, cos) = (angle.sin(), angle.cos()); let transform = self.state.borrow().transform; - self.state.borrow_mut().transform = transform.pre_transform(&Transform2D::row_major( - cos as f32, - sin as f32, - -sin as f32, - cos as f32, - 0.0, - 0.0, - )); + self.state.borrow_mut().transform = + Transform2D::new(cos as f32, sin as f32, -sin as f32, cos as f32, 0.0, 0.0) + .then(&transform); self.update_transform() } @@ -1530,9 +1525,9 @@ impl CanvasState { } let transform = self.state.borrow().transform; - self.state.borrow_mut().transform = transform.pre_transform(&Transform2D::row_major( - a as f32, b as f32, c as f32, d as f32, e as f32, f as f32, - )); + self.state.borrow_mut().transform = + Transform2D::new(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32) + .then(&transform); self.update_transform() } @@ -1558,7 +1553,7 @@ impl CanvasState { } self.state.borrow_mut().transform = - Transform2D::row_major(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32); + Transform2D::new(a as f32, b as f32, c as f32, d as f32, e as f32, f as f32); self.update_transform() } diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index ff724524909..84ef18fd8fc 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -181,7 +181,7 @@ impl DOMMatrixReadOnly { dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| { // Step 2. let mut matrix = self.matrix.borrow_mut(); - *matrix = other_matrix.post_transform(&matrix); + *matrix = other_matrix.then(&matrix); // Step 3. if !is2D { self.is2D.set(false); @@ -196,7 +196,7 @@ impl DOMMatrixReadOnly { dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| { // Step 2. let mut matrix = self.matrix.borrow_mut(); - *matrix = other_matrix.pre_transform(&matrix); + *matrix = matrix.then(&other_matrix); // Step 3. if !is2D { self.is2D.set(false); @@ -208,9 +208,9 @@ impl DOMMatrixReadOnly { // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself pub fn translate_self(&self, tx: f64, ty: f64, tz: f64) { // Step 1. - let translation = Transform3D::create_translation(tx, ty, tz); + let translation = Transform3D::translation(tx, ty, tz); let mut matrix = self.matrix.borrow_mut(); - *matrix = translation.post_transform(&matrix); + *matrix = translation.then(&matrix); // Step 2. if tz != 0.0 { self.is2D.set(false); @@ -234,9 +234,9 @@ impl DOMMatrixReadOnly { let scaleY = scaleY.unwrap_or(scaleX); // Step 3. { - let scale3D = Transform3D::create_scale(scaleX, scaleY, scaleZ); + let scale3D = Transform3D::scale(scaleX, scaleY, scaleZ); let mut matrix = self.matrix.borrow_mut(); - *matrix = scale3D.post_transform(&matrix); + *matrix = scale3D.then(&matrix); } // Step 4. originX = -originX; @@ -257,9 +257,9 @@ impl DOMMatrixReadOnly { self.translate_self(originX, originY, originZ); // Step 2. { - let scale3D = Transform3D::create_scale(scale, scale, scale); + let scale3D = Transform3D::scale(scale, scale, scale); let mut matrix = self.matrix.borrow_mut(); - *matrix = scale3D.post_transform(&matrix); + *matrix = scale3D.then(&matrix); } // Step 3. self.translate_self(-originX, -originY, -originZ); @@ -288,27 +288,21 @@ impl DOMMatrixReadOnly { } if rotZ != 0.0 { // Step 5. - // Beware: pass negated value until https://github.com/servo/euclid/issues/354 - let rotation = - Transform3D::create_rotation(0.0, 0.0, -1.0, Angle::radians(rotZ.to_radians())); + let rotation = Transform3D::rotation(0.0, 0.0, 1.0, Angle::radians(rotZ.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_transform(&matrix); + *matrix = rotation.then(&matrix); } if rotY != 0.0 { // Step 6. - // Beware: pass negated value until https://github.com/servo/euclid/issues/354 - let rotation = - Transform3D::create_rotation(0.0, -1.0, 0.0, Angle::radians(rotY.to_radians())); + let rotation = Transform3D::rotation(0.0, 1.0, 0.0, Angle::radians(rotY.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_transform(&matrix); + *matrix = rotation.then(&matrix); } if rotX != 0.0 { // Step 7. - // Beware: pass negated value until https://github.com/servo/euclid/issues/354 - let rotation = - Transform3D::create_rotation(-1.0, 0.0, 0.0, Angle::radians(rotX.to_radians())); + let rotation = Transform3D::rotation(1.0, 0.0, 0.0, Angle::radians(rotX.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_transform(&matrix); + *matrix = rotation.then(&matrix); } // Step 8 in DOMMatrix.RotateSelf } @@ -319,10 +313,9 @@ impl DOMMatrixReadOnly { if y != 0.0 || x < 0.0 { // Step 1. let rotZ = Angle::radians(f64::atan2(y, x)); - // Beware: pass negated value until https://github.com/servo/euclid/issues/354 - let rotation = Transform3D::create_rotation(0.0, 0.0, -1.0, rotZ); + let rotation = Transform3D::rotation(0.0, 0.0, 1.0, rotZ); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_transform(&matrix); + *matrix = rotation.then(&matrix); } // Step 2 in DOMMatrix.RotateFromVectorSelf } @@ -332,14 +325,10 @@ impl DOMMatrixReadOnly { // Step 1. let (norm_x, norm_y, norm_z) = normalize_point(x, y, z); // Beware: pass negated value until https://github.com/servo/euclid/issues/354 - let rotation = Transform3D::create_rotation( - -norm_x, - -norm_y, - -norm_z, - Angle::radians(angle.to_radians()), - ); + let rotation = + Transform3D::rotation(norm_x, norm_y, norm_z, Angle::radians(angle.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = rotation.post_transform(&matrix); + *matrix = rotation.then(&matrix); // Step 2. if x != 0.0 || y != 0.0 { self.is2D.set(false); @@ -350,18 +339,18 @@ impl DOMMatrixReadOnly { // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself pub fn skew_x_self(&self, sx: f64) { // Step 1. - let skew = Transform3D::create_skew(Angle::radians(sx.to_radians()), Angle::radians(0.0)); + let skew = Transform3D::skew(Angle::radians(sx.to_radians()), Angle::radians(0.0)); let mut matrix = self.matrix.borrow_mut(); - *matrix = skew.post_transform(&matrix); + *matrix = skew.then(&matrix); // Step 2 in DOMMatrix.SkewXSelf } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself pub fn skew_y_self(&self, sy: f64) { // Step 1. - let skew = Transform3D::create_skew(Angle::radians(0.0), Angle::radians(sy.to_radians())); + let skew = Transform3D::skew(Angle::radians(0.0), Angle::radians(sy.to_radians())); let mut matrix = self.matrix.borrow_mut(); - *matrix = skew.post_transform(&matrix); + *matrix = skew.then(&matrix); // Step 2 in DOMMatrix.SkewYSelf } @@ -372,7 +361,7 @@ impl DOMMatrixReadOnly { *matrix = matrix.inverse().unwrap_or_else(|| { // Step 2. self.is2D.set(false); - Transform3D::row_major( + Transform3D::new( f64::NAN, f64::NAN, f64::NAN, @@ -628,20 +617,20 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx fn FlipX(&self) -> DomRoot<DOMMatrix> { let is2D = self.is2D.get(); - let flip = Transform3D::row_major( + let flip = Transform3D::new( -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ); - let matrix = flip.post_transform(&self.matrix.borrow()); + let matrix = flip.then(&self.matrix.borrow()); DOMMatrix::new(&self.global(), is2D, matrix) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy fn FlipY(&self) -> DomRoot<DOMMatrix> { let is2D = self.is2D.get(); - let flip = Transform3D::row_major( + let flip = Transform3D::new( 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ); - let matrix = flip.post_transform(&self.matrix.borrow()); + let matrix = flip.then(&self.matrix.borrow()); DOMMatrix::new(&self.global(), is2D, matrix) } @@ -673,7 +662,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { let vec: Vec<f32> = self .matrix .borrow() - .to_row_major_array() + .to_array() .iter() .map(|&x| x as f32) .collect(); @@ -687,7 +676,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-tofloat64array #[allow(unsafe_code)] fn ToFloat64Array(&self, cx: JSContext) -> NonNull<JSObject> { - let arr = self.matrix.borrow().to_row_major_array(); + let arr = self.matrix.borrow().to_array(); unsafe { rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>()); let _ = Float64Array::create(*cx, CreateWith::Slice(&arr), array.handle_mut()).unwrap(); @@ -698,7 +687,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { // https://drafts.fxtf.org/geometry-1/#create-a-2d-matrix fn create_2d_matrix(entries: &[f64]) -> Transform3D<f64> { - Transform3D::row_major( + Transform3D::new( entries[0], entries[1], 0.0, 0.0, entries[2], entries[3], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, entries[4], entries[5], 0.0, 1.0, ) @@ -706,7 +695,7 @@ fn create_2d_matrix(entries: &[f64]) -> Transform3D<f64> { // https://drafts.fxtf.org/geometry-1/#create-a-3d-matrix fn create_3d_matrix(entries: &[f64]) -> Transform3D<f64> { - Transform3D::row_major( + Transform3D::new( entries[0], entries[1], entries[2], @@ -794,7 +783,7 @@ pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transfor if is_2d.is_none() { is_2d = Some(true); } - let matrix = Transform3D::row_major( + let matrix = Transform3D::new( m11, m12, dict.m13, dict.m14, m21, m22, dict.m23, dict.m24, dict.m31, dict.m32, dict.m33, dict.m34, m41, m42, dict.m43, dict.m44, ); diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index 888a6b16574..5a3b9af24df 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -248,7 +248,7 @@ impl PaintWorkletGlobalScope { arguments: &[String], ) -> DrawAPaintImageResult { debug!( - "Invoking a paint callback {}({},{}) at {}.", + "Invoking a paint callback {}({},{}) at {:?}.", name, size_in_px.width, size_in_px.height, device_pixel_ratio ); diff --git a/components/script/dom/xrframe.rs b/components/script/dom/xrframe.rs index 914d96333b5..5086626e256 100644 --- a/components/script/dom/xrframe.rs +++ b/components/script/dom/xrframe.rs @@ -130,7 +130,7 @@ impl XRFrameMethods for XRFrame { } else { return Ok(None); }; - let pose = relative_to.inverse().pre_transform(&space); + let pose = space.then(&relative_to.inverse()); Ok(Some(XRPose::new(&self.global(), pose))) } @@ -158,7 +158,7 @@ impl XRFrameMethods for XRFrame { } else { return Ok(None); }; - let pose = relative_to.inverse().pre_transform(&joint_frame.pose); + let pose = joint_frame.pose.then(&relative_to.inverse()); Ok(Some(XRJointPose::new( &self.global(), pose.cast_unit(), diff --git a/components/script/dom/xrhittestresult.rs b/components/script/dom/xrhittestresult.rs index be11f3dc7b6..9c7c36a24ef 100644 --- a/components/script/dom/xrhittestresult.rs +++ b/components/script/dom/xrhittestresult.rs @@ -45,7 +45,7 @@ impl XRHitTestResultMethods for XRHitTestResult { // https://immersive-web.github.io/hit-test/#dom-xrhittestresult-getpose fn GetPose(&self, base: &XRSpace) -> Option<DomRoot<XRPose>> { let base = self.frame.get_pose(base)?; - let pose = base.inverse().pre_transform(&self.result.space); + let pose = self.result.space.then(&base.inverse()); Some(XRPose::new(&self.global(), pose.cast_unit())) } } diff --git a/components/script/dom/xrray.rs b/components/script/dom/xrray.rs index 37262732c3a..cb5e29d9c62 100644 --- a/components/script/dom/xrray.rs +++ b/components/script/dom/xrray.rs @@ -136,10 +136,10 @@ impl XRRayMethods for XRRay { let translation = self.ray.origin; // Step 7 // According to the spec all matrices are column-major, - // however euclid uses row vectors so we use .to_row_major_array() + // however euclid uses row vectors so we use .to_array() let arr = RigidTransform3D::new(rotation, translation) .to_transform() - .to_row_major_array(); + .to_array(); create_typed_array(cx, &arr, &self.matrix); } NonNull::new(self.matrix.get()).unwrap() diff --git a/components/script/dom/xrreferencespace.rs b/components/script/dom/xrreferencespace.rs index fb4f890e766..1bd368c5834 100644 --- a/components/script/dom/xrreferencespace.rs +++ b/components/script/dom/xrreferencespace.rs @@ -73,7 +73,7 @@ impl XRReferenceSpace { impl XRReferenceSpaceMethods for XRReferenceSpace { /// https://immersive-web.github.io/webxr/#dom-xrreferencespace-getoffsetreferencespace fn GetOffsetReferenceSpace(&self, new: &XRRigidTransform) -> DomRoot<Self> { - let offset = self.offset.transform().pre_transform(&new.transform()); + let offset = new.transform().then(&self.offset.transform()); let offset = XRRigidTransform::new(&self.global(), offset); Self::new_offset( &self.global(), @@ -106,7 +106,7 @@ impl XRReferenceSpace { // offset is a transform from offset space to unoffset space, // we want a transform from unoffset space to native space, // which is pose * offset in column vector notation - Some(pose.pre_transform(&offset)) + Some(offset.then(&pose)) } /// Gets pose represented by this space diff --git a/components/script/dom/xrrigidtransform.rs b/components/script/dom/xrrigidtransform.rs index ac752d5a3dd..0488d4584eb 100644 --- a/components/script/dom/xrrigidtransform.rs +++ b/components/script/dom/xrrigidtransform.rs @@ -119,8 +119,8 @@ impl XRRigidTransformMethods for XRRigidTransform { if self.matrix.get().is_null() { let cx = self.global().get_cx(); // According to the spec all matrices are column-major, - // however euclid uses row vectors so we use .to_row_major_array() - let arr = self.transform.to_transform().to_row_major_array(); + // however euclid uses row vectors so we use .to_array() + let arr = self.transform.to_transform().to_array(); create_typed_array(cx, &arr, &self.matrix); } NonNull::new(self.matrix.get()).unwrap() diff --git a/components/script/dom/xrview.rs b/components/script/dom/xrview.rs index 55cac600f6b..a5972e26955 100644 --- a/components/script/dom/xrview.rs +++ b/components/script/dom/xrview.rs @@ -57,7 +57,7 @@ impl XRView { viewport_index: usize, to_base: &BaseTransform, ) -> DomRoot<XRView> { - let transform: RigidTransform3D<f32, V, BaseSpace> = to_base.pre_transform(&view.transform); + let transform: RigidTransform3D<f32, V, BaseSpace> = view.transform.then(&to_base); let transform = XRRigidTransform::new(global, cast_transform(transform)); reflect_dom_object( @@ -92,7 +92,7 @@ impl XRViewMethods for XRView { if self.proj.get().is_null() { let cx = self.global().get_cx(); // row_major since euclid uses row vectors - let proj = self.view.projection.to_row_major_array(); + let proj = self.view.projection.to_array(); create_typed_array(cx, &proj, &self.proj); } NonNull::new(self.proj.get()).unwrap() diff --git a/components/script/dom/xrviewerpose.rs b/components/script/dom/xrviewerpose.rs index 3d11185c809..7a2f4a6b441 100644 --- a/components/script/dom/xrviewerpose.rs +++ b/components/script/dom/xrviewerpose.rs @@ -150,7 +150,7 @@ impl XRViewerPose { }, }; let transform: RigidTransform3D<f32, Viewer, BaseSpace> = - to_base.pre_transform(&viewer_pose.transform); + viewer_pose.transform.then(&to_base); let transform = XRRigidTransform::new(global, cast_transform(transform)); let pose = reflect_dom_object(Box::new(XRViewerPose::new_inherited(&transform)), global); diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index be547d5619f..815d79d652c 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -15,7 +15,7 @@ app_units = "0.7" atomic_refcell = "0.1" canvas_traits = { path = "../canvas_traits" } crossbeam-channel = "0.4" -euclid = "0.20" +euclid = "0.22" fxhash = "0.2" gfx_traits = { path = "../gfx_traits" } html5ever = "0.26" diff --git a/components/script_traits/Cargo.toml b/components/script_traits/Cargo.toml index 209901ceba1..cd59c8da8a9 100644 --- a/components/script_traits/Cargo.toml +++ b/components/script_traits/Cargo.toml @@ -18,7 +18,7 @@ cookie = "0.12" crossbeam-channel = "0.4" devtools_traits = { path = "../devtools_traits" } embedder_traits = { path = "../embedder_traits" } -euclid = "0.20" +euclid = "0.22" gfx_traits = { path = "../gfx_traits" } headers = "0.3" http = "0.2" diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index d7155325919..791cf868287 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -50,7 +50,7 @@ devtools = { path = "../devtools" } devtools_traits = { path = "../devtools_traits" } embedder_traits = { path = "../embedder_traits" } env_logger = "0.8" -euclid = "0.20" +euclid = "0.22" gfx = { path = "../gfx" } gfx_traits = { path = "../gfx_traits" } gleam = "0.12" @@ -78,7 +78,7 @@ servo_url = { path = "../url" } sparkle = "0.1" style = { path = "../style", features = ["servo"] } style_traits = { path = "../style_traits", features = ["servo"] } -surfman = "0.4" +surfman = "0.5" webdriver_server = { path = "../webdriver_server", optional = true } webgpu = { path = "../webgpu" } webrender = { git = "https://github.com/servo/webrender" } diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 45765497481..1997f37efa3 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -38,7 +38,7 @@ byteorder = "1.0" cssparser = "0.29" derive_more = "0.99" encoding_rs = { version = "0.8", optional = true } -euclid = "0.20" +euclid = "0.22" fallible = { path = "../fallible" } fxhash = "0.2" hashglobe = { path = "../hashglobe" } diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index e5739b6ef56..4d1df3d58ea 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -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(), @@ -451,64 +451,62 @@ where let theta = TWO_PI - 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, - euclid::Angle::radians(theta), + -euclid::Angle::radians(theta), ) }, RotateX(theta) => { let theta = euclid::Angle::radians(TWO_PI - theta.radians64()); - Transform3D::create_rotation(1., 0., 0., theta) + Transform3D::rotation(1., 0., 0., -theta) }, RotateY(theta) => { let theta = euclid::Angle::radians(TWO_PI - theta.radians64()); - Transform3D::create_rotation(0., 1., 0., theta) + 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) + 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) - }, - Skew(theta_x, theta_y) => Transform3D::create_skew( + TranslateZ(ref z) => Transform3D::translation(0., 0., z.to_pixel_length(None)? as f64), + 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 +545,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 +563,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 +573,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 +593,7 @@ pub fn create_perspective_matrix(d: CSSFloat) -> Transform3D<CSSFloat> { if d <= 0.0 { Transform3D::identity() } else { - Transform3D::create_perspective(d) + Transform3D::perspective(d) } } diff --git a/components/style_traits/Cargo.toml b/components/style_traits/Cargo.toml index 693698b441b..88c0aab1757 100644 --- a/components/style_traits/Cargo.toml +++ b/components/style_traits/Cargo.toml @@ -17,7 +17,7 @@ gecko = [] app_units = "0.7" bitflags = "1.0" cssparser = "0.29" -euclid = "0.20" +euclid = "0.22" lazy_static = "1" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = "0.1" diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml index d7641f944a2..4b10e1ccd6c 100644 --- a/components/webdriver_server/Cargo.toml +++ b/components/webdriver_server/Cargo.toml @@ -15,7 +15,7 @@ base64 = "0.10" compositing = { path = "../compositing" } cookie = "0.12" crossbeam-channel = "0.4" -euclid = "0.20" +euclid = "0.22" headers = "0.3" http = "0.2" image = "0.24" diff --git a/components/webgpu/Cargo.toml b/components/webgpu/Cargo.toml index 725ede669e0..5d3ab22191f 100644 --- a/components/webgpu/Cargo.toml +++ b/components/webgpu/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] arrayvec = { version = "0.7", features = ["serde"] } -euclid = "0.20" +euclid = "0.22" ipc-channel = "0.14" log = "0.4" malloc_size_of = { path = "../malloc_size_of" } diff --git a/components/webrender_surfman/Cargo.toml b/components/webrender_surfman/Cargo.toml index 68b514db260..b69345374d2 100644 --- a/components/webrender_surfman/Cargo.toml +++ b/components/webrender_surfman/Cargo.toml @@ -11,7 +11,7 @@ name = "webrender_surfman" path = "lib.rs" [dependencies] -euclid = "0.20" -surfman = "0.4" -surfman-chains = "0.6" +euclid = "0.22" +surfman = "0.5" +surfman-chains = "0.7" diff --git a/components/webrender_traits/Cargo.toml b/components/webrender_traits/Cargo.toml index 2e59d884516..59732b9b93c 100644 --- a/components/webrender_traits/Cargo.toml +++ b/components/webrender_traits/Cargo.toml @@ -11,6 +11,6 @@ name = "webrender_traits" path = "lib.rs" [dependencies] -euclid = "0.20" +euclid = "0.22" webrender_api = { git = "https://github.com/servo/webrender" } |