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

DrawCacheModifier

public interface DrawCacheModifier extends DrawModifier


DrawModifier implementation that supports building a cache of objects to be referenced across draw calls

Summary

Public methods

abstract void

Callback invoked to re-build objects to be re-used across draw calls.

Inherited methods

From androidx.compose.ui.draw.DrawModifier
abstract void
From androidx.compose.ui.Modifier
default @NonNull Modifier

Concatenates this modifier with another.

From androidx.compose.ui.Modifier.Element
default boolean
all(
    @NonNull Function1<@NonNull Modifier.Element, @NonNull Boolean> predicate
)

Returns true if predicate returns true for all Elements in this Modifier or if this Modifier contains no Elements.

default boolean
any(
    @NonNull Function1<@NonNull Modifier.Element, @NonNull Boolean> predicate
)

Returns true if predicate returns true for any Element in this Modifier.

default @NonNull R
<R extends Object> foldIn(
    @NonNull R initial,
    @NonNull Function2<@NonNull R, @NonNull Modifier.Element, @NonNull R> operation
)

Accumulates a value starting with initial and applying operation to the current value and each element from outside in.

default @NonNull R
<R extends Object> foldOut(
    @NonNull R initial,
    @NonNull Function2<@NonNull Modifier.Element, @NonNull R, @NonNull R> operation
)

Accumulates a value starting with initial and applying operation to the current value and each element from inside out.

Public methods

onBuildCache

abstract void onBuildCache(@NonNull BuildDrawCacheParams params)

Callback invoked to re-build objects to be re-used across draw calls. This is useful to conditionally recreate objects only if the size of the drawing environment changes, or if state parameters that are inputs to objects change. This method is guaranteed to be called before DrawModifier.draw.

Parameters
@NonNull BuildDrawCacheParams params

The params to be used to build the cache.