Skip to content

Commit

Permalink
Allow setting skiko properties using skiko.properties file inside jar (
Browse files Browse the repository at this point in the history
…#994)

In order to use two different versions of skiko in one app (using
multiple classloaders), it is required to use the unpacking strategy, as
the skiko.library.path is a system property, which is same for all
classloaders.

This change will allow to use presigned natives shipped together with
the app, while still being able to use multiple versions as the property
skiko.library.path will be loaded from current classloader resources,
with fallback to system property.

Co-authored-by: Jakub Senohrabek <[email protected]>
  • Loading branch information
jakub-senohrabek-jb and jakub-senohrabek authored Dec 9, 2024
1 parent dbc6bdb commit bccb17a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jetbrains.skiko

import java.lang.System.getProperty
import java.util.*

// TODO maybe we can get rid of global properties, and pass SkiaLayerProperties to Window -> ComposeWindow -> SkiaLayer
@Suppress("SameParameterValue")
Expand Down Expand Up @@ -89,6 +89,19 @@ object SkikoProperties {

val macOsOpenGLEnabled: Boolean get() = getProperty("skiko.macos.opengl.enabled")?.toBoolean() ?: false

private val properties = run {
val resourcePropertiesEnabled = System.getProperty("skiko.resource.properties.enabled")?.toBoolean() ?: false
val resources = if (resourcePropertiesEnabled) {
SkikoProperties::class.java.classLoader.getResourceAsStream("skiko.properties")
} else {
null
}
val systemProps = System.getProperties()
if (resources == null) systemProps else Properties(systemProps).apply { load(resources) }
}

private fun getProperty(key: String): String? = properties.getProperty(key)

internal fun parseRenderApi(text: String?): GraphicsApi {
when(text) {
"SOFTWARE_COMPAT" -> return GraphicsApi.SOFTWARE_COMPAT
Expand Down

0 comments on commit bccb17a

Please sign in to comment.