mirror of
https://github.com/penpot/penpot.git
synced 2026-09-21 03:16:15 +00:00
* 🐛 Fix shadows on a masked group in the WASM renderer A masked group renders in two passes: its content, then the mask shape composited with DstIn so everything outside the mask silhouette is erased. Both happen inside one save_layer, and the group's drop shadow was composited into that same layer before the mask pass — so the mask erased it. A drop shadow lives mostly outside the silhouette, so it disappeared entirely. Inner shadows never drew at all: render_fill_inner_shadows needs fill geometry to paint into, and a group has none. Both now ride on an image filter set on the masked-group layer, which Skia evaluates after the mask is composited, so the shadow comes from the real masked pixels rather than the group's own, empty geometry. The effects compose in the order the SVG renderer uses for a group: drop shadows, then the source, then inner shadows, with the layer blur over all of it. That layer is opened on a canvas carrying no transform, so the filter is built in device units. Shadow::scale_to_device does that rather than scale_content, because radius_to_sigma is affine: scaling the radius applies its constant term once at device scale, while a filter built in document space has the term scaled by the canvas matrix. The two would blur differently by 0.5 · (scale - 1) sigma, visible as a masked group's own shadow being narrower than the same shadow on its parent. The masked-group layer blur had the same flaw. Three paths are suppressed for masked groups so nothing is drawn twice: the silhouette composite, the nested_shadows inheritance that would reach text descendants, and the fill inner-shadow pass. Every save and restore around that layer is keyed on the shape alone. Enter and exit run on different walker passes, and a pan or zoom in between changes fast mode, so deriving them from render state could leave the canvas clip stack unbalanced. Refs #11697 AI-assisted-by: claude-opus-5 * 🐛 Fix a container's drop shadow over a masked group in WASM A container builds its drop shadow by drawing each descendant as a black silhouette and blurring the result. The walk descends only through children that can be flattened, and a masked group never can, so it stopped there and asked the group to draw its own geometry. A group has none, so nothing was drawn and the shadow layer stayed blank: no shadow at all for a group, board or frame holding a masked group. This is what the file attached to the issue reproduces. render_drop_black_shadow now draws the masked silhouette for such a group — content children flat black, DstIn the mask, and only then the offset, blur and spread. Masking after the blur would trim the shadow along the wrong edge. The walk recurses, so it narrows the clip the way the main walker does: content a clipping container hides must not widen the shadow. The clip rule now lives in one place, shared with the walker, and a test pins the two against each other. The shadow layer is sized to the silhouette plus the shadow's reach rather than falling back to the clip, so a wide blur is not cut at the tile edge. Spread keeps the renderer's existing behaviour: the silhouette goes through the same get_drop_shadow_filter every other shadow uses, so a masked group gains no ordering of its own. Closes #11697 AI-assisted-by: claude-opus-5