Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
8e84e9e0
Unverified
Commit
8e84e9e0
authored
Feb 07, 2022
by
Nikolay Igotti
Committed by
GitHub
Feb 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate docs (#480)
parent
9a95f214
Changes
44
Show whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
165 additions
and
93 deletions
+165
-93
ci.yml
.github/workflows/ci.yml
+3
-2
docs.yml
.github/workflows/docs.yml
+33
-0
build.gradle.kts
skiko/build.gradle.kts
+1
-0
SkiaLayer.awt.kt
...o/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
+7
-1
AnimationDisposalMethod.kt
...Main/kotlin/org/jetbrains/skia/AnimationDisposalMethod.kt
+4
-1
AnimationDisposalMode.kt
...onMain/kotlin/org/jetbrains/skia/AnimationDisposalMode.kt
+4
-1
ColorInfo.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/ColorInfo.kt
+4
-4
Data.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Data.kt
+2
-2
EncodedOrigin.kt
...src/commonMain/kotlin/org/jetbrains/skia/EncodedOrigin.kt
+4
-1
Expects.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
+4
-4
Font.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Font.kt
+1
-1
ImageFilter.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/ImageFilter.kt
+1
-1
Paint.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Paint.kt
+1
-1
Path.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Path.kt
+1
-1
StdVectorDecoder.kt
.../commonMain/kotlin/org/jetbrains/skia/StdVectorDecoder.kt
+1
-1
Typeface.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
+1
-1
Library.kt
.../src/commonMain/kotlin/org/jetbrains/skia/impl/Library.kt
+3
-0
Managed.kt
.../src/commonMain/kotlin/org/jetbrains/skia/impl/Managed.kt
+13
-0
Native.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/impl/Native.kt
+20
-24
RefCnt.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/impl/RefCnt.kt
+7
-1
Stats.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Stats.kt
+3
-0
LineMetrics.kt
...onMain/kotlin/org/jetbrains/skia/paragraph/LineMetrics.kt
+1
-1
ParagraphStyle.kt
...ain/kotlin/org/jetbrains/skia/paragraph/ParagraphStyle.kt
+1
-1
Shadow.kt
.../commonMain/kotlin/org/jetbrains/skia/paragraph/Shadow.kt
+1
-1
StrutStyle.kt
...monMain/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
+1
-1
TextStyle.kt
...mmonMain/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
+1
-1
SVGLength.kt
...src/commonMain/kotlin/org/jetbrains/skia/svg/SVGLength.kt
+1
-1
ClipRectangle.kt
...rc/commonMain/kotlin/org/jetbrains/skiko/ClipRectangle.kt
+3
-0
TestUtils.kt
.../commonTest/kotlin/org/jetbrains/skiko/tests/TestUtils.kt
+1
-1
Actuals.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skia/Actuals.js.kt
+1
-1
Managed.js.kt
...o/src/jsMain/kotlin/org/jetbrains/skia/impl/Managed.js.kt
+1
-1
Native.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/Native.js.kt
+6
-8
RefCnt.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/RefCnt.js.kt
+1
-1
TestUtils.js.kt
skiko/src/jsTest/kotlin/TestUtils.js.kt
+2
-2
Actuals.jvm.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Actuals.jvm.kt
+3
-3
Native.jvm.kt
.../src/jvmMain/kotlin/org/jetbrains/skia/impl/Native.jvm.kt
+7
-7
RefCnt.jvm.kt
.../src/jvmMain/kotlin/org/jetbrains/skia/impl/RefCnt.jvm.kt
+1
-1
TestUtils.jvm.kt
skiko/src/jvmTest/kotlin/TestUtils.jvm.kt
+1
-1
Shaper.nativejs.kt
...sMain/kotlin/org/jetbrains/skia/shaper/Shaper.nativejs.kt
+1
-1
Actuals.native.kt
...rc/nativeMain/kotlin/org/jetbrains/skia/Actuals.native.kt
+4
-4
Managed.native.kt
...tiveMain/kotlin/org/jetbrains/skia/impl/Managed.native.kt
+1
-1
Native.native.kt
...ativeMain/kotlin/org/jetbrains/skia/impl/Native.native.kt
+6
-6
RefCnt.native.kt
...ativeMain/kotlin/org/jetbrains/skia/impl/RefCnt.native.kt
+1
-1
TestUtils.native.kt
...Test/kotlin/org/jetbrains/skiko/tests/TestUtils.native.kt
+1
-1
No files found.
.github/workflows/
blank
.yml
→
.github/workflows/
ci
.yml
View file @
8e84e9e0
# This is a basic workflow to help you get started with Actions
# Default Skiko CI
name
:
CI
# Controls when the action will run.
...
...
@@ -7,6 +6,7 @@ on:
# Triggers the workflow on push or pull request events but only for the master branch
push
:
branches
:
[
master
]
# TODO: temporary for faster tests, restore!
pull_request
:
branches
:
[
master
]
...
...
@@ -160,3 +160,4 @@ jobs:
name
:
test-reports-windows
path
:
./skiko/build/reports/tests
retention-days
:
5
.github/workflows/docs.yml
0 → 100644
View file @
8e84e9e0
# 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
skiko/build.gradle.kts
View file @
8e84e9e0
...
...
@@ -9,6 +9,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins
{
kotlin
(
"multiplatform"
)
version
"1.6.10"
id
(
"org.jetbrains.dokka"
)
version
"1.6.10"
`
maven
-
publish
`
signing
id
(
"org.gradle.crypto.checksum"
)
version
"1.1.0"
...
...
skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
View file @
8e84e9e0
...
...
@@ -22,7 +22,7 @@ actual open class SkiaLayer internal constructor(
private
val
renderFactory
:
RenderFactory
=
RenderFactory
.
Default
)
:
JPanel
()
{
companion
object
{
internal
companion
object
{
init
{
Library
.
load
()
}
...
...
@@ -527,10 +527,16 @@ actual open class SkiaLayer internal constructor(
}
}
/**
* Disable showing window title bar.
*/
fun
SkiaLayer
.
disableTitleBar
(
customHeaderHeight
:
Float
)
{
backedLayer
.
disableTitleBar
(
customHeaderHeight
)
}
/**
* Request to show emoji and symbols popup.
*/
fun
orderEmojiAndSymbolsPopup
()
{
platformOperations
.
orderEmojiAndSymbolsPopup
()
}
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/AnimationDisposalMethod.kt
View file @
8e84e9e0
...
...
@@ -8,7 +8,10 @@ package org.jetbrains.skia
* Names are based on the GIF 89a spec.
*/
enum
class
AnimationDisposalMethod
{
_UNUSED
,
/**
* Do not use
*/
UNUSED
,
/**
*
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/AnimationDisposalMode.kt
View file @
8e84e9e0
...
...
@@ -8,7 +8,10 @@ package org.jetbrains.skia
* Names are based on the GIF 89a spec.
*/
enum
class
AnimationDisposalMode
{
_UNUSED
,
/**
* Do not use
*/
UNUSED
,
/**
*
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/ColorInfo.kt
View file @
8e84e9e0
...
...
@@ -46,11 +46,11 @@ class ColorInfo(val colorType: ColorType, val alphaType: ColorAlphaType, val col
}
override
fun
hashCode
():
Int
{
val
PRIME
=
59
val
prime
=
59
var
result
=
1
result
=
result
*
PRIME
+
colorType
.
hashCode
()
result
=
result
*
PRIME
+
alphaType
.
hashCode
()
result
=
result
*
PRIME
+
colorSpace
.
hashCode
()
result
=
result
*
prime
+
colorType
.
hashCode
()
result
=
result
*
prime
+
alphaType
.
hashCode
()
result
=
result
*
prime
+
colorSpace
.
hashCode
()
return
result
}
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Data.kt
View file @
8e84e9e0
...
...
@@ -87,14 +87,14 @@ class Data internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
override
fun
equals
(
other
:
Any
?):
Boolean
{
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,
* effectively returning 0 == memcmp(...)
*/
override
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
override
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nEquals
(
_ptr
,
getPtr
(
other
))
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/EncodedOrigin.kt
View file @
8e84e9e0
package
org.jetbrains.skia
enum
class
EncodedOrigin
{
_UNUSED
,
/**
* Do not use
*/
UNUSED
,
/**
* Default
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
View file @
8e84e9e0
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
...
...
@@ -19,7 +19,7 @@ expect class Matcher {
fun
matches
():
Boolean
}
expect
fun
compilePattern
(
regex
:
String
):
Pattern
internal
expect
fun
compilePattern
(
regex
:
String
):
Pattern
@OptIn
(
ExperimentalMultiplatform
::
class
)
@OptionalExpectation
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Font.kt
View file @
8e84e9e0
...
...
@@ -77,7 +77,7 @@ class Font : Managed {
* Compares fonts, and returns true if they are equivalent.
* 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
{
Font_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/ImageFilter.kt
View file @
8e84e9e0
...
...
@@ -659,7 +659,7 @@ private external fun _nMakeArithmetic(
enforcePMColor
:
Boolean
,
bg
:
NativePointer
,
fg
:
NativePointer
,
crop
:
InteropPointer
?
crop
:
InteropPointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_ImageFilter__1nMakeBlend"
)
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Paint.kt
View file @
8e84e9e0
...
...
@@ -49,7 +49,7 @@ class Paint : Managed {
}
}
override
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
override
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Paint_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Path.kt
View file @
8e84e9e0
...
...
@@ -239,7 +239,7 @@ class Path internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
* @param other Path to compare
* @return true if this and Path are equivalent
*/
override
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
override
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Path_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/StdVectorDecoder.kt
View file @
8e84e9e0
...
...
@@ -25,7 +25,7 @@ class ArrayDecoder(private val ptr: NativePointer, private val disposePtr: Nativ
get
()
=
StdVectorDecoder_nGetArraySize
(
ptr
)
}
inline
fun
<
T
>
arrayDecoderScope
(
arrayDecoderBlock
:
()
->
ArrayDecoder
,
block
:
(
arrayCode
:
ArrayDecoder
)
->
T
):
T
{
in
ternal
in
line
fun
<
T
>
arrayDecoderScope
(
arrayDecoderBlock
:
()
->
ArrayDecoder
,
block
:
(
arrayCode
:
ArrayDecoder
)
->
T
):
T
{
var
arrayDecoder
:
ArrayDecoder
?
=
null
return
try
{
arrayDecoder
=
arrayDecoderBlock
()
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
View file @
8e84e9e0
...
...
@@ -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
*/
override
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
override
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Typeface_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Library.kt
View file @
8e84e9e0
package
org.jetbrains.skia.impl
/**
* Object representing native library containing non-Kotlin part of Skiko.
*/
expect
class
Library
{
companion
object
{
fun
staticLoad
()
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Managed.kt
View file @
8e84e9e0
package
org.jetbrains.skia.impl
/**
* Peer for a native object.
*/
expect
abstract
class
Managed
(
ptr
:
NativePointer
,
finalizer
:
NativePointer
,
managed
:
Boolean
=
true
)
:
Native
{
/**
* Free underlying native resource, peer is useless afterwards.
*/
open
fun
close
()
/**
* Check if underlying resource is closed.
*/
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
{
return
try
{
block
(
this
)
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Native.kt
View file @
8e84e9e0
...
...
@@ -7,8 +7,8 @@ expect class NativePointer
expect
class
InteropPointer
expect
abstract
class
Native
(
ptr
:
NativePointer
)
{
var
_ptr
:
NativePointer
open
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
internal
var
_ptr
:
NativePointer
internal
open
fun
nativeEquals
(
other
:
Native
?):
Boolean
companion
object
{
val
NullPointer
:
NativePointer
...
...
@@ -17,11 +17,11 @@ expect abstract class Native(ptr: NativePointer) {
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
(
array
:
ByteArray
?):
InteropPointer
...
...
@@ -74,16 +74,16 @@ expect class InteropScope() {
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
{
in
ternal
in
line
fun
withResult
(
result
:
ByteArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
ByteArray
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
block
(
handle
)
handle
.
fromInterop
(
result
)
result
}
inline
fun
withNullableResult
(
result
:
ByteArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Boolean
):
ByteArray
?
=
interopScope
{
in
ternal
in
line
fun
withNullableResult
(
result
:
ByteArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Boolean
):
ByteArray
?
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
return
if
(
block
(
handle
))
{
handle
.
fromInterop
(
result
)
...
...
@@ -93,14 +93,14 @@ inline fun withNullableResult(result: ByteArray, block: InteropScope.(InteropPoi
}
}
inline
fun
withResult
(
result
:
FloatArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
FloatArray
=
interopScope
{
in
ternal
in
line
fun
withResult
(
result
:
FloatArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
FloatArray
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
block
(
handle
)
handle
.
fromInterop
(
result
)
result
}
inline
fun
withNullableResult
(
result
:
FloatArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Boolean
):
FloatArray
?
=
interopScope
{
in
ternal
in
line
fun
withNullableResult
(
result
:
FloatArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Boolean
):
FloatArray
?
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
val
blockResult
=
block
(
handle
)
if
(
blockResult
)
{
...
...
@@ -111,14 +111,14 @@ inline fun withNullableResult(result: FloatArray, block: InteropScope.(InteropPo
}
}
inline
fun
withResult
(
result
:
IntArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
IntArray
=
interopScope
{
in
ternal
in
line
fun
withResult
(
result
:
IntArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
IntArray
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
block
(
handle
)
handle
.
fromInterop
(
result
)
result
}
inline
fun
withNullableResult
(
result
:
IntArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Boolean
):
IntArray
?
=
interopScope
{
in
ternal
in
line
fun
withNullableResult
(
result
:
IntArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Boolean
):
IntArray
?
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
return
if
(
block
(
handle
))
{
handle
.
fromInterop
(
result
)
...
...
@@ -128,21 +128,21 @@ inline fun withNullableResult(result: IntArray, block: InteropScope.(InteropPoin
}
}
inline
fun
withResult
(
result
:
ShortArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
ShortArray
=
interopScope
{
in
ternal
in
line
fun
withResult
(
result
:
ShortArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
ShortArray
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
block
(
handle
)
handle
.
fromInterop
(
result
)
result
}
inline
fun
withResult
(
result
:
DoubleArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
DoubleArray
=
interopScope
{
in
ternal
in
line
fun
withResult
(
result
:
DoubleArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
DoubleArray
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
block
(
handle
)
handle
.
fromInterop
(
result
)
result
}
inline
fun
withResult
(
result
:
NativePointerArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
NativePointerArray
=
interopScope
{
in
ternal
in
line
fun
withResult
(
result
:
NativePointerArray
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
NativePointerArray
=
interopScope
{
val
handle
=
toInteropForResult
(
result
)
block
(
handle
)
handle
.
fromInterop
(
result
)
...
...
@@ -153,13 +153,11 @@ inline fun withResult(result: NativePointerArray, block: InteropScope.(InteropPo
/**
* Creates String from SkString* result and deletes SkString*.
*/
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
inline
fun
withStringResult
(
block
:
()
->
NativePointer
):
String
{
internal
inline
fun
withStringResult
(
block
:
()
->
NativePointer
):
String
{
return
ManagedString
(
block
()).
use
{
it
.
toString
()
}
}
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
inline
fun
withStringResult
(
pointer
:
NativePointer
):
String
{
internal
inline
fun
withStringResult
(
pointer
:
NativePointer
):
String
{
return
ManagedString
(
pointer
).
use
{
it
.
toString
()
}
}
...
...
@@ -168,14 +166,12 @@ inline fun withStringResult(pointer: NativePointer): String {
* It is caller responsibility to destroy underlying SkString. Use it if pointer
* is received from reference (SkString&)
*/
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
inline
fun
withStringReferenceResult
(
block
:
()
->
NativePointer
):
String
{
internal
inline
fun
withStringReferenceResult
(
block
:
()
->
NativePointer
):
String
{
val
string
=
ManagedString
(
block
(),
false
)
return
string
.
toString
()
}
@Suppress
(
"NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
)
inline
fun
withStringReferenceNullableResult
(
block
:
()
->
NativePointer
):
String
?
{
internal
inline
fun
withStringReferenceNullableResult
(
block
:
()
->
NativePointer
):
String
?
{
val
ptr
=
block
()
if
(
ptr
==
Native
.
NullPointer
)
return
null
...
...
@@ -184,7 +180,7 @@ inline fun withStringReferenceNullableResult(block: () -> NativePointer): String
}
interface
ArrayInteropDecoder
<
T
>
{
inter
nal
inter
face
ArrayInteropDecoder
<
T
>
{
fun
getArrayElement
(
array
:
InteropPointer
,
index
:
Int
):
T
fun
getArraySize
(
array
:
InteropPointer
):
Int
fun
disposeArray
(
array
:
InteropPointer
)
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/RefCnt.kt
View file @
8e84e9e0
package
org.jetbrains.skia.impl
/**
* Peer for reference counted native object.
*/
expect
abstract
class
RefCnt
:
Managed
{
protected
constructor
(
ptr
:
NativePointer
)
protected
constructor
(
ptr
:
NativePointer
,
allowClose
:
Boolean
)
/**
* Number of references on underlying native object.
*/
val
refCount
:
Int
}
expect
fun
RefCnt_nGetFinalizer
():
NativePointer
internal
expect
fun
RefCnt_nGetFinalizer
():
NativePointer
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Stats.kt
View file @
8e84e9e0
package
org.jetbrains.skia.impl
/**
* Statistics of native operations.
*/
expect
object
Stats
{
fun
onNativeCall
()
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/paragraph/LineMetrics.kt
View file @
8e84e9e0
...
...
@@ -134,7 +134,7 @@ class LineMetrics(
return
result
}
companion
object
:
ArrayInteropDecoder
<
LineMetrics
>
{
internal
companion
object
:
ArrayInteropDecoder
<
LineMetrics
>
{
override
fun
getArraySize
(
array
:
InteropPointer
)
=
LineMetrics_nGetArraySize
(
array
)
override
fun
disposeArray
(
array
:
InteropPointer
)
=
LineMetrics_nDisposeArray
(
array
)
override
fun
getArrayElement
(
array
:
InteropPointer
,
index
:
Int
):
LineMetrics
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/paragraph/ParagraphStyle.kt
View file @
8e84e9e0
...
...
@@ -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
{
Stats
.
onNativeCall
()
_nEquals
(
_ptr
,
getPtr
(
other
))
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/paragraph/Shadow.kt
View file @
8e84e9e0
...
...
@@ -55,7 +55,7 @@ class Shadow(val color: Int, val offsetX: Float, val offsetY: Float, val blurSig
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
)
->
val
blurSigma
=
(
blurSigmaA
.
toLong
()
shl
32
)
or
(
blurSigmaB
.
toLong
()
and
0
xFFFFFFFFL
)
Shadow
(
color
,
Float
.
fromBits
(
offsetX
),
Float
.
fromBits
(
offsetY
),
Double
.
fromBits
(
blurSigma
))
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
View file @
8e84e9e0
...
...
@@ -25,7 +25,7 @@ class StrutStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finali
Stats
.
onNativeCall
()
}
override
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
override
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
StrutStyle_nEquals
(
_ptr
,
getPtr
(
other
))
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
View file @
8e84e9e0
...
...
@@ -15,7 +15,7 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
Stats
.
onNativeCall
()
}
override
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
override
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
TextStyle_nEquals
(
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/svg/SVGLength.kt
View file @
8e84e9e0
...
...
@@ -40,6 +40,6 @@ class SVGLength(val value: Float, val unit: SVGLengthUnit) {
}
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
skiko/src/commonMain/kotlin/org/jetbrains/skiko/ClipRectangle.kt
View file @
8e84e9e0
package
org.jetbrains.skiko
/**
* Rectangle used for clipping.
*/
interface
ClipRectangle
{
val
x
:
Float
val
y
:
Float
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skiko/tests/TestUtils.kt
View file @
8e84e9e0
...
...
@@ -6,7 +6,7 @@ import org.jetbrains.skia.impl.NativePointer
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
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skia/Actuals.js.kt
View file @
8e84e9e0
...
...
@@ -4,7 +4,7 @@ import kotlinx.browser.window
actual
abstract
class
OutputStream
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
internal
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
block
()
}
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/Managed.js.kt
View file @
8e84e9e0
...
...
@@ -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
unregister
(
obj
:
dynamic
)
}
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/Native.js.kt
View file @
8e84e9e0
...
...
@@ -9,12 +9,12 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
if
(
this
===
other
)
return
true
if
(
null
==
other
)
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
actual
open
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
internal
actual
open
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
false
}
...
...
@@ -33,14 +33,12 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
}
}
actual
fun
reachabilityBarrier
(
obj
:
Any
?)
{
// TODO: impl later
}
internal
actual
fun
reachabilityBarrier
(
obj
:
Any
?)
{}
actual
typealias
NativePointer
=
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
()
try
{
return
scope
.
block
()
...
...
@@ -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
var
callbacksInitialized
=
false
...
...
@@ -216,7 +214,7 @@ actual class InteropScope actual constructor() {
actual
inline
fun
<
reified
T
>
InteropPointer
.
fromInterop
(
decoder
:
ArrayInteropDecoder
<
T
>):
Array
<
T
>
{
val
size
=
decoder
.
getArraySize
(
this
)
val
result
=
Array
<
T
>
(
size
)
{
val
result
=
Array
(
size
)
{
decoder
.
getArrayElement
(
this
,
it
)
}
decoder
.
disposeArray
(
this
)
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/RefCnt.js.kt
View file @
8e84e9e0
...
...
@@ -23,6 +23,6 @@ private object _FinalizerHolder {
}
@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"
)
private
external
fun
_nGetRefCount
(
ptr
:
NativePointer
):
Int
skiko/src/jsTest/kotlin/TestUtils.js.kt
View file @
8e84e9e0
...
...
@@ -13,7 +13,7 @@ actual fun runTest(block: suspend () -> Unit): dynamic = GlobalScope.promise {
block
()
}
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
internal
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
return
toInterop
(
ByteArray
(
size
))
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Actuals.jvm.kt
View file @
8e84e9e0
...
...
@@ -2,11 +2,11 @@ package org.jetbrains.skia
import
java.util.*
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
internal
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
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
...
...
@@ -14,6 +14,6 @@ actual typealias Matcher = java.util.regex.Matcher
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
skiko/src/jvmMain/kotlin/org/jetbrains/skia/impl/Native.jvm.kt
View file @
8e84e9e0
...
...
@@ -3,7 +3,7 @@ package org.jetbrains.skia.impl
import
java.lang.ref.Reference
actual
abstract
class
Native
actual
constructor
(
ptr
:
NativePointer
)
{
actual
var
_ptr
:
NativePointer
internal
actual
var
_ptr
:
NativePointer
actual
companion
object
{
actual
val
NullPointer
:
NativePointer
...
...
@@ -20,7 +20,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
if
(
null
==
other
)
return
false
if
(!
javaClass
.
isInstance
(
other
))
return
false
val
nOther
=
other
as
Native
if
(
_ptr
==
nOther
.
_ptr
)
true
else
_
nativeEquals
(
nOther
)
if
(
_ptr
==
nOther
.
_ptr
)
true
else
nativeEquals
(
nOther
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
...
...
@@ -32,7 +32,7 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
return
java
.
lang
.
Long
.
hashCode
(
_ptr
)
}
actual
open
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
internal
actual
open
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
false
}
...
...
@@ -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
)
}
...
...
@@ -50,12 +50,12 @@ actual typealias NativePointer = Long
actual
typealias
InteropPointer
=
Any
?
object
theScope
:
InteropScope
()
actual
inline
fun
<
T
>
interopScope
(
block
:
InteropScope
.()
->
T
):
T
{
internal
object
theScope
:
InteropScope
()
internal
actual
inline
fun
<
T
>
interopScope
(
block
:
InteropScope
.()
->
T
):
T
{
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
(
array
:
ByteArray
?):
InteropPointer
=
array
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/impl/RefCnt.jvm.kt
View file @
8e84e9e0
...
...
@@ -31,4 +31,4 @@ actual abstract class RefCnt : Managed {
}
}
actual
fun
RefCnt_nGetFinalizer
()
=
RefCnt
.
_nGetFinalizer
()
\ No newline at end of file
internal
actual
fun
RefCnt_nGetFinalizer
()
=
RefCnt
.
_nGetFinalizer
()
\ No newline at end of file
skiko/src/jvmTest/kotlin/TestUtils.jvm.kt
View file @
8e84e9e0
...
...
@@ -12,7 +12,7 @@ actual fun runTest(block: suspend () -> Unit) {
runBlocking
{
block
()
}
}
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
internal
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
return
BufferUtil
.
getPointerFromByteBuffer
(
ByteBuffer
.
allocateDirect
(
size
))
}
...
...
skiko/src/nativeJsMain/kotlin/org/jetbrains/skia/shaper/Shaper.nativejs.kt
View file @
8e84e9e0
...
...
@@ -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
{
fun
fromIterator
(
iterator
:
Iterator
<
BidiRun
?
>,
text
:
ManagedString
):
RunIteratorBase
=
...
...
skiko/src/nativeMain/kotlin/org/jetbrains/skia/Actuals.native.kt
View file @
8e84e9e0
...
...
@@ -7,11 +7,11 @@ import org.jetbrains.skia.impl.withResult
actual
abstract
class
OutputStream
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
internal
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
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
)
{
private
val
_regex
=
Regex
(
regex
)
...
...
@@ -42,9 +42,9 @@ private val LANG by lazy {
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
...
...
skiko/src/nativeMain/kotlin/org/jetbrains/skia/impl/Managed.native.kt
View file @
8e84e9e0
...
...
@@ -59,4 +59,4 @@ actual abstract class Managed actual constructor(
}
@ExternalSymbolName
(
"org_jetbrains_skia_impl_Managed__invokeFinalizer"
)
external
fun
_nInvokeFinalizer
(
finalizer
:
NativePointer
,
ptr
:
NativePointer
)
internal
external
fun
_nInvokeFinalizer
(
finalizer
:
NativePointer
,
ptr
:
NativePointer
)
skiko/src/nativeMain/kotlin/org/jetbrains/skia/impl/Native.native.kt
View file @
8e84e9e0
...
...
@@ -5,20 +5,20 @@ import org.jetbrains.skia.ExternalSymbolName
import
kotlin.native.internal.NativePtr
actual
abstract
class
Native
actual
constructor
(
ptr
:
NativePointer
)
{
actual
var
_ptr
:
NativePointer
internal
actual
var
_ptr
:
NativePointer
override
fun
equals
(
other
:
Any
?):
Boolean
{
if
(
this
===
other
)
return
true
if
(
null
==
other
)
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
{
return
_ptr
.
toLong
().
hashCode
()
}
actual
open
fun
_
nativeEquals
(
other
:
Native
?):
Boolean
{
internal
actual
open
fun
nativeEquals
(
other
:
Native
?):
Boolean
{
return
false
}
...
...
@@ -50,11 +50,11 @@ actual abstract class Native actual constructor(ptr: NativePointer) {
actual
typealias
NativePointer
=
NativePtr
actual
typealias
InteropPointer
=
NativePtr
actual
fun
reachabilityBarrier
(
obj
:
Any
?)
{
internal
actual
fun
reachabilityBarrier
(
obj
:
Any
?)
{
// 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
()
try
{
return
scope
.
block
()
...
...
@@ -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
{
return
if
(
string
!=
null
)
{
// encodeToByteArray encodes to utf8
...
...
skiko/src/nativeMain/kotlin/org/jetbrains/skia/impl/RefCnt.native.kt
View file @
8e84e9e0
...
...
@@ -25,6 +25,6 @@ actual abstract class RefCnt : Managed {
}
@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"
)
private
external
fun
_nGetRefCount
(
ptr
:
NativePointer
):
Int
skiko/src/nativeTest/kotlin/org/jetbrains/skiko/tests/TestUtils.native.kt
View file @
8e84e9e0
...
...
@@ -10,7 +10,7 @@ actual fun runTest(block: suspend () -> Unit) {
runBlocking
{
block
()
}
}
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
internal
actual
fun
InteropScope
.
allocateBytesForPixels
(
size
:
Int
):
NativePointer
{
return
toInterop
(
ByteArray
(
size
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment