- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.8k
gpui: Add support for super ellipse corner rendering #41232
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
base: main
Are you sure you want to change the base?
Conversation
This commit adds support for squircle (superellipse) corner rendering
to GPUI elements using GPU-accelerated signed distance field (SDF)
calculations.
Key features:
- New `.smoothness()` method on all styled elements (div, img, etc.)
- Smoothness parameter: 0.0 (circle) to 0.5 (squircle) to 1.0 (square)
- GPU-based SDF rendering for high performance
- Cross-platform: WGSL (Linux), Metal (macOS), HLSL (Windows)
- Fully backward compatible (defaults to 0.0)
Implementation:
- Extended Style struct with optional smoothness field
- Added smoothness to PaintQuad for quad rendering
- Updated all three shader backends to use squircle_sdf() when
  smoothness > 0.0
- Reuses existing squircle SDF infrastructure from sprite rendering
- Proper struct alignment (168 bytes) for GPU compatibility
Usage:
```rust
div()
    .rounded(px(40.0))
    .smoothness(0.5)  // Squircle corners
    .bg(red())
img(path)
    .rounded(px(50.0))
    .smoothness(0.5)
```
    | We require contributors to sign our Contributor License Agreement, and we don't have @ahkohd on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. | 
| @cla-bot check | 
| We require contributors to sign our Contributor License Agreement, and we don't have @ahkohd on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. | 
| The cla-bot has been summoned, and re-checked this pull request! | 
| @cla-bot check | 
| The cla-bot has been summoned, and re-checked this pull request! | 
This PR adds support for squircle (superellipse) corner rendering to GPUI elements using GPU-accelerated signed distance field (SDF) calculations.
Key features:
.smoothness()method on all styled elements (div, img, etc.)Implementation:
Usage:
Demo:

Linux/Wayland - WGSL demo
macOS - Metal demo
Windows - HLSL demo
Testing:
Release Notes: