CacheDrawScope
class CacheDrawScope internal constructor() : Density
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
Properties
val size: Size
Provides the dimensions of the current drawing environment
val layoutDirection: LayoutDirection
Provides the LayoutDirection
.
Functions
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.
fun obtainShadowContext(): ShadowContext
Returns the ShadowContext
used to create InnerShadowPainter
and DropShadowPainter
to
render inner and drop shadows respectively
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
fun onDrawBehind(block: DrawScope.() -> Unit): DrawResult
Issue drawing commands to be executed before the layout content is drawn
fun onDrawWithContent(block: ContentDrawScope.() -> Unit): DrawResult
Issue drawing commands before or after the layout's drawing contents