Skip to content

Commit

Permalink
Run hardware blurring on the IO threads
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Sep 15, 2024
1 parent 3fc7b67 commit d43074b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cloudy/src/main/kotlin/com/skydoves/cloudy/CloudyModifierNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ private class CloudyModifierNode(
onStateChanged.invoke(CloudyState.Loading)

try {
val targetBitmap: Bitmap = runBlocking(Dispatchers.IO) {
graphicsLayer.toImageBitmap().asAndroidBitmap()
val blurredBitmap: Bitmap = runBlocking(Dispatchers.IO) {
val targetBitmap: Bitmap = graphicsLayer.toImageBitmap().asAndroidBitmap()
.copy(Bitmap.Config.ARGB_8888, true)
} ?: throw RuntimeException("Couldn't capture a bitmap from the composable tree")

val blurredBitmap = iterativeBlur(
androidBitmap = targetBitmap,
radius = radius
)?.apply {
drawImage(this.asImageBitmap())
}
iterativeBlur(
androidBitmap = targetBitmap,
radius = radius
)?.apply {
drawImage(this.asImageBitmap())
}
} ?: throw RuntimeException("Couldn't capture a bitmap from the composable tree")

onStateChanged.invoke(CloudyState.Success(blurredBitmap))
} catch (e: Exception) {
Expand Down

0 comments on commit d43074b

Please sign in to comment.