Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions webrender/src/tiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use renderer::ImageBufferKind;
use resource_cache::{GlyphFetchResult, ResourceCache};
use std::{cmp, usize, f32, i32};
use texture_allocator::GuillotineAllocator;
use util::{TransformedRect, TransformedRectKind};
use util::{MatrixHelpers, TransformedRect, TransformedRectKind};
use euclid::rect;

// Special sentinel value recognized by the shader. It is considered to be
// a dummy task that doesn't mask out anything.
Expand Down Expand Up @@ -1686,7 +1687,13 @@ impl PackedLayer {
screen_rect: &DeviceIntRect,
device_pixel_ratio: f32,
) -> Option<(TransformedRectKind, DeviceIntRect)> {
self.local_clip_rect = *local_rect;
self.local_clip_rect = if self.transform.has_perspective_component() {
// Given a very large rect which means any rect would be inside this rect.
// That is, nothing would be clipped.
rect(f32::MIN / 2.0, f32::MIN / 2.0, f32::MAX, f32::MAX)
} else {
*local_rect
};
let xf_rect = TransformedRect::new(local_rect, &self.transform, device_pixel_ratio);
xf_rect
.bounding_rect
Expand Down
5 changes: 5 additions & 0 deletions webrender/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub trait MatrixHelpers<Src, Dst> {
fn transform_rect(&self, rect: &TypedRect<f32, Src>) -> TypedRect<f32, Dst>;
fn is_identity(&self) -> bool;
fn preserves_2d_axis_alignment(&self) -> bool;
fn has_perspective_component(&self) -> bool;
fn inverse_project(&self, target: &TypedPoint2D<f32, Dst>) -> Option<TypedPoint2D<f32, Src>>;
fn inverse_rect_footprint(&self, rect: &TypedRect<f32, Dst>) -> TypedRect<f32, Src>;
}
Expand Down Expand Up @@ -66,6 +67,10 @@ impl<Src, Dst> MatrixHelpers<Src, Dst> for TypedTransform3D<f32, Src, Dst> {
col0 < 2 && col1 < 2 && row0 < 2 && row1 < 2
}

fn has_perspective_component(&self) -> bool {
self.m14 != 0.0 || self.m24 != 0.0 || self.m34 != 0.0 || self.m44 != 1.0
}

fn inverse_project(&self, target: &TypedPoint2D<f32, Dst>) -> Option<TypedPoint2D<f32, Src>> {
let m: TypedTransform2D<f32, Src, Dst>;
m = TypedTransform2D::column_major(
Expand Down
9 changes: 9 additions & 0 deletions wrench/reftests/split/perspective-clipping-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
root:
items:
- type: stacking-context
bounds: 0 0 1024 768
items:
- type: rect
bounds: 0 0 1024 768
color: green
22 changes: 22 additions & 0 deletions wrench/reftests/split/perspective-clipping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
root:
items:
- type: stacking-context
bounds: 0 0 1024 768
items:
- type: rect
bounds: 0 0 1024 768
color: red
- type: stacking-context
bounds: 0 0 1024 768
transform-style: preserve-3d
perspective: 300
items:
- type: stacking-context
bounds: 0 0 1024 768
# translate-Z(-300) scale(2)
transform: 2 0 0 0 0 2 0 0 0 0 2 0 0 0 -300 1
items:
- type: rect
bounds: 0 0 1024 768
color: green
1 change: 1 addition & 0 deletions wrench/reftests/split/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
== order.yaml order-ref.yaml
== nested.yaml nested-ref.yaml
== nested-preserve3d-crash.yaml nested-preserve3d-crash.yaml
== perspective-clipping.yaml perspective-clipping-ref.yaml
#== cross.yaml cross-ref.yaml #TODO: investigate sub-pixel differences