Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated Matrix4 with Matrix4D #267

Merged
merged 1 commit into from May 2, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Replace deprecated Matrix4 with Matrix4D

  • Loading branch information
UK992 committed May 1, 2016
commit 016e53f9540f28e462d9215a04512825e672c36f
@@ -5,7 +5,7 @@
use debug_font_data;
use device::{Device, ProgramId, VAOId, TextureId, VertexFormat};
use device::{TextureFilter, VertexUsageHint};
use euclid::{Matrix4, Point2D, Size2D, Rect};
use euclid::{Matrix4D, Point2D, Size2D, Rect};
use gleam::gl;
use internal_types::{ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE};
use internal_types::{DebugFontVertex, DebugColorVertex, RenderTargetMode, PackedColor};
@@ -171,12 +171,12 @@ impl DebugRenderer {
gl::blend_func_separate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA,
gl::ONE, gl::ONE);

let projection = Matrix4::ortho(0.0,
viewport_size.width as f32,
viewport_size.height as f32,
0.0,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);
let projection = Matrix4D::ortho(0.0,
viewport_size.width as f32,
viewport_size.height as f32,
0.0,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);

// Triangles
device.bind_program(self.color_program_id, &projection);
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use euclid::Matrix4;
use euclid::Matrix4D;
use fnv::FnvHasher;
use gleam::gl;
use internal_types::{PackedColor, PackedVertex, PackedVertexForQuad};
@@ -1038,7 +1038,7 @@ impl Device {

pub fn bind_program(&mut self,
program_id: ProgramId,
projection: &Matrix4) {
projection: &Matrix4D<f32>) {
debug_assert!(self.inside_frame);

if self.bound_program != program_id {
@@ -1496,7 +1496,7 @@ impl Device {

pub fn set_uniform_mat4_array(&self,
uniform: UniformLocation,
matrices: &[Matrix4]) {
matrices: &[Matrix4D<f32>]) {
debug_assert!(self.inside_frame);
let UniformLocation(location) = uniform;

@@ -1524,7 +1524,7 @@ impl Device {
gl::uniform_matrix_4fv(location, false, &floats);
}

fn set_uniforms(&self, program: &Program, transform: &Matrix4) {
fn set_uniforms(&self, program: &Program, transform: &Matrix4D<f32>) {
debug_assert!(self.inside_frame);
gl::uniform_matrix_4fv(program.u_transform, false, &transform.to_array());
}
@@ -5,7 +5,7 @@
use app_units::Au;
use batch::{MAX_MATRICES_PER_BATCH, OffsetParams};
use device::{TextureId, TextureFilter};
use euclid::{Rect, Point2D, Point3D, Point4D, Size2D, Matrix4};
use euclid::{Matrix4D, Point2D, Point3D, Point4D, Rect, Size2D};
use fnv::FnvHasher;
use geometry::ray_intersects_rect;
use internal_types::{AxisDirection, LowLevelFilterOp, CompositionOp, DrawListItemIndex};
@@ -98,8 +98,8 @@ struct FlattenInfo {
fixed_scroll_layer_id: ScrollLayerId,
offset_from_origin: Point2D<f32>,
offset_from_current_layer: Point2D<f32>,
transform: Matrix4,
perspective: Matrix4,
transform: Matrix4D<f32>,
perspective: Matrix4D<f32>,
}

#[derive(Debug)]
@@ -214,7 +214,7 @@ impl RenderTarget {

let layer = &layers[&draw_list_group.scroll_layer_id];
let mut matrix_palette =
vec![Matrix4::identity(); draw_list_group.draw_list_ids.len()];
vec![Matrix4D::identity(); draw_list_group.draw_list_ids.len()];
let mut offset_palette =
vec![OffsetParams::identity(); draw_list_group.draw_list_ids.len()];

@@ -344,7 +344,7 @@ impl RenderTarget {
op: CompositionOp,
texture_id: TextureId,
target: Rect<f32>,
transform: &Matrix4,
transform: &Matrix4D<f32>,
child_layer_index: ChildLayerIndex,
z_clear_needed: bool) {
// TODO(gw): Relax the restriction on batch breaks for FB reads
@@ -589,7 +589,7 @@ impl Frame {
pub fn get_scroll_layer(&self,
cursor: &Point2D<f32>,
scroll_layer_id: ScrollLayerId,
parent_transform: &Matrix4) -> Option<ScrollLayerId> {
parent_transform: &Matrix4D<f32>) -> Option<ScrollLayerId> {
self.layers.get(&scroll_layer_id).and_then(|layer| {
let transform = parent_transform.mul(&layer.local_transform);

@@ -642,7 +642,7 @@ impl Frame {

let scroll_layer_id = match self.get_scroll_layer(&cursor,
root_scroll_layer_id,
&Matrix4::identity()) {
&Matrix4D::identity()) {
Some(scroll_layer_id) => scroll_layer_id,
None => return,
};
@@ -741,7 +741,7 @@ impl Frame {
Layer::new(root_stacking_context.stacking_context.overflow.origin,
root_stacking_context.stacking_context.overflow.size,
root_pipeline.viewport_size,
Matrix4::identity()));
Matrix4D::identity()));

// Work around borrow check on resource cache
{
@@ -761,8 +761,8 @@ impl Frame {
actual_scroll_layer_id: root_scroll_layer_id,
fixed_scroll_layer_id: root_fixed_layer_id,
current_clip_rect: MAX_RECT,
transform: Matrix4::identity(),
perspective: Matrix4::identity(),
transform: Matrix4D::identity(),
perspective: Matrix4D::identity(),
};

let root_pipeline = SceneItemKind::Pipeline(root_pipeline);
@@ -971,20 +971,20 @@ impl Frame {
// Build world space transform
let origin = parent_info.offset_from_current_layer + stacking_context.bounds.origin;
let local_transform = if composition_operations.is_empty() {
Matrix4::identity().translate(origin.x, origin.y, 0.0)
.mul(&stacking_context.transform)
.translate(-origin.x, -origin.y, 0.0)
Matrix4D::identity().translate(origin.x, origin.y, 0.0)
.mul(&stacking_context.transform)
.translate(-origin.x, -origin.y, 0.0)
} else {
Matrix4::identity()
Matrix4D::identity()
};

let transform = parent_info.perspective.mul(&parent_info.transform)
.mul(&local_transform);

// Build world space perspective transform
let perspective = Matrix4::identity().translate(origin.x, origin.y, 0.0)
.mul(&stacking_context.perspective)
.translate(-origin.x, -origin.y, 0.0);
let perspective = Matrix4D::identity().translate(origin.x, origin.y, 0.0)
.mul(&stacking_context.perspective)
.translate(-origin.x, -origin.y, 0.0);

let mut info = FlattenInfo {
viewport_size: parent_info.viewport_size,
@@ -1022,8 +1022,8 @@ impl Frame {
info.default_scroll_layer_id = scroll_layer_id;
info.actual_scroll_layer_id = scroll_layer_id;
info.offset_from_current_layer = Point2D::zero();
info.transform = Matrix4::identity();
info.perspective = Matrix4::identity();
info.transform = Matrix4D::identity();
info.perspective = Matrix4D::identity();
info.current_clip_rect = Rect::new(Point2D::zero(),
stacking_context.overflow.size);
}
@@ -1084,9 +1084,9 @@ impl Frame {
Some(texture_id));

let local_transform =
Matrix4::identity().translate(origin.x, origin.y, 0.0)
.mul(&stacking_context.transform)
.translate(-origin.x, -origin.y, 0.0);
Matrix4D::identity().translate(origin.x, origin.y, 0.0)
.mul(&stacking_context.transform)
.translate(-origin.x, -origin.y, 0.0);
for composition_operation in composition_operations {
target.push_composite(composition_operation,
texture_id,
@@ -1149,7 +1149,7 @@ impl Frame {

fn update_layer_transform(&mut self,
layer_id: ScrollLayerId,
parent_transform: &Matrix4) {
parent_transform: &Matrix4D<f32>) {
// TODO(gw): This is an ugly borrow check workaround to clone these.
// Restructure this to avoid the clones!
let (layer_transform, layer_children) = {
@@ -1176,7 +1176,7 @@ impl Frame {

fn update_layer_transforms(&mut self) {
if let Some(root_scroll_layer_id) = self.root_scroll_layer_id {
self.update_layer_transform(root_scroll_layer_id, &Matrix4::identity());
self.update_layer_transform(root_scroll_layer_id, &Matrix4D::identity());
}

// Update any fixed layers
@@ -1191,7 +1191,7 @@ impl Frame {
}

for layer_id in fixed_layers {
self.update_layer_transform(layer_id, &Matrix4::identity());
self.update_layer_transform(layer_id, &Matrix4D::identity());
}
}

@@ -5,7 +5,7 @@
use app_units::Au;
use batch::{VertexBuffer, Batch, VertexBufferId, OffsetParams, TileParams};
use device::{TextureId, TextureFilter};
use euclid::{Matrix4, Point2D, Rect, Size2D};
use euclid::{Matrix4D, Point2D, Rect, Size2D};
use fnv::FnvHasher;
use freelist::{FreeListItem, FreeListItemId};
use num_traits::Zero;
@@ -452,12 +452,12 @@ pub struct DrawCall {
#[derive(Clone, Debug)]
pub struct OutputMask {
pub rect: Rect<f32>,
pub transform: Matrix4,
pub transform: Matrix4D<f32>,
}

impl OutputMask {
pub fn new(rect: Rect<f32>,
transform: Matrix4) -> OutputMask {
transform: Matrix4D<f32>) -> OutputMask {
OutputMask {
rect: rect,
transform: transform,
@@ -481,20 +481,20 @@ impl MaskRegion {

pub fn add_mask(&mut self,
rect: Rect<f32>,
transform: Matrix4) {
transform: Matrix4D<f32>) {
self.masks.push(OutputMask::new(rect, transform));
}
}

#[derive(Clone, Debug)]
pub struct BatchInfo {
pub matrix_palette: Vec<Matrix4>,
pub matrix_palette: Vec<Matrix4D<f32>>,
pub offset_palette: Vec<OffsetParams>,
pub regions: Vec<MaskRegion>,
}

impl BatchInfo {
pub fn new(matrix_palette: Vec<Matrix4>,
pub fn new(matrix_palette: Vec<Matrix4D<f32>>,
offset_palette: Vec<OffsetParams>) -> BatchInfo {
BatchInfo {
matrix_palette: matrix_palette,
@@ -507,7 +507,7 @@ impl BatchInfo {
#[derive(Debug, Clone)]
pub struct CompositeBatchJob {
pub rect: Rect<f32>,
pub transform: Matrix4,
pub transform: Matrix4D<f32>,
pub child_layer_index: ChildLayerIndex,
}

@@ -601,8 +601,8 @@ pub struct RenderTargetId(pub usize);
pub struct StackingContextInfo {
pub offset_from_layer: Point2D<f32>,
pub local_clip_rect: Rect<f32>,
pub transform: Matrix4,
pub perspective: Matrix4,
pub transform: Matrix4D<f32>,
pub perspective: Matrix4D<f32>,
pub z_clear_needed: bool,
}

@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use aabbtree::{AABBTree, NodeIndex};
use euclid::{Point2D, Rect, Size2D, Matrix4};
use euclid::{Matrix4D, Point2D, Rect, Size2D};
use internal_types::{BatchUpdate, BatchUpdateList, BatchUpdateOp};
use internal_types::{DrawListItemIndex, DrawListId, DrawListGroupId};
use spring::{DAMPING, STIFFNESS, Spring};
@@ -16,16 +16,16 @@ pub struct Layer {
pub viewport_size: Size2D<f32>,
pub layer_size: Size2D<f32>,
pub world_origin: Point2D<f32>,
pub local_transform: Matrix4,
pub world_transform: Matrix4,
pub local_transform: Matrix4D<f32>,
pub world_transform: Matrix4D<f32>,
pub children: Vec<ScrollLayerId>,
}

impl Layer {
pub fn new(world_origin: Point2D<f32>,
layer_size: Size2D<f32>,
viewport_size: Size2D<f32>,
transform: Matrix4) -> Layer {
transform: Matrix4D<f32>) -> Layer {
let rect = Rect::new(Point2D::zero(), layer_size);
let aabb_tree = AABBTree::new(1024.0, &rect);

@@ -6,7 +6,7 @@ use batch::{RasterBatch, VertexBufferId};
use debug_render::DebugRenderer;
use device::{Device, ProgramId, TextureId, UniformLocation, VertexFormat, GpuProfile};
use device::{TextureFilter, VAOId, VBOId, VertexUsageHint, FileWatcherHandler};
use euclid::{Rect, Matrix4, Point2D, Size2D};
use euclid::{Matrix4D, Point2D, Rect, Size2D};
use fnv::FnvHasher;
use gleam::gl;
use internal_types::{RendererFrame, ResultMsg, TextureUpdateOp, BatchUpdateOp, BatchUpdateList};
@@ -954,12 +954,12 @@ impl Renderer {
// Disable MSAA here for raster ops
self.enable_msaa(false);

let projection = Matrix4::ortho(0.0,
self.max_raster_op_size as f32,
0.0,
self.max_raster_op_size as f32,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);
let projection = Matrix4D::ortho(0.0,
self.max_raster_op_size as f32,
0.0,
self.max_raster_op_size as f32,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);

// All horizontal blurs must complete before anything else.
let mut remaining_batches = vec![];
@@ -994,7 +994,7 @@ impl Renderer {
color_texture_id: TextureId,
program_id: ProgramId,
blur_direction: Option<AxisDirection>,
projection: &Matrix4) {
projection: &Matrix4D<f32>) {
if !self.device.texture_has_alpha(target_texture_id) {
gl::enable(gl::BLEND);
gl::blend_func(gl::SRC_ALPHA, gl::ZERO);
@@ -1176,12 +1176,12 @@ impl Renderer {
gl::clear_color(clear_color.r, clear_color.g, clear_color.b, clear_color.a);
gl::clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT);

let projection = Matrix4::ortho(0.0,
layer.size.width,
layer.size.height,
0.0,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);
let projection = Matrix4D::ortho(0.0,
layer.size.width,
layer.size.height,
0.0,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);

for cmd in &layer.commands {
match cmd {
@@ -1240,7 +1240,7 @@ impl Renderer {

// If the mask is larger than the viewport / scissor rect
// then there is no need to draw it.
if mask.transform == Matrix4::identity() &&
if mask.transform == Matrix4D::identity() &&
mask.rect.contains_rect(&layer_rect) {
continue;
}
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use euclid::{Matrix4, Point2D, Rect, Size2D};
use euclid::{Matrix4D, Point2D, Rect, Size2D};
use internal_types::{RectColors};
use num_traits::Zero;
use time::precise_time_ns;
@@ -40,7 +40,7 @@ pub trait MatrixHelpers {
fn transform_rect(&self, rect: &Rect<f32>) -> Rect<f32>;
}

impl MatrixHelpers for Matrix4 {
impl MatrixHelpers for Matrix4D<f32> {
#[inline]
fn transform_rect(&self, rect: &Rect<f32>) -> Rect<f32> {
let top_left = self.transform_point(&rect.origin);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.