applySoftMask

open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: KiteRectangle, maskCtm: KiteMatrix, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)(source)

Apply a soft mask to the content rendered inside render (ISO 32000-1 §11.6.5). The default implementation just calls render. Backends without offscreen compositing fall back to painting through the mask.

Concrete implementations: open a saveLayer for the content, render() it, then over-paint via renderMask using DstIn blend mode so the mask's alpha determines the visible region.

The shipped backends implement both SMask kinds: Alpha uses the mask group's own alpha, and Luminosity composites the group over an opaque black backdrop and converts luminance to alpha (Skia's LUMA filter, a Compose colour-matrix filter, a per-pixel pass on AWT) per §11.6.5.2.


open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: KiteRectangle, maskCtm: KiteMatrix, transfer: KiteMaskTransfer?, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)(source)

ISO 32000-1, 11.6.5.2: the mask group draws into a bitmap of its own. Its alpha, or its luminosity over a black backdrop, becomes a grey mask that the content paints through with CGContextClipToMask. So the mask group's colours never reach the page, and each paint keeps its own blend mode against the page (#79). The transfer table maps each value of the grey mask.