Skip to content

Feature/blur backdrop - #956

Merged
nat3Github merged 8 commits into
david-vanderson:mainfrom
nat3Github:feature/blur-backdrop
Aug 21, 2026
Merged

Feature/blur backdrop#956
nat3Github merged 8 commits into
david-vanderson:mainfrom
nat3Github:feature/blur-backdrop

Conversation

@nat3Github

@nat3Github nat3Github commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

adds backdrop blur to dvui.
image

i tested in in the web browser (the serve-web-app is great for that!), sdl3, raylib, sdl2
its worth to note that the blur in my testing looked different for sdl2 then the other backends.

sdl2 skews/compresses a quad's UV mapping rather than clamping the edge resulting in a visually different blur.

#923

…ndow

captureEnd() used to strip the bracketed content's queued RenderCommands
out of the subwindow's render queue and replay them immediately, out of
order, during build. That's fine at top level, but when BlurBackdrop is
nested inside another floating window (as in the Blur Backdrop showcase
tab), the enclosing window's own background fill is also a queued
command - queued earlier but only actually drawn later, during
Window.endRendering. Paint order became: bracketed content drawn early,
then the enclosing background drawn late right over it - the
checkerboard vanishing behind the window on every dirty frame (every
tick of a slider drag), self-healing only once idle.

Fix: leave the commands in the subwindow's normal queue instead of
stripping/replaying them, so they draw exactly once, in their natural
order, via the same endRendering pass as everything else.

Also slider continuity/fractional radius tweaks in the demo, and a
live-backend regression test (reads raw SDL_Renderer pixels directly,
bypassing dvui.Picture, which redirects into its own offscreen target
and can't see this ordering bug) that drives a real drag and asserts
the checkerboard stays visible on every frame.
It reads pixels via SDL_RenderReadPixels, which the testing backend
used in CI's -Dbackend=testing job doesn't support.
Its pixel readback uses the SDL3 SDL_RenderReadPixels signature,
which differs from SDL2's (rect/pixels/pitch args vs surface return).
@david-vanderson

Copy link
Copy Markdown
Owner

Sorry I am traveling right now, will get to this in a few days, thanks!

@david-vanderson

Copy link
Copy Markdown
Owner

I love this!

  • I'm surprised by the lifecycle of BlurBackdrop. That kind of "store the object in the datastore, it will be automatically collected" isn't something I had thought of before. When it is garbage collected, the texture is as well right? If true, deinit is not needed?
    • I haven't been able to figure out the right shape for stuff like this - Picture has the same problem, and maybe this is the solution.
  • The reason you can't use Picture is because the drawing might go across the boundary right? I think your method of recording which render commands is good, sorry it's so fiddly. If we see another usecase that needs to record/replay render commands we can make a better api.

Looks great - merge when ready. Thank you!

@foxnne

foxnne commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

This is awesome, well done!

@nat3Github

Copy link
Copy Markdown
Collaborator Author

When it is garbage collected, the texture is as well right? If true, deinit is not needed?

thanks for the feedback! afaik yes, but deinit is still needed. actually its wired up false in the example and leaks.
i modified the api to make it more in line with what we already have, should be good to go now

The reason you can't use Picture is because the drawing might go across the boundary right?

i am not 100% sure if you could achieve something similar with Picture, but boundary crossing content was the issue.

new api:

...
const backdrop = dvui.BlurBackdrop.get(@src());
...
backdrop.init(some_rect, .{backdrop.radius_px});
defer backdrop.deinit();

@david-vanderson

Copy link
Copy Markdown
Owner

Excellent, I will chew on that new api and see if Picture should do the same thing.

Can you move the new demo part into the "Applets" section? Then merge it. Thank you!

@nat3Github
nat3Github merged commit e0cf954 into david-vanderson:main Aug 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants