@@ -16,11 +16,7 @@ use texturegl::TextureTarget::{TextureTarget2D, TextureTargetRectangle};
16
16
use tiling:: Tile ;
17
17
use platform:: surface:: NativeDisplay ;
18
18
19
- use euclid:: matrix:: Matrix4 ;
20
- use euclid:: Matrix2D ;
21
- use euclid:: point:: Point2D ;
22
- use euclid:: rect:: Rect ;
23
- use euclid:: size:: Size2D ;
19
+ use euclid:: { Matrix2D , Matrix4D , Point2D , Rect , Size2D } ;
24
20
use libc:: c_int;
25
21
use gleam:: gl;
26
22
use gleam:: gl:: { GLenum , GLfloat , GLint , GLsizei , GLuint } ;
@@ -68,8 +64,8 @@ impl TextureVertex {
68
64
const ORTHO_NEAR_PLANE : f32 = -1000000.0 ;
69
65
const ORTHO_FAR_PLANE : f32 = 1000000.0 ;
70
66
71
- fn create_ortho ( scene_size : & Size2D < f32 > ) -> Matrix4 {
72
- Matrix4 :: ortho ( 0.0 , scene_size. width , scene_size. height , 0.0 , ORTHO_NEAR_PLANE , ORTHO_FAR_PLANE )
67
+ fn create_ortho ( scene_size : & Size2D < f32 > ) -> Matrix4D < f32 > {
68
+ Matrix4D :: ortho ( 0.0 , scene_size. width , scene_size. height , 0.0 , ORTHO_NEAR_PLANE , ORTHO_FAR_PLANE )
73
69
}
74
70
75
71
static TEXTURE_FRAGMENT_SHADER_SOURCE : & ' static str = "
@@ -212,9 +208,9 @@ impl TextureProgram {
212
208
213
209
fn bind_uniforms_and_attributes ( & self ,
214
210
vertices : & [ TextureVertex ; 4 ] ,
215
- transform : & Matrix4 ,
216
- projection_matrix : & Matrix4 ,
217
- texture_space_transform : & Matrix4 ,
211
+ transform : & Matrix4D < f32 > ,
212
+ projection_matrix : & Matrix4D < f32 > ,
213
+ texture_space_transform : & Matrix4D < f32 > ,
218
214
buffers : & Buffers ,
219
215
opacity : f32 ) {
220
216
gl:: uniform_1i ( self . sampler_uniform , 0 ) ;
@@ -284,8 +280,8 @@ impl SolidColorProgram {
284
280
}
285
281
286
282
fn bind_uniforms_and_attributes_common ( & self ,
287
- transform : & Matrix4 ,
288
- projection_matrix : & Matrix4 ,
283
+ transform : & Matrix4D < f32 > ,
284
+ projection_matrix : & Matrix4D < f32 > ,
289
285
color : & Color ) {
290
286
gl:: uniform_matrix_4fv ( self . modelview_uniform , false , & transform. to_array ( ) ) ;
291
287
gl:: uniform_matrix_4fv ( self . projection_uniform , false , & projection_matrix. to_array ( ) ) ;
@@ -298,8 +294,8 @@ impl SolidColorProgram {
298
294
299
295
fn bind_uniforms_and_attributes_for_lines ( & self ,
300
296
vertices : & [ ColorVertex ; 5 ] ,
301
- transform : & Matrix4 ,
302
- projection_matrix : & Matrix4 ,
297
+ transform : & Matrix4D < f32 > ,
298
+ projection_matrix : & Matrix4D < f32 > ,
303
299
buffers : & Buffers ,
304
300
color : & Color ) {
305
301
self . bind_uniforms_and_attributes_common ( transform, projection_matrix, color) ;
@@ -311,8 +307,8 @@ impl SolidColorProgram {
311
307
312
308
fn bind_uniforms_and_attributes_for_quad ( & self ,
313
309
vertices : & [ ColorVertex ; 4 ] ,
314
- transform : & Matrix4 ,
315
- projection_matrix : & Matrix4 ,
310
+ transform : & Matrix4D < f32 > ,
311
+ projection_matrix : & Matrix4D < f32 > ,
316
312
buffers : & Buffers ,
317
313
color : & Color ) {
318
314
self . bind_uniforms_and_attributes_common ( transform, projection_matrix, color) ;
@@ -521,8 +517,8 @@ impl RenderContext {
521
517
522
518
fn bind_and_render_solid_quad ( & self ,
523
519
vertices : & [ ColorVertex ; 4 ] ,
524
- transform : & Matrix4 ,
525
- projection : & Matrix4 ,
520
+ transform : & Matrix4D < f32 > ,
521
+ projection : & Matrix4D < f32 > ,
526
522
color : & Color ) {
527
523
self . solid_color_program . enable_attribute_arrays ( ) ;
528
524
gl:: use_program ( self . solid_color_program . program . id ) ;
@@ -538,8 +534,8 @@ impl RenderContext {
538
534
fn bind_and_render_quad ( & self ,
539
535
vertices : & [ TextureVertex ; 4 ] ,
540
536
texture : & Texture ,
541
- transform : & Matrix4 ,
542
- projection_matrix : & Matrix4 ,
537
+ transform : & Matrix4D < f32 > ,
538
+ projection_matrix : & Matrix4D < f32 > ,
543
539
opacity : f32 ) {
544
540
let mut texture_coordinates_need_to_be_scaled_by_size = false ;
545
541
let program = match texture. target {
@@ -569,7 +565,7 @@ impl RenderContext {
569
565
// We calculate a transformation matrix for the texture coordinates
570
566
// which is useful for flipping the texture vertically or scaling the
571
567
// coordinates when dealing with GL_ARB_texture_rectangle.
572
- let mut texture_transform = Matrix4 :: identity ( ) ;
568
+ let mut texture_transform = Matrix4D :: identity ( ) ;
573
569
if texture. flip == VerticalFlip {
574
570
texture_transform = texture_transform. scale ( 1.0 , -1.0 , 1.0 ) ;
575
571
}
@@ -599,8 +595,8 @@ impl RenderContext {
599
595
600
596
pub fn bind_and_render_quad_lines ( & self ,
601
597
vertices : & [ ColorVertex ; 5 ] ,
602
- transform : & Matrix4 ,
603
- projection : & Matrix4 ,
598
+ transform : & Matrix4D < f32 > ,
599
+ projection : & Matrix4D < f32 > ,
604
600
color : & Color ,
605
601
line_thickness : usize ) {
606
602
self . solid_color_program . enable_attribute_arrays ( ) ;
@@ -617,8 +613,8 @@ impl RenderContext {
617
613
618
614
fn render_layer < T > ( & self ,
619
615
layer : Rc < Layer < T > > ,
620
- transform : & Matrix4 ,
621
- projection : & Matrix4 ,
616
+ transform : & Matrix4D < f32 > ,
617
+ projection : & Matrix4D < f32 > ,
622
618
clip_rect : Option < Rect < f32 > > ,
623
619
gfx_context : & NativeDisplay ) {
624
620
let ts = layer. transform_state . borrow ( ) ;
@@ -685,7 +681,7 @@ impl RenderContext {
685
681
ColorVertex :: new ( aabb. origin ) ,
686
682
] ;
687
683
self . bind_and_render_quad_lines ( & debug_vertices,
688
- & Matrix4 :: identity ( ) ,
684
+ & Matrix4D :: identity ( ) ,
689
685
projection,
690
686
& LAYER_AABB_DEBUG_BORDER_COLOR ,
691
687
LAYER_AABB_DEBUG_BORDER_THICKNESS ) ;
@@ -695,8 +691,8 @@ impl RenderContext {
695
691
fn render_tile ( & self ,
696
692
tile : & Tile ,
697
693
layer_origin : & Point2D < f32 > ,
698
- transform : & Matrix4 ,
699
- projection : & Matrix4 ,
694
+ transform : & Matrix4D < f32 > ,
695
+ projection : & Matrix4D < f32 > ,
700
696
clip_rect : Option < Rect < f32 > > ,
701
697
opacity : f32 ) {
702
698
if tile. texture . is_zero ( ) || !tile. bounds . is_some ( ) {
@@ -754,8 +750,8 @@ impl RenderContext {
754
750
755
751
fn render_3d_context < T > ( & self ,
756
752
context : & RenderContext3D < T > ,
757
- transform : & Matrix4 ,
758
- projection : & Matrix4 ,
753
+ transform : & Matrix4D < f32 > ,
754
+ projection : & Matrix4D < f32 > ,
759
755
gfx_context : & NativeDisplay ) {
760
756
if context. children . is_empty ( ) {
761
757
return ;
@@ -831,7 +827,7 @@ pub fn render_scene<T>(root_layer: Rc<Layer<T>>,
831
827
gl:: depth_func ( gl:: LEQUAL ) ;
832
828
833
829
// Set up the initial modelview matrix.
834
- let transform = Matrix4 :: identity ( ) . scale ( scene. scale . get ( ) , scene. scale . get ( ) , 1.0 ) ;
830
+ let transform = Matrix4D :: identity ( ) . scale ( scene. scale . get ( ) , scene. scale . get ( ) , 1.0 ) ;
835
831
let projection = create_ortho ( & scene. viewport . size . to_untyped ( ) ) ;
836
832
837
833
// Build the list of render items
0 commit comments