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
  • Loading branch information
jakub-senohrabek committed Oct 10, 2024
1 parent 896ee8d commit 848d91e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 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,23 @@ object SkikoProperties {

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

val resourcePropertiesEnabled: Boolean get() = System.getProperty("skiko.resource.properties.enabled")?.toBoolean() ?: false

private fun getProperty(key: String): String? {
return if (resourcePropertiesEnabled) {
classLoaderProperties?.getProperty(key) ?: System.getProperty(key)
} else {
System.getProperty(key)
}
}

private val classLoaderProperties by lazy {
val res = SkikoProperties::class.java.classLoader.getResourceAsStream("skiko.properties") ?: return@lazy null
val props = Properties()
props.load(res)
props
}

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

0 comments on commit 848d91e

Please sign in to comment.