mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
First step towards 3d transforms.
* Add parser support for 3d transforms. * Change ComputedMatrix to a representation that suits interpolation. * Switch stacking contexts to use 4x4 matrices. The transforms themselves are still converted to 2d and handled by azure for now, but this is a small standalone part that can be landed now to make it easier to review.
This commit is contained in:
parent
09f2977cc9
commit
f47ba6fd33
12 changed files with 530 additions and 186 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
use fragment::Fragment;
|
||||
|
||||
use geom::{Matrix2D, SideOffsets2D, Size2D};
|
||||
use geom::{Matrix4, SideOffsets2D, Size2D};
|
||||
use std::cmp::{max, min};
|
||||
use std::fmt;
|
||||
use style::computed_values::transform::ComputedMatrix;
|
||||
|
@ -426,21 +426,24 @@ pub fn padding_from_style(style: &ComputedValues, containing_block_inline_size:
|
|||
}
|
||||
|
||||
pub trait ToGfxMatrix {
|
||||
fn to_gfx_matrix(&self, containing_size: &Size2D<Au>) -> Matrix2D<f32>;
|
||||
fn to_gfx_matrix(&self, containing_size: &Size2D<Au>) -> Matrix4<f32>;
|
||||
}
|
||||
|
||||
impl ToGfxMatrix for ComputedMatrix {
|
||||
fn to_gfx_matrix(&self, containing_size: &Size2D<Au>) -> Matrix2D<f32> {
|
||||
Matrix2D::new(self.m11 as f32,
|
||||
self.m12 as f32,
|
||||
self.m21 as f32,
|
||||
self.m22 as f32,
|
||||
self.m31.to_au(containing_size.width).to_f32_px(),
|
||||
self.m32.to_au(containing_size.height).to_f32_px())
|
||||
fn to_gfx_matrix(&self, containing_size: &Size2D<Au>) -> Matrix4<f32> {
|
||||
Matrix4 {
|
||||
m11: self.m11 as f32, m12: self.m12 as f32, m13: self.m13 as f32, m14: self.m14 as f32,
|
||||
m21: self.m21 as f32, m22: self.m22 as f32, m23: self.m23 as f32, m24: self.m24 as f32,
|
||||
m31: self.m31 as f32, m32: self.m32 as f32, m33: self.m33 as f32, m34: self.m34 as f32,
|
||||
m41: self.m41.to_au(containing_size.width).to_f32_px(),
|
||||
m42: self.m42.to_au(containing_size.height).to_f32_px(),
|
||||
m43: self.m43 as f32,
|
||||
m44: self.m44 as f32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait ToAu {
|
||||
pub trait ToAu {
|
||||
fn to_au(&self, containing_size: Au) -> Au;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue