Octacone wrote:
Sorry for stealing the thread, but I'm also working on a compositor at the moment.
If I wanted to add blur to this whole scheme taking the last buffer and blurring its content would be the only additional step required, right?
Blurring adds a lot of complications - there's good reasons certain modern real-world OSes strongly prefer that only one foreground window has blurring...
You need render everything normally up to the blurred surface, then copy the buffer to a new working buffer to do the blurring, then mix that instead of the actual backbuffer when alpha blending.
And you need to make sure you render a bit more than what you clipped into that secondary buffer so the blur doesn't have weird artifacts around edges of clip regions.
e: There's also other complications with blurring, like determining where to actually use the blurred background vs. the unblurred - you may want soft edges around an antialiased window decoration, but blurred background behind all t he semitransparent parts inside the window, for example.
e2: Thinking about it a bit more, here's what I'd do:
- Render all damage regions under the first blurred-behind window into one buffer, using an expanded clip region that includes extra space for the blur radius.
- Blur that buffer into a second buffer.
- Use a mask to determine where to combine the foreground of the blurred-behind window with the second (blurred) buffer and where to combine it directly with the first buffer, and draw it into the first buffer.
- Repeat as necessary up the stack.
- Blit only the actual calculated clip regions into the final result.
e3:
Done.e4: I tweaked some settings, doing a single large-radius box blur pass; my blur function is still rather slow, but this is still reasonably usable in select cases, like
the alt-f2 and
alt-tab windows. I also made it available for the terminal
though it has some issues due to the reuse of the transparency as the blur mask.