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
5c256dcf
Unverified
Commit
5c256dcf
authored
Sep 03, 2021
by
Nikolay Igotti
Committed by
GitHub
Sep 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Roughly complete commonization (#161)
parent
fc166bd6
Changes
36
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
352 additions
and
377 deletions
+352
-377
Codec.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Codec.kt
+20
-22
Expects.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
+2
-0
FontExtents.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/FontExtents.kt
+10
-8
OutputWStream.kt
...src/commonMain/kotlin/org/jetbrains/skia/OutputWStream.kt
+2
-1
PaintFilterCanvas.kt
...commonMain/kotlin/org/jetbrains/skia/PaintFilterCanvas.kt
+4
-4
PathMeasure.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/PathMeasure.kt
+18
-18
PictureRecorder.kt
...c/commonMain/kotlin/org/jetbrains/skia/PictureRecorder.kt
+7
-5
RuntimeEffect.kt
...src/commonMain/kotlin/org/jetbrains/skia/RuntimeEffect.kt
+2
-0
ShadowUtils.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/ShadowUtils.kt
+4
-2
Surface.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Surface.kt
+66
-119
TextBlobBuilder.kt
...c/commonMain/kotlin/org/jetbrains/skia/TextBlobBuilder.kt
+15
-16
Managed.kt
.../src/commonMain/kotlin/org/jetbrains/skia/impl/Managed.kt
+2
-1
DecorationStyle.kt
...in/kotlin/org/jetbrains/skia/paragraph/DecorationStyle.kt
+2
-2
FontCollection.kt
...ain/kotlin/org/jetbrains/skia/paragraph/FontCollection.kt
+17
-16
LineMetrics.kt
...onMain/kotlin/org/jetbrains/skia/paragraph/LineMetrics.kt
+16
-16
Paragraph.kt
...mmonMain/kotlin/org/jetbrains/skia/paragraph/Paragraph.kt
+32
-31
ParagraphBuilder.kt
...n/kotlin/org/jetbrains/skia/paragraph/ParagraphBuilder.kt
+11
-10
ParagraphCache.kt
...ain/kotlin/org/jetbrains/skia/paragraph/ParagraphCache.kt
+15
-13
ParagraphStyle.kt
...ain/kotlin/org/jetbrains/skia/paragraph/ParagraphStyle.kt
+20
-18
PlaceholderStyle.kt
...n/kotlin/org/jetbrains/skia/paragraph/PlaceholderStyle.kt
+11
-11
PositionWithAffinity.kt
...tlin/org/jetbrains/skia/paragraph/PositionWithAffinity.kt
+3
-3
Shadow.kt
.../commonMain/kotlin/org/jetbrains/skia/paragraph/Shadow.kt
+7
-7
StrutStyle.kt
...monMain/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
+14
-12
TextBox.kt
...commonMain/kotlin/org/jetbrains/skia/paragraph/TextBox.kt
+0
-0
TextStyle.kt
...mmonMain/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
+32
-30
TypefaceFontProvider.kt
...tlin/org/jetbrains/skia/paragraph/TypefaceFontProvider.kt
+5
-5
TextBlobBuilderRunHandler.kt
...in/org/jetbrains/skia/shaper/TextBlobBuilderRunHandler.kt
+6
-6
TrivialBidiRunIterator.kt
...otlin/org/jetbrains/skia/shaper/TrivialBidiRunIterator.kt
+0
-0
TrivialFontRunIterator.kt
...otlin/org/jetbrains/skia/shaper/TrivialFontRunIterator.kt
+0
-0
TrivialScriptRunIterator.kt
...lin/org/jetbrains/skia/shaper/TrivialScriptRunIterator.kt
+0
-0
Actuals.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skia/Actuals.js.kt
+1
-0
Managed.js.kt
...o/src/jsMain/kotlin/org/jetbrains/skia/impl/Managed.js.kt
+3
-0
Actuals.jvm.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Actuals.jvm.kt
+1
-0
Managed.jvm.kt
...src/jvmMain/kotlin/org/jetbrains/skia/impl/Managed.jvm.kt
+1
-1
Actuals.native.kt
.../macosX64Main/kotlin/org/jetbrains/skia/Actuals.native.kt
+1
-0
Managed.native.kt
...sX64Main/kotlin/org/jetbrains/skia/impl/Managed.native.kt
+2
-0
No files found.
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Codec.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Codec.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.IllegalArgumentException
import
java.lang.RuntimeException
import
java.lang.UnsupportedOperationException
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Codec
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
),
IHasImageInfo
{
companion
object
{
...
...
@@ -19,11 +17,11 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromData
(
Native
.
getPtr
(
data
))
_nMakeFromData
(
getPtr
(
data
))
require
(
ptr
!=
0L
)
{
"Unsupported format"
}
Codec
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
data
)
}
}
...
...
@@ -67,29 +65,29 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
}
_imageInfo
!!
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
size
:
IPoint
get
()
=
try
{
Stats
.
onNativeCall
()
IPoint
.
Companion
.
_makeFromLong
(
_nGetSize
(
_ptr
))
IPoint
.
_makeFromLong
(
_nGetSize
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
encodedOrigin
:
EncodedOrigin
get
()
=
try
{
Stats
.
onNativeCall
()
EncodedOrigin
.
values
().
get
(
_nGetEncodedOrigin
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
encodedImageFormat
:
EncodedImageFormat
get
()
=
try
{
Stats
.
onNativeCall
()
EncodedImageFormat
.
values
().
get
(
_nGetEncodedImageFormat
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -150,14 +148,14 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
_validateResult
(
_nReadPixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
getPtr
(
bitmap
),
0
,
-
1
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
bitmap
)
}
}
...
...
@@ -207,14 +205,14 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
_validateResult
(
_nReadPixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
getPtr
(
bitmap
),
frame
,
-
1
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
bitmap
)
}
}
...
...
@@ -265,14 +263,14 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
_validateResult
(
_nReadPixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
getPtr
(
bitmap
),
frame
,
priorFrame
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
bitmap
)
}
}
...
...
@@ -288,7 +286,7 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nGetFrameCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -305,7 +303,7 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nGetFrameInfo
(
_ptr
,
frame
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -328,7 +326,7 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nGetFramesInfo
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -355,7 +353,7 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nGetRepetitionCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
internal
object
_FinalizerHolder
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
View file @
5c256dcf
...
...
@@ -8,6 +8,8 @@ expect fun String.intCodePoints(): IntArray
expect
fun
defaultLanguageTag
():
String
expect
abstract
class
OutputStream
expect
class
Pattern
{
fun
split
(
input
:
CharSequence
):
Array
<
String
?
>?
fun
matcher
(
input
:
CharSequence
):
Matcher
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontExtents.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontExtents.kt
View file @
5c256dcf
package
org.jetbrains.skia
import
kotlin.math.abs
class
FontExtents
(
val
ascender
:
Float
,
val
descender
:
Float
,
val
lineGap
:
Float
)
{
val
ascenderAbs
:
Float
get
()
=
Math
.
abs
(
ascender
)
get
()
=
abs
(
ascender
)
val
lineHeight
:
Float
get
()
=
-
ascender
+
descender
+
lineGap
...
...
@@ -11,9 +13,9 @@ class FontExtents(val ascender: Float, val descender: Float, val lineGap: Float)
if
(
o
!
is
FontExtents
)
return
false
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
java
.
lang
.
Float
.
compare
(
ascender
,
other
.
ascender
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
descender
,
other
.
descender
)
!=
0
)
return
false
return
if
(
java
.
lang
.
Float
.
compare
(
lineGap
,
other
.
lineGap
)
!=
0
)
false
else
true
if
(
ascender
.
compareTo
(
other
.
ascender
)
!=
0
)
return
false
if
(
descender
.
compareTo
(
other
.
descender
)
!=
0
)
return
false
return
lineGap
.
compareTo
(
other
.
lineGap
)
==
0
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -23,13 +25,13 @@ class FontExtents(val ascender: Float, val descender: Float, val lineGap: Float)
override
fun
hashCode
():
Int
{
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
ascender
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
descender
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
lineGap
)
result
=
result
*
PRIME
+
ascender
.
toBits
(
)
result
=
result
*
PRIME
+
descender
.
toBits
(
)
result
=
result
*
PRIME
+
lineGap
.
toBits
(
)
return
result
}
override
fun
toString
():
String
{
return
"FontExtents(_ascender=
"
+
ascender
+
", _descender="
+
descender
+
", _lineGap="
+
lineGap
+
"
)"
return
"FontExtents(_ascender=
$ascender, _descender=$descender, _lineGap=$lineGap
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/OutputWStream.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/OutputWStream.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Stats
import
java.io.OutputStream
import
kotlin.jvm.JvmStatic
class
OutputWStream
(
out
:
OutputStream
?)
:
WStream
(
_nMake
(
out
),
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PaintFilterCanvas.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PaintFilterCanvas.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
/**
* A utility proxy base class for implementing draw/paint filters.
*/
abstract
class
PaintFilterCanvas
(
canvas
:
Canvas
,
unrollDrawable
:
Boolean
)
:
Canvas
(
_nMake
(
Native
.
Companion
.
getPtr
(
canvas
),
unrollDrawable
),
true
,
canvas
)
{
Canvas
(
_nMake
(
getPtr
(
canvas
),
unrollDrawable
),
true
,
canvas
)
{
companion
object
{
external
fun
_nMake
(
canvasPtr
:
Long
,
unrollDrawable
:
Boolean
):
Long
...
...
@@ -42,6 +42,6 @@ abstract class PaintFilterCanvas(canvas: Canvas, unrollDrawable: Boolean) :
Stats
.
onNativeCall
()
_nAttachToJava
(
_ptr
)
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
canvas
)
reachabilityBarrier
(
canvas
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PathMeasure.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PathMeasure.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
PathMeasure
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -53,14 +54,13 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
* Initialize the pathmeasure with the specified path. The parts of the path that are needed
* are copied, so the client is free to modify/delete the path after this call.
*/
@JvmOverloads
constructor
(
path
:
Path
?,
forceClosed
:
Boolean
=
false
,
resScale
:
Float
=
1f
)
:
this
(
_nMakePath
(
Native
.
Companion
.
getPtr
(
path
),
forceClosed
,
resScale
))
{
)
:
this
(
_nMakePath
(
getPtr
(
path
),
forceClosed
,
resScale
))
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
path
)
reachabilityBarrier
(
path
)
}
/**
...
...
@@ -70,10 +70,10 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
fun
setPath
(
path
:
Path
?,
forceClosed
:
Boolean
):
PathMeasure
{
return
try
{
Stats
.
onNativeCall
()
_nSetPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
path
),
forceClosed
)
_nSetPath
(
_ptr
,
getPtr
(
path
),
forceClosed
)
this
}
finally
{
Reference
.
reachabilityFence
(
path
)
reachabilityBarrier
(
path
)
}
}
...
...
@@ -86,7 +86,7 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
Stats
.
onNativeCall
()
_nGetLength
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -100,7 +100,7 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
Stats
.
onNativeCall
()
_nGetPosition
(
_ptr
,
distance
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -115,7 +115,7 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
Stats
.
onNativeCall
()
_nGetTangent
(
_ptr
,
distance
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -130,7 +130,7 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
Stats
.
onNativeCall
()
_nGetRSXform
(
_ptr
,
distance
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -144,9 +144,9 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
return
try
{
Stats
.
onNativeCall
()
val
mat
=
_nGetMatrix
(
_ptr
,
distance
,
getPosition
,
getTangent
)
mat
?.
let
{
Matrix33
(*
it
.
c
lone
())
}
mat
?.
let
{
Matrix33
(*
it
.
c
opyOf
())
}
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -164,12 +164,12 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
_ptr
,
startD
,
endD
,
Native
.
Companion
.
getPtr
(
dst
),
getPtr
(
dst
),
startWithMoveTo
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dst
)
}
}
...
...
@@ -181,7 +181,7 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
Stats
.
onNativeCall
()
_nIsClosed
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -193,7 +193,7 @@ class PathMeasure internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolde
Stats
.
onNativeCall
()
_nNextContour
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PictureRecorder.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PictureRecorder.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
PictureRecorder
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -72,7 +74,7 @@ class PictureRecorder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
),
false
,
this
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -85,7 +87,7 @@ class PictureRecorder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
val
ptr
=
_nGetRecordingCanvas
(
_ptr
)
if
(
ptr
==
0L
)
null
else
Canvas
(
ptr
,
false
,
this
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -104,7 +106,7 @@ class PictureRecorder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
Stats
.
onNativeCall
()
Picture
(
_nFinishRecordingAsPicture
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -131,7 +133,7 @@ class PictureRecorder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
}
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/RuntimeEffect.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/RuntimeEffect.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
kotlin.jvm.JvmStatic
class
RuntimeEffect
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/ShadowUtils.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/ShadowUtils.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
kotlin.jvm.JvmStatic
object
ShadowUtils
{
/**
...
...
@@ -39,8 +41,8 @@ object ShadowUtils {
if
(
transparentOccluder
)
flags
=
flags
or
1
if
(
geometricOnly
)
flags
=
flags
or
2
_nDrawShadow
(
Native
.
Companion
.
getPtr
(
canvas
),
Native
.
Companion
.
getPtr
(
path
),
Native
.
getPtr
(
canvas
),
Native
.
getPtr
(
path
),
zPlaneParams
.
x
,
zPlaneParams
.
y
,
zPlaneParams
.
z
,
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Surface.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Surface.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.IllegalArgumentException
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Surface
:
RefCnt
{
companion
object
{
...
...
@@ -53,21 +53,16 @@ class Surface : RefCnt {
surfaceProps
:
SurfaceProps
?
):
Surface
{
return
try
{
assert
(
pixmap
!=
null
)
{
"Can’t makeRasterDirect with pixmap == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeRasterDirectWithPixmap
(
Native
.
Companion
.
getPtr
(
pixmap
),
surfaceProps
getPtr
(
pixmap
),
surfaceProps
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeRasterDirect(%s, %s)"
,
pixmap
,
surfaceProps
)
"Failed Surface.makeRasterDirect($pixmap, $surfaceProps)"
}
Surface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -107,30 +102,23 @@ class Surface : RefCnt {
surfaceProps
:
SurfaceProps
?
):
Surface
{
return
try
{
assert
(
imageInfo
!=
null
)
{
"Can’t makeRasterDirect with imageInfo == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeRasterDirect
(
imageInfo
.
width
,
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
pixelsPtr
,
rowBytes
,
surfaceProps
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeRasterDirect(%s, %d, %d, %s)"
,
imageInfo
,
pixelsPtr
,
rowBytes
,
surfaceProps
)
"Failed Surface.makeRasterDirect($imageInfo, $pixelsPtr, $rowBytes, $surfaceProps)"
}
Surface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -213,28 +201,22 @@ class Surface : RefCnt {
surfaceProps
:
SurfaceProps
?
):
Surface
{
return
try
{
assert
(
imageInfo
!=
null
)
{
"Can’t makeRaster with imageInfo == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeRaster
(
imageInfo
.
width
,
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
rowBytes
,
surfaceProps
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeRaster(%s, %d, %s)"
,
imageInfo
,
rowBytes
,
surfaceProps
)
"Failed Surface.makeRaster($imageInfo, $rowBytes, $surfaceProps)"
}
Surface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
}
}
/**
...
...
@@ -282,7 +264,6 @@ class Surface : RefCnt {
* @return Surface if all parameters are valid; otherwise, null
* @see [https://fiddle.skia.org/c/@Surface_MakeFromBackendTexture](https://fiddle.skia.org/c/@Surface_MakeFromBackendTexture)
*/
@JvmOverloads
fun
makeFromBackendRenderTarget
(
context
:
DirectContext
,
rt
:
BackendRenderTarget
,
...
...
@@ -292,34 +273,23 @@ class Surface : RefCnt {
surfaceProps
:
SurfaceProps
?
=
null
):
Surface
{
return
try
{
assert
(
context
!=
null
)
{
"Can’t makeFromBackendRenderTarget with context == null"
}
assert
(
rt
!=
null
)
{
"Can’t makeFromBackendRenderTarget with rt == null"
}
assert
(
origin
!=
null
)
{
"Can’t makeFromBackendRenderTarget with origin == null"
}
assert
(
colorFormat
!=
null
)
{
"Can’t makeFromBackendRenderTarget with colorFormat == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromBackendRenderTarget
(
Native
.
Companion
.
getPtr
(
context
),
Native
.
Companion
.
getPtr
(
rt
),
getPtr
(
context
),
getPtr
(
rt
),
origin
.
ordinal
,
colorFormat
.
ordinal
,
Native
.
Companion
.
getPtr
(
colorSpace
),
getPtr
(
colorSpace
),
surfaceProps
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeFromBackendRenderTarget(%s, %s, %s, %s, %s)"
,
context
,
rt
,
origin
,
colorFormat
,
colorSpace
)
"Failed Surface.makeFromBackendRenderTarget($context, $rt, $origin, $colorFormat, $colorSpace)"
}
Surface
(
ptr
,
context
,
rt
)
}
finally
{
Reference
.
reachabilityFence
(
context
)
Reference
.
reachabilityFence
(
rt
)
Reference
.
reachabilityFence
(
colorSpace
)
reachabilityBarrier
(
context
)
reachabilityBarrier
(
rt
)
reachabilityBarrier
(
colorSpace
)
}
}
...
...
@@ -333,34 +303,23 @@ class Surface : RefCnt {
surfaceProps
:
SurfaceProps
?
):
Surface
{
return
try
{
assert
(
context
!=
null
)
{
"Can’t makeFromBackendRenderTarget with context == null"
}
assert
(
origin
!=
null
)
{
"Can’t makeFromBackendRenderTarget with origin == null"
}
assert
(
colorFormat
!=
null
)
{
"Can’t makeFromBackendRenderTarget with colorFormat == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromMTKView
(
Native
.
Companion
.
getPtr
(
context
),
getPtr
(
context
),
mtkViewPtr
,
origin
.
ordinal
,
sampleCount
,
colorFormat
.
ordinal
,
Native
.
Companion
.
getPtr
(
colorSpace
),
getPtr
(
colorSpace
),
surfaceProps
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeFromMTKView(%s, %s, %s, %s, %s, %s)"
,
context
,
mtkViewPtr
,
origin
,
colorFormat
,
colorSpace
,
surfaceProps
)
"Failed Surface.makeFromMTKView($context, $mtkViewPtr $origin, $colorFormat, $surfaceProps)"
}
Surface
(
ptr
,
context
)
}
finally
{
Reference
.
reachabilityFence
(
context
)
Reference
.
reachabilityFence
(
colorSpace
)
reachabilityBarrier
(
context
)
reachabilityBarrier
(
colorSpace
)
}
}
...
...
@@ -390,7 +349,7 @@ class Surface : RefCnt {
fun
makeRasterN32Premul
(
width
:
Int
,
height
:
Int
):
Surface
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeRasterN32Premul
(
width
,
height
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeRasterN32Premul(%d, %d)"
,
width
,
height
)
}
require
(
ptr
!=
0L
)
{
"Failed Surface.makeRasterN32Premul($width, $height)"
}
return
Surface
(
ptr
)
}
...
...
@@ -526,39 +485,27 @@ class Surface : RefCnt {
shouldCreateWithMips
:
Boolean
):
Surface
{
return
try
{
assert
(
context
!=
null
)
{
"Can’t makeFromBackendRenderTarget with context == null"
}
assert
(
imageInfo
!=
null
)
{
"Can’t makeFromBackendRenderTarget with imageInfo == null"
}
assert
(
origin
!=
null
)
{
"Can’t makeFromBackendRenderTarget with origin == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeRenderTarget
(
Native
.
getPtr
(
context
),
getPtr
(
context
),
budgeted
,
imageInfo
.
width
,
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
Companion
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
sampleCount
,
origin
.
ordinal
,
surfaceProps
,
shouldCreateWithMips
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeRenderTarget(%s, %b, %s, %d, %s, %s, %b)"
,
context
,
budgeted
,
imageInfo
,
sampleCount
,
origin
,
surfaceProps
,
shouldCreateWithMips
)
"Failed Surface.makeRenderTarget($context, $budgeted, $imageInfo, $sampleCount, $origin, $surfaceProps, $shouldCreateWithMips)"
}
Surface
(
ptr
,
context
)
}
finally
{
Reference
.
reachabilityFence
(
context
)
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
context
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -575,7 +522,7 @@ class Surface : RefCnt {
fun
makeNull
(
width
:
Int
,
height
:
Int
):
Surface
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeNull
(
width
,
height
)
require
(
ptr
!=
0L
)
{
String
.
format
(
"Failed Surface.makeNull(%d, %d)"
,
width
,
height
)
}
require
(
ptr
!=
0L
)
{
"Failed Surface.makeNull($width, $height)"
}
return
Surface
(
ptr
)
}
...
...
@@ -686,7 +633,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nGetWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -701,7 +648,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -715,7 +662,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nGetImageInfo
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -733,7 +680,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nGenerationId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -750,7 +697,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nNotifyContentWillChange
(
_ptr
,
mode
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -766,7 +713,7 @@ class Surface : RefCnt {
val
ptr
=
_nGetRecordingContext
(
_ptr
)
if
(
ptr
==
0L
)
null
else
DirectContext
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -785,7 +732,7 @@ class Surface : RefCnt {
val
ptr
=
_nGetCanvas
(
_ptr
)
if
(
ptr
==
0L
)
throw
IllegalArgumentException
()
else
Canvas
(
ptr
,
false
,
this
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -812,11 +759,11 @@ class Surface : RefCnt {
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
Companion
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
)
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
)
)
Surface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -842,7 +789,7 @@ class Surface : RefCnt {
val
ptr
=
_nMakeSurface
(
_ptr
,
width
,
height
)
Surface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -862,7 +809,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
Image
(
_nMakeImageSnapshot
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -896,7 +843,7 @@ class Surface : RefCnt {
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -916,11 +863,11 @@ class Surface : RefCnt {
fun
draw
(
canvas
:
Canvas
?,
x
:
Int
,
y
:
Int
,
paint
:
Paint
?)
{
try
{
Stats
.
onNativeCall
()
_nDraw
(
_ptr
,
Native
.
Companion
.
getPtr
(
canvas
),
x
.
toFloat
(),
y
.
toFloat
(),
Native
.
Companion
.
getPtr
(
paint
))
_nDraw
(
_ptr
,
getPtr
(
canvas
),
x
.
toFloat
(),
y
.
toFloat
(),
getPtr
(
paint
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
canvas
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
canvas
)
reachabilityBarrier
(
paint
)
}
}
...
...
@@ -929,11 +876,11 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nPeekPixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixmap
)
getPtr
(
pixmap
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -942,13 +889,13 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nReadPixelsToPixmap
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixmap
),
getPtr
(
pixmap
),
srcX
,
srcY
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -997,23 +944,23 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nReadPixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
getPtr
(
bitmap
),
srcX
,
srcY
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
bitmap
)
}
}
fun
writePixels
(
pixmap
:
Pixmap
?,
x
:
Int
,
y
:
Int
)
{
try
{
Stats
.
onNativeCall
()
_nWritePixelsFromPixmap
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixmap
),
x
,
y
)
_nWritePixelsFromPixmap
(
_ptr
,
getPtr
(
pixmap
),
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -1037,10 +984,10 @@ class Surface : RefCnt {
fun
writePixels
(
bitmap
:
Bitmap
?,
x
:
Int
,
y
:
Int
)
{
try
{
Stats
.
onNativeCall
()
_nWritePixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
x
,
y
)
_nWritePixels
(
_ptr
,
getPtr
(
bitmap
),
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
bitmap
)
}
}
...
...
@@ -1060,7 +1007,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nFlushAndSubmit
(
_ptr
,
false
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -1082,7 +1029,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nFlushAndSubmit
(
_ptr
,
syncCpu
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -1091,7 +1038,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nFlush
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -1107,7 +1054,7 @@ class Surface : RefCnt {
Stats
.
onNativeCall
()
_nUnique
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
internal
constructor
(
ptr
:
Long
)
:
super
(
ptr
)
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/TextBlobBuilder.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/TextBlobBuilder.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
TextBlobBuilder
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -58,7 +59,7 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
val
ptr
=
_nBuild
(
_ptr
)
if
(
ptr
==
0L
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -119,7 +120,7 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
Stats
.
onNativeCall
()
_nAppendRun
(
_ptr
,
Native
.
getPtr
(
font
),
getPtr
(
font
),
glyphs
,
x
,
y
,
...
...
@@ -127,7 +128,7 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
)
this
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
/**
...
...
@@ -156,7 +157,6 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
* @param y vertical offset within the blob
* @return this
*/
@JvmOverloads
fun
appendRunPosH
(
font
:
Font
?,
glyphs
:
ShortArray
,
...
...
@@ -165,11 +165,11 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
bounds
:
Rect
?
=
null
):
TextBlobBuilder
{
return
try
{
assert
(
glyphs
.
size
==
xs
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != xs.length "
+
xs
.
size
}
require
(
glyphs
.
size
==
xs
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != xs.length "
+
xs
.
size
}
Stats
.
onNativeCall
()
_nAppendRunPosH
(
_ptr
,
Native
.
Companion
.
getPtr
(
font
),
getPtr
(
font
),
glyphs
,
xs
,
y
,
...
...
@@ -177,7 +177,7 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
)
this
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
/**
...
...
@@ -204,10 +204,9 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
* @param pos positions of glyphs within the blob
* @return this
*/
@JvmOverloads
fun
appendRunPos
(
font
:
Font
?,
glyphs
:
ShortArray
,
pos
:
Array
<
Point
>,
bounds
:
Rect
?
=
null
):
TextBlobBuilder
{
return
try
{
assert
(
glyphs
.
size
==
pos
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != pos.length "
+
pos
.
size
}
require
(
glyphs
.
size
==
pos
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != pos.length "
+
pos
.
size
}
val
floatPos
=
FloatArray
(
pos
.
size
*
2
)
for
(
i
in
pos
.
indices
)
{
floatPos
[
i
*
2
]
=
pos
[
i
].
x
...
...
@@ -216,20 +215,20 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
Stats
.
onNativeCall
()
_nAppendRunPos
(
_ptr
,
Native
.
Companion
.
getPtr
(
font
),
getPtr
(
font
),
glyphs
,
floatPos
,
bounds
)
this
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
fun
appendRunRSXform
(
font
:
Font
?,
glyphs
:
ShortArray
,
xform
:
Array
<
RSXform
>):
TextBlobBuilder
{
return
try
{
assert
(
glyphs
.
size
==
xform
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != xform.length "
+
xform
.
size
}
require
(
glyphs
.
size
==
xform
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != xform.length "
+
xform
.
size
}
val
floatXform
=
FloatArray
(
xform
.
size
*
4
)
for
(
i
in
xform
.
indices
)
{
floatXform
[
i
*
4
]
=
xform
[
i
].
scos
...
...
@@ -240,13 +239,13 @@ class TextBlobBuilder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
Stats
.
onNativeCall
()
_nAppendRunRSXform
(
_ptr
,
Native
.
Companion
.
getPtr
(
font
),
getPtr
(
font
),
glyphs
,
floatXform
)
this
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Managed.kt
View file @
5c256dcf
package
org.jetbrains.skia.impl
expect
abstract
class
Managed
(
ptr
:
Long
,
finalizer
:
Long
,
managed
:
Boolean
=
true
)
:
Native
{
open
fun
close
():
Unit
open
fun
close
()
open
val
isClosed
:
Boolean
}
inline
fun
<
T
:
Managed
,
R
>
T
.
use
(
block
:
(
T
)
->
R
):
R
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/DecorationStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/DecorationStyle.kt
View file @
5c256dcf
...
...
@@ -60,7 +60,7 @@ class DecorationStyle(
if
(
_lineThrough
!=
other
.
_lineThrough
)
return
false
if
(
_gaps
!=
other
.
_gaps
)
return
false
if
(
color
!=
other
.
color
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
thicknessMultiplier
,
other
.
thicknessMultiplier
)
!=
0
)
return
false
if
(
thicknessMultiplier
.
compareTo
(
other
.
thicknessMultiplier
)
!=
0
)
return
false
val
`
this
$
_lineStyle
`
:
Any
=
lineStyle
val
`
other
$
_lineStyle
`
:
Any
=
other
.
lineStyle
return
`
this
$
_lineStyle
`
==
`
other
$
_lineStyle
`
...
...
@@ -78,7 +78,7 @@ class DecorationStyle(
result
=
result
*
PRIME
+
if
(
_lineThrough
)
79
else
97
result
=
result
*
PRIME
+
if
(
_gaps
)
79
else
97
result
=
result
*
PRIME
+
color
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
thicknessMultiplier
)
result
=
result
*
PRIME
+
thicknessMultiplier
.
toBits
(
)
val
`$
_lineStyle
`
:
Any
=
lineStyle
result
=
result
*
PRIME
+
(
`$
_lineStyle
`
?.
hashCode
()
?:
43
)
return
result
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/FontCollection.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/FontCollection.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
FontCollection
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -36,16 +37,16 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetFontManagersCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setAssetFontManager
(
fontMgr
:
FontMgr
?):
FontCollection
{
return
try
{
Stats
.
onNativeCall
()
_nSetAssetFontManager
(
_ptr
,
Native
.
Companion
.
getPtr
(
fontMgr
))
_nSetAssetFontManager
(
_ptr
,
getPtr
(
fontMgr
))
this
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -54,21 +55,21 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nSetDynamicFontManager
(
_ptr
,
Native
.
Companion
.
getPtr
(
fontMgr
)
getPtr
(
fontMgr
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
fun
setTestFontManager
(
fontMgr
:
FontMgr
?):
FontCollection
{
return
try
{
Stats
.
onNativeCall
()
_nSetTestFontManager
(
_ptr
,
Native
.
Companion
.
getPtr
(
fontMgr
))
_nSetTestFontManager
(
_ptr
,
getPtr
(
fontMgr
))
this
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -81,12 +82,12 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nSetDefaultFontManager
(
_ptr
,
Native
.
Companion
.
getPtr
(
fontMgr
),
getPtr
(
fontMgr
),
defaultFamilyName
)
this
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -96,7 +97,7 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
val
ptr
=
_nGetFallbackManager
(
_ptr
)
if
(
ptr
==
0L
)
null
else
FontMgr
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
findTypefaces
(
familyNames
:
Array
<
String
?
>?,
style
:
FontStyle
):
Array
<
Typeface
?
>
{
...
...
@@ -107,7 +108,7 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
for
(
i
in
ptrs
.
indices
)
res
[
i
]
=
Typeface
(
ptrs
[
i
])
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -117,7 +118,7 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
val
ptr
=
_nDefaultFallbackChar
(
_ptr
,
unicode
,
style
.
_value
,
locale
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -127,7 +128,7 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
val
ptr
=
_nDefaultFallback
(
_ptr
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -142,6 +143,6 @@ class FontCollection internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
ParagraphCache
(
this
,
_nGetParagraphCache
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/LineMetrics.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/LineMetrics.kt
View file @
5c256dcf
...
...
@@ -103,14 +103,14 @@ class LineMetrics(
if
(
endExcludingWhitespaces
!=
other
.
endExcludingWhitespaces
)
return
false
if
(
endIncludingNewline
!=
other
.
endIncludingNewline
)
return
false
if
(
isHardBreak
!=
other
.
isHardBreak
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
ascent
,
other
.
ascent
)
!=
0
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
descent
,
other
.
descent
)
!=
0
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
unscaledAscent
,
other
.
unscaledAscent
)
!=
0
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
height
,
other
.
height
)
!=
0
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
width
,
other
.
width
)
!=
0
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
left
,
other
.
left
)
!=
0
)
return
false
if
(
java
.
lang
.
Double
.
compare
(
baseline
,
other
.
baseline
)
!=
0
)
return
false
return
if
(
lineNumber
!=
other
.
lineNumber
)
false
else
true
if
(
ascent
.
compareTo
(
other
.
ascent
)
!=
0
)
return
false
if
(
descent
.
compareTo
(
other
.
descent
)
!=
0
)
return
false
if
(
unscaledAscent
.
compareTo
(
other
.
unscaledAscent
)
!=
0
)
return
false
if
(
height
.
compareTo
(
other
.
height
)
!=
0
)
return
false
if
(
width
.
compareTo
(
other
.
width
)
!=
0
)
return
false
if
(
left
.
compareTo
(
other
.
left
)
!=
0
)
return
false
if
(
baseline
.
compareTo
(
other
.
baseline
)
!=
0
)
return
false
return
lineNumber
==
other
.
lineNumber
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -129,19 +129,19 @@ class LineMetrics(
val
`$
_endIncludingNewline
`
=
endIncludingNewline
result
=
result
*
PRIME
+
(
`$
_endIncludingNewline
`
ushr
32
xor
`$
_endIncludingNewline
`
).
toInt
()
result
=
result
*
PRIME
+
if
(
isHardBreak
)
79
else
97
val
`$
_ascent
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
ascent
)
val
`$
_ascent
`
=
ascent
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_ascent
`
ushr
32
xor
`$
_ascent
`
).
toInt
()
val
`$
_descent
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
descent
)
val
`$
_descent
`
=
descent
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_descent
`
ushr
32
xor
`$
_descent
`
).
toInt
()
val
`$
_unscaledAscent
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
unscaledAscent
)
val
`$
_unscaledAscent
`
=
unscaledAscent
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_unscaledAscent
`
ushr
32
xor
`$
_unscaledAscent
`
).
toInt
()
val
`$
_height
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
height
)
val
`$
_height
`
=
height
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_height
`
ushr
32
xor
`$
_height
`
).
toInt
()
val
`$
_width
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
width
)
val
`$
_width
`
=
width
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_width
`
ushr
32
xor
`$
_width
`
).
toInt
()
val
`$
_left
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
left
)
val
`$
_left
`
=
left
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_left
`
ushr
32
xor
`$
_left
`
).
toInt
()
val
`$
_baseline
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
baseline
)
val
`$
_baseline
`
=
baseline
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_baseline
`
ushr
32
xor
`$
_baseline
`
).
toInt
()
val
`$
_lineNumber
`
=
lineNumber
result
=
result
*
PRIME
+
(
`$
_lineNumber
`
ushr
32
xor
`$
_lineNumber
`
).
toInt
()
...
...
@@ -149,6 +149,6 @@ class LineMetrics(
}
override
fun
toString
():
String
{
return
"LineMetrics(_startIndex=
"
+
startIndex
+
", _endIndex="
+
endIndex
+
", _endExcludingWhitespaces="
+
endExcludingWhitespaces
+
", _endIncludingNewline="
+
endIncludingNewline
+
", _hardBreak="
+
isHardBreak
+
", _ascent="
+
ascent
+
", _descent="
+
descent
+
", _unscaledAscent="
+
unscaledAscent
+
", _height="
+
height
+
", _width="
+
width
+
", _left="
+
left
+
", _baseline="
+
baseline
+
", _lineNumber="
+
lineNumber
+
"
)"
return
"LineMetrics(_startIndex=
$startIndex, _endIndex=$endIndex, _endExcludingWhitespaces=$endExcludingWhitespaces, _endIncludingNewline=$endIncludingNewline, _hardBreak=$isHardBreak, _ascent=$ascent, _descent=$descent, _unscaledAscent=$unscaledAscent, _height=$height, _width=$width, _left=$left, _baseline=$baseline, _lineNumber=$lineNumber
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/Paragraph.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/Paragraph.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Paragraph
internal
constructor
(
ptr
:
Long
,
text
:
ManagedString
?)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -60,49 +61,49 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Stats
.
onNativeCall
()
_nGetMaxWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
height
:
Float
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
minIntrinsicWidth
:
Float
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetMinIntrinsicWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
maxIntrinsicWidth
:
Float
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetMaxIntrinsicWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
alphabeticBaseline
:
Float
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetAlphabeticBaseline
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
ideographicBaseline
:
Float
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetIdeographicBaseline
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
longestLine
:
Float
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetLongestLine
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
didExceedMaxLines
():
Boolean
{
...
...
@@ -110,7 +111,7 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Stats
.
onNativeCall
()
_nDidExceedMaxLines
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -123,10 +124,10 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
fun
paint
(
canvas
:
Canvas
?,
x
:
Float
,
y
:
Float
):
Paragraph
{
return
try
{
Stats
.
onNativeCall
()
_nPaint
(
_ptr
,
Native
.
Companion
.
getPtr
(
canvas
),
x
,
y
)
_nPaint
(
_ptr
,
getPtr
(
canvas
),
x
,
y
)
this
}
finally
{
Reference
.
reachabilityFence
(
canvas
)
reachabilityBarrier
(
canvas
)
}
}
...
...
@@ -144,7 +145,7 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Stats
.
onNativeCall
()
_nGetRectsForRange
(
_ptr
,
start
,
end
,
rectHeightMode
.
ordinal
,
rectWidthMode
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -153,7 +154,7 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Stats
.
onNativeCall
()
_nGetRectsForPlaceholders
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
getGlyphPositionAtCoordinate
(
dx
:
Float
,
dy
:
Float
):
PositionWithAffinity
{
...
...
@@ -165,7 +166,7 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Affinity
.
UPSTREAM
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -174,7 +175,7 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Stats
.
onNativeCall
()
IRange
.
Companion
.
_makeFromLong
(
_nGetWordBoundary
(
_ptr
,
offset
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -184,18 +185,18 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
arrayOfNulls
(
0
)
}
else
{
Stats
.
onNativeCall
()
_nGetLineMetrics
(
_ptr
,
Native
.
Companion
.
getPtr
(
_text
))
_nGetLineMetrics
(
_ptr
,
getPtr
(
_text
))
}
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
_text
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
_text
)
}
val
lineNumber
:
Long
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetLineNumber
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
markDirty
():
Paragraph
{
...
...
@@ -209,7 +210,7 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
Stats
.
onNativeCall
()
_nGetUnresolvedGlyphsCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
updateAlignment
(
alignment
:
Alignment
):
Paragraph
{
...
...
@@ -233,12 +234,12 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
from
,
to
,
size
,
Native
.
Companion
.
getPtr
(
_text
)
getPtr
(
_text
)
)
}
this
}
finally
{
Reference
.
reachabilityFence
(
_text
)
reachabilityBarrier
(
_text
)
}
}
...
...
@@ -250,14 +251,14 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
_ptr
,
from
,
to
,
Native
.
Companion
.
getPtr
(
paint
),
Native
.
Companion
.
getPtr
(
_text
)
getPtr
(
paint
),
getPtr
(
_text
)
)
}
this
}
finally
{
Reference
.
reachabilityFence
(
paint
)
Reference
.
reachabilityFence
(
_text
)
reachabilityBarrier
(
paint
)
reachabilityBarrier
(
_text
)
}
}
...
...
@@ -269,14 +270,14 @@ class Paragraph internal constructor(ptr: Long, text: ManagedString?) : Managed(
_ptr
,
from
,
to
,
Native
.
Companion
.
getPtr
(
paint
),
Native
.
Companion
.
getPtr
(
_text
)
getPtr
(
paint
),
getPtr
(
_text
)
)
}
this
}
finally
{
Reference
.
reachabilityFence
(
paint
)
Reference
.
reachabilityFence
(
_text
)
reachabilityBarrier
(
paint
)
reachabilityBarrier
(
_text
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/ParagraphBuilder.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/ParagraphBuilder.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.ManagedString
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
ParagraphBuilder
(
style
:
ParagraphStyle
?,
fc
:
FontCollection
?)
:
Managed
(
_nMake
(
Native
.
getPtr
(
style
),
Native
.
getPtr
(
fc
)),
_FinalizerHolder
.
PTR
)
{
Managed
(
_nMake
(
getPtr
(
style
),
getPtr
(
fc
)),
_FinalizerHolder
.
PTR
)
{
companion
object
{
@JvmStatic
external
fun
_nMake
(
paragraphStylePtr
:
Long
,
fontCollectionPtr
:
Long
):
Long
@JvmStatic
external
fun
_nGetFinalizer
():
Long
...
...
@@ -36,10 +37,10 @@ class ParagraphBuilder(style: ParagraphStyle?, fc: FontCollection?) :
fun
pushStyle
(
style
:
TextStyle
?):
ParagraphBuilder
{
return
try
{
Stats
.
onNativeCall
()
_nPushStyle
(
_ptr
,
Native
.
Companion
.
getPtr
(
style
))
_nPushStyle
(
_ptr
,
getPtr
(
style
))
this
}
finally
{
Reference
.
reachabilityFence
(
style
)
reachabilityBarrier
(
style
)
}
}
...
...
@@ -72,10 +73,10 @@ class ParagraphBuilder(style: ParagraphStyle?, fc: FontCollection?) :
fun
setParagraphStyle
(
style
:
ParagraphStyle
?):
ParagraphBuilder
{
return
try
{
Stats
.
onNativeCall
()
_nSetParagraphStyle
(
_ptr
,
Native
.
getPtr
(
style
))
_nSetParagraphStyle
(
_ptr
,
getPtr
(
style
))
this
}
finally
{
Reference
.
reachabilityFence
(
style
)
reachabilityBarrier
(
style
)
}
}
...
...
@@ -86,7 +87,7 @@ class ParagraphBuilder(style: ParagraphStyle?, fc: FontCollection?) :
_text
=
null
paragraph
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -96,7 +97,7 @@ class ParagraphBuilder(style: ParagraphStyle?, fc: FontCollection?) :
init
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
style
)
Reference
.
reachabilityFence
(
fc
)
reachabilityBarrier
(
style
)
reachabilityBarrier
(
fc
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/ParagraphCache.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/ParagraphCache.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
ParagraphCache
internal
constructor
(
owner
:
FontCollection
,
ptr
:
Long
)
:
Native
(
ptr
)
{
companion
object
{
...
...
@@ -26,7 +28,7 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
Stats
.
onNativeCall
()
_nAbandon
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -36,7 +38,7 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
Stats
.
onNativeCall
()
_nReset
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -44,10 +46,10 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
return
try
{
_validate
()
Stats
.
onNativeCall
()
_nUpdateParagraph
(
_ptr
,
Native
.
getPtr
(
paragraph
))
_nUpdateParagraph
(
_ptr
,
getPtr
(
paragraph
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
paragraph
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
paragraph
)
}
}
...
...
@@ -55,10 +57,10 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
return
try
{
_validate
()
Stats
.
onNativeCall
()
_nFindParagraph
(
_ptr
,
Native
.
Companion
.
getPtr
(
paragraph
))
_nFindParagraph
(
_ptr
,
getPtr
(
paragraph
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
paragraph
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
paragraph
)
}
}
...
...
@@ -68,7 +70,7 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
Stats
.
onNativeCall
()
_nPrintStatistics
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -78,7 +80,7 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
Stats
.
onNativeCall
()
_nSetEnabled
(
_ptr
,
value
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -88,7 +90,7 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
Stats
.
onNativeCall
()
_nGetCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
internal
val
_owner
:
FontCollection
...
...
@@ -96,7 +98,7 @@ class ParagraphCache internal constructor(owner: FontCollection, ptr: Long) : Na
try
{
check
(
Native
.
getPtr
(
_owner
)
!=
0L
)
{
"ParagraphCache needs owning FontCollection to be alive"
}
}
finally
{
Reference
.
reachabilityFence
(
_owner
)
reachabilityBarrier
(
_owner
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/ParagraphStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/ParagraphStyle.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
ParagraphStyle
:
Managed
(
_nMake
(),
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -39,10 +41,10 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nEquals
(
_ptr
,
Native
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -51,16 +53,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
StrutStyle
(
_nGetStrutStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setStrutStyle
(
s
:
StrutStyle
?):
ParagraphStyle
{
return
try
{
Stats
.
onNativeCall
()
_nSetStrutStyle
(
_ptr
,
Native
.
getPtr
(
s
))
_nSetStrutStyle
(
_ptr
,
getPtr
(
s
))
this
}
finally
{
Reference
.
reachabilityFence
(
s
)
reachabilityBarrier
(
s
)
}
}
...
...
@@ -69,16 +71,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
TextStyle
(
_nGetTextStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setTextStyle
(
style
:
TextStyle
?):
ParagraphStyle
{
return
try
{
Stats
.
onNativeCall
()
_nSetTextStyle
(
_ptr
,
Native
.
Companion
.
getPtr
(
style
))
_nSetTextStyle
(
_ptr
,
getPtr
(
style
))
this
}
finally
{
Reference
.
reachabilityFence
(
style
)
reachabilityBarrier
(
style
)
}
}
...
...
@@ -87,7 +89,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
Direction
.
values
()[
_nGetDirection
(
_ptr
)]
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setDirection
(
style
:
Direction
):
ParagraphStyle
{
...
...
@@ -101,7 +103,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
Alignment
.
values
()[
_nGetAlignment
(
_ptr
)]
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setAlignment
(
alignment
:
Alignment
):
ParagraphStyle
{
...
...
@@ -115,7 +117,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nGetMaxLinesCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setMaxLinesCount
(
count
:
Long
):
ParagraphStyle
{
...
...
@@ -129,7 +131,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nGetEllipsis
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setEllipsis
(
ellipsis
:
String
?):
ParagraphStyle
{
...
...
@@ -143,7 +145,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setHeight
(
height
:
Float
):
ParagraphStyle
{
...
...
@@ -157,7 +159,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
HeightMode
.
values
()[
_nGetHeightMode
(
_ptr
)]
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setHeightMode
(
behavior
:
HeightMode
):
ParagraphStyle
{
...
...
@@ -171,14 +173,14 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
Alignment
.
values
()[
_nGetEffectiveAlignment
(
_ptr
)]
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
isHintingEnabled
:
Boolean
get
()
=
try
{
Stats
.
onNativeCall
()
_nIsHintingEnabled
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
disableHinting
():
ParagraphStyle
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/PlaceholderStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/PlaceholderStyle.kt
View file @
5c256dcf
...
...
@@ -44,15 +44,15 @@ class PlaceholderStyle(
if
(
o
!
is
PlaceholderStyle
)
return
false
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
java
.
lang
.
Float
.
compare
(
width
,
other
.
width
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
height
,
other
.
height
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
baseline
,
other
.
baseline
)
!=
0
)
return
false
if
(
width
.
compareTo
(
other
.
width
)
!=
0
)
return
false
if
(
height
.
compareTo
(
other
.
height
)
!=
0
)
return
false
if
(
baseline
.
compareTo
(
other
.
baseline
)
!=
0
)
return
false
val
`
this
$
_alignment
`
:
Any
=
alignment
val
`
other
$
_alignment
`
:
Any
=
other
.
alignment
if
(
if
(
`
this
$
_alignment
`
==
null
)
`
other
$
_alignment
`
!=
null
else
`
this
$
_alignment
`
!=
`
other
$
_alignment
`
)
return
false
if
(
`
this
$
_alignment
`
!=
`
other
$
_alignment
`
)
return
false
val
`
this
$
_baselineMode
`
:
Any
=
baselineMode
val
`
other
$
_baselineMode
`
:
Any
=
other
.
baselineMode
return
if
(
if
(
`
this
$
_baselineMode
`
==
null
)
`
other
$
_baselineMode
`
!=
null
else
`
this
$
_baselineMode
`
!=
`
other
$
_baselineMode
`
)
false
else
true
return
`
this
$
_baselineMode
`
==
`
other
$
_baselineMode
`
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -62,18 +62,18 @@ class PlaceholderStyle(
override
fun
hashCode
():
Int
{
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
width
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
height
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
baseline
)
result
=
result
*
PRIME
+
width
.
toBits
(
)
result
=
result
*
PRIME
+
height
.
toBits
(
)
result
=
result
*
PRIME
+
baseline
.
toBits
(
)
val
`$
_alignment
`
:
Any
=
alignment
result
=
result
*
PRIME
+
(
`$
_alignment
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_alignment
`
.
hashCode
()
)
val
`$
_baselineMode
`
:
Any
=
baselineMode
result
=
result
*
PRIME
+
(
`$
_baselineMode
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_baselineMode
`
.
hashCode
()
)
return
result
}
override
fun
toString
():
String
{
return
"PlaceholderStyle(_width=
"
+
width
+
", _height="
+
height
+
", _alignment="
+
alignment
+
", _baselineMode="
+
baselineMode
+
", _baseline="
+
baseline
+
"
)"
return
"PlaceholderStyle(_width=
$width, _height=$height, _alignment=$alignment, _baselineMode=$baselineMode, _baseline=$baseline
)"
}
init
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/PositionWithAffinity.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/PositionWithAffinity.kt
View file @
5c256dcf
...
...
@@ -13,7 +13,7 @@ class PositionWithAffinity(val position: Int, affinity: Affinity) {
if
(
position
!=
other
.
position
)
return
false
val
`
this
$
_affinity
`
:
Any
=
affinity
val
`
other
$
_affinity
`
:
Any
=
other
.
affinity
return
if
(
if
(
`
this
$
_affinity
`
==
null
)
`
other
$
_affinity
`
!=
null
else
`
this
$
_affinity
`
!=
`
other
$
_affinity
`
)
false
else
true
return
`
this
$
_affinity
`
==
`
other
$
_affinity
`
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -25,12 +25,12 @@ class PositionWithAffinity(val position: Int, affinity: Affinity) {
var
result
=
1
result
=
result
*
PRIME
+
position
val
`$
_affinity
`
:
Any
=
affinity
result
=
result
*
PRIME
+
(
`$
_affinity
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_affinity
`
?.
hashCode
())
return
result
}
override
fun
toString
():
String
{
return
"PositionWithAffinity(_position=
"
+
position
+
", _affinity="
+
affinity
+
"
)"
return
"PositionWithAffinity(_position=
$position, _affinity=$affinity
)"
}
init
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/Shadow.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/Shadow.kt
View file @
5c256dcf
...
...
@@ -15,9 +15,9 @@ class Shadow(val color: Int, val offsetX: Float, val offsetY: Float, val blurSig
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
color
!=
other
.
color
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
offsetX
,
other
.
offsetX
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
offsetY
,
other
.
offsetY
)
!=
0
)
return
false
return
if
(
java
.
lang
.
Double
.
compare
(
blurSigma
,
other
.
blurSigma
)
!=
0
)
false
else
true
if
(
offsetX
.
compareTo
(
other
.
offsetX
)
!=
0
)
return
false
if
(
offsetY
.
compareTo
(
other
.
offsetY
)
!=
0
)
return
false
return
blurSigma
.
compareTo
(
other
.
blurSigma
)
==
0
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -28,15 +28,15 @@ class Shadow(val color: Int, val offsetX: Float, val offsetY: Float, val blurSig
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
color
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
offsetX
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
offsetY
)
val
`$
_blurSigma
`
=
java
.
lang
.
Double
.
doubleToLongBits
(
blurSigma
)
result
=
result
*
PRIME
+
offsetX
.
toBits
(
)
result
=
result
*
PRIME
+
offsetY
.
toBits
(
)
val
`$
_blurSigma
`
=
blurSigma
.
toBits
(
)
result
=
result
*
PRIME
+
(
`$
_blurSigma
`
ushr
32
xor
`$
_blurSigma
`
).
toInt
()
return
result
}
override
fun
toString
():
String
{
return
"Shadow(_color=
"
+
color
+
", _offsetX="
+
offsetX
+
", _offsetY="
+
offsetY
+
", _blurSigma="
+
blurSigma
+
"
)"
return
"Shadow(_color=
$color, _offsetX=$offsetX, _offsetY=$offsetY, _blurSigma=$blurSigma
)"
}
fun
withColor
(
_color
:
Int
):
Shadow
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
...
...
@@ -5,7 +6,8 @@ import org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
StrutStyle
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -41,10 +43,10 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nEquals
(
_ptr
,
Native
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -53,7 +55,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nGetFontFamilies
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setFontFamilies
(
families
:
Array
<
String
?
>?):
StrutStyle
{
...
...
@@ -67,7 +69,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
FontStyle
(
_nGetFontStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setFontStyle
(
style
:
FontStyle
):
StrutStyle
{
...
...
@@ -81,7 +83,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nGetFontSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setFontSize
(
value
:
Float
):
StrutStyle
{
...
...
@@ -95,7 +97,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setHeight
(
value
:
Float
):
StrutStyle
{
...
...
@@ -109,7 +111,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nGetLeading
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setLeading
(
value
:
Float
):
StrutStyle
{
...
...
@@ -123,7 +125,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nIsEnabled
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setEnabled
(
value
:
Boolean
):
StrutStyle
{
...
...
@@ -137,7 +139,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nIsHeightForced
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setHeightForced
(
value
:
Boolean
):
StrutStyle
{
...
...
@@ -151,7 +153,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
Stats
.
onNativeCall
()
_nIsHeightOverridden
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setHeightOverridden
(
value
:
Boolean
):
StrutStyle
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/TextBox.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/TextBox.kt
View file @
5c256dcf
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
...
...
@@ -5,7 +6,8 @@ import org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
TextStyle
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -73,11 +75,11 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nEquals
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
)
getPtr
(
other
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -87,11 +89,11 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
_nAttributeEquals
(
_ptr
,
attribute
.
ordinal
,
Native
.
getPtr
(
other
)
getPtr
(
other
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -100,7 +102,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetColor
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setColor
(
color
:
Int
):
TextStyle
{
...
...
@@ -115,7 +117,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
val
ptr
=
_nGetForeground
(
_ptr
)
if
(
ptr
==
0L
)
null
else
Paint
(
ptr
,
true
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setForeground
(
paint
:
Paint
?):
TextStyle
{
...
...
@@ -123,11 +125,11 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nSetForeground
(
_ptr
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
}
}
...
...
@@ -137,7 +139,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
val
ptr
=
_nGetBackground
(
_ptr
)
if
(
ptr
==
0L
)
null
else
Paint
(
ptr
,
true
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setBackground
(
paint
:
Paint
?):
TextStyle
{
...
...
@@ -145,11 +147,11 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nSetBackground
(
_ptr
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
}
}
...
...
@@ -158,7 +160,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetDecorationStyle
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setDecorationStyle
(
d
:
DecorationStyle
):
TextStyle
{
...
...
@@ -181,7 +183,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
FontStyle
(
_nGetFontStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setFontStyle
(
s
:
FontStyle
):
TextStyle
{
...
...
@@ -195,7 +197,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetShadows
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
addShadow
(
s
:
Shadow
):
TextStyle
{
...
...
@@ -220,7 +222,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetFontFeatures
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
addFontFeature
(
f
:
FontFeature
):
TextStyle
{
...
...
@@ -245,7 +247,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetFontSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setFontSize
(
size
:
Float
):
TextStyle
{
...
...
@@ -259,7 +261,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetFontFamilies
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setFontFamily
(
family
:
String
):
TextStyle
{
...
...
@@ -277,7 +279,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setHeight
(
height
:
Float
?):
TextStyle
{
...
...
@@ -291,7 +293,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetLetterSpacing
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setLetterSpacing
(
letterSpacing
:
Float
):
TextStyle
{
...
...
@@ -305,7 +307,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetWordSpacing
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setWordSpacing
(
wordSpacing
:
Float
):
TextStyle
{
...
...
@@ -320,7 +322,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
val
ptr
=
_nGetTypeface
(
_ptr
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setTypeface
(
typeface
:
Typeface
?):
TextStyle
{
...
...
@@ -328,11 +330,11 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nSetTypeface
(
_ptr
,
Native
.
Companion
.
getPtr
(
typeface
)
getPtr
(
typeface
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
typeface
)
reachabilityBarrier
(
typeface
)
}
}
...
...
@@ -341,7 +343,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetLocale
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setLocale
(
locale
:
String
?):
TextStyle
{
...
...
@@ -355,7 +357,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
BaselineMode
.
values
().
get
(
_nGetBaselineMode
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setBaselineMode
(
baseline
:
BaselineMode
):
TextStyle
{
...
...
@@ -369,14 +371,14 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetFontMetrics
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
isPlaceholder
:
Boolean
get
()
=
try
{
Stats
.
onNativeCall
()
_nIsPlaceholder
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setPlaceholder
():
TextStyle
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/paragraph/TypefaceFontProvider.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/paragraph/TypefaceFontProvider.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.paragraph
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.Typeface
import
org.jetbrains.skia.FontMgr
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
TypefaceFontProvider
:
FontMgr
(
_nMake
())
{
companion
object
{
...
...
@@ -17,18 +18,17 @@ class TypefaceFontProvider : FontMgr(_nMake()) {
}
}
@JvmOverloads
fun
registerTypeface
(
typeface
:
Typeface
?,
alias
:
String
?
=
null
):
TypefaceFontProvider
{
return
try
{
Stats
.
onNativeCall
()
_nRegisterTypeface
(
_ptr
,
Native
.
getPtr
(
typeface
),
getPtr
(
typeface
),
alias
)
this
}
finally
{
Reference
.
reachabilityFence
(
typeface
)
reachabilityBarrier
(
typeface
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/TextBlobBuilderRunHandler.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/TextBlobBuilderRunHandler.kt
View file @
5c256dcf
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.shaper
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.UnsupportedOperationException
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
TextBlobBuilderRunHandler
<
T
>
internal
constructor
(
text
:
ManagedString
?,
...
...
@@ -14,7 +14,7 @@ class TextBlobBuilderRunHandler<T> internal constructor(
offsetX
:
Float
,
offsetY
:
Float
)
:
Managed
(
_nMake
(
Native
.
Companion
.
getPtr
(
text
),
offsetX
,
offsetY
),
_FinalizerHolder
.
PTR
_nMake
(
getPtr
(
text
),
offsetX
,
offsetY
),
_FinalizerHolder
.
PTR
),
RunHandler
{
companion
object
{
@JvmStatic
external
fun
_nGetFinalizer
():
Long
...
...
@@ -66,7 +66,7 @@ class TextBlobBuilderRunHandler<T> internal constructor(
val
ptr
=
_nMakeBlob
(
_ptr
)
if
(
0L
==
ptr
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -76,6 +76,6 @@ class TextBlobBuilderRunHandler<T> internal constructor(
init
{
_text
=
if
(
manageText
)
text
else
null
Reference
.
reachabilityFence
(
text
)
reachabilityBarrier
(
text
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/TrivialBidiRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/TrivialBidiRunIterator.kt
View file @
5c256dcf
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/TrivialFontRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/TrivialFontRunIterator.kt
View file @
5c256dcf
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/TrivialScriptRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/TrivialScriptRunIterator.kt
View file @
5c256dcf
File moved
skiko/src/jsMain/kotlin/org/jetbrains/skia/Actuals.js.kt
View file @
5c256dcf
package
org.jetbrains.skia
actual
abstract
class
OutputStream
actual
abstract
class
ByteBuffer
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
...
...
skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/Managed.js.kt
View file @
5c256dcf
...
...
@@ -2,4 +2,7 @@ package org.jetbrains.skia.impl
actual
abstract
class
Managed
actual
constructor
(
ptr
:
Long
,
finalizer
:
Long
,
managed
:
Boolean
)
:
Native
(
ptr
)
{
actual
open
fun
close
():
Unit
=
TODO
()
actual
open
val
isClosed
:
Boolean
get
()
=
_ptr
==
0L
}
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Actuals.jvm.kt
View file @
5c256dcf
...
...
@@ -18,3 +18,4 @@ actual fun defaultLanguageTag(): String = Locale.getDefault().toLanguageTag()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
Pattern
.
compile
(
regex
)
actual
typealias
OutputStream
=
java
.
io
.
OutputStream
skiko/src/jvmMain/kotlin/org/jetbrains/skia/impl/Managed.jvm.kt
View file @
5c256dcf
...
...
@@ -15,7 +15,7 @@ actual abstract class Managed actual constructor(ptr: Long, finalizer: Long, man
}
}
open
val
isClosed
:
Boolean
actual
open
val
isClosed
:
Boolean
get
()
=
_ptr
==
0L
class
CleanerThunk
(
var
_className
:
String
,
var
_ptr
:
Long
,
var
_finalizerPtr
:
Long
)
:
Runnable
{
...
...
skiko/src/macosX64Main/kotlin/org/jetbrains/skia/Actuals.native.kt
View file @
5c256dcf
package
org.jetbrains.skia
actual
abstract
class
ByteBuffer
actual
abstract
class
OutputStream
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
block
()
...
...
skiko/src/macosX64Main/kotlin/org/jetbrains/skia/impl/Managed.native.kt
View file @
5c256dcf
...
...
@@ -2,4 +2,6 @@ package org.jetbrains.skia.impl
actual
abstract
class
Managed
actual
constructor
(
ptr
:
Long
,
finalizer
:
Long
,
managed
:
Boolean
)
:
Native
(
ptr
)
{
actual
open
fun
close
():
Unit
=
TODO
()
actual
open
val
isClosed
:
Boolean
get
()
=
_ptr
==
0L
}
\ No newline at end of file
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