Unverified Commit bccb17a4 authored by jakub-senohrabek-jb's avatar jakub-senohrabek-jb Committed by GitHub

Allow setting skiko properties using skiko.properties file inside jar (#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: 's avatarJakub Senohrabek <jakub@senohrabek.net>
parent dbc6bdbd
package org.jetbrains.skiko 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 // TODO maybe we can get rid of global properties, and pass SkiaLayerProperties to Window -> ComposeWindow -> SkiaLayer
@Suppress("SameParameterValue") @Suppress("SameParameterValue")
...@@ -89,6 +89,19 @@ object SkikoProperties { ...@@ -89,6 +89,19 @@ object SkikoProperties {
val macOsOpenGLEnabled: Boolean get() = getProperty("skiko.macos.opengl.enabled")?.toBoolean() ?: false 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 { internal fun parseRenderApi(text: String?): GraphicsApi {
when(text) { when(text) {
"SOFTWARE_COMPAT" -> return GraphicsApi.SOFTWARE_COMPAT "SOFTWARE_COMPAT" -> return GraphicsApi.SOFTWARE_COMPAT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment