Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intended as an upstream PR to
linebender/vello(opened on this fork because Devin lacks permission to open cross-fork PRs on the upstream repo). Upstream compare link: linebender/vello@main...DioxusLabs:vello:non-uniform-blurred-rect-radiiSummary
Extends the analytic blurred-rounded-rect paint in the sparse strips crates (
vello_cpu,vello_hybrid,vello_common) to support a different (scalar) radius per corner, as needed for CSS box shadows on boxes with non-uniformborder-radius. Elliptical corner radii remain unsupported.Breaking API change:
BlurredRoundedRectangle::radius: f32becomesradii: RoundedRectRadii, andfill_blurred_rounded_rectonvello_cpu::RenderContext/vello_hybrid::Scenetakesradii: RoundedRectRadiiinstead ofradius: f32(a uniform radius isr.into()).Approach
The distance-field part of Raph's approximation folds the rect into one quadrant via
abs(x)/abs(y)with a singler1/exponent. This generalizes cleanly: the encoder now precomputes(r1, exponent, recip_exponent)per corner, and the fine shaders select the active corner's parameters from the sign of the pixel's local coordinates. The field stays continuous across quadrant boundaries because along edge midlines the corner terms clamp to zero, makingdindependent ofr1there.The global normalization terms keep their existing form; the
scaleterm now uses the mean of the four corner radii (identical to before for uniform radii).vello_common: per-corner[f32; 4]fields (r1,exponent,recip_exponent) onEncodedBlurredRoundedRectangle, ordered[top-left, top-right, bottom-left, bottom-right], computed per corner inencode_into.vello_cpu: the SIMD fine painter selects per-lane corner parameters with two sign masks +select_f32x8;powfnow takes a per-lane exponent.vello_hybrid:GpuBlurredRoundedRectgrows from 5 to 6 texels (twovec4s of per-cornerr1/exponent;recip_exponentis computed in-shader);render.weslpicks the corner viaselect(0u, 1u, x >= 0.0) + select(0u, 2u, y >= 0.0).Uniform-radius rendering is unchanged (all existing snapshots pass bit-identically). New snapshot tests cover non-uniform radii (regular, large std-dev, rotated, and inverted), passing on both the CPU and hybrid/wgpu renderers, e.g.:
Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/f0e29f278fc544ebb7a91bfeed0bcc85
Requested by: @nicoburns