Unverified Commit 8e84e9e0 authored by Nikolay Igotti's avatar Nikolay Igotti Committed by GitHub

Generate docs (#480)

parent 9a95f214
# This is a basic workflow to help you get started with Actions # Default Skiko CI
name: CI name: CI
# Controls when the action will run. # Controls when the action will run.
...@@ -7,6 +6,7 @@ on: ...@@ -7,6 +6,7 @@ on:
# Triggers the workflow on push or pull request events but only for the master branch # Triggers the workflow on push or pull request events but only for the master branch
push: push:
branches: [ master ] branches: [ master ]
# TODO: temporary for faster tests, restore!
pull_request: pull_request:
branches: [ master ] branches: [ master ]
...@@ -160,3 +160,4 @@ jobs: ...@@ -160,3 +160,4 @@ jobs:
name: test-reports-windows name: test-reports-windows
path: ./skiko/build/reports/tests path: ./skiko/build/reports/tests
retention-days: 5 retention-days: 5
# Build Skiko documentation
name: Doc
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
# Temporary, for testing. Remove!
#pull_request:
# branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# See https://github.com/marketplace/actions/deploy-to-github-pages
jobs:
dokka:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Build docs
run: bash -c 'JAVA_OPTS="-Xmx4g" ./gradlew --no-daemon -Pskiko.native.enabled=true -Pskiko.wasm.enabled=true -Pskiko.android.enabled=true :skiko:dokkaHtml'
- name: Publish documentation
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: ./skiko/build/dokka/html
\ No newline at end of file
...@@ -9,6 +9,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat ...@@ -9,6 +9,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins { plugins {
kotlin("multiplatform") version "1.6.10" kotlin("multiplatform") version "1.6.10"
id("org.jetbrains.dokka") version "1.6.10"
`maven-publish` `maven-publish`
signing signing
id("org.gradle.crypto.checksum") version "1.1.0" id("org.gradle.crypto.checksum") version "1.1.0"
......
...@@ -22,7 +22,7 @@ actual open class SkiaLayer internal constructor( ...@@ -22,7 +22,7 @@ actual open class SkiaLayer internal constructor(
private val renderFactory: RenderFactory = RenderFactory.Default private val renderFactory: RenderFactory = RenderFactory.Default
) : JPanel() { ) : JPanel() {
companion object { internal companion object {
init { init {
Library.load() Library.load()
} }
...@@ -527,10 +527,16 @@ actual open class SkiaLayer internal constructor( ...@@ -527,10 +527,16 @@ actual open class SkiaLayer internal constructor(
} }
} }
/**
* Disable showing window title bar.
*/
fun SkiaLayer.disableTitleBar(customHeaderHeight: Float) { fun SkiaLayer.disableTitleBar(customHeaderHeight: Float) {
backedLayer.disableTitleBar(customHeaderHeight) backedLayer.disableTitleBar(customHeaderHeight)
} }
/**
* Request to show emoji and symbols popup.
*/
fun orderEmojiAndSymbolsPopup() { fun orderEmojiAndSymbolsPopup() {
platformOperations.orderEmojiAndSymbolsPopup() platformOperations.orderEmojiAndSymbolsPopup()
} }
......
...@@ -8,7 +8,10 @@ package org.jetbrains.skia ...@@ -8,7 +8,10 @@ package org.jetbrains.skia
* Names are based on the GIF 89a spec. * Names are based on the GIF 89a spec.
*/ */
enum class AnimationDisposalMethod { enum class AnimationDisposalMethod {
_UNUSED, /**
* Do not use
*/
UNUSED,
/** /**
* *
......
...@@ -8,7 +8,10 @@ package org.jetbrains.skia ...@@ -8,7 +8,10 @@ package org.jetbrains.skia
* Names are based on the GIF 89a spec. * Names are based on the GIF 89a spec.
*/ */
enum class AnimationDisposalMode { enum class AnimationDisposalMode {
_UNUSED, /**
* Do not use
*/
UNUSED,
/** /**
* *
......
...@@ -46,11 +46,11 @@ class ColorInfo(val colorType: ColorType, val alphaType: ColorAlphaType, val col ...@@ -46,11 +46,11 @@ class ColorInfo(val colorType: ColorType, val alphaType: ColorAlphaType, val col
} }
override fun hashCode(): Int { override fun hashCode(): Int {
val PRIME = 59 val prime = 59
var result = 1 var result = 1
result = result * PRIME + colorType.hashCode() result = result * prime + colorType.hashCode()
result = result * PRIME + alphaType.hashCode() result = result * prime + alphaType.hashCode()
result = result * PRIME + colorSpace.hashCode() result = result * prime + colorSpace.hashCode()
return result return result
} }
......
...@@ -87,14 +87,14 @@ class Data internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol ...@@ -87,14 +87,14 @@ class Data internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
val otherData = other as? Data ?: return false val otherData = other as? Data ?: return false
return _nativeEquals(otherData) return nativeEquals(otherData)
} }
/** /**
* Returns true if these two objects have the same length and contents, * Returns true if these two objects have the same length and contents,
* effectively returning 0 == memcmp(...) * effectively returning 0 == memcmp(...)
*/ */
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Stats.onNativeCall() Stats.onNativeCall()
_nEquals(_ptr, getPtr(other)) _nEquals(_ptr, getPtr(other))
......
package org.jetbrains.skia package org.jetbrains.skia
enum class EncodedOrigin { enum class EncodedOrigin {
_UNUSED, /**
* Do not use
*/
UNUSED,
/** /**
* Default * Default
......
package org.jetbrains.skia package org.jetbrains.skia
expect fun <R> commonSynchronized(lock: Any, block: () -> R) internal expect fun <R> commonSynchronized(lock: Any, block: () -> R)
expect fun String.intCodePoints(): IntArray internal expect fun String.intCodePoints(): IntArray
expect fun defaultLanguageTag(): String internal expect fun defaultLanguageTag(): String
expect abstract class OutputStream expect abstract class OutputStream
...@@ -19,7 +19,7 @@ expect class Matcher { ...@@ -19,7 +19,7 @@ expect class Matcher {
fun matches(): Boolean fun matches(): Boolean
} }
expect fun compilePattern(regex: String): Pattern internal expect fun compilePattern(regex: String): Pattern
@OptIn(ExperimentalMultiplatform::class) @OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation @OptionalExpectation
......
...@@ -77,7 +77,7 @@ class Font : Managed { ...@@ -77,7 +77,7 @@ class Font : Managed {
* Compares fonts, and returns true if they are equivalent. * Compares fonts, and returns true if they are equivalent.
* May return false if Typeface has identical contents but different pointers. * May return false if Typeface has identical contents but different pointers.
*/ */
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Font_nEquals(_ptr, getPtr(other)) Font_nEquals(_ptr, getPtr(other))
} finally { } finally {
......
...@@ -659,7 +659,7 @@ private external fun _nMakeArithmetic( ...@@ -659,7 +659,7 @@ private external fun _nMakeArithmetic(
enforcePMColor: Boolean, enforcePMColor: Boolean,
bg: NativePointer, bg: NativePointer,
fg: NativePointer, fg: NativePointer,
crop: InteropPointer? crop: InteropPointer
): NativePointer ): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeBlend") @ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeBlend")
......
...@@ -49,7 +49,7 @@ class Paint : Managed { ...@@ -49,7 +49,7 @@ class Paint : Managed {
} }
} }
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Paint_nEquals(_ptr, getPtr(other)) Paint_nEquals(_ptr, getPtr(other))
} finally { } finally {
......
...@@ -239,7 +239,7 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol ...@@ -239,7 +239,7 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
* @param other Path to compare * @param other Path to compare
* @return true if this and Path are equivalent * @return true if this and Path are equivalent
*/ */
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Path_nEquals(_ptr, getPtr(other)) Path_nEquals(_ptr, getPtr(other))
} finally { } finally {
......
...@@ -25,7 +25,7 @@ class ArrayDecoder(private val ptr: NativePointer, private val disposePtr: Nativ ...@@ -25,7 +25,7 @@ class ArrayDecoder(private val ptr: NativePointer, private val disposePtr: Nativ
get() = StdVectorDecoder_nGetArraySize(ptr) get() = StdVectorDecoder_nGetArraySize(ptr)
} }
inline fun <T> arrayDecoderScope(arrayDecoderBlock: () -> ArrayDecoder, block: (arrayCode: ArrayDecoder) -> T): T { internal inline fun <T> arrayDecoderScope(arrayDecoderBlock: () -> ArrayDecoder, block: (arrayCode: ArrayDecoder) -> T): T {
var arrayDecoder: ArrayDecoder? = null var arrayDecoder: ArrayDecoder? = null
return try { return try {
arrayDecoder = arrayDecoderBlock() arrayDecoder = arrayDecoderBlock()
......
...@@ -155,7 +155,7 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) { ...@@ -155,7 +155,7 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
/** /**
* @return true if the two typefaces reference the same underlying font, treating null as the default font * @return true if the two typefaces reference the same underlying font, treating null as the default font
*/ */
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Typeface_nEquals(_ptr, getPtr(other)) Typeface_nEquals(_ptr, getPtr(other))
} finally { } finally {
......
package org.jetbrains.skia.impl package org.jetbrains.skia.impl
/**
* Object representing native library containing non-Kotlin part of Skiko.
*/
expect class Library { expect class Library {
companion object { companion object {
fun staticLoad() fun staticLoad()
......
package org.jetbrains.skia.impl package org.jetbrains.skia.impl
/**
* Peer for a native object.
*/
expect abstract class Managed(ptr: NativePointer, finalizer: NativePointer, managed: Boolean = true) : Native { expect abstract class Managed(ptr: NativePointer, finalizer: NativePointer, managed: Boolean = true) : Native {
/**
* Free underlying native resource, peer is useless afterwards.
*/
open fun close() open fun close()
/**
* Check if underlying resource is closed.
*/
open val isClosed: Boolean open val isClosed: Boolean
} }
/**
* Utility function to use managed object and them immediately release it.
*/
inline fun <T: Managed, R> T.use(block: (T) -> R): R { inline fun <T: Managed, R> T.use(block: (T) -> R): R {
return try { return try {
block(this) block(this)
......
...@@ -7,8 +7,8 @@ expect class NativePointer ...@@ -7,8 +7,8 @@ expect class NativePointer
expect class InteropPointer expect class InteropPointer
expect abstract class Native(ptr: NativePointer) { expect abstract class Native(ptr: NativePointer) {
var _ptr: NativePointer internal var _ptr: NativePointer
open fun _nativeEquals(other: Native?): Boolean internal open fun nativeEquals(other: Native?): Boolean
companion object { companion object {
val NullPointer: NativePointer val NullPointer: NativePointer
...@@ -17,11 +17,11 @@ expect abstract class Native(ptr: NativePointer) { ...@@ -17,11 +17,11 @@ expect abstract class Native(ptr: NativePointer) {
override fun toString(): String override fun toString(): String
} }
expect fun reachabilityBarrier(obj: Any?) internal expect fun reachabilityBarrier(obj: Any?)
fun getPtr(n: Native?): NativePointer = n?._ptr ?: Native.NullPointer internal fun getPtr(n: Native?): NativePointer = n?._ptr ?: Native.NullPointer
expect class InteropScope() { internal expect class InteropScope() {
fun toInterop(string: String?): InteropPointer fun toInterop(string: String?): InteropPointer
fun toInterop(array: ByteArray?): InteropPointer fun toInterop(array: ByteArray?): InteropPointer
...@@ -74,16 +74,16 @@ expect class InteropScope() { ...@@ -74,16 +74,16 @@ expect class InteropScope() {
fun release() fun release()
} }
expect inline fun <T> interopScope(block: InteropScope.() -> T): T internal expect inline fun <T> interopScope(block: InteropScope.() -> T): T
inline fun withResult(result: ByteArray, block: InteropScope.(InteropPointer) -> Unit): ByteArray = interopScope { internal inline fun withResult(result: ByteArray, block: InteropScope.(InteropPointer) -> Unit): ByteArray = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
block(handle) block(handle)
handle.fromInterop(result) handle.fromInterop(result)
result result
} }
inline fun withNullableResult(result: ByteArray, block: InteropScope.(InteropPointer) -> Boolean): ByteArray? = interopScope { internal inline fun withNullableResult(result: ByteArray, block: InteropScope.(InteropPointer) -> Boolean): ByteArray? = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
return if (block(handle)) { return if (block(handle)) {
handle.fromInterop(result) handle.fromInterop(result)
...@@ -93,14 +93,14 @@ inline fun withNullableResult(result: ByteArray, block: InteropScope.(InteropPoi ...@@ -93,14 +93,14 @@ inline fun withNullableResult(result: ByteArray, block: InteropScope.(InteropPoi
} }
} }
inline fun withResult(result: FloatArray, block: InteropScope.(InteropPointer) -> Unit): FloatArray = interopScope { internal inline fun withResult(result: FloatArray, block: InteropScope.(InteropPointer) -> Unit): FloatArray = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
block(handle) block(handle)
handle.fromInterop(result) handle.fromInterop(result)
result result
} }
inline fun withNullableResult(result: FloatArray, block: InteropScope.(InteropPointer) -> Boolean): FloatArray? = interopScope { internal inline fun withNullableResult(result: FloatArray, block: InteropScope.(InteropPointer) -> Boolean): FloatArray? = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
val blockResult = block(handle) val blockResult = block(handle)
if (blockResult) { if (blockResult) {
...@@ -111,14 +111,14 @@ inline fun withNullableResult(result: FloatArray, block: InteropScope.(InteropPo ...@@ -111,14 +111,14 @@ inline fun withNullableResult(result: FloatArray, block: InteropScope.(InteropPo
} }
} }
inline fun withResult(result: IntArray, block: InteropScope.(InteropPointer) -> Unit): IntArray = interopScope { internal inline fun withResult(result: IntArray, block: InteropScope.(InteropPointer) -> Unit): IntArray = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
block(handle) block(handle)
handle.fromInterop(result) handle.fromInterop(result)
result result
} }
inline fun withNullableResult(result: IntArray, block: InteropScope.(InteropPointer) -> Boolean): IntArray? = interopScope { internal inline fun withNullableResult(result: IntArray, block: InteropScope.(InteropPointer) -> Boolean): IntArray? = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
return if (block(handle)) { return if (block(handle)) {
handle.fromInterop(result) handle.fromInterop(result)
...@@ -128,21 +128,21 @@ inline fun withNullableResult(result: IntArray, block: InteropScope.(InteropPoin ...@@ -128,21 +128,21 @@ inline fun withNullableResult(result: IntArray, block: InteropScope.(InteropPoin
} }
} }
inline fun withResult(result: ShortArray, block: InteropScope.(InteropPointer) -> Unit): ShortArray = interopScope { internal inline fun withResult(result: ShortArray, block: InteropScope.(InteropPointer) -> Unit): ShortArray = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
block(handle) block(handle)
handle.fromInterop(result) handle.fromInterop(result)
result result
} }
inline fun withResult(result: DoubleArray, block: InteropScope.(InteropPointer) -> Unit): DoubleArray = interopScope { internal inline fun withResult(result: DoubleArray, block: InteropScope.(InteropPointer) -> Unit): DoubleArray = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
block(handle) block(handle)
handle.fromInterop(result) handle.fromInterop(result)
result result
} }
inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPointer) -> Unit): NativePointerArray = interopScope { internal inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPointer) -> Unit): NativePointerArray = interopScope {
val handle = toInteropForResult(result) val handle = toInteropForResult(result)
block(handle) block(handle)
handle.fromInterop(result) handle.fromInterop(result)
...@@ -153,13 +153,11 @@ inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPo ...@@ -153,13 +153,11 @@ inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPo
/** /**
* Creates String from SkString* result and deletes SkString*. * Creates String from SkString* result and deletes SkString*.
*/ */
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") internal inline fun withStringResult(block: () -> NativePointer): String {
inline fun withStringResult(block: () -> NativePointer): String {
return ManagedString(block()).use { it.toString() } return ManagedString(block()).use { it.toString() }
} }
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") internal inline fun withStringResult(pointer: NativePointer): String {
inline fun withStringResult(pointer: NativePointer): String {
return ManagedString(pointer).use { it.toString() } return ManagedString(pointer).use { it.toString() }
} }
...@@ -168,14 +166,12 @@ inline fun withStringResult(pointer: NativePointer): String { ...@@ -168,14 +166,12 @@ inline fun withStringResult(pointer: NativePointer): String {
* It is caller responsibility to destroy underlying SkString. Use it if pointer * It is caller responsibility to destroy underlying SkString. Use it if pointer
* is received from reference (SkString&) * is received from reference (SkString&)
*/ */
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") internal inline fun withStringReferenceResult(block: () -> NativePointer): String {
inline fun withStringReferenceResult(block: () -> NativePointer): String {
val string = ManagedString(block(), false) val string = ManagedString(block(), false)
return string.toString() return string.toString()
} }
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") internal inline fun withStringReferenceNullableResult(block: () -> NativePointer): String? {
inline fun withStringReferenceNullableResult(block: () -> NativePointer): String? {
val ptr = block() val ptr = block()
if (ptr == Native.NullPointer) return null if (ptr == Native.NullPointer) return null
...@@ -184,7 +180,7 @@ inline fun withStringReferenceNullableResult(block: () -> NativePointer): String ...@@ -184,7 +180,7 @@ inline fun withStringReferenceNullableResult(block: () -> NativePointer): String
} }
interface ArrayInteropDecoder<T> { internal interface ArrayInteropDecoder<T> {
fun getArrayElement(array: InteropPointer, index: Int): T fun getArrayElement(array: InteropPointer, index: Int): T
fun getArraySize(array: InteropPointer): Int fun getArraySize(array: InteropPointer): Int
fun disposeArray(array: InteropPointer) fun disposeArray(array: InteropPointer)
......
package org.jetbrains.skia.impl package org.jetbrains.skia.impl
/**
* Peer for reference counted native object.
*/
expect abstract class RefCnt : Managed { expect abstract class RefCnt : Managed {
protected constructor(ptr: NativePointer) protected constructor(ptr: NativePointer)
protected constructor(ptr: NativePointer, allowClose: Boolean) protected constructor(ptr: NativePointer, allowClose: Boolean)
/**
* Number of references on underlying native object.
*/
val refCount: Int val refCount: Int
} }
expect fun RefCnt_nGetFinalizer(): NativePointer internal expect fun RefCnt_nGetFinalizer(): NativePointer
package org.jetbrains.skia.impl package org.jetbrains.skia.impl
/**
* Statistics of native operations.
*/
expect object Stats { expect object Stats {
fun onNativeCall() fun onNativeCall()
......
...@@ -134,7 +134,7 @@ class LineMetrics( ...@@ -134,7 +134,7 @@ class LineMetrics(
return result return result
} }
companion object : ArrayInteropDecoder<LineMetrics> { internal companion object : ArrayInteropDecoder<LineMetrics> {
override fun getArraySize(array: InteropPointer) = LineMetrics_nGetArraySize(array) override fun getArraySize(array: InteropPointer) = LineMetrics_nGetArraySize(array)
override fun disposeArray(array: InteropPointer) = LineMetrics_nDisposeArray(array) override fun disposeArray(array: InteropPointer) = LineMetrics_nDisposeArray(array)
override fun getArrayElement(array: InteropPointer, index: Int): LineMetrics { override fun getArrayElement(array: InteropPointer, index: Int): LineMetrics {
......
...@@ -19,7 +19,7 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) { ...@@ -19,7 +19,7 @@ class ParagraphStyle : Managed(ParagraphStyle_nMake(), _FinalizerHolder.PTR) {
} }
} }
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Stats.onNativeCall() Stats.onNativeCall()
_nEquals(_ptr, getPtr(other)) _nEquals(_ptr, getPtr(other))
......
...@@ -55,7 +55,7 @@ class Shadow(val color: Int, val offsetX: Float, val offsetY: Float, val blurSig ...@@ -55,7 +55,7 @@ class Shadow(val color: Int, val offsetX: Float, val offsetY: Float, val blurSig
companion object companion object
} }
fun Shadow.Companion.fromInteropPointer(shadowsCount: Int, block: InteropScope.(InteropPointer) -> Unit): Array<Shadow> { internal fun Shadow.Companion.fromInteropPointer(shadowsCount: Int, block: InteropScope.(InteropPointer) -> Unit): Array<Shadow> {
return withResult(IntArray(shadowsCount * 5), block).toList().chunked(5).map { (color, offsetX, offsetY, blurSigmaA, blurSigmaB) -> return withResult(IntArray(shadowsCount * 5), block).toList().chunked(5).map { (color, offsetX, offsetY, blurSigmaA, blurSigmaB) ->
val blurSigma = (blurSigmaA.toLong() shl 32) or (blurSigmaB.toLong() and 0xFFFFFFFFL) val blurSigma = (blurSigmaA.toLong() shl 32) or (blurSigmaB.toLong() and 0xFFFFFFFFL)
Shadow(color, Float.fromBits(offsetX), Float.fromBits(offsetY), Double.fromBits(blurSigma)) Shadow(color, Float.fromBits(offsetX), Float.fromBits(offsetY), Double.fromBits(blurSigma))
......
...@@ -25,7 +25,7 @@ class StrutStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finali ...@@ -25,7 +25,7 @@ class StrutStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finali
Stats.onNativeCall() Stats.onNativeCall()
} }
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Stats.onNativeCall() Stats.onNativeCall()
StrutStyle_nEquals(_ptr, getPtr(other)) StrutStyle_nEquals(_ptr, getPtr(other))
......
...@@ -15,7 +15,7 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -15,7 +15,7 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
Stats.onNativeCall() Stats.onNativeCall()
} }
override fun _nativeEquals(other: Native?): Boolean { override fun nativeEquals(other: Native?): Boolean {
return try { return try {
Stats.onNativeCall() Stats.onNativeCall()
TextStyle_nEquals( TextStyle_nEquals(
......
...@@ -40,6 +40,6 @@ class SVGLength(val value: Float, val unit: SVGLengthUnit) { ...@@ -40,6 +40,6 @@ class SVGLength(val value: Float, val unit: SVGLengthUnit) {
} }
fun withUnit(_unit: SVGLengthUnit): SVGLength { fun withUnit(_unit: SVGLengthUnit): SVGLength {
return if (this.unit === unit) this else SVGLength(value, unit) return if (this.unit === _unit) this else SVGLength(value, unit)
} }
} }
\ No newline at end of file
package org.jetbrains.skiko package org.jetbrains.skiko
/**
* Rectangle used for clipping.
*/
interface ClipRectangle { interface ClipRectangle {
val x: Float val x: Float
val y: Float val y: Float
......
...@@ -6,7 +6,7 @@ import org.jetbrains.skia.impl.NativePointer ...@@ -6,7 +6,7 @@ import org.jetbrains.skia.impl.NativePointer
expect fun runTest(block: suspend () -> Unit) expect fun runTest(block: suspend () -> Unit)
expect fun InteropScope.allocateBytesForPixels(size: Int): NativePointer internal expect fun InteropScope.allocateBytesForPixels(size: Int): NativePointer
expect annotation class SkipNativeTarget expect annotation class SkipNativeTarget
......
...@@ -4,7 +4,7 @@ import kotlinx.browser.window ...@@ -4,7 +4,7 @@ import kotlinx.browser.window
actual abstract class OutputStream actual abstract class OutputStream
actual fun <R> commonSynchronized(lock: Any, block: () -> R) { internal actual fun <R> commonSynchronized(lock: Any, block: () -> R) {
block() block()
} }
......
...@@ -8,7 +8,7 @@ private class FinalizationThunk(private val finalizer: NativePointer, private va ...@@ -8,7 +8,7 @@ private class FinalizationThunk(private val finalizer: NativePointer, private va
} }
} }
external class FinalizationRegistry(cleanup: (dynamic) -> Unit) { internal external class FinalizationRegistry(cleanup: (dynamic) -> Unit) {
fun register(obj: dynamic, handle: dynamic) fun register(obj: dynamic, handle: dynamic)
fun unregister(obj: dynamic) fun unregister(obj: dynamic)
} }
......
...@@ -9,12 +9,12 @@ actual abstract class Native actual constructor(ptr: NativePointer) { ...@@ -9,12 +9,12 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
if (this === other) return true if (this === other) return true
if (null == other) return false if (null == other) return false
if (other !is Native) return false if (other !is Native) return false
return if (_ptr == other._ptr) true else _nativeEquals(other) return if (_ptr == other._ptr) true else nativeEquals(other)
} }
override fun hashCode(): Int = _ptr override fun hashCode(): Int = _ptr
actual open fun _nativeEquals(other: Native?): Boolean { internal actual open fun nativeEquals(other: Native?): Boolean {
return false return false
} }
...@@ -33,14 +33,12 @@ actual abstract class Native actual constructor(ptr: NativePointer) { ...@@ -33,14 +33,12 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
} }
} }
actual fun reachabilityBarrier(obj: Any?) { internal actual fun reachabilityBarrier(obj: Any?) {}
// TODO: impl later
}
actual typealias NativePointer = Int actual typealias NativePointer = Int
actual typealias InteropPointer = Int actual typealias InteropPointer = Int
actual inline fun <T> interopScope(block: InteropScope.() -> T): T { internal actual inline fun <T> interopScope(block: InteropScope.() -> T): T {
val scope = InteropScope() val scope = InteropScope()
try { try {
return scope.block() return scope.block()
...@@ -49,7 +47,7 @@ actual inline fun <T> interopScope(block: InteropScope.() -> T): T { ...@@ -49,7 +47,7 @@ actual inline fun <T> interopScope(block: InteropScope.() -> T): T {
} }
} }
actual class InteropScope actual constructor() { internal actual class InteropScope actual constructor() {
private val elements = mutableListOf<NativePointer>() private val elements = mutableListOf<NativePointer>()
private var callbacksInitialized = false private var callbacksInitialized = false
...@@ -216,7 +214,7 @@ actual class InteropScope actual constructor() { ...@@ -216,7 +214,7 @@ actual class InteropScope actual constructor() {
actual inline fun <reified T> InteropPointer.fromInterop(decoder: ArrayInteropDecoder<T>): Array<T> { actual inline fun <reified T> InteropPointer.fromInterop(decoder: ArrayInteropDecoder<T>): Array<T> {
val size = decoder.getArraySize(this) val size = decoder.getArraySize(this)
val result = Array<T>(size) { val result = Array(size) {
decoder.getArrayElement(this, it) decoder.getArrayElement(this, it)
} }
decoder.disposeArray(this) decoder.disposeArray(this)
......
...@@ -23,6 +23,6 @@ private object _FinalizerHolder { ...@@ -23,6 +23,6 @@ private object _FinalizerHolder {
} }
@ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getFinalizer") @ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getFinalizer")
actual external fun RefCnt_nGetFinalizer(): NativePointer internal actual external fun RefCnt_nGetFinalizer(): NativePointer
@ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getRefCount") @ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getRefCount")
private external fun _nGetRefCount(ptr: NativePointer): Int private external fun _nGetRefCount(ptr: NativePointer): Int
...@@ -13,7 +13,7 @@ actual fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise { ...@@ -13,7 +13,7 @@ actual fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise {
block() block()
} }
actual fun InteropScope.allocateBytesForPixels(size: Int): NativePointer { internal actual fun InteropScope.allocateBytesForPixels(size: Int): NativePointer {
return toInterop(ByteArray(size)) return toInterop(ByteArray(size))
} }
...@@ -23,4 +23,4 @@ actual annotation class SkipJvmTarget ...@@ -23,4 +23,4 @@ actual annotation class SkipJvmTarget
actual annotation class SkipNativeTarget actual annotation class SkipNativeTarget
actual fun makeFromFileName(path: String?): Data = Data(0) actual fun makeFromFileName(path: String?): Data = Data(0)
\ No newline at end of file
...@@ -2,11 +2,11 @@ package org.jetbrains.skia ...@@ -2,11 +2,11 @@ package org.jetbrains.skia
import java.util.* import java.util.*
actual fun <R> commonSynchronized(lock: Any, block: () -> R) { internal actual fun <R> commonSynchronized(lock: Any, block: () -> R) {
synchronized(lock, block) synchronized(lock, block)
} }
actual fun String.intCodePoints(): IntArray = this.codePoints().toArray() internal actual fun String.intCodePoints(): IntArray = this.codePoints().toArray()
actual typealias Pattern = java.util.regex.Pattern actual typealias Pattern = java.util.regex.Pattern
...@@ -14,6 +14,6 @@ actual typealias Matcher = java.util.regex.Matcher ...@@ -14,6 +14,6 @@ actual typealias Matcher = java.util.regex.Matcher
actual fun defaultLanguageTag(): String = Locale.getDefault().toLanguageTag() actual fun defaultLanguageTag(): String = Locale.getDefault().toLanguageTag()
actual fun compilePattern(regex: String): Pattern = Pattern.compile(regex) internal actual fun compilePattern(regex: String): Pattern = Pattern.compile(regex)
actual typealias OutputStream = java.io.OutputStream actual typealias OutputStream = java.io.OutputStream
...@@ -3,7 +3,7 @@ package org.jetbrains.skia.impl ...@@ -3,7 +3,7 @@ package org.jetbrains.skia.impl
import java.lang.ref.Reference import java.lang.ref.Reference
actual abstract class Native actual constructor(ptr: NativePointer) { actual abstract class Native actual constructor(ptr: NativePointer) {
actual var _ptr: NativePointer internal actual var _ptr: NativePointer
actual companion object { actual companion object {
actual val NullPointer: NativePointer actual val NullPointer: NativePointer
...@@ -20,7 +20,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) { ...@@ -20,7 +20,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
if (null == other) return false if (null == other) return false
if (!javaClass.isInstance(other)) return false if (!javaClass.isInstance(other)) return false
val nOther = other as Native val nOther = other as Native
if (_ptr == nOther._ptr) true else _nativeEquals(nOther) if (_ptr == nOther._ptr) true else nativeEquals(nOther)
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
Reference.reachabilityFence(other) Reference.reachabilityFence(other)
...@@ -32,7 +32,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) { ...@@ -32,7 +32,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
return java.lang.Long.hashCode(_ptr) return java.lang.Long.hashCode(_ptr)
} }
actual open fun _nativeEquals(other: Native?): Boolean { internal actual open fun nativeEquals(other: Native?): Boolean {
return false return false
} }
...@@ -42,7 +42,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) { ...@@ -42,7 +42,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
} }
} }
actual fun reachabilityBarrier(obj: Any?) { internal actual fun reachabilityBarrier(obj: Any?) {
Reference.reachabilityFence(obj) Reference.reachabilityFence(obj)
} }
...@@ -50,12 +50,12 @@ actual typealias NativePointer = Long ...@@ -50,12 +50,12 @@ actual typealias NativePointer = Long
actual typealias InteropPointer = Any? actual typealias InteropPointer = Any?
object theScope: InteropScope() internal object theScope: InteropScope()
actual inline fun <T> interopScope(block: InteropScope.() -> T): T { internal actual inline fun <T> interopScope(block: InteropScope.() -> T): T {
return theScope.block() return theScope.block()
} }
actual open class InteropScope actual constructor() { internal actual open class InteropScope actual constructor() {
actual fun toInterop(string: String?): InteropPointer = string actual fun toInterop(string: String?): InteropPointer = string
actual fun toInterop(array: ByteArray?): InteropPointer = array actual fun toInterop(array: ByteArray?): InteropPointer = array
......
...@@ -31,4 +31,4 @@ actual abstract class RefCnt : Managed { ...@@ -31,4 +31,4 @@ actual abstract class RefCnt : Managed {
} }
} }
actual fun RefCnt_nGetFinalizer() = RefCnt._nGetFinalizer() internal actual fun RefCnt_nGetFinalizer() = RefCnt._nGetFinalizer()
\ No newline at end of file \ No newline at end of file
...@@ -12,7 +12,7 @@ actual fun runTest(block: suspend () -> Unit) { ...@@ -12,7 +12,7 @@ actual fun runTest(block: suspend () -> Unit) {
runBlocking { block() } runBlocking { block() }
} }
actual fun InteropScope.allocateBytesForPixels(size: Int): NativePointer { internal actual fun InteropScope.allocateBytesForPixels(size: Int): NativePointer {
return BufferUtil.getPointerFromByteBuffer(ByteBuffer.allocateDirect(size)) return BufferUtil.getPointerFromByteBuffer(ByteBuffer.allocateDirect(size))
} }
......
...@@ -78,7 +78,7 @@ sealed class RunIteratorBase(type: Int, ptr: NativePointer) : Managed(ptr, _Fina ...@@ -78,7 +78,7 @@ sealed class RunIteratorBase(type: Int, ptr: NativePointer) : Managed(ptr, _Fina
} }
} }
protected abstract fun InteropScope.getOnCurrentCallback(): InteropPointer internal abstract fun InteropScope.getOnCurrentCallback(): InteropPointer
companion object { companion object {
fun fromIterator(iterator: Iterator<BidiRun?>, text: ManagedString): RunIteratorBase = fun fromIterator(iterator: Iterator<BidiRun?>, text: ManagedString): RunIteratorBase =
......
...@@ -7,11 +7,11 @@ import org.jetbrains.skia.impl.withResult ...@@ -7,11 +7,11 @@ import org.jetbrains.skia.impl.withResult
actual abstract class OutputStream actual abstract class OutputStream
actual fun <R> commonSynchronized(lock: Any, block: () -> R) { internal actual fun <R> commonSynchronized(lock: Any, block: () -> R) {
block() block()
} }
actual fun String.intCodePoints(): IntArray = IntArray(this.length) { this[it].code } internal actual fun String.intCodePoints(): IntArray = IntArray(this.length) { this[it].code }
actual class Pattern constructor(regex: String) { actual class Pattern constructor(regex: String) {
private val _regex = Regex(regex) private val _regex = Regex(regex)
...@@ -42,9 +42,9 @@ private val LANG by lazy { ...@@ -42,9 +42,9 @@ private val LANG by lazy {
langTag.ifEmpty { "en-US" } langTag.ifEmpty { "en-US" }
} }
actual fun defaultLanguageTag(): String = LANG internal actual fun defaultLanguageTag(): String = LANG
actual fun compilePattern(regex: String): Pattern = Pattern(regex) internal actual fun compilePattern(regex: String): Pattern = Pattern(regex)
actual typealias ExternalSymbolName = kotlin.native.SymbolName actual typealias ExternalSymbolName = kotlin.native.SymbolName
......
...@@ -59,4 +59,4 @@ actual abstract class Managed actual constructor( ...@@ -59,4 +59,4 @@ actual abstract class Managed actual constructor(
} }
@ExternalSymbolName("org_jetbrains_skia_impl_Managed__invokeFinalizer") @ExternalSymbolName("org_jetbrains_skia_impl_Managed__invokeFinalizer")
external fun _nInvokeFinalizer(finalizer: NativePointer, ptr: NativePointer) internal external fun _nInvokeFinalizer(finalizer: NativePointer, ptr: NativePointer)
...@@ -5,20 +5,20 @@ import org.jetbrains.skia.ExternalSymbolName ...@@ -5,20 +5,20 @@ import org.jetbrains.skia.ExternalSymbolName
import kotlin.native.internal.NativePtr import kotlin.native.internal.NativePtr
actual abstract class Native actual constructor(ptr: NativePointer) { actual abstract class Native actual constructor(ptr: NativePointer) {
actual var _ptr: NativePointer internal actual var _ptr: NativePointer
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (null == other) return false if (null == other) return false
if (other !is Native) return false if (other !is Native) return false
return if (_ptr == other._ptr) true else _nativeEquals(other) return if (_ptr == other._ptr) true else nativeEquals(other)
} }
override fun hashCode(): Int { override fun hashCode(): Int {
return _ptr.toLong().hashCode() return _ptr.toLong().hashCode()
} }
actual open fun _nativeEquals(other: Native?): Boolean { internal actual open fun nativeEquals(other: Native?): Boolean {
return false return false
} }
...@@ -50,11 +50,11 @@ actual abstract class Native actual constructor(ptr: NativePointer) { ...@@ -50,11 +50,11 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
actual typealias NativePointer = NativePtr actual typealias NativePointer = NativePtr
actual typealias InteropPointer = NativePtr actual typealias InteropPointer = NativePtr
actual fun reachabilityBarrier(obj: Any?) { internal actual fun reachabilityBarrier(obj: Any?) {
// TODO: implement native barrier // TODO: implement native barrier
} }
actual inline fun <T> interopScope(block: InteropScope.() -> T): T { internal actual inline fun <T> interopScope(block: InteropScope.() -> T): T {
val scope = InteropScope() val scope = InteropScope()
try { try {
return scope.block() return scope.block()
...@@ -63,7 +63,7 @@ actual inline fun <T> interopScope(block: InteropScope.() -> T): T { ...@@ -63,7 +63,7 @@ actual inline fun <T> interopScope(block: InteropScope.() -> T): T {
} }
} }
actual class InteropScope actual constructor() { internal actual class InteropScope actual constructor() {
actual fun toInterop(string: String?): InteropPointer { actual fun toInterop(string: String?): InteropPointer {
return if (string != null) { return if (string != null) {
// encodeToByteArray encodes to utf8 // encodeToByteArray encodes to utf8
......
...@@ -25,6 +25,6 @@ actual abstract class RefCnt : Managed { ...@@ -25,6 +25,6 @@ actual abstract class RefCnt : Managed {
} }
@ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getFinalizer") @ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getFinalizer")
actual external fun RefCnt_nGetFinalizer(): NativePointer internal actual external fun RefCnt_nGetFinalizer(): NativePointer
@ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getRefCount") @ExternalSymbolName("org_jetbrains_skia_impl_RefCnt__getRefCount")
private external fun _nGetRefCount(ptr: NativePointer): Int private external fun _nGetRefCount(ptr: NativePointer): Int
...@@ -10,7 +10,7 @@ actual fun runTest(block: suspend () -> Unit) { ...@@ -10,7 +10,7 @@ actual fun runTest(block: suspend () -> Unit) {
runBlocking { block() } runBlocking { block() }
} }
actual fun InteropScope.allocateBytesForPixels(size: Int): NativePointer { internal actual fun InteropScope.allocateBytesForPixels(size: Int): NativePointer {
return toInterop(ByteArray(size)) return toInterop(ByteArray(size))
} }
......
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