Skip to content

Conversation

@ahkohd
Copy link

@ahkohd ahkohd commented Oct 26, 2025

This PR 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:

div()
    .rounded(px(40.0))
    .smoothness(0.5)  // Squircle corners
    .bg(red())

img(path)
    .rounded(px(50.0))
    .smoothness(0.5)

Demo:
2025-10-26-155802_hyprshot

Linux/Wayland - WGSL demo

image

macOS - Metal demo

image

Windows - HLSL demo

Testing:

  • Linux/Wayland - WGSL ✅ Tested
  • macOS - Metal ✅ Tested
  • Windows - HLSL ✅ Tested
  • Various smoothness values (0.0, 0.25, 0.5, 0.75, 1.0)
  • Borders with smoothness
  • Large corner radii
  • Small corner radii

Release Notes:

  • N/A

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)
```
@cla-bot
Copy link

cla-bot bot commented Oct 26, 2025

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'.

@maxdeviant maxdeviant changed the title feat: add support for super ellipse corner rendering to GPUI elements gpui: Add support for super ellipse corner rendering Oct 26, 2025
@ahkohd
Copy link
Author

ahkohd commented Oct 26, 2025

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Oct 26, 2025

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
Copy link

cla-bot bot commented Oct 26, 2025

The cla-bot has been summoned, and re-checked this pull request!

@ahkohd
Copy link
Author

ahkohd commented Oct 26, 2025

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 26, 2025
@cla-bot
Copy link

cla-bot bot commented Oct 26, 2025

The cla-bot has been summoned, and re-checked this pull request!

@zed-industries-bot
Copy link

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against b3243e5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants