mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #6214 - glennw:parse-transforms, r=pcwalton
* 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. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6214) <!-- Reviewable:end -->
This commit is contained in:
commit
05212b702d
9 changed files with 527 additions and 183 deletions
|
@ -27,7 +27,7 @@ use azure::azure::AzFloat;
|
|||
use azure::azure_hl::{Color};
|
||||
|
||||
use collections::linked_list::{self, LinkedList};
|
||||
use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D};
|
||||
use geom::{Matrix2D, Point2D, Rect, SideOffsets2D, Size2D, Matrix4};
|
||||
use geom::approxeq::ApproxEq;
|
||||
use geom::num::Zero;
|
||||
use libc::uintptr_t;
|
||||
|
@ -254,9 +254,7 @@ pub struct StackingContext {
|
|||
pub blend_mode: mix_blend_mode::T,
|
||||
|
||||
/// A transform to be applied to this stacking context.
|
||||
///
|
||||
/// TODO(pcwalton): 3D transforms.
|
||||
pub transform: Matrix2D<AzFloat>,
|
||||
pub transform: Matrix4<AzFloat>,
|
||||
}
|
||||
|
||||
impl StackingContext {
|
||||
|
@ -266,7 +264,7 @@ impl StackingContext {
|
|||
bounds: &Rect<Au>,
|
||||
overflow: &Rect<Au>,
|
||||
z_index: i32,
|
||||
transform: &Matrix2D<AzFloat>,
|
||||
transform: &Matrix4<AzFloat>,
|
||||
filters: filter::T,
|
||||
blend_mode: mix_blend_mode::T,
|
||||
layer: Option<Arc<PaintLayer>>)
|
||||
|
@ -287,7 +285,7 @@ impl StackingContext {
|
|||
pub fn optimize_and_draw_into_context(&self,
|
||||
paint_context: &mut PaintContext,
|
||||
tile_bounds: &Rect<AzFloat>,
|
||||
transform: &Matrix2D<AzFloat>,
|
||||
transform: &Matrix4<AzFloat>,
|
||||
clip_rect: Option<&Rect<Au>>) {
|
||||
let transform = transform.mul(&self.transform);
|
||||
let temporary_draw_target =
|
||||
|
@ -320,7 +318,10 @@ impl StackingContext {
|
|||
|
||||
// Set up our clip rect and transform.
|
||||
let old_transform = paint_subcontext.draw_target.get_transform();
|
||||
paint_subcontext.draw_target.set_transform(&transform);
|
||||
let xform_2d = Matrix2D::new(transform.m11, transform.m12,
|
||||
transform.m21, transform.m22,
|
||||
transform.m41, transform.m42);
|
||||
paint_subcontext.draw_target.set_transform(&xform_2d);
|
||||
paint_subcontext.push_clip_if_applicable();
|
||||
|
||||
// Steps 1 and 2: Borders and background for the root.
|
||||
|
@ -342,7 +343,8 @@ impl StackingContext {
|
|||
positioned_kid.bounds
|
||||
.origin
|
||||
.y
|
||||
.to_nearest_px() as AzFloat);
|
||||
.to_nearest_px() as AzFloat,
|
||||
0.0);
|
||||
let new_tile_rect =
|
||||
self.compute_tile_rect_for_child_stacking_context(tile_bounds,
|
||||
&**positioned_kid);
|
||||
|
@ -390,7 +392,8 @@ impl StackingContext {
|
|||
positioned_kid.bounds
|
||||
.origin
|
||||
.y
|
||||
.to_nearest_px() as AzFloat);
|
||||
.to_nearest_px() as AzFloat,
|
||||
0.0);
|
||||
let new_tile_rect =
|
||||
self.compute_tile_rect_for_child_stacking_context(tile_bounds,
|
||||
&**positioned_kid);
|
||||
|
|
|
@ -12,7 +12,8 @@ use paint_context::PaintContext;
|
|||
|
||||
use azure::azure_hl::{SurfaceFormat, Color, DrawTarget, BackendType};
|
||||
use azure::AzFloat;
|
||||
use geom::matrix2d::Matrix2D;
|
||||
use geom::Matrix4;
|
||||
use geom::matrix::identity;
|
||||
use geom::point::Point2D;
|
||||
use geom::rect::Rect;
|
||||
use geom::size::Size2D;
|
||||
|
@ -621,10 +622,11 @@ impl WorkerThread {
|
|||
stacking_context.overflow.origin.y.to_f32_px()));
|
||||
|
||||
// Apply the translation to paint the tile we want.
|
||||
let matrix: Matrix2D<AzFloat> = Matrix2D::identity();
|
||||
let matrix = matrix.scale(scale as AzFloat, scale as AzFloat);
|
||||
let matrix: Matrix4<AzFloat> = identity();
|
||||
let matrix = matrix.scale(scale as AzFloat, scale as AzFloat, 1.0);
|
||||
let matrix = matrix.translate(-tile_bounds.origin.x as AzFloat,
|
||||
-tile_bounds.origin.y as AzFloat);
|
||||
-tile_bounds.origin.y as AzFloat,
|
||||
0.0);
|
||||
|
||||
// Clear the buffer.
|
||||
paint_context.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue