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

Ensure that non-local clips are defaulted to be in the clip mask. #2964

Merged
merged 1 commit into from Aug 10, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Ensure that non-local clips are defaulted to be in the clip mask.

If we can't calculate a local space rect for the clip, due to
perspective weirdness, just assume that it should be in the
clip mask, for now.
  • Loading branch information
gw3583 committed Aug 10, 2018
commit 5ec9cc505d20ba852d87494d9b275b1582dac382
@@ -556,52 +556,63 @@ impl ClipStore {
let node = &mut self.clip_nodes[node_info.node_index.0 as usize];

// Convert the prim rect into the clip nodes local space
if let Some(prim_rect) = node_info
let prim_rect = node_info
.conversion
.transform_from_prim_space(&current_local_clip_rect) {
.transform_from_prim_space(&current_local_clip_rect);

// See how this clip affects the prim region.
let clip_result = node.item.get_clip_result(&prim_rect);
// See how this clip affects the prim region.
let clip_result = match prim_rect {
Some(prim_rect) => {
node.item.get_clip_result(&prim_rect)
}
None => {
// If we can't get a local rect due to perspective
// weirdness, just assume that we need a clip mask
// for this case.
// TODO(gw): We can probably improve on this once
// we support local space picture raster.
ClipResult::Partial
}
};

match clip_result {
ClipResult::Accept => {
// Doesn't affect the primitive at all, so skip adding to list
}
ClipResult::Reject => {
// Completely clips the supplied prim rect
return None;
}
ClipResult::Partial => {
// Needs a mask -> add to clip node indices

// TODO(gw): Ensure this only runs once on each node per frame?
node.update(
gpu_cache,
resource_cache,
device_pixel_scale,
);

// Calculate some flags that are required for the segment
// building logic.
let flags = match node_info.conversion {
ClipSpaceConversion::Local => {
ClipNodeFlags::SAME_SPATIAL_NODE | ClipNodeFlags::SAME_COORD_SYSTEM
}
ClipSpaceConversion::Offset(..) => {
ClipNodeFlags::SAME_COORD_SYSTEM
}
ClipSpaceConversion::Transform(..) => {
has_clips_from_other_coordinate_systems = true;
ClipNodeFlags::empty()
}
};
match clip_result {
ClipResult::Accept => {
// Doesn't affect the primitive at all, so skip adding to list
}
ClipResult::Reject => {
// Completely clips the supplied prim rect
return None;
}
ClipResult::Partial => {
// Needs a mask -> add to clip node indices

// TODO(gw): Ensure this only runs once on each node per frame?
node.update(
gpu_cache,
resource_cache,
device_pixel_scale,
);

// Calculate some flags that are required for the segment
// building logic.
let flags = match node_info.conversion {
ClipSpaceConversion::Local => {
ClipNodeFlags::SAME_SPATIAL_NODE | ClipNodeFlags::SAME_COORD_SYSTEM
}
ClipSpaceConversion::Offset(..) => {
ClipNodeFlags::SAME_COORD_SYSTEM
}
ClipSpaceConversion::Transform(..) => {
has_clips_from_other_coordinate_systems = true;
ClipNodeFlags::empty()
}
};

// Store this in the index buffer for this clip chain instance.
self.clip_node_indices
.push(ClipNodeInstance::new(node_info.node_index, flags));
// Store this in the index buffer for this clip chain instance.
self.clip_node_indices
.push(ClipNodeInstance::new(node_info.node_index, flags));

has_non_root_coord_system |= node_info.has_non_root_coord_system;
}
has_non_root_coord_system |= node_info.has_non_root_coord_system;
}
}
}
Binary file not shown.
@@ -0,0 +1,22 @@
---
root:
items:
-
type: "scroll-frame"
id: 2
"content-size": [500, 100]
bounds: [0, 0, 500, 100]
items:
-
type: "stacking-context"
perspective: 125
items:
-
type: "stacking-context"
bounds: [0, 0, 250, 100]
transform: rotate-y(-54)
items:
-
bounds: [0, 0, 128, 128]
type: rect
color: red
@@ -18,3 +18,4 @@ platform(linux) fuzzy(11,4592) == screen-space-blur.yaml screen-space-blur.png
platform(linux,mac) == nested-rotate-x.yaml nested-rotate-x.png
platform(linux,mac) == nested-preserve-3d.yaml nested-preserve-3d.png
platform(linux,mac) == near-plane-clip.yaml near-plane-clip.png
platform(linux,mac) == perspective-mask.yaml perspective-mask.png
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.