diff --git a/composeApp/src/androidMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.android.kt b/composeApp/src/androidMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.android.kt index 83c05358b..badca773b 100644 --- a/composeApp/src/androidMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.android.kt +++ b/composeApp/src/androidMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.android.kt @@ -9,6 +9,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.nativeCanvas +internal actual val ashSwarmMaxGrainBudget: Int = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) 26000 else 15000 + internal actual class AshSwarmRenderer actual constructor(maxGrains: Int) { private val batched = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.kt index f168a0814..b93c933c6 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.kt @@ -2,6 +2,8 @@ package com.nuvio.app.core.ui import androidx.compose.ui.graphics.drawscope.DrawScope +internal expect val ashSwarmMaxGrainBudget: Int + internal expect class AshSwarmRenderer(maxGrains: Int) { fun draw( scope: DrawScope, diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/DisintegrationEffect.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/DisintegrationEffect.kt index de6e8e6f9..29da4ad2c 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/DisintegrationEffect.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/core/ui/DisintegrationEffect.kt @@ -99,8 +99,7 @@ private class AshField( val clipOutline = Path() } -private const val ASH_COLS = 100 -private const val ASH_MAX_TILES = 15000 +private const val ASH_COLS = 130 private const val TILE_LIFESPAN = 0.5f private const val TAU = 6.2831855f @@ -112,10 +111,11 @@ private fun frontValue(nx: Float, ny: Float, phase: Float): Float = private fun buildAshField(bitmap: ImageBitmap, seed: Long): AshField { val aspect = bitmap.height.toFloat() / bitmap.width.toFloat() + val maxTiles = ashSwarmMaxGrainBudget var cols = ASH_COLS var rows = (cols * aspect).toInt().coerceAtLeast(8) - if (cols * rows > ASH_MAX_TILES) { - cols = (kotlin.math.sqrt(ASH_MAX_TILES / aspect)).toInt().coerceAtLeast(12) + if (cols * rows > maxTiles) { + cols = (kotlin.math.sqrt(maxTiles / aspect)).toInt().coerceAtLeast(12) rows = (cols * aspect).toInt().coerceAtLeast(8) } val pixels = bitmap.toPixelMap() diff --git a/composeApp/src/iosMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.ios.kt b/composeApp/src/iosMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.ios.kt index 0d3d84b3b..fcb54b538 100644 --- a/composeApp/src/iosMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.ios.kt +++ b/composeApp/src/iosMain/kotlin/com/nuvio/app/core/ui/AshSwarmRenderer.ios.kt @@ -6,6 +6,8 @@ import org.jetbrains.skia.BlendMode import org.jetbrains.skia.Paint import org.jetbrains.skia.VertexMode +internal actual val ashSwarmMaxGrainBudget: Int = 26000 + internal actual class AshSwarmRenderer actual constructor(maxGrains: Int) { private val positions = FloatArray(maxGrains * 12) private val vertexColors = IntArray(maxGrains * 6)