mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
`capture_backdrop` copied the whole target into the backdrop texture for every callback that asked for one, so a panel-sized blur on a large screen paid for the entire frame, once per blur. Ask the callback what it needs instead: `CallbackTrait::backdrop_rect` is given the rect the callback will be drawn into, its own rect already cut down by the clip rect, and returns the region it needs to read. Those are different questions — a blur reads its radius beyond every edge it draws — and keeping them apart is what lets the margin survive clipping, which inflating the callback's own rect could not do: that rect is also the viewport it draws into. `Backdrop::valid_in_pixels` reports what was captured. The texture stays full-size so a pixel is still where the effect expects it; only the region that was asked for holds this frame. The default answer is the rect the callback is drawn into, which is right for an effect that only reads the pixels it covers, so nothing has to change unless it reads further out. With nine blurred panels of 240x150 at radius 24 on a 1600x1200 canvas, this plus scissoring the blur passes in regui takes the frame rate from 146 to 1690 fps on WebGPU and 135 to 616 on WebGL2, measured in Chrome; the marginal cost of one blur drops about twentyfold. egui_kittest's snapshots of the same blurs come out pixel for pixel identical.
egui-wgpu
This crates provides bindings between egui and wgpu.
This was originally hosted at https://github.com/hasenbanck/egui_wgpu_backend