gpui: Support rounded content masks#5
Conversation
Summary by CodeRabbit
WalkthroughThis change extends ChangesRounded Content Masks
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant StyleOverflowMask
participant WindowContentMask
participant WgpuRenderer
participant GPUShaders
StyleOverflowMask->>WindowContentMask: create rounded ContentMask
WindowContentMask->>WgpuRenderer: localize complete mask
WgpuRenderer->>GPUShaders: upload mask geometry
GPUShaders->>GPUShaders: apply rounded mask alpha
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/gpui/src/window.rs`:
- Around line 1743-1772: The ContentMask::intersect method currently retains
only one rounded geometry when rounded bounds partially overlap, allowing pixels
outside the descendant clip. Update ContentMask and its intersect logic to
represent and enforce both rounded constraints, or their exact intersection,
while preserving rectangular intersection behavior; add a test covering
partially overlapping ancestor and child rounded masks, including the child’s
excluded corner.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0163f453-daf6-45b5-8a53-e0ae030ac7ae
⛔ Files ignored due to path filters (1)
crates/gpui_windows/src/shaders.hlslis excluded by!**/*.hlsl
📒 Files selected for processing (10)
crates/gpui/src/elements/list.rscrates/gpui/src/elements/uniform_list.rscrates/gpui/src/scene.rscrates/gpui/src/style.rscrates/gpui/src/window.rscrates/gpui_macos/src/metal_renderer.rscrates/gpui_macos/src/shaders.metalcrates/gpui_wgpu/src/shaders.wgslcrates/gpui_wgpu/src/wgpu_renderer.rscrates/gpui_windows/src/directx_renderer.rs
| /// Intersect the content mask with the given content mask. | ||
| /// | ||
| /// Rectangular bounds intersect exactly. When both masks are rounded, the inner clip is kept | ||
| /// if its complete rectangular bounds fit inside the ancestor's rounded geometry. Otherwise, | ||
| /// the existing ancestor clip (`other`) is retained; content masks currently carry one rounded | ||
| /// geometry. | ||
| pub fn intersect(&self, other: &Self) -> Self { | ||
| let bounds = self.bounds.intersect(&other.bounds); | ||
| ContentMask { bounds } | ||
| let self_is_rounded = self.corner_radii != Corners::default(); | ||
| let other_is_rounded = other.corner_radii != Corners::default(); | ||
| let (rounded_bounds, corner_radii) = if self_is_rounded | ||
| && (!other_is_rounded | ||
| || rounded_rect_contains_bounds( | ||
| other.rounded_bounds, | ||
| other.corner_radii, | ||
| self.bounds, | ||
| )) { | ||
| (self.rounded_bounds, self.corner_radii) | ||
| } else if other_is_rounded { | ||
| (other.rounded_bounds, other.corner_radii) | ||
| } else { | ||
| (bounds, Corners::default()) | ||
| }; | ||
|
|
||
| ContentMask { | ||
| bounds, | ||
| rounded_bounds, | ||
| corner_radii, | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve both rounded clips when their bounds partially overlap.
intersect drops the descendant's rounded geometry whenever its full rectangle is not inside the ancestor’s rounded shape. For an ancestor (0,0,100×100,r=20) and child (0,0,50×50,r=10), point (49,1) passes the retained ancestor mask but is outside the child’s top-right corner. Rendering and hit testing therefore leak outside the descendant clip.
Represent both rounded constraints (or their exact intersection) and add a partially overlapping test.
Also applies to: 6290-6305
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/gpui/src/window.rs` around lines 1743 - 1772, The
ContentMask::intersect method currently retains only one rounded geometry when
rounded bounds partially overlap, allowing pixels outside the descendant clip.
Update ContentMask and its intersect logic to represent and enforce both rounded
constraints, or their exact intersection, while preserving rectangular
intersection behavior; add a test covering partially overlapping ancestor and
child rounded masks, including the child’s excluded corner.
Summary
ContentMaskwith rounded clip geometry while preserving rectangular clip boundsVerification
cargo check --manifest-path /Volumes/Portkey/Projects/gpui/Cargo.toml -p gpui -p gpui_wgpu -p gpui_macos --all-targetsPlatform notes
lib.exetoolchain is not installed on this host