Landry Norris
02/23/2023, 7:16 PMLandry Norris
02/23/2023, 7:18 PM@Composable
fun Foo(width: Int, height: Int) {
println("Composing Foo")
val paint = remember { Paint() }
val bitmap = remember(width, height) {
createBitmap(IntSize(width, height))
}
Box(modifier = Modifier.fillMaxSize()
.then(
if(bitmap != null)
Modifier.drawBehind {
println("drawBehind")
drawIntoCanvas { canvas ->
...
}
}
else Modifier
)
)
}
@Composable
fun ClickableFoo(width: Int, height: Int) {
Box(modifier = Modifier.clickable(...)) {
Foo(width, height)
}
}
Landry Norris
02/23/2023, 7:19 PMColton Idle
02/23/2023, 9:18 PMdrawBehindCached
or something?Colton Idle
02/23/2023, 9:20 PMdrawWithCache
? ive never really used the draw apis. so im just regurgitating stuff that ive seen thrown around in this slack. 🙈Landry Norris
02/23/2023, 9:38 PMLoney Chou
02/24/2023, 1:13 AMdrawBehind
, drawWithContent
, drawWithCache
won't save their content. Add a .graphicsLayer()
before drawXxx
to enable caching.