CacheDrawScope


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

Summary

Public functions

GraphicsLayer

Returns a managed GraphicsLayer instance.

Cmn
DrawResult
onDrawBehind(block: DrawScope.() -> Unit)

Issue drawing commands to be executed before the layout content is drawn

Cmn
DrawResult

Issue drawing commands before or after the layout's drawing contents

Cmn
Unit
GraphicsLayer.record(
    density: Density,
    layoutDirection: LayoutDirection,
    size: IntSize,
    block: ContentDrawScope.() -> Unit
)

Record the drawing commands into the GraphicsLayer with the Density, LayoutDirection and Size are given from the provided CacheDrawScope

Cmn

Public properties

open Float

The logical density of the display.

Cmn
open Float

Current user preference for the scaling factor for fonts.

Cmn
LayoutDirection

Provides the LayoutDirection.

Cmn
Size

Provides the dimensions of the current drawing environment

Cmn

Inherited functions

From androidx.compose.ui.unit.Density
open Int

Convert Dp to Int by rounding

Cmn
open Int

Convert Sp to Int by rounding

Cmn
open Dp

Convert an Int pixel value to Dp.

Cmn
open Dp

Convert a Float pixel value to a Dp

Cmn
open DpSize

Convert a Size to a DpSize.

Cmn
open Float

Convert Dp to pixels.

Cmn
open Float

Convert Sp to pixels.

Cmn
open Rect

Convert a DpRect to a Rect.

Cmn
open Size

Convert a DpSize to a Size.

Cmn
open TextUnit

Convert an Int pixel value to Sp.

Cmn
open TextUnit

Convert a Float pixel value to a Sp

Cmn
From androidx.compose.ui.unit.FontScaling
open Dp

Convert Sp to Dp.

Cmn
open TextUnit

Convert Dp to Sp.

Cmn

Public 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.

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

record

fun GraphicsLayer.record(
    density: Density = this@CacheDrawScope,
    layoutDirection: LayoutDirection = this@CacheDrawScope.layoutDirection,
    size: IntSize = this@CacheDrawScope.size.toIntSize(),
    block: ContentDrawScope.() -> Unit
): Unit

Record the drawing commands into the GraphicsLayer with the Density, LayoutDirection and Size are given from the provided CacheDrawScope

Public properties

density

open val densityFloat

The logical density of the display. This is a scaling factor for the Dp unit.

fontScale

open val fontScaleFloat

Current user preference for the scaling factor for fonts.

layoutDirection

val layoutDirectionLayoutDirection

Provides the LayoutDirection.

size

val sizeSize

Provides the dimensions of the current drawing environment