in components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/DrawCache.kt [40:70]
fun drawCachedImage(
config: ImageBitmapConfig,
size: IntSize,
density: Density,
layoutDirection: LayoutDirection,
block: DrawScope.() -> Unit
) {
this.scopeDensity = density
this.layoutDirection = layoutDirection
var targetImage = mCachedImage
var targetCanvas = cachedCanvas
if (targetImage == null ||
targetCanvas == null ||
size.width > targetImage.width ||
size.height > targetImage.height ||
this.config != config
) {
targetImage = ImageBitmap(size.width, size.height, config = config)
targetCanvas = Canvas(targetImage)
mCachedImage = targetImage
cachedCanvas = targetCanvas
this.config = config
}
this.size = size
cacheScope.draw(density, layoutDirection, targetCanvas, size.toSize()) {
clear()
block()
}
targetImage.prepareToDraw()
}