Unverified Commit b5864536 authored by Nikolay Igotti's avatar Nikolay Igotti Committed by GitHub

Loader and initializer tweaks. (#39)

parent 2e828022
...@@ -5,7 +5,6 @@ import java.io.InputStreamReader ...@@ -5,7 +5,6 @@ import java.io.InputStreamReader
import java.io.File import java.io.File
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.StandardCopyOption import java.nio.file.StandardCopyOption
import javax.swing.UIManager
object Library { object Library {
private var loaded = false private var loaded = false
...@@ -38,7 +37,11 @@ object Library { ...@@ -38,7 +37,11 @@ object Library {
val name = "skiko-$hostId" val name = "skiko-$hostId"
val platformName = System.mapLibraryName(name) val platformName = System.mapLibraryName(name)
val hash = Library::class.java.getResourceAsStream("$resourcePath$platformName.sha256").use { val hashResourceStream = Library::class.java.getResourceAsStream(
"$resourcePath$platformName.sha256") ?: throw LibraryLoadException(
"Cannot find $platformName.sha256, proper native dependency missing."
)
val hash = hashResourceStream.use {
BufferedReader(InputStreamReader(it)).lines().toArray()[0] as String BufferedReader(InputStreamReader(it)).lines().toArray()[0] as String
} }
val cacheDir = File("$cacheRoot/$hash") val cacheDir = File("$cacheRoot/$hash")
...@@ -49,7 +52,10 @@ object Library { ...@@ -49,7 +52,10 @@ object Library {
loadOrGet(cacheDir, resourcePath, "icudtl.dat", false) loadOrGet(cacheDir, resourcePath, "icudtl.dat", false)
} }
miscSystemInit() Setup.init(
System.getProperty("skiko.rendering.laf.global") == "true",
System.getProperty("skiko.rendering.noerasebackground") != "false"
)
try { try {
// Init code executed after library was loaded. // Init code executed after library was loaded.
...@@ -60,18 +66,5 @@ object Library { ...@@ -60,18 +66,5 @@ object Library {
loaded = true loaded = true
} }
// This function doesn't actually belong to this file.
private fun miscSystemInit() {
// we have to set this property to avoid render flickering.
System.setProperty("sun.awt.noerasebackground", "true")
System.setProperty("skija.staticLoad", "false")
// setup menu look and feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
System.setProperty("apple.laf.useScreenMenuBar", "true")
} catch (e: UnsupportedOperationException) {
// Not all platforms allow this.
}
}
} }
package org.jetbrains.skiko
import java.lang.RuntimeException
class LibraryLoadException(message: String) : RuntimeException(message)
\ No newline at end of file
package org.jetbrains.skiko
import javax.swing.UIManager
object Setup {
fun init(globalLAF: Boolean = false, noEraseBackground: Boolean = true) {
if (noEraseBackground) {
// we have to set this property to avoid render flickering.
System.setProperty("sun.awt.noerasebackground", "true")
}
try {
if (globalLAF) {
// Setup menu look and feel.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
System.setProperty("apple.laf.useScreenMenuBar", "true")
}
} catch (e: UnsupportedOperationException) {
// Not all platforms allow this.
}
}
}
\ No newline at end of file
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