Skip to content
This repository was archived by the owner on Feb 16, 2025. It is now read-only.

Commit b5a4b93

Browse files
author
bors-servo
authored
Auto merge of #24 - servo:revert-euclid, r=emilio
Revert euclid None
2 parents 6603553 + 4925ba7 commit b5a4b93

11 files changed

Lines changed: 57 additions & 57 deletions

File tree

webxr-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ path = "lib.rs"
2222
ipc = ["serde", "typetag", "ipc-channel", "euclid/serde"]
2323

2424
[dependencies]
25-
euclid = "0.20"
25+
euclid = "0.19"
2626
gleam = "0.6"
2727
ipc-channel = { version = "0.11", optional = true }
2828
serde = { version = "1.0", optional = true }

webxr-api/device.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use crate::SessionMode;
1616
use crate::Viewport;
1717
use crate::Views;
1818

19-
use euclid::default::Size2D as UntypedSize2D;
20-
use euclid::RigidTransform3D;
2119
use euclid::Size2D;
20+
use euclid::TypedRigidTransform3D;
21+
use euclid::TypedSize2D;
2222

2323
use gleam::gl::GLsync;
2424

@@ -31,19 +31,19 @@ pub trait Discovery: 'static {
3131
/// A trait for using an XR device
3232
pub trait Device: 'static {
3333
/// The transform from native coordinates to the floor.
34-
fn floor_transform(&self) -> RigidTransform3D<f32, Native, Floor>;
34+
fn floor_transform(&self) -> TypedRigidTransform3D<f32, Native, Floor>;
3535

3636
/// The transforms from viewer coordinates to the eyes, and their associated viewports.
3737
fn views(&self) -> Views;
3838

