nutrient Backdrop Source
Records the drawing of the composable it is applied to into state, so chrome drawn later in the same composition can sample it — the "what's behind" half of a backdrop blur.
Apply it to the com.pspdfkit.jetpack.compose.views.DocumentView, and only there. The scrims that read the backdrop — NutrientStatusBarScrim and com.pspdfkit.jetpack.compose.toolbar.NutrientDocumentStatusBarScrim — exist to blur the document scrolling under the status bar, and they blur whatever this modifier recorded. On any other composable they blur that composable instead: put it on the enclosing Box and the scrim samples its own toolbar; put it on a spacer and it samples nothing. The modifier is public so a host can place it on its own DocumentView call, not because it is meant for other content.
Nothing about the type system enforces this. Modifier extensions cannot be restricted to one composable without changing the shape of that composable's API, so the contract is this KDoc.
The rules, all of which the setup in com.pspdfkit.jetpack.compose.toolbar.NutrientDocumentStatusBarScrim satisfies:
One document per state. Recording two composables into the same NutrientBackdropState leaves the scrim sampling whichever drew last.
Same composition, document first. The scrim samples what has already drawn this frame, so the
DocumentViewcarrying this modifier is declared before the scrim in the sameBox.Last in the chain. Chain it after the sizing and padding modifiers, as in
Modifier.fillMaxSize().nutrientBackdropSource(backdrop), so the recording covers exactly the pixels the document occupies. Placed first it would record the un-padded, un-clipped node.
This works over a DocumentView even though the document is an Android View subtree: Compose rasterizes an embedded view into the same canvas it hands to this modifier, so the recorded layer contains the rendered pages. It does not work when the document is a View sibling of the composition rather than a child of it — the PdfActivity / nutrientToolbarsComposeView mountings, where the toolbars overlay the document from a separate ComposeView. There is nothing to record there, and the scrim falls back to a flat tint.
The capture costs one offscreen buffer the size of the document view, re-recorded on every frame the document redraws.
Parameters
The backdrop created with rememberNutrientBackdropState. Pass the same instance to the scrim's state.