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

If the transform contains perspective component, the clip rect don't affect by this transform. #1693

Merged
merged 1 commit into from Oct 5, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

If the transform contains perspective component, skip the LCCR calcul…

…ation.
  • Loading branch information
mephisto41 committed Oct 4, 2017
commit 90aa4c281143f02dcc421d94b3d81bc5a517918c
@@ -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.
@@ -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
@@ -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>;
}
@@ -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(
@@ -0,0 +1,9 @@
---
root:
items:
- type: stacking-context
bounds: 0 0 1024 768
items:
- type: rect
bounds: 0 0 1024 768
color: green
@@ -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
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.