Browse Source

Dispatch image cache manipulation to the cache dispatcher (#3921)

pull/3929/head
Konstantin 1 year ago committed by GitHub
parent
commit
1be81af584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt

5
components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt

@ -9,6 +9,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import kotlinx.coroutines.withContext
import org.jetbrains.compose.resources.vector.toImageVector import org.jetbrains.compose.resources.vector.toImageVector
import org.jetbrains.compose.resources.vector.xmldom.Element import org.jetbrains.compose.resources.vector.xmldom.Element
@ -98,4 +99,6 @@ private suspend fun loadImage(
path: String, path: String,
resourceReader: ResourceReader, resourceReader: ResourceReader,
decode: (ByteArray) -> ImageCache decode: (ByteArray) -> ImageCache
): ImageCache = imageCache.getOrPut(path) { decode(resourceReader.read(path)) } ): ImageCache = withContext(cacheDispatcher) {
imageCache.getOrPut(path) { decode(resourceReader.read(path)) }
}

Loading…
Cancel
Save