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 ;
65use euclid:: Angle ;
7- use euclid:: Point2D ;
8- use euclid:: Rect ;
9- use euclid:: RigidTransform3D ;
106use euclid:: Size2D ;
11- use euclid:: Transform3D ;
127use 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
1515use gleam:: gl;
1616use gleam:: gl:: GLsizei ;
@@ -48,7 +48,7 @@ const FAR: f32 = 100.0;
4848pub 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
9393impl 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