3939
/// A resolution large enough to contain all the viewports.
4040
/// https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution
41-
fn recommended_framebuffer_resolution(&self) -> Size2D<i32, Viewport> {
41+
fn recommended_framebuffer_resolution(&self) -> TypedSize2D<i32, Viewport> {
4242
let viewport = match self.views() {
4343
Views::Mono(view) => view.viewport,
4444
Views::Stereo(left, right) => left.viewport.union(&right.viewport),
4545
};
46-
Size2D::new(viewport.max_x(), viewport.max_y())
46+
TypedSize2D::new(viewport.max_x(), viewport.max_y())
4747
}
4848

4949
/// This method should block waiting for the next frame,
@@ -53,7 +53,7 @@ pub trait Device: 'static {
5353
/// This method should render a GL texture to the device.
5454
/// While this method is being called, the device has unique access
5555
/// to the texture. The texture should be sync'd using glWaitSync before being used.
56-
fn render_animation_frame(&mut self, texture_id: u32, size: UntypedSize2D<i32>, sync: GLsync);
56+
fn render_animation_frame(&mut self, texture_id: u32, size: Size2D<i32>, sync: GLsync);
5757

5858
/// Inputs registered with the device on initialization. More may be added, which
5959
/// should be communicated through a yet-undecided event mechanism

webxr-api/frame.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::InputFrame;
66
use crate::Native;
77
use crate::Viewer;
88

9-
use euclid::RigidTransform3D;
9+
use euclid::TypedRigidTransform3D;
1010

1111
/// The per-frame data that is provided by the device.
1212
/// https://www.w3.org/TR/webxr/#xrframe
@@ -18,7 +18,7 @@ pub struct Frame {
1818
///
1919
/// This is equivalent to the pose of the viewer in native coordinates.
2020
/// This is the inverse of the view matrix.
21-
pub transform: RigidTransform3D<f32, Viewer, Native>,
21+
pub transform: TypedRigidTransform3D<f32, Viewer, Native>,
2222

2323
/// Frame information for each connected input source
2424
pub inputs: Vec<InputFrame>,

webxr-api/input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::Input;
66
use crate::Native;
77

8-
use euclid::RigidTransform3D;
8+
use euclid::TypedRigidTransform3D;
99

1010
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
1111
#[cfg_attr(feature = "ipc", derive(serde::Serialize, serde::Deserialize))]
@@ -39,5 +39,5 @@ pub struct InputSource {
3939
#[cfg_attr(feature = "ipc", derive(serde::Serialize, serde::Deserialize))]
4040
pub struct InputFrame {
4141
pub id: InputId,
42-
pub target_ray_origin: RigidTransform3D<f32, Input, Native>,
42+
pub target_ray_origin: TypedRigidTransform3D<f32, Input, Native>,
4343
}

webxr-api/mock.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::TargetRayMode;
1616
use crate::Viewer;
1717
use crate::Views;
1818

19-
use euclid::RigidTransform3D;
19+
use euclid::TypedRigidTransform3D;
2020

2121
#[cfg(feature = "ipc")]
2222
use serde::{Deserialize, Serialize};
@@ -33,17 +33,17 @@ pub trait MockDiscovery: 'static {
3333
#[derive(Clone, Debug)]
3434
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
3535
pub struct MockDeviceInit {
36-
pub floor_origin: RigidTransform3D<f32, Floor, Native>,
36+
pub floor_origin: TypedRigidTransform3D<f32, Floor, Native>,
3737
pub supports_immersive: bool,
3838
pub supports_unbounded: bool,
39-
pub viewer_origin: RigidTransform3D<f32, Viewer, Native>,
39+
pub viewer_origin: TypedRigidTransform3D<f32, Viewer, Native>,
4040
pub views: Views,
4141
}
4242

4343
#[derive(Debug)]
4444
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
4545
pub enum MockDeviceMsg {
46-
SetViewerOrigin(RigidTransform3D<f32, Viewer, Native>),
46+
SetViewerOrigin(TypedRigidTransform3D<f32, Viewer, Native>),
4747
SetViews(Views),
4848
AddInputSource(MockInputInit),
4949
MessageInputSource(InputId, MockInputMsg),
@@ -56,15 +56,15 @@ pub enum MockDeviceMsg {
5656
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
5757
pub struct MockInputInit {
5858
pub source: InputSource,
59-
pub pointer_origin: RigidTransform3D<f32, Input, Native>,
59+
pub pointer_origin: TypedRigidTransform3D<f32, Input, Native>,
6060
}
6161

6262
#[derive(Debug)]
6363
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
6464
pub enum MockInputMsg {
6565
SetHandedness(Handedness),
6666
SetTargetRayMode(TargetRayMode),
67-
SetPointerOrigin(RigidTransform3D<f32, Input, Native>),
67+
SetPointerOrigin(TypedRigidTransform3D<f32, Input, Native>),
6868
Disconnect,
6969
Reconnect,
7070
}

webxr-api/session.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::Viewport;
1515
use crate::Views;
1616
use crate::WebGLExternalImageApi;
1717

18-
use euclid::RigidTransform3D;
19-
use euclid::Size2D;
18+
use euclid::TypedRigidTransform3D;
19+
use euclid::TypedSize2D;
2020

2121
use std::thread;
2222
use std::time::Duration;
@@ -60,15 +60,15 @@ enum SessionMsg {
6060
/// https://www.w3.org/TR/webxr/#xrsession-interface
6161
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
6262
pub struct Session {
63-
floor_transform: RigidTransform3D<f32, Native, Floor>,
63+
floor_transform: TypedRigidTransform3D<f32, Native, Floor>,
6464
views: Views,
65-
resolution: Size2D<i32, Viewport>,
65+
resolution: TypedSize2D<i32, Viewport>,
6666
sender: Sender<SessionMsg>,
6767
initial_inputs: Vec<InputSource>,
6868
}
6969

7070
impl Session {
71-
pub fn floor_transform(&self) -> RigidTransform3D<f32, Native, Floor> {
71+
pub fn floor_transform(&self) -> TypedRigidTransform3D<f32, Native, Floor> {
7272
self.floor_transform.clone()
7373
}
7474

@@ -80,7 +80,7 @@ impl Session {
8080
self.views.clone()
8181
}
8282

83-
pub fn recommended_framebuffer_resolution(&self) -> Size2D<i32, Viewport> {
83+
pub fn recommended_framebuffer_resolution(&self) -> TypedSize2D<i32, Viewport> {
8484
self.resolution
8585
}
8686

webxr-api/view.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
//! This crate uses `euclid`'s typed units, and exposes different coordinate spaces.
66
7-
use euclid::Rect;
8-
use euclid::RigidTransform3D;
9-
use euclid::Transform3D;
7+
use euclid::TypedRect;
8+
use euclid::TypedRigidTransform3D;
9+
use euclid::TypedTransform3D;
1010

1111
#[cfg(feature = "ipc")]
1212
use serde::{Deserialize, Serialize};
@@ -68,9 +68,9 @@ pub enum Input {}
6868
#[derive(Clone, Debug)]
6969
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
7070
pub struct View<Eye> {
71-
pub transform: RigidTransform3D<f32, Viewer, Eye>,
72-
pub projection: Transform3D<f32, Eye, Display>,
73-
pub viewport: Rect<i32, Viewport>,
71+
pub transform: TypedRigidTransform3D<f32, Viewer, Eye>,
72+
pub projection: TypedTransform3D<f32, Eye, Display>,
73+
pub viewport: TypedRect<i32, Viewport>,
7474
}
7575

7676
/// Whether a device is mono or stereo, and the views it supports.

webxr-api/webgl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! The WebGL functionality needed by WebXR.
66
77
use crate::Error;
8-
use euclid::default::Size2D;
8+
use euclid::Size2D;
99
use gleam::gl::GLsync;
1010
use gleam::gl::GLuint;
1111

webxr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ipc = ["webxr-api/ipc"]
2525

2626
[dependencies]
2727
webxr-api = { path = "../webxr-api" }
28-
euclid = "0.20"
28+
euclid = "0.19"
2929
gleam = "0.6"
3030
glutin = { version = "0.21", optional = true }
3131
log = "0.4"

webxr/glwindow/mod.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44

5-
use euclid::default::Size2D as UntypedSize2D;
65
use euclid::Angle;
7-
use euclid::Point2D;
8-
use euclid::Rect;
9-
use euclid::RigidTransform3D;
106
use euclid::Size2D;
11-
use euclid::Transform3D;
127
use euclid::Trig;
13-
use euclid::Vector3D;
8+
use euclid::TypedPoint2D;
9+
use euclid::TypedRect;
10+
use euclid::TypedRigidTransform3D;
11+
use euclid::TypedSize2D;
12+
use euclid::TypedTransform3D;
13+
use euclid::TypedVector3D;
1414

1515
use gleam::gl;
1616
use gleam::gl::GLsizei;
@@ -48,7 +48,7 @@ const FAR: f32 = 100.0;
4848
pub trait GlWindow {
4949
fn make_current(&mut self);
5050
fn swap_buffers(&mut self);
51-
fn size(&self) -> UntypedSize2D<GLsizei>;
51+
fn size(&self) -> Size2D<GLsizei>;
5252
fn new_window(&self) -> Result<Box<dyn GlWindow>, ()>;
5353
}
5454

@@ -91,9 +91,9 @@ pub struct GlWindowDevice {
9191
}
9292

9393
impl Device for GlWindowDevice {
94-
fn floor_transform(&self) -> RigidTransform3D<f32, Native, Floor> {
95-
let translation = Vector3D::new(-HEIGHT, 0.0, 0.0);
96-
RigidTransform3D::from_translation(translation)
94+
fn floor_transform(&self) -> TypedRigidTransform3D<f32, Native, Floor> {
95+
let translation = TypedVector3D::new(-HEIGHT, 0.0, 0.0);
96+
TypedRigidTransform3D::from_translation(translation)
9797
}
9898

9999
fn views(&self) -> Views {
@@ -104,15 +104,15 @@ impl Device for GlWindowDevice {
104104

105105
fn wait_for_animation_frame(&mut self) -> Frame {
106106
self.window.swap_buffers();
107-
let translation = Vector3D::new(0.0, 0.0, -5.0);
108-
let transform = RigidTransform3D::from_translation(translation);
107+
let translation = TypedVector3D::new(0.0, 0.0, -5.0);
108+
let transform = TypedRigidTransform3D::from_translation(translation);
109109
Frame {
110110
transform,
111111
inputs: vec![],
112112
}
113113
}
114114

115-
fn render_animation_frame(&mut self, texture_id: u32, size: UntypedSize2D<i32>, sync: GLsync) {
115+
fn render_animation_frame(&mut self, texture_id: u32, size: Size2D<i32>, sync: GLsync) {
116116
self.window.make_current();
117117

118118
let width = size.width as GLsizei;
@@ -190,26 +190,26 @@ impl GlWindowDevice {
190190

191191
fn view<Eye>(&self, is_right: bool) -> View<Eye> {
192192
let window_size = self.window.size();
193-
let viewport_size = Size2D::new(window_size.width / 2, window_size.height);
193+
let viewport_size = TypedSize2D::new(window_size.width / 2, window_size.height);
194194
let viewport_x_origin = if is_right { viewport_size.width } else { 0 };
195-
let viewport_origin = Point2D::new(viewport_x_origin, 0);
196-
let viewport = Rect::new(viewport_origin, viewport_size);
195+
let viewport_origin = TypedPoint2D::new(viewport_x_origin, 0);
196+
let viewport = TypedRect::new(viewport_origin, viewport_size);
197197
let projection = self.perspective(NEAR, FAR);
198198
let eye_distance = if is_right {
199199
EYE_DISTANCE
200200
} else {
201201
-EYE_DISTANCE
202202
};
203-
let translation = Vector3D::new(eye_distance, 0.0, 0.0);
204-
let transform = RigidTransform3D::from_translation(translation);
203+
let translation = TypedVector3D::new(eye_distance, 0.0, 0.0);
204+
let transform = TypedRigidTransform3D::from_translation(translation);
205205
View {
206206
transform,
207207
projection,
208208
viewport,
209209
}
210210
}
211211

212-
fn perspective<Eye>(&self, near: f32, far: f32) -> Transform3D<f32, Eye, Display> {
212+
fn perspective<Eye>(&self, near: f32, far: f32) -> TypedTransform3D<f32, Eye, Display> {
213213
// https://github.com/toji/gl-matrix/blob/bd3307196563fbb331b40fc6ebecbbfcc2a4722c/src/mat4.js#L1271
214214
let size = self.window.size();
215215
let width = size.width as f32;
@@ -223,7 +223,7 @@ impl GlWindowDevice {
223223
{
224224
#[rustfmt::skip]
225225
// Sigh, row-major vs column-major
226-
return Transform3D::row_major(
226+
return TypedTransform3D::row_major(
227227
f / aspect, 0.0, 0.0, 0.0,
228228
0.0, f, 0.0, 0.0,
229229
0.0, 0.0, (far + near) * nf, -1.0,

0 commit comments

Comments
 (0)