diff --git a/cloudy/src/main/kotlin/com/skydoves/cloudy/CloudyModifierNode.kt b/cloudy/src/main/kotlin/com/skydoves/cloudy/CloudyModifierNode.kt index a36a464..c7e4fa4 100644 --- a/cloudy/src/main/kotlin/com/skydoves/cloudy/CloudyModifierNode.kt +++ b/cloudy/src/main/kotlin/com/skydoves/cloudy/CloudyModifierNode.kt @@ -119,7 +119,7 @@ private class CloudyModifierNode( val blurredBitmap = iterativeBlur( androidBitmap = targetBitmap, radius = radius - )?.apply { + ).await()?.apply { drawImage(this.asImageBitmap()) } ?: throw RuntimeException("Couldn't capture a bitmap from the composable tree") diff --git a/cloudy/src/main/kotlin/com/skydoves/cloudy/internals/render/RenderScriptToolkit.kt b/cloudy/src/main/kotlin/com/skydoves/cloudy/internals/render/RenderScriptToolkit.kt index f89a57d..946cb70 100644 --- a/cloudy/src/main/kotlin/com/skydoves/cloudy/internals/render/RenderScriptToolkit.kt +++ b/cloudy/src/main/kotlin/com/skydoves/cloudy/internals/render/RenderScriptToolkit.kt @@ -18,7 +18,9 @@ package com.skydoves.cloudy.internals.render import android.graphics.Bitmap -import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async // This string is used for error messages. private const val externalName = "RenderScript Toolkit" @@ -316,10 +318,10 @@ internal fun vectorSize(bitmap: Bitmap): Int { } } -internal suspend fun iterativeBlur( +internal fun CoroutineScope.iterativeBlur( androidBitmap: Bitmap, radius: Int -): Bitmap? = coroutineScope { +): Deferred = async { val iterate = (radius + 1) / 25 var bitmap: Bitmap? = RenderScriptToolkit.blur( inputBitmap = androidBitmap,