Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion skiko/build-with-local-skia.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
####### Variables you can edit to change build config, or set same environment variables before script execution #######
SKIA_VERSION="${SKIA_VERSION:="m138-80d088a-1"}" # Version of Skia m###-commit-sha-#. This commit sha will be cloned from repository https://github.com/JetBrains/skia
SKIA_VERSION="${SKIA_VERSION:="m138-80d088a-2"}" # Version of Skia m###-commit-sha-#. This commit sha will be cloned from repository https://github.com/JetBrains/skia
SKIA_DEBUG_MODE="${SKIA_DEBUG_MODE:="false"}" # in debug mode Skiko will be published with postix "+debug", for example "0.0.0-SNAPSHOT+debug"
SKIA_TARGET="${SKIA_TARGET:="iosSim"}" # possible values: "ios", "iosSim", "macos", "windows", "linux", "wasm", "android", "tvos", "tvosSim"
# For M1 Mac use "iosSim" to build for simulator, and ios to build for device.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,26 +271,32 @@ fun SkikoProjectContext.createLinkJvmBindings(
)
}
OS.Linux -> {
osFlags = arrayOf(
"-shared",
// `libstdc++.so.6.*` binaries are forward-compatible and used from GCC 3.4 to 16+,
// so do not use `-static-libstdc++` to avoid issues with complex setup.
"-static-libgcc",
"-lGL",
"-lX11",
"-lfontconfig",
// Enforce immediate symbol resolution at library load time to prevent
// lazy-binding issues and make GOT read-only afterwards.
"-Wl,-z,relro,-z,now",
// Hack to fix problem with linker not always finding certain declarations.
"$skiaBinDir/libsksg.a",
"$skiaBinDir/libskia.a",
"$skiaBinDir/libskunicode_core.a",
"$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskshaper.a",
"$skiaBinDir/libjsonreader.a",

)
osFlags = mutableListOf<String>().apply {
addAll(
arrayOf(
"-shared",
// `libstdc++.so.6.*` binaries are forward-compatible and used from GCC 3.4 to 16+,
// so do not use `-static-libstdc++` to avoid issues with complex setup.
"-static-libgcc",
"-lGL",
"-lX11",
"-lfontconfig",
// Enforce immediate symbol resolution at library load time to prevent
// lazy-binding issues and make GOT read-only afterwards.
"-Wl,-z,relro,-z,now",
// Hack to fix problem with linker not always finding certain declarations.
"$skiaBinDir/libsksg.a",
"$skiaBinDir/libskia.a",
"$skiaBinDir/libskunicode_core.a",
"$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskshaper.a",
"$skiaBinDir/libjsonreader.a"
)
)
if (targetArch == Arch.Arm64) {
add("-lEGL")
}
}.toTypedArray()
}
OS.Windows -> {
libDirs.set(windowsSdkPaths.libDirs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ fun SkikoProjectContext.configureNativeTarget(os: OS, arch: Arch, target: Kotlin
"$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskia.a"
)
if (arch == Arch.Arm64) {
options.add("-lEGL")
}
// When cross-compiling for ARM64 from x64, use the ARM toolchain sysroot
if (arch == Arch.Arm64 && hostArch != Arch.Arm64) {
// ARM GNU toolchain sysroot paths
Expand Down
2 changes: 1 addition & 1 deletion skiko/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ kotlin.mpp.enableCInteropCommonization=true
deploy.version=0.0.0

# a tag from https://github.com/JetBrains/skia-pack
dependencies.skia=m138-80d088a-1
dependencies.skia=m138-80d088a-2

# a tag from https://github.com/JetBrains/angle-pack
dependencies.angle=ec4d8f8e4d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DirectContextNativeTest {

@Test
fun resourceCacheLimitTest() {
if (!TestGlContext.isAvailabale()) return
if (!TestGlContext.isAvailable()) return

TestGlContext.run {
DirectContext.makeGL().useContext { context ->
Expand Down
12 changes: 11 additions & 1 deletion skiko/src/commonTest/kotlin/org/jetbrains/skia/SurfaceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package org.jetbrains.skia

import org.jetbrains.skia.impl.interopScope
import org.jetbrains.skia.impl.use
import org.jetbrains.skiko.Arch
import org.jetbrains.skiko.KotlinBackend
import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostArch
import org.jetbrains.skiko.hostOs
import org.jetbrains.skiko.kotlinBackend
import org.jetbrains.skiko.tests.TestGlContext
import org.jetbrains.skiko.tests.allocateBytesForPixels
import org.jetbrains.skiko.tests.runTest
Expand Down Expand Up @@ -105,8 +111,12 @@ class SurfaceTest {

@Test
fun canMakeRenderTarget() {
if (!TestGlContext.isAvailabale()) return
if (!TestGlContext.isAvailable()) return

if (hostOs == OS.Linux && kotlinBackend == KotlinBackend.Native && hostArch == Arch.Arm64) {
// TODO: fix test on Linux arm64 using EGL
return
}
val pixels = TestGlContext.run {
DirectContext.makeGL().useContext { ctx ->
val imageInfo = ImageInfo.makeN32Premul(16, 16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package org.jetbrains.skiko.tests

import org.jetbrains.skia.*
import org.jetbrains.skia.impl.*
import org.jetbrains.skiko.Arch
import org.jetbrains.skiko.KotlinBackend
import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostArch
import org.jetbrains.skiko.hostOs
import org.jetbrains.skiko.kotlinBackend

Expand All @@ -24,20 +22,16 @@ internal class TestGlContext : Managed(TestGlContext_nCreate(), FinalizerHolder.

companion object {

fun isAvailabale(): Boolean {
fun isAvailable(): Boolean {
if (hostOs != OS.Linux || kotlinBackend != KotlinBackend.Native) {
// TODO implement for other platforms and render targets
return false
}
if (hostArch == Arch.Arm64) {
// TODO implement and test EGL on arm64
return false
}
return true
}

inline fun <T> run(block: TestGlContext.() -> T): T {
check(isAvailabale()) { "TestGlContext is not available" }
check(isAvailable()) { "TestGlContext is not available" }
return TestGlContext().use {
it.makeCurrent()
val result = it.block()
Expand Down