martmists
10/03/2021, 10:15 AMGavin Ray
10/04/2021, 7:34 PMskija
library which is Java, bound to some JNI code in C++.
I didn't know Kotlin Native could even do this (import Java code that used JNI -- thought you could only use direct C bindings)
EG, class Canvas
, Canvas.drawPicture()
• https://github.com/JetBrains/skija/blob/64b715ceb0764e366eb98ff852d3c42fe30328ab/platform/cc/Canvas.cc#L147-L154
• https://github.com/JetBrains/skija/blob/64b715ceb0764e366eb98ff852d3c42fe30328ab/shared/java/Canvas.java#L448-L461
Then the skiko
Kotlin Native code for drawing on canvas:
• https://github.com/JetBrains/skiko/blob/023a169556129b0f68d236eac1c38d08d9741039/s[…]nativeMain/kotlin/org/jetbrains/skiko/context/ContextHandler.ktGavin Ray
10/04/2021, 7:38 PMCPPBind
to generate a C ABI for C++, or rust-bindgen
for generating a C ABI for Rust, etc
▪︎ https://github.com/Time0o/CPPBind
▪︎ https://github.com/rust-lang/rust-bindgen
• Then you follow the c-interop
guide for consuming the C ABI from Kotlin Native
◦ https://kotlinlang.org/docs/native-c-interop.html
◦ This amounts to basically linking in the static/shared library that exposes the C ABI, and running a tool to auto-generate the Kotlin type signatures for the C ABI headersGavin Ray
10/04/2021, 7:41 PMGavin Ray
10/04/2021, 7:45 PM