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

Don't calculate inner rectangles for non-axis-aligned clips #2171

Closed
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -10,7 +10,7 @@ use freelist::{FreeList, FreeListHandle, WeakFreeListHandle};
use gpu_cache::{GpuCache, GpuCacheHandle, ToGpuBlocks};
use prim_store::{ClipData, ImageMaskData};
use resource_cache::ResourceCache;
use util::{MaxRect, calculate_screen_bounding_rect, extract_inner_rect_safe};
use util::{MatrixHelpers, MaxRect, calculate_screen_bounding_rect, extract_inner_rect_safe};

pub type ClipStore = FreeList<ClipSources>;
pub type ClipSourcesHandle = FreeListHandle<ClipSources>;
@@ -251,8 +251,20 @@ impl ClipSources {
transform: &LayerToWorldTransform,
device_pixel_ratio: f32,
) -> (DeviceIntRect, Option<DeviceIntRect>) {
let screen_inner_rect =
calculate_screen_bounding_rect(transform, &self.local_inner_rect, device_pixel_ratio);
// If this translation isn't axis aligned or has a perspective component, don't try to
// calculate the inner rectangle. The rectangle that we produce would include potentially
// clipped screen area.
// TODO(mrobinson): We should eventually try to calculate an inner region or some inner
// rectangle so that we can do screen inner rectangle optimizations for these kind of
// cilps.
let can_calculate_inner_rect =
transform.preserves_2d_axis_alignment() && !transform.has_perspective_component();
let screen_inner_rect = if can_calculate_inner_rect {
calculate_screen_bounding_rect(transform, &self.local_inner_rect, device_pixel_ratio)
} else {
DeviceIntRect::zero()
};

let screen_outer_rect = self.local_outer_rect.map(|outer_rect|
calculate_screen_bounding_rect(transform, &outer_rect, device_pixel_ratio)
);
Binary file not shown.
@@ -0,0 +1,35 @@
# Test that transformed content is clipped properly by clips with a different transform.
---
root:
items:
-
bounds: [0, 0, 0, 0]
"clip-rect": [0, 0, 0, 0]
"clip-and-scroll": 0
type: "stacking-context"
transform: rotate(45) translate(200, 0)
items:
-
bounds: [0, 0, 300, 300]
"clip-rect": [0, 0, 300, 300]
"clip-and-scroll": 0
type: rect
color: red
-
bounds: [0, 0, 300, 300]
"clip-rect": [0, 0, 300, 300]
"clip-and-scroll": 0
type: clip
id: 5
-
bounds: [0, 0, 0, 0]
"clip-rect": [0, 0, 0, 0]
"clip-and-scroll": 5
type: "stacking-context"
transform: rotate(-45) translate(-300, 0)
items:
-
bounds: [0, 0, 1598, 1200]
"clip-rect": [0, 0, 1598, 1200]
type: rect
color: green
@@ -1,3 +1,4 @@
== clip-mode.yaml clip-mode.png
== clip-ellipse.yaml clip-ellipse.png
== clip-45-degree-rotation.yaml clip-45-degree-rotation-ref.png

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.