Skip to content

Commit 39ef630

Browse files
author
Peter
committed
Updated to for compatibility with Euclid PR servo#149
1 parent 614d62f commit 39ef630

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

src/layers.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ impl<T> Layer<T> {
196196
let y0 = ts.world_rect.origin.y;
197197

198198
// Build world space transform
199-
let local_transform = Matrix4D::identity().translate(x0, y0, 0.0)
200-
.mul(&*self.transform.borrow())
201-
.translate(-x0, -y0, 0.0);
199+
let local_transform = Matrix4D::identity().pre_translated(x0, y0, 0.0)
200+
.pre_mul(&*self.transform.borrow())
201+
.pre_translated(-x0, -y0, 0.0);
202202

203-
ts.final_transform = parent_perspective.mul(&local_transform).mul(&parent_transform);
203+
ts.final_transform = parent_perspective.pre_mul(&local_transform).pre_mul(&parent_transform);
204204
ts.screen_rect = project_rect_to_screen(&ts.world_rect, &ts.final_transform);
205205

206206
// TODO(gw): This is quite bogus. It's a hack to allow the paint task
@@ -211,9 +211,9 @@ impl<T> Layer<T> {
211211
ts.has_transform = ts.final_transform != Matrix4D::identity();
212212

213213
// Build world space perspective transform
214-
let perspective_transform = Matrix4D::identity().translate(x0, y0, 0.0)
215-
.mul(&*self.perspective.borrow())
216-
.translate(-x0, -y0, 0.0);
214+
let perspective_transform = Matrix4D::identity().pre_translated(x0, y0, 0.0)
215+
.pre_mul(&*self.perspective.borrow())
216+
.pre_translated(-x0, -y0, 0.0);
217217

218218
for child in self.children().iter() {
219219
child.update_transform_state(&ts.final_transform,

src/rendergl.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ impl TextureProgram {
214214
buffers: &Buffers,
215215
opacity: f32) {
216216
gl::uniform_1i(self.sampler_uniform, 0);
217-
gl::uniform_matrix_4fv(self.modelview_uniform, false, &transform.to_array());
218-
gl::uniform_matrix_4fv(self.projection_uniform, false, &projection_matrix.to_array());
217+
gl::uniform_matrix_4fv(self.modelview_uniform, false, &transform.to_row_major_array());
218+
gl::uniform_matrix_4fv(self.projection_uniform, false, &projection_matrix.to_row_major_array());
219219

220220
let vertex_size = mem::size_of::<TextureVertex>();
221221

@@ -226,7 +226,7 @@ impl TextureProgram {
226226

227227
gl::uniform_matrix_4fv(self.texture_space_transform_uniform,
228228
false,
229-
&texture_space_transform.to_array());
229+
&texture_space_transform.to_row_major_array());
230230

231231
gl::uniform_1f(self.opacity_uniform, opacity);
232232
}
@@ -283,8 +283,8 @@ impl SolidColorProgram {
283283
transform: &Matrix4D<f32>,
284284
projection_matrix: &Matrix4D<f32>,
285285
color: &Color) {
286-
gl::uniform_matrix_4fv(self.modelview_uniform, false, &transform.to_array());
287-
gl::uniform_matrix_4fv(self.projection_uniform, false, &projection_matrix.to_array());
286+
gl::uniform_matrix_4fv(self.modelview_uniform, false, &transform.to_row_major_array());
287+
gl::uniform_matrix_4fv(self.projection_uniform, false, &projection_matrix.to_row_major_array());
288288
gl::uniform_4f(self.color_uniform,
289289
color.r as GLfloat,
290290
color.g as GLfloat,
@@ -567,15 +567,15 @@ impl RenderContext {
567567
// coordinates when dealing with GL_ARB_texture_rectangle.
568568
let mut texture_transform = Matrix4D::identity();
569569
if texture.flip == VerticalFlip {
570-
texture_transform = texture_transform.scale(1.0, -1.0, 1.0);
570+
texture_transform = texture_transform.pre_scaled(1.0, -1.0, 1.0);
571571
}
572572
if texture_coordinates_need_to_be_scaled_by_size {
573-
texture_transform = texture_transform.scale(texture.size.width as f32,
574-
texture.size.height as f32,
575-
1.0);
573+
texture_transform = texture_transform.pre_scaled(texture.size.width as f32,
574+
texture.size.height as f32,
575+
1.0);
576576
}
577577
if texture.flip == VerticalFlip {
578-
texture_transform = texture_transform.translate(0.0, -1.0, 0.0);
578+
texture_transform = texture_transform.pre_translated(0.0, -1.0, 0.0);
579579
}
580580

581581
program.bind_uniforms_and_attributes(vertices,
@@ -618,7 +618,7 @@ impl RenderContext {
618618
clip_rect: Option<Rect<f32>>,
619619
gfx_context: &NativeDisplay) {
620620
let ts = layer.transform_state.borrow();
621-
let transform = transform.mul(&ts.final_transform);
621+
let transform = transform.pre_mul(&ts.final_transform);
622622
let background_color = *layer.background_color.borrow();
623623

624624
// Create native textures for this layer
@@ -784,11 +784,12 @@ impl RenderContext {
784784
} else {
785785
// If the transform is 2d, invert it and back-transform
786786
// the clip rect into world space.
787-
let transform = m.invert();
788-
let xform_2d = Matrix2D::new(transform.m11, transform.m12,
789-
transform.m21, transform.m22,
790-
transform.m41, transform.m42);
791-
Some(xform_2d.transform_rect(&cr))
787+
m.inverse().map(|transform| {
788+
let xform_2d = Matrix2D::row_major(transform.m11, transform.m12,
789+
transform.m21, transform.m22,
790+
transform.m41, transform.m42);
791+
xform_2d.transform_rect(&cr)
792+
})
792793
}
793794

794795
});
@@ -827,7 +828,7 @@ pub fn render_scene<T>(root_layer: Rc<Layer<T>>,
827828
gl::depth_func(gl::LEQUAL);
828829

829830
// Set up the initial modelview matrix.
830-
let transform = Matrix4D::identity().scale(scene.scale.get(), scene.scale.get(), 1.0);
831+
let transform = Matrix4D::identity().pre_scaled(scene.scale.get(), scene.scale.get(), 1.0);
831832
let projection = create_ortho(&scene.viewport.size.to_untyped());
832833

833834
// Build the list of render items

src/tiling.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl TileGrid {
164164
layer_transform: &Matrix4D<f32>) -> bool {
165165
let tile_rect = self.get_rect_for_tile_index(*tile_index,
166166
current_layer_size);
167-
let tile_rect = tile_rect.as_f32()
167+
let tile_rect = tile_rect.to_f32()
168168
.to_untyped()
169169
.translate(layer_world_origin);
170170

@@ -225,7 +225,7 @@ impl TileGrid {
225225
tile.content_age_of_pending_buffer = Some(current_content_age);
226226

227227
Some(BufferRequest::new(tile_rect.to_untyped(),
228-
tile_rect.as_f32().to_untyped(),
228+
tile_rect.to_f32().to_untyped(),
229229
current_content_age))
230230
}
231231

0 commit comments

Comments
 (0)