v0.23.0
Alpha-aware software rasterisation. Offscreen buffers can now signal that their alpha channel matters downstream, and SwRenderer writes accumulate dst.a via non-premultiplied source-over instead of clobbering it to 255. Unblocks effect widgets (DropShadow and similar) that read the buffer's alpha as a silhouette mask.
Added
AlphaModeenum +Texture::alpha_modefield (src/draw/texture.rs):Opaque(default — keeps the framebuffer path's "always write 255" behaviour) andBlend(accumulatesdst.avia non-premultiplied source-over).AlphaModeis also re-exported fromcrate::draw::swso existinguse mirui::draw::sw::*callers see it alongsideSwRenderer.SwRenderer::with_alpha_mode(mode)builder (src/draw/sw/mod.rs): sets the underlying target's mode. DefaultSwRenderer::new(target)is unchanged —Opaque.- Four unit tests covering Opaque vs Blend semantics (
src/draw/sw/mod.rs): default-mode regression, transparent-buffer first-hit alpha pass-through, two-fill source-over composition (±2 u8 rounding tolerance), and thesrc.a = 255source-over identity short-circuit.
Changed
Texture::blend_pixel_intreadsself.alpha_mode(src/draw/texture.rs): the existing 4-arg signature is preserved (no caller migration needed). InBlendmode the destination alpha is composed viaout.a = src.a + dst.a × (255 − src.a) / 255instead of writing 255. Thea == 255short-circuit still writes 255 in both modes — that's the source-over identity at full source alpha.fill_axis_alignedfalls back from the memcpy fast path whenBlendmode + partial alpha (src/draw/sw/rect_fill.rs):fill_first_row_then_replicatewould otherwise clobber the destination's alpha byte. The Opaque path and the fully-opaque source case in Blend mode keep the memcpy fast path.blit_1to1_argb_to_argbaccumulatesdst.ain Blend mode (src/draw/sw/blit_fast.rs): partial-alpha source pixels compose into the destination's alpha channel rather than overwriting it.render_system::try_draw_offscreenselectsAlphaModefromOffscreenAlphaMode(src/widget/render_system.rs): an entity carryingOffscreenAlphaMode::clear_transparent()makes the innerSwRendereruseBlend. Other offscreen entities keepOpaqueso the framebuffer's alpha gets pre-seeded as before.