androidx.compose.ui.draw
CacheDrawScope
Class · from org.jetbrains.compose.ui:ui:1.12.2
No hand-written docs yet.
Handle to a drawing environment that enables caching of content based on the resolved size. Consumers define parameters and refer to them in the captured draw callback provided in onDrawBehind or onDrawWithContent.
class CacheDrawScope : Density
Is a
Used by
Parameters that take a CacheDrawScope.
Properties
size
val size: Size
Provides the dimensions of the current drawing environment
layoutDirection
val layoutDirection: LayoutDirection
Provides the LayoutDirection.
Functions
obtainGraphicsLayer
fun obtainGraphicsLayer(): GraphicsLayer
Returns a managed GraphicsLayer instance. This GraphicsLayer maybe newly created or return a previously allocated instance. Consumers are not expected to release this instance as it is automatically recycled upon invalidation of the CacheDrawScope and released when the DrawCacheModifier is detached.
obtainShadowContextSince 1.9
fun obtainShadowContext(): ShadowContext
Returns the ShadowContext used to create InnerShadowPainter and DropShadowPainter to render inner and drop shadows respectively
record
fun GraphicsLayer.record(
density: Density = this@CacheDrawScope,
layoutDirection: LayoutDirection = this@CacheDrawScope.layoutDirection,
size: IntSize = this@CacheDrawScope.size.toIntSize(),
block: ContentDrawScope.() -> Unit,
)
Record the drawing commands into the GraphicsLayer with the Density, LayoutDirection and Size are given from the provided CacheDrawScope
onDrawBehind
fun onDrawBehind(block: DrawScope.() -> Unit): DrawResult
Issue drawing commands to be executed before the layout content is drawn
onDrawWithContent
fun onDrawWithContent(block: ContentDrawScope.() -> Unit): DrawResult
Issue drawing commands before or after the layout's drawing contents
Library docs
Handle to a drawing environment that enables caching of content based on the resolved size.
Consumers define parameters and refer to them in the captured draw callback provided in
onDrawBehind or onDrawWithContent.
onDrawBehind will draw behind the layout's drawing contents however, onDrawWithContent will
provide the ability to draw before or after the layout's contents