Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit a93dd1a

Browse files
committed
Merge branch 'master' into armv7
2 parents beced41 + d7a8a6a commit a93dd1a

File tree

4 files changed

+49
-54
lines changed

4 files changed

+49
-54
lines changed

src/layers.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use color::Color;
1111
use geometry::{DevicePixel, LayerPixel};
1212
use tiling::{Tile, TileGrid};
1313

14-
use euclid::matrix::Matrix4;
14+
use euclid::Matrix4D;
1515
use euclid::scale_factor::ScaleFactor;
1616
use euclid::size::{Size2D, TypedSize2D};
1717
use euclid::point::{Point2D, TypedPoint2D};
@@ -42,7 +42,7 @@ impl ContentAge {
4242
#[cfg_attr(feature = "plugins", derive(HeapSizeOf))]
4343
pub struct TransformState {
4444
/// Final, concatenated transform + perspective matrix for this layer
45-
pub final_transform: Matrix4,
45+
pub final_transform: Matrix4D<f32>,
4646

4747
/// If this is none, the rect was clipped and is not visible at all!
4848
pub screen_rect: Option<ScreenRect>,
@@ -57,7 +57,7 @@ pub struct TransformState {
5757
impl TransformState {
5858
fn new() -> TransformState {
5959
TransformState {
60-
final_transform: Matrix4::identity(),
60+
final_transform: Matrix4D::identity(),
6161
screen_rect: None,
6262
world_rect: Rect::zero(),
6363
has_transform: false,
@@ -67,8 +67,8 @@ impl TransformState {
6767

6868
pub struct Layer<T> {
6969
pub children: RefCell<Vec<Rc<Layer<T>>>>,
70-
pub transform: RefCell<Matrix4>,
71-
pub perspective: RefCell<Matrix4>,
70+
pub transform: RefCell<Matrix4D<f32>>,
71+
pub perspective: RefCell<Matrix4D<f32>>,
7272
pub tile_size: usize,
7373
pub extra_data: RefCell<T>,
7474
tile_grid: RefCell<TileGrid>,
@@ -108,8 +108,8 @@ impl<T> Layer<T> {
108108
-> Layer<T> {
109109
Layer {
110110
children: RefCell::new(vec!()),
111-
transform: RefCell::new(Matrix4::identity()),
112-
perspective: RefCell::new(Matrix4::identity()),
111+
transform: RefCell::new(Matrix4D::identity()),
112+
perspective: RefCell::new(Matrix4D::identity()),
113113
bounds: RefCell::new(bounds),
114114
tile_size: tile_size,
115115
extra_data: RefCell::new(data),
@@ -182,8 +182,8 @@ impl<T> Layer<T> {
182182
}
183183

184184
pub fn update_transform_state(&self,
185-
parent_transform: &Matrix4,
186-
parent_perspective: &Matrix4,
185+
parent_transform: &Matrix4D<f32>,
186+
parent_perspective: &Matrix4D<f32>,
187187
parent_origin: &Point2D<f32>) {
188188
let mut ts = self.transform_state.borrow_mut();
189189
let rect_without_scroll = self.bounds.borrow()
@@ -196,9 +196,9 @@ impl<T> Layer<T> {
196196
let y0 = ts.world_rect.origin.y;
197197

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

203203
ts.final_transform = parent_perspective.mul(&local_transform).mul(&parent_transform);
204204
ts.screen_rect = project_rect_to_screen(&ts.world_rect, &ts.final_transform);
@@ -208,12 +208,12 @@ impl<T> Layer<T> {
208208
// We should probably make the display list optimizer work with transforms!
209209
// This layer is part of a 3d context if its concatenated transform
210210
// is not identity, since 2d transforms don't get layers.
211-
ts.has_transform = ts.final_transform != Matrix4::identity();
211+
ts.has_transform = ts.final_transform != Matrix4D::identity();
212212

213213
// Build world space perspective transform
214-
let perspective_transform = Matrix4::identity().translate(x0, y0, 0.0)
215-
.mul(&*self.perspective.borrow())
216-
.translate(-x0, -y0, 0.0);
214+
let perspective_transform = Matrix4D::identity().translate(x0, y0, 0.0)
215+
.mul(&*self.perspective.borrow())
216+
.translate(-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: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ use texturegl::TextureTarget::{TextureTarget2D, TextureTargetRectangle};
1616
use tiling::Tile;
1717
use platform::surface::NativeDisplay;
1818

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};
2420
use libc::c_int;
2521
use gleam::gl;
2622
use gleam::gl::{GLenum, GLfloat, GLint, GLsizei, GLuint};
@@ -68,8 +64,8 @@ impl TextureVertex {
6864
const ORTHO_NEAR_PLANE: f32 = -1000000.0;
6965
const ORTHO_FAR_PLANE: f32 = 1000000.0;
7066

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)
7369
}
7470

7571
static TEXTURE_FRAGMENT_SHADER_SOURCE: &'static str = "
@@ -212,9 +208,9 @@ impl TextureProgram {
212208

213209
fn bind_uniforms_and_attributes(&self,
214210
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>,
218214
buffers: &Buffers,
219215
opacity: f32) {
220216
gl::uniform_1i(self.sampler_uniform, 0);
@@ -284,8 +280,8 @@ impl SolidColorProgram {
284280
}
285281

286282
fn bind_uniforms_and_attributes_common(&self,
287-
transform: &Matrix4,
288-
projection_matrix: &Matrix4,
283+
transform: &Matrix4D<f32>,
284+
projection_matrix: &Matrix4D<f32>,
289285
color: &Color) {
290286
gl::uniform_matrix_4fv(self.modelview_uniform, false, &transform.to_array());
291287
gl::uniform_matrix_4fv(self.projection_uniform, false, &projection_matrix.to_array());
@@ -298,8 +294,8 @@ impl SolidColorProgram {
298294

299295
fn bind_uniforms_and_attributes_for_lines(&self,
300296
vertices: &[ColorVertex; 5],
301-
transform: &Matrix4,
302-
projection_matrix: &Matrix4,
297+
transform: &Matrix4D<f32>,
298+
projection_matrix: &Matrix4D<f32>,
303299
buffers: &Buffers,
304300
color: &Color) {
305301
self.bind_uniforms_and_attributes_common(transform, projection_matrix, color);
@@ -311,8 +307,8 @@ impl SolidColorProgram {
311307

312308
fn bind_uniforms_and_attributes_for_quad(&self,
313309
vertices: &[ColorVertex; 4],
314-
transform: &Matrix4,
315-
projection_matrix: &Matrix4,
310+
transform: &Matrix4D<f32>,
311+
projection_matrix: &Matrix4D<f32>,
316312
buffers: &Buffers,
317313
color: &Color) {
318314
self.bind_uniforms_and_attributes_common(transform, projection_matrix, color);
@@ -521,8 +517,8 @@ impl RenderContext {
521517

522518
fn bind_and_render_solid_quad(&self,
523519
vertices: &[ColorVertex; 4],
524-
transform: &Matrix4,
525-
projection: &Matrix4,
520+
transform: &Matrix4D<f32>,
521+
projection: &Matrix4D<f32>,
526522
color: &Color) {
527523
self.solid_color_program.enable_attribute_arrays();
528524
gl::use_program(self.solid_color_program.program.id);
@@ -538,8 +534,8 @@ impl RenderContext {
538534
fn bind_and_render_quad(&self,
539535
vertices: &[TextureVertex; 4],
540536
texture: &Texture,
541-
transform: &Matrix4,
542-
projection_matrix: &Matrix4,
537+
transform: &Matrix4D<f32>,
538+
projection_matrix: &Matrix4D<f32>,
543539
opacity: f32) {
544540
let mut texture_coordinates_need_to_be_scaled_by_size = false;
545541
let program = match texture.target {
@@ -569,7 +565,7 @@ impl RenderContext {
569565
// We calculate a transformation matrix for the texture coordinates
570566
// which is useful for flipping the texture vertically or scaling the
571567
// coordinates when dealing with GL_ARB_texture_rectangle.
572-
let mut texture_transform = Matrix4::identity();
568+
let mut texture_transform = Matrix4D::identity();
573569
if texture.flip == VerticalFlip {
574570
texture_transform = texture_transform.scale(1.0, -1.0, 1.0);
575571
}
@@ -599,8 +595,8 @@ impl RenderContext {
599595

600596
pub fn bind_and_render_quad_lines(&self,
601597
vertices: &[ColorVertex; 5],
602-
transform: &Matrix4,
603-
projection: &Matrix4,
598+
transform: &Matrix4D<f32>,
599+
projection: &Matrix4D<f32>,
604600
color: &Color,
605601
line_thickness: usize) {
606602
self.solid_color_program.enable_attribute_arrays();
@@ -617,8 +613,8 @@ impl RenderContext {
617613

618614
fn render_layer<T>(&self,
619615
layer: Rc<Layer<T>>,
620-
transform: &Matrix4,
621-
projection: &Matrix4,
616+
transform: &Matrix4D<f32>,
617+
projection: &Matrix4D<f32>,
622618
clip_rect: Option<Rect<f32>>,
623619
gfx_context: &NativeDisplay) {
624620
let ts = layer.transform_state.borrow();
@@ -685,7 +681,7 @@ impl RenderContext {
685681
ColorVertex::new(aabb.origin),
686682
];
687683
self.bind_and_render_quad_lines(&debug_vertices,
688-
&Matrix4::identity(),
684+
&Matrix4D::identity(),
689685
projection,
690686
&LAYER_AABB_DEBUG_BORDER_COLOR,
691687
LAYER_AABB_DEBUG_BORDER_THICKNESS);
@@ -695,8 +691,8 @@ impl RenderContext {
695691
fn render_tile(&self,
696692
tile: &Tile,
697693
layer_origin: &Point2D<f32>,
698-
transform: &Matrix4,
699-
projection: &Matrix4,
694+
transform: &Matrix4D<f32>,
695+
projection: &Matrix4D<f32>,
700696
clip_rect: Option<Rect<f32>>,
701697
opacity: f32) {
702698
if tile.texture.is_zero() || !tile.bounds.is_some() {
@@ -754,8 +750,8 @@ impl RenderContext {
754750

755751
fn render_3d_context<T>(&self,
756752
context: &RenderContext3D<T>,
757-
transform: &Matrix4,
758-
projection: &Matrix4,
753+
transform: &Matrix4D<f32>,
754+
projection: &Matrix4D<f32>,
759755
gfx_context: &NativeDisplay) {
760756
if context.children.is_empty() {
761757
return;
@@ -831,7 +827,7 @@ pub fn render_scene<T>(root_layer: Rc<Layer<T>>,
831827
gl::depth_func(gl::LEQUAL);
832828

833829
// 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);
835831
let projection = create_ortho(&scene.viewport.size.to_untyped());
836832

837833
// Build the list of render items

src/tiling.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use texturegl::Texture;
1414
use util::project_rect_to_screen;
1515

1616
use euclid::length::Length;
17-
use euclid::matrix::Matrix4;
18-
use euclid::point::Point2D;
17+
use euclid::{Matrix4D, Point2D};
1918
use euclid::rect::{Rect, TypedRect};
2019
use euclid::size::{Size2D, TypedSize2D};
2120
use std::collections::HashMap;
@@ -161,7 +160,7 @@ impl TileGrid {
161160
test_rect: &Rect<f32>,
162161
current_layer_size: TypedSize2D<DevicePixel, f32>,
163162
layer_world_origin: &Point2D<f32>,
164-
layer_transform: &Matrix4) -> bool {
163+
layer_transform: &Matrix4D<f32>) -> bool {
165164
let tile_rect = self.get_rect_for_tile_index(*tile_index,
166165
current_layer_size);
167166
let tile_rect = tile_rect.as_f32()
@@ -182,7 +181,7 @@ impl TileGrid {
182181
pub fn mark_tiles_outside_of_rect_as_unused(&mut self,
183182
rect: TypedRect<DevicePixel, f32>,
184183
layer_world_origin: &Point2D<f32>,
185-
layer_transform: &Matrix4,
184+
layer_transform: &Matrix4D<f32>,
186185
current_layer_size: TypedSize2D<DevicePixel, f32>) {
187186
let mut tile_indexes_to_take = Vec::new();
188187

@@ -236,7 +235,7 @@ impl TileGrid {
236235
viewport: TypedRect<DevicePixel, f32>,
237236
current_layer_size: TypedSize2D<DevicePixel, f32>,
238237
layer_world_origin: &Point2D<f32>,
239-
layer_transform: &Matrix4,
238+
layer_transform: &Matrix4D<f32>,
240239
current_content_age: ContentAge)
241240
-> Vec<BufferRequest> {
242241
let mut buffer_requests = Vec::new();

src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Miscellaneous utilities.
1111

1212
use std::iter::repeat;
13-
use euclid::{Rect, Point2D, Point3D, Point4D, Matrix4, Size2D};
13+
use euclid::{Matrix4D, Point2D, Point3D, Point4D, Rect, Size2D};
1414
use std::f32;
1515

1616
const W_CLIPPING_PLANE: f32 = 0.00001;
@@ -89,7 +89,7 @@ fn clip_polygon_to_near_plane(clip_space_vertices: &[Point4D<f32>; 4])
8989
}
9090

9191
pub fn project_rect_to_screen(rect: &Rect<f32>,
92-
transform: &Matrix4) -> Option<ScreenRect> {
92+
transform: &Matrix4D<f32>) -> Option<ScreenRect> {
9393
let mut result = None;
9494

9595
let x0 = rect.min_x();

0 commit comments

Comments
 (0)