aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/Cargo.toml2
-rw-r--r--components/script/canvas_state.rs19
-rw-r--r--components/script/dom/dommatrixreadonly.rs77
-rw-r--r--components/script/dom/paintworkletglobalscope.rs2
-rw-r--r--components/script/dom/xrframe.rs4
-rw-r--r--components/script/dom/xrhittestresult.rs2
-rw-r--r--components/script/dom/xrray.rs4
-rw-r--r--components/script/dom/xrreferencespace.rs4
-rw-r--r--components/script/dom/xrrigidtransform.rs4
-rw-r--r--components/script/dom/xrview.rs4
-rw-r--r--components/script/dom/xrviewerpose.rs2
11 files changed, 54 insertions, 70 deletions
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);