{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

CompositingStrategy.Companion

public static class CompositingStrategy.Companion


Summary

Public methods

static final @NonNull CompositingStrategy

Rendering to an offscreen buffer will be determined automatically by the rest of the graphicsLayer parameters.

static final @NonNull CompositingStrategy

Modulates alpha for each of the drawing instructions recorded within the graphicsLayer.

static final @NonNull CompositingStrategy

Rendering of content will always be rendered into an offscreen buffer first then drawn to the destination regardless of the other parameters configured on the graphics layer.

Public methods

getAuto

public static final @NonNull CompositingStrategy getAuto()

Rendering to an offscreen buffer will be determined automatically by the rest of the graphicsLayer parameters. This is the default behavior. For example, whenever an alpha value less than 1.0f is provided on Modifier.graphicsLayer, a compositing layer is created automatically to first render the contents fully opaque, then draw this offscreen buffer to the destination with the corresponding alpha. This is necessary for correctness otherwise alpha applied to individual drawing instructions that overlap will have a different result than expected. Additionally usage of RenderEffect on the graphicsLayer will also render into an intermediate offscreen buffer before being drawn into the destination.

getModulateAlpha

public static final @NonNull CompositingStrategy getModulateAlpha()

Modulates alpha for each of the drawing instructions recorded within the graphicsLayer. This avoids usage of an offscreen buffer for purposes of alpha rendering. ModulateAlpha is more efficient than Auto in performance in scenarios where an alpha value less than 1.0f is provided. Otherwise the performance is similar to that of Auto. However, this can provide different results than Auto if there is overlapping content within the layer and alpha is applied. This should only be used if the contents of the layer are known well in advance and are expected to not be overlapping.

getOffscreen

public static final @NonNull CompositingStrategy getOffscreen()

Rendering of content will always be rendered into an offscreen buffer first then drawn to the destination regardless of the other parameters configured on the graphics layer. This is useful for leveraging different blending algorithms for masking content. For example, the contents can be drawn into this graphics layer and masked out by drawing additional shapes with BlendMode.Clear