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
f794e4bb
Unverified
Commit
f794e4bb
authored
Sep 02, 2021
by
Nikolay Igotti
Committed by
GitHub
Sep 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commonalization, part 3. (#155)
parent
711c728b
Changes
66
Hide whitespace changes
Inline
Side-by-side
Showing
66 changed files
with
1295 additions
and
1103 deletions
+1295
-1103
Bitmap.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Bitmap.kt
+58
-64
Canvas.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Canvas.kt
+310
-282
Data.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Data.kt
+9
-11
Drawable.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Drawable.kt
+7
-7
Expects.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
+30
-0
Font.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Font.kt
+49
-49
FontFamilyName.kt
...rc/commonMain/kotlin/org/jetbrains/skia/FontFamilyName.kt
+5
-5
FontFeature.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/FontFeature.kt
+15
-17
FontMetrics.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/FontMetrics.kt
+22
-22
FontMgr.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/FontMgr.kt
+11
-12
FontStyle.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/FontStyle.kt
+4
-4
FontStyleSet.kt
.../src/commonMain/kotlin/org/jetbrains/skia/FontStyleSet.kt
+8
-7
FontVariation.kt
...src/commonMain/kotlin/org/jetbrains/skia/FontVariation.kt
+9
-10
FontVariationAxis.kt
...commonMain/kotlin/org/jetbrains/skia/FontVariationAxis.kt
+11
-11
GradientStyle.kt
...src/commonMain/kotlin/org/jetbrains/skia/GradientStyle.kt
+0
-0
IHasImageInfo.kt
...src/commonMain/kotlin/org/jetbrains/skia/IHasImageInfo.kt
+0
-0
Image.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Image.kt
+40
-44
ImageFilter.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/ImageFilter.kt
+68
-74
ImageInfo.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/ImageInfo.kt
+2
-2
ManagedString.kt
...src/commonMain/kotlin/org/jetbrains/skia/ManagedString.kt
+3
-2
MaskFilter.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/MaskFilter.kt
+4
-5
Paint.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Paint.kt
+48
-47
Path.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Path.kt
+60
-68
PathEffect.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/PathEffect.kt
+12
-12
PathSegment.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/PathSegment.kt
+133
-0
PathSegmentIterator.kt
...mmonMain/kotlin/org/jetbrains/skia/PathSegmentIterator.kt
+4
-6
Picture.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Picture.kt
+13
-16
PixelRef.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/PixelRef.kt
+7
-6
Pixmap.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Pixmap.kt
+37
-38
RSXform.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/RSXform.kt
+14
-11
Region.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Region.kt
+54
-54
Shader.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Shader.kt
+31
-34
SurfaceProps.kt
.../src/commonMain/kotlin/org/jetbrains/skia/SurfaceProps.kt
+1
-2
TextBlob.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/TextBlob.kt
+27
-28
TextLine.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/TextLine.kt
+19
-21
Typeface.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
+32
-40
WStream.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/WStream.kt
+0
-0
BufferUtil.kt
...c/commonMain/kotlin/org/jetbrains/skia/impl/BufferUtil.kt
+2
-1
Managed.kt
.../src/commonMain/kotlin/org/jetbrains/skia/impl/Managed.kt
+9
-1
Native.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/impl/Native.kt
+3
-1
BidiRun.kt
...rc/commonMain/kotlin/org/jetbrains/skia/shaper/BidiRun.kt
+0
-0
FontMgrRunIterator.kt
...in/kotlin/org/jetbrains/skia/shaper/FontMgrRunIterator.kt
+7
-6
FontRun.kt
...rc/commonMain/kotlin/org/jetbrains/skia/shaper/FontRun.kt
+5
-5
HbIcuScriptRunIterator.kt
...otlin/org/jetbrains/skia/shaper/HbIcuScriptRunIterator.kt
+5
-5
IcuBidiRunIterator.kt
...in/kotlin/org/jetbrains/skia/shaper/IcuBidiRunIterator.kt
+5
-5
LanguageRun.kt
...ommonMain/kotlin/org/jetbrains/skia/shaper/LanguageRun.kt
+3
-3
ManagedRunIterator.kt
...in/kotlin/org/jetbrains/skia/shaper/ManagedRunIterator.kt
+6
-6
RunHandler.kt
...commonMain/kotlin/org/jetbrains/skia/shaper/RunHandler.kt
+0
-0
RunInfo.kt
...rc/commonMain/kotlin/org/jetbrains/skia/shaper/RunInfo.kt
+6
-6
ScriptRun.kt
.../commonMain/kotlin/org/jetbrains/skia/shaper/ScriptRun.kt
+3
-3
Shaper.kt
...src/commonMain/kotlin/org/jetbrains/skia/shaper/Shaper.kt
+21
-30
ShapingOptions.kt
...onMain/kotlin/org/jetbrains/skia/shaper/ShapingOptions.kt
+3
-4
TrivialLanguageRunIterator.kt
...n/org/jetbrains/skia/shaper/TrivialLanguageRunIterator.kt
+0
-0
Actuals.jvm.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Actuals.jvm.kt
+20
-0
Codec.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Codec.kt
+1
-1
PaintFilterCanvas.kt
...rc/jvmMain/kotlin/org/jetbrains/skia/PaintFilterCanvas.kt
+1
-1
PictureRecorder.kt
.../src/jvmMain/kotlin/org/jetbrains/skia/PictureRecorder.kt
+2
-2
RuntimeEffect.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skia/RuntimeEffect.kt
+1
-1
Surface.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Surface.kt
+2
-2
Native.jvm.kt
.../src/jvmMain/kotlin/org/jetbrains/skia/impl/Native.jvm.kt
+1
-1
StrutStyle.kt
...jvmMain/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
+1
-1
TextStyle.kt
.../jvmMain/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
+3
-3
Library.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
+2
-1
Actuals.native.kt
.../macosX64Main/kotlin/org/jetbrains/skia/Actuals.native.kt
+23
-0
Managed.native.kt
...sX64Main/kotlin/org/jetbrains/skia/impl/Managed.native.kt
+1
-3
Native.native.kt
...osX64Main/kotlin/org/jetbrains/skia/impl/Native.native.kt
+2
-0
No files found.
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Bitmap.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Bitmap.kt
View file @
f794e4bb
...
...
@@ -2,16 +2,13 @@ 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.RuntimeException
import
java.lang.ref.Reference
import
java.nio.ByteBuffer
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Bitmap
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
),
IHasImageInfo
{
companion
object
{
fun
makeFromImage
(
image
:
Image
):
Bitmap
{
assert
(
image
!=
null
)
{
"Can’t makeFromImage with image == null"
}
val
bitmap
=
Bitmap
()
bitmap
.
allocPixels
(
image
.
imageInfo
)
return
if
(
image
.
readPixels
(
bitmap
))
bitmap
else
{
...
...
@@ -139,7 +136,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
Bitmap
(
_nMakeClone
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -152,10 +149,10 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
*/
fun
swap
(
other
:
Bitmap
)
{
Stats
.
onNativeCall
()
_nSwap
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nSwap
(
_ptr
,
getPtr
(
other
))
_imageInfo
=
null
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
override
val
imageInfo
:
ImageInfo
...
...
@@ -166,7 +163,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
}
_imageInfo
!!
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -180,7 +177,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nGetRowBytesAsPixels
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -196,7 +193,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nIsNull
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -223,7 +220,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nGetRowBytes
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -269,7 +266,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
_imageInfo
=
null
_nSetAlphaType
(
_ptr
,
alphaType
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -286,7 +283,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nComputeByteSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -306,7 +303,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nIsImmutable
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -373,7 +370,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nComputeIsOpaque
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -383,7 +380,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
* @see [https://fiddle.skia.org/c/@Bitmap_getBounds_2](https://fiddle.skia.org/c/@Bitmap_getBounds_2)
*/
val
bounds
:
IRect
get
()
=
IRect
.
Companion
.
makeXYWH
(
0
,
0
,
width
,
height
)
get
()
=
IRect
.
makeXYWH
(
0
,
0
,
width
,
height
)
/**
* Returns the bounds of this bitmap, offset by its PixelRef origin.
...
...
@@ -391,7 +388,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
val
subset
:
IRect
get
()
{
val
origin
=
pixelRefOrigin
return
IRect
.
Companion
.
makeXYWH
(
origin
.
x
,
origin
.
y
,
width
,
height
)
return
IRect
.
makeXYWH
(
origin
.
x
,
origin
.
y
,
width
,
height
)
}
/**
...
...
@@ -473,12 +470,12 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
rowBytes
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -515,8 +512,8 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
if
(
zeroPixels
)
1
else
0
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -550,12 +547,12 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
info
.
height
,
info
.
colorInfo
.
colorType
.
ordinal
,
info
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
Companion
.
getPtr
(
info
.
colorInfo
.
colorSpace
),
getPtr
(
info
.
colorInfo
.
colorSpace
),
rowBytes
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
info
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
info
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -615,10 +612,9 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
* @param height pixel row count; must be zero or greater
* @return true if pixel storage is allocated
*/
@JvmOverloads
fun
allocN32Pixels
(
width
:
Int
,
height
:
Int
,
opaque
:
Boolean
=
false
):
Boolean
{
return
allocPixels
(
ImageInfo
.
Companion
.
makeN32
(
ImageInfo
.
makeN32
(
width
,
height
,
if
(
opaque
)
ColorAlphaType
.
OPAQUE
else
ColorAlphaType
.
PREMUL
...
...
@@ -658,13 +654,13 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
info
.
height
,
info
.
colorInfo
.
colorType
.
ordinal
,
info
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
info
.
colorInfo
.
colorSpace
),
getPtr
(
info
.
colorInfo
.
colorSpace
),
pixels
,
rowBytes
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
info
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
info
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -684,7 +680,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nAllocPixels
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -702,7 +698,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
val
res
=
_nGetPixelRef
(
_ptr
)
if
(
res
==
0L
)
null
else
PixelRef
(
res
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -728,7 +724,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
val
res
=
_nGetPixelRefOrigin
(
_ptr
)
IPoint
((
res
and
-
0
x1
).
toInt
(),
(
res
ushr
32
).
toInt
())
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -756,13 +752,13 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nSetPixelRef
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixelRef
),
getPtr
(
pixelRef
),
dx
,
dy
)
this
}
finally
{
Reference
.
reachabilityFence
(
pixelRef
)
reachabilityBarrier
(
pixelRef
)
}
}
...
...
@@ -776,7 +772,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nIsReadyToDraw
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -797,7 +793,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nGetGenerationId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -813,7 +809,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
_nNotifyPixelsChanged
(
_ptr
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -833,7 +829,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
_nEraseColor
(
_ptr
,
color
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -856,7 +852,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
_nErase
(
_ptr
,
color
,
area
.
left
,
area
.
top
,
area
.
right
,
area
.
bottom
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -884,7 +880,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nGetColor
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -903,7 +899,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nGetAlphaf
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -939,15 +935,15 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nExtractSubset
(
_ptr
,
Native
.
Companion
.
getPtr
(
dst
),
getPtr
(
dst
),
subset
.
left
,
subset
.
top
,
subset
.
right
,
subset
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dst
)
}
}
...
...
@@ -985,7 +981,6 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
* @param srcY row index whose absolute value is less than height()
* @return pixel data or null
*/
@JvmOverloads
fun
readPixels
(
dstInfo
:
ImageInfo
=
imageInfo
,
dstRowBytes
:
Long
=
rowBytes
,
...
...
@@ -1000,14 +995,14 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
dstInfo
.
height
,
dstInfo
.
colorInfo
.
colorType
.
ordinal
,
dstInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
dstInfo
.
colorInfo
.
colorSpace
),
getPtr
(
dstInfo
.
colorInfo
.
colorSpace
),
dstRowBytes
,
srcX
,
srcY
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dstInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dstInfo
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -1042,13 +1037,13 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nExtractAlpha
(
_ptr
,
Native
.
Companion
.
getPtr
(
dst
),
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
dst
),
getPtr
(
paint
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dst
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dst
)
reachabilityBarrier
(
paint
)
}
}
...
...
@@ -1065,12 +1060,12 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
Stats
.
onNativeCall
()
_nPeekPixels
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
fun
makeShader
(
localMatrix
:
Matrix33
?):
Shader
{
return
makeShader
(
FilterTileMode
.
CLAMP
,
FilterTileMode
.
CLAMP
,
SamplingMode
.
Companion
.
DEFAULT
,
localMatrix
)
return
makeShader
(
FilterTileMode
.
CLAMP
,
FilterTileMode
.
CLAMP
,
SamplingMode
.
DEFAULT
,
localMatrix
)
}
fun
makeShader
(
...
...
@@ -1078,10 +1073,9 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
tmy
:
FilterTileMode
,
localMatrix
:
Matrix33
?
):
Shader
{
return
makeShader
(
tmx
,
tmy
,
SamplingMode
.
Companion
.
DEFAULT
,
localMatrix
)
return
makeShader
(
tmx
,
tmy
,
SamplingMode
.
DEFAULT
,
localMatrix
)
}
@JvmOverloads
fun
makeShader
(
tmx
:
FilterTileMode
=
FilterTileMode
.
CLAMP
,
tmy
:
FilterTileMode
=
FilterTileMode
.
CLAMP
,
...
...
@@ -1089,9 +1083,9 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
localMatrix
:
Matrix33
?
=
null
):
Shader
{
return
try
{
assert
(
tmx
!=
null
)
{
"Can’t Bitmap.makeShader with tmx == null"
}
assert
(
tmy
!=
null
)
{
"Can’t Bitmap.makeShader with tmy == null"
}
assert
(
sampling
!=
null
)
{
"Can’t Bitmap.makeShader with sampling == null"
}
require
(
tmx
!=
null
)
{
"Can’t Bitmap.makeShader with tmx == null"
}
require
(
tmy
!=
null
)
{
"Can’t Bitmap.makeShader with tmy == null"
}
require
(
sampling
!=
null
)
{
"Can’t Bitmap.makeShader with sampling == null"
}
Stats
.
onNativeCall
()
Shader
(
_nMakeShader
(
...
...
@@ -1103,7 +1097,7 @@ class Bitmap internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Canvas.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Canvas.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.ImageFilter.Companion.makeDropShadowOnly
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
org.jetbrains.skia.impl.use
import
kotlin.jvm.JvmStatic
open
class
Canvas
internal
constructor
(
ptr
:
Long
,
managed
:
Boolean
,
internal
val
_owner
:
Any
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
,
managed
)
{
companion
object
{
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMakeFromBitmap
(
bitmapPtr
:
Long
,
flags
:
Int
,
pixelGeometry
:
Int
):
Long
@JvmStatic
external
fun
_nDrawPoint
(
ptr
:
Long
,
x
:
Float
,
y
:
Float
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawPoints
(
ptr
:
Long
,
mode
:
Int
,
coords
:
FloatArray
?,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawLine
(
ptr
:
Long
,
x0
:
Float
,
y0
:
Float
,
x1
:
Float
,
y1
:
Float
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawArc
(
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMakeFromBitmap
(
bitmapPtr
:
Long
,
flags
:
Int
,
pixelGeometry
:
Int
):
Long
@JvmStatic
external
fun
_nDrawPoint
(
ptr
:
Long
,
x
:
Float
,
y
:
Float
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawPoints
(
ptr
:
Long
,
mode
:
Int
,
coords
:
FloatArray
?,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawLine
(
ptr
:
Long
,
x0
:
Float
,
y0
:
Float
,
x1
:
Float
,
y1
:
Float
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawArc
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
...
...
@@ -27,9 +34,12 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawRect
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawOval
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
paint
:
Long
)
@JvmStatic
external
fun
_nDrawRRect
(
@JvmStatic
external
fun
_nDrawRect
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawOval
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
paint
:
Long
)
@JvmStatic
external
fun
_nDrawRRect
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
...
...
@@ -39,7 +49,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawDRRect
(
@JvmStatic
external
fun
_nDrawDRRect
(
ptr
:
Long
,
ol
:
Float
,
ot
:
Float
,
...
...
@@ -54,8 +65,10 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawPath
(
ptr
:
Long
,
nativePath
:
Long
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawImageRect
(
@JvmStatic
external
fun
_nDrawPath
(
ptr
:
Long
,
nativePath
:
Long
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawImageRect
(
ptr
:
Long
,
nativeImage
:
Long
,
sl
:
Float
,
...
...
@@ -71,7 +84,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
strict
:
Boolean
)
@JvmStatic
external
fun
_nDrawImageNine
(
@JvmStatic
external
fun
_nDrawImageNine
(
ptr
:
Long
,
nativeImage
:
Long
,
cl
:
Int
,
...
...
@@ -86,11 +100,16 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawRegion
(
ptr
:
Long
,
nativeRegion
:
Long
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawString
(
ptr
:
Long
,
string
:
String
?,
x
:
Float
,
y
:
Float
,
font
:
Long
,
paint
:
Long
)
@JvmStatic
external
fun
_nDrawTextBlob
(
ptr
:
Long
,
blob
:
Long
,
x
:
Float
,
y
:
Float
,
paint
:
Long
)
@JvmStatic
external
fun
_nDrawPicture
(
ptr
:
Long
,
picturePtr
:
Long
,
matrix
:
FloatArray
?,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawVertices
(
@JvmStatic
external
fun
_nDrawRegion
(
ptr
:
Long
,
nativeRegion
:
Long
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawString
(
ptr
:
Long
,
string
:
String
?,
x
:
Float
,
y
:
Float
,
font
:
Long
,
paint
:
Long
)
@JvmStatic
external
fun
_nDrawTextBlob
(
ptr
:
Long
,
blob
:
Long
,
x
:
Float
,
y
:
Float
,
paint
:
Long
)
@JvmStatic
external
fun
_nDrawPicture
(
ptr
:
Long
,
picturePtr
:
Long
,
matrix
:
FloatArray
?,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawVertices
(
ptr
:
Long
,
verticesMode
:
Int
,
cubics
:
FloatArray
?,
...
...
@@ -101,7 +120,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawPatch
(
@JvmStatic
external
fun
_nDrawPatch
(
ptr
:
Long
,
cubics
:
FloatArray
?,
colors
:
IntArray
?,
...
...
@@ -110,13 +130,20 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
)
@JvmStatic
external
fun
_nDrawDrawable
(
ptr
:
Long
,
drawablePrt
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nClear
(
ptr
:
Long
,
color
:
Int
)
@JvmStatic
external
fun
_nDrawPaint
(
ptr
:
Long
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nSetMatrix
(
ptr
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nGetLocalToDevice
(
ptr
:
Long
):
FloatArray
@JvmStatic
external
fun
_nResetMatrix
(
ptr
:
Long
)
@JvmStatic
external
fun
_nClipRect
(
@JvmStatic
external
fun
_nDrawDrawable
(
ptr
:
Long
,
drawablePrt
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nClear
(
ptr
:
Long
,
color
:
Int
)
@JvmStatic
external
fun
_nDrawPaint
(
ptr
:
Long
,
paintPtr
:
Long
)
@JvmStatic
external
fun
_nSetMatrix
(
ptr
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nGetLocalToDevice
(
ptr
:
Long
):
FloatArray
@JvmStatic
external
fun
_nResetMatrix
(
ptr
:
Long
)
@JvmStatic
external
fun
_nClipRect
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
...
...
@@ -126,7 +153,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
antiAlias
:
Boolean
)
@JvmStatic
external
fun
_nClipRRect
(
@JvmStatic
external
fun
_nClipRRect
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
...
...
@@ -137,15 +165,24 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
antiAlias
:
Boolean
)
@JvmStatic
external
fun
_nClipPath
(
ptr
:
Long
,
nativePath
:
Long
,
mode
:
Int
,
antiAlias
:
Boolean
)
@JvmStatic
external
fun
_nClipRegion
(
ptr
:
Long
,
nativeRegion
:
Long
,
mode
:
Int
)
@JvmStatic
external
fun
_nConcat
(
ptr
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nConcat44
(
ptr
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nReadPixels
(
ptr
:
Long
,
bitmapPtr
:
Long
,
srcX
:
Int
,
srcY
:
Int
):
Boolean
@JvmStatic
external
fun
_nWritePixels
(
ptr
:
Long
,
bitmapPtr
:
Long
,
x
:
Int
,
y
:
Int
):
Boolean
@JvmStatic
external
fun
_nSave
(
ptr
:
Long
):
Int
@JvmStatic
external
fun
_nSaveLayer
(
ptr
:
Long
,
paintPtr
:
Long
):
Int
@JvmStatic
external
fun
_nSaveLayerRect
(
@JvmStatic
external
fun
_nClipPath
(
ptr
:
Long
,
nativePath
:
Long
,
mode
:
Int
,
antiAlias
:
Boolean
)
@JvmStatic
external
fun
_nClipRegion
(
ptr
:
Long
,
nativeRegion
:
Long
,
mode
:
Int
)
@JvmStatic
external
fun
_nConcat
(
ptr
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nConcat44
(
ptr
:
Long
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nReadPixels
(
ptr
:
Long
,
bitmapPtr
:
Long
,
srcX
:
Int
,
srcY
:
Int
):
Boolean
@JvmStatic
external
fun
_nWritePixels
(
ptr
:
Long
,
bitmapPtr
:
Long
,
x
:
Int
,
y
:
Int
):
Boolean
@JvmStatic
external
fun
_nSave
(
ptr
:
Long
):
Int
@JvmStatic
external
fun
_nSaveLayer
(
ptr
:
Long
,
paintPtr
:
Long
):
Int
@JvmStatic
external
fun
_nSaveLayerRect
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
...
...
@@ -154,9 +191,12 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paintPtr
:
Long
):
Int
@JvmStatic
external
fun
_nGetSaveCount
(
ptr
:
Long
):
Int
@JvmStatic
external
fun
_nRestore
(
ptr
:
Long
)
@JvmStatic
external
fun
_nRestoreToCount
(
ptr
:
Long
,
saveCount
:
Int
)
@JvmStatic
external
fun
_nGetSaveCount
(
ptr
:
Long
):
Int
@JvmStatic
external
fun
_nRestore
(
ptr
:
Long
)
@JvmStatic
external
fun
_nRestoreToCount
(
ptr
:
Long
,
saveCount
:
Int
)
init
{
staticLoad
()
...
...
@@ -195,7 +235,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap](https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap)
*/
@JvmOverloads
constructor
(
bitmap
:
Bitmap
,
surfaceProps
:
SurfaceProps
=
SurfaceProps
())
:
this
(
_nMakeFromBitmap
(
bitmap
.
_ptr
,
...
...
@@ -204,14 +243,13 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
),
true
,
bitmap
)
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
bitmap
)
}
fun
drawPoint
(
x
:
Float
,
y
:
Float
,
paint
:
Paint
):
Canvas
{
assert
(
paint
!=
null
)
{
"Can’t drawPoint with paint == null"
}
Stats
.
onNativeCall
()
_nDrawPoint
(
_ptr
,
x
,
y
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawPoint
(
_ptr
,
x
,
y
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -241,7 +279,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun
drawPoints
(
coords
:
Array
<
Point
>,
paint
:
Paint
):
Canvas
{
return
drawPoints
(
Point
.
Companion
.
flattenArray
(
coords
)
!!
,
paint
)
return
drawPoints
(
Point
.
flattenArray
(
coords
)
!!
,
paint
)
}
/**
...
...
@@ -269,12 +307,10 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun
drawPoints
(
coords
:
FloatArray
,
paint
:
Paint
):
Canvas
{
assert
(
coords
!=
null
)
{
"Can’t drawPoints with coords == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawPoints with paint == null"
}
fun
drawPoints
(
coords
:
FloatArray
,
paint
:
Paint
):
Canvas
{
Stats
.
onNativeCall
()
_nDrawPoints
(
_ptr
,
0
/* SkCanvas::PointMode::kPoints_PointMode */
,
coords
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawPoints
(
_ptr
,
0
/* SkCanvas::PointMode::kPoints_PointMode */
,
coords
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -301,8 +337,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun
drawLines
(
coords
:
Array
<
Point
>,
paint
:
Paint
):
Canvas
{
return
drawLines
(
Point
.
Companion
.
flattenArray
(
coords
)
!!
,
paint
)
fun
drawLines
(
coords
:
Array
<
Point
>,
paint
:
Paint
):
Canvas
{
return
drawLines
(
Point
.
flattenArray
(
coords
)
!!
,
paint
)
}
/**
...
...
@@ -328,12 +364,10 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun
drawLines
(
coords
:
FloatArray
,
paint
:
Paint
):
Canvas
{
assert
(
coords
!=
null
)
{
"Can’t drawLines with coords == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawLines with paint == null"
}
fun
drawLines
(
coords
:
FloatArray
,
paint
:
Paint
):
Canvas
{
Stats
.
onNativeCall
()
_nDrawPoints
(
_ptr
,
1
/* SkCanvas::PointMode::kLines_PointMode */
,
coords
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawPoints
(
_ptr
,
1
/* SkCanvas::PointMode::kLines_PointMode */
,
coords
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -359,8 +393,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun
drawPolygon
(
coords
:
Array
<
Point
>,
paint
:
Paint
):
Canvas
{
return
drawPolygon
(
Point
.
Companion
.
flattenArray
(
coords
)
!!
,
paint
)
fun
drawPolygon
(
coords
:
Array
<
Point
>,
paint
:
Paint
):
Canvas
{
return
drawPolygon
(
Point
.
flattenArray
(
coords
)
!!
,
paint
)
}
/**
...
...
@@ -385,24 +419,24 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun
drawPolygon
(
coords
:
FloatArray
,
paint
:
Paint
):
Canvas
{
assert
(
coords
!=
null
)
{
"Can’t drawPolygon with coords == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawPolygon with paint == null"
}
fun
drawPolygon
(
coords
:
FloatArray
,
paint
:
Paint
):
Canvas
{
require
(
coords
!=
null
)
{
"Can’t drawPolygon with coords == null"
}
require
(
paint
!=
null
)
{
"Can’t drawPolygon with paint == null"
}
Stats
.
onNativeCall
()
_nDrawPoints
(
_ptr
,
2
/* SkCanvas::PointMode::kPolygon_PointMode */
,
coords
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawPoints
(
_ptr
,
2
/* SkCanvas::PointMode::kPolygon_PointMode */
,
coords
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawLine
(
x0
:
Float
,
y0
:
Float
,
x1
:
Float
,
y1
:
Float
,
paint
:
Paint
):
Canvas
{
assert
(
paint
!=
null
)
{
"Can’t drawLine with paint == null"
}
fun
drawLine
(
x0
:
Float
,
y0
:
Float
,
x1
:
Float
,
y1
:
Float
,
paint
:
Paint
):
Canvas
{
require
(
paint
!=
null
)
{
"Can’t drawLine with paint == null"
}
Stats
.
onNativeCall
()
_nDrawLine
(
_ptr
,
x0
,
y0
,
x1
,
y1
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawLine
(
_ptr
,
x0
,
y0
,
x1
,
y1
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawArc
(
fun
drawArc
(
left
:
Float
,
top
:
Float
,
right
:
Float
,
...
...
@@ -412,52 +446,52 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
includeCenter
:
Boolean
,
paint
:
Paint
):
Canvas
{
assert
(
paint
!=
null
)
{
"Can’t drawArc with paint == null"
}
require
(
paint
!=
null
)
{
"Can’t drawArc with paint == null"
}
Stats
.
onNativeCall
()
_nDrawArc
(
_ptr
,
left
,
top
,
right
,
bottom
,
startAngle
,
sweepAngle
,
includeCenter
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawArc
(
_ptr
,
left
,
top
,
right
,
bottom
,
startAngle
,
sweepAngle
,
includeCenter
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawRect
(
r
:
Rect
,
paint
:
Paint
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t drawRect with r == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawRect with paint == null"
}
fun
drawRect
(
r
:
Rect
,
paint
:
Paint
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t drawRect with r == null"
}
require
(
paint
!=
null
)
{
"Can’t drawRect with paint == null"
}
Stats
.
onNativeCall
()
_nDrawRect
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawRect
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawOval
(
r
:
Rect
,
paint
:
Paint
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t drawOval with r == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawOval with paint == null"
}
fun
drawOval
(
r
:
Rect
,
paint
:
Paint
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t drawOval with r == null"
}
require
(
paint
!=
null
)
{
"Can’t drawOval with paint == null"
}
Stats
.
onNativeCall
()
_nDrawOval
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawOval
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawCircle
(
x
:
Float
,
y
:
Float
,
radius
:
Float
,
paint
:
Paint
):
Canvas
{
assert
(
paint
!=
null
)
{
"Can’t drawCircle with paint == null"
}
fun
drawCircle
(
x
:
Float
,
y
:
Float
,
radius
:
Float
,
paint
:
Paint
):
Canvas
{
require
(
paint
!=
null
)
{
"Can’t drawCircle with paint == null"
}
Stats
.
onNativeCall
()
_nDrawOval
(
_ptr
,
x
-
radius
,
y
-
radius
,
x
+
radius
,
y
+
radius
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawOval
(
_ptr
,
x
-
radius
,
y
-
radius
,
x
+
radius
,
y
+
radius
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawRRect
(
r
:
RRect
,
paint
:
Paint
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t drawRRect with r == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawRRect with paint == null"
}
fun
drawRRect
(
r
:
RRect
,
paint
:
Paint
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t drawRRect with r == null"
}
require
(
paint
!=
null
)
{
"Can’t drawRRect with paint == null"
}
Stats
.
onNativeCall
()
_nDrawRRect
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
r
.
radii
,
Native
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawRRect
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
r
.
radii
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
fun
drawDRRect
(
outer
:
RRect
,
inner
:
RRect
,
paint
:
Paint
):
Canvas
{
assert
(
outer
!=
null
)
{
"Can’t drawDRRect with outer == null"
}
assert
(
inner
!=
null
)
{
"Can’t drawDRRect with inner == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawDRRect with paint == null"
}
fun
drawDRRect
(
outer
:
RRect
,
inner
:
RRect
,
paint
:
Paint
):
Canvas
{
require
(
outer
!=
null
)
{
"Can’t drawDRRect with outer == null"
}
require
(
inner
!=
null
)
{
"Can’t drawDRRect with inner == null"
}
require
(
paint
!=
null
)
{
"Can’t drawDRRect with paint == null"
}
Stats
.
onNativeCall
()
_nDrawDRRect
(
_ptr
,
...
...
@@ -471,18 +505,18 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
inner
.
right
,
inner
.
bottom
,
inner
.
radii
,
Native
.
getPtr
(
paint
)
getPtr
(
paint
)
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawRectShadow
(
r
:
Rect
,
dx
:
Float
,
dy
:
Float
,
blur
:
Float
,
color
:
Int
):
Canvas
{
fun
drawRectShadow
(
r
:
Rect
,
dx
:
Float
,
dy
:
Float
,
blur
:
Float
,
color
:
Int
):
Canvas
{
return
drawRectShadow
(
r
,
dx
,
dy
,
blur
,
0f
,
color
)
}
fun
drawRectShadow
(
r
:
Rect
,
dx
:
Float
,
dy
:
Float
,
blur
:
Float
,
spread
:
Float
,
color
:
Int
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t drawRectShadow with r == null"
}
fun
drawRectShadow
(
r
:
Rect
,
dx
:
Float
,
dy
:
Float
,
blur
:
Float
,
spread
:
Float
,
color
:
Int
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t drawRectShadow with r == null"
}
val
insides
=
r
.
inflate
(-
1f
)
if
(!
insides
.
isEmpty
)
{
save
()
...
...
@@ -493,11 +527,11 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
return
this
}
fun
drawRectShadowNoclip
(
r
:
Rect
,
dx
:
Float
,
dy
:
Float
,
blur
:
Float
,
spread
:
Float
,
color
:
Int
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t drawRectShadow with r == null"
}
fun
drawRectShadowNoclip
(
r
:
Rect
,
dx
:
Float
,
dy
:
Float
,
blur
:
Float
,
spread
:
Float
,
color
:
Int
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t drawRectShadow with r == null"
}
val
outline
=
r
.
inflate
(
spread
)
makeDropShadowOnly
(
dx
,
dy
,
blur
/
2f
,
blur
/
2f
,
color
).
use
{
f
->
org
.
jetbrains
.
skia
.
Paint
().
use
{
p
->
Paint
().
use
{
p
->
p
.
setImageFilter
(
f
)
if
(
outline
is
RRect
)
drawRRect
(
outline
,
p
)
else
drawRect
(
outline
,
p
)
}
...
...
@@ -505,50 +539,48 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
return
this
}
fun
drawPath
(
path
:
Path
,
paint
:
Paint
):
Canvas
{
assert
(
path
!=
null
)
{
"Can’t drawPath with path == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawPath with paint == null"
}
fun
drawPath
(
path
:
Path
,
paint
:
Paint
):
Canvas
{
Stats
.
onNativeCall
()
_nDrawPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
path
),
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
path
)
Reference
.
reachabilityFence
(
paint
)
_nDrawPath
(
_ptr
,
getPtr
(
path
),
getPtr
(
paint
))
reachabilityBarrier
(
path
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawImage
(
image
:
Image
,
left
:
Float
,
top
:
Float
):
Canvas
{
fun
drawImage
(
image
:
Image
,
left
:
Float
,
top
:
Float
):
Canvas
{
return
drawImageRect
(
image
,
Rect
.
Companion
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
Rect
.
Companion
.
makeXYWH
(
left
,
top
,
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
SamplingMode
.
Companion
.
DEFAULT
,
Rect
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
Rect
.
makeXYWH
(
left
,
top
,
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
SamplingMode
.
DEFAULT
,
null
,
true
)
}
fun
drawImage
(
image
:
Image
,
left
:
Float
,
top
:
Float
,
paint
:
Paint
?):
Canvas
{
fun
drawImage
(
image
:
Image
,
left
:
Float
,
top
:
Float
,
paint
:
Paint
?):
Canvas
{
return
drawImageRect
(
image
,
Rect
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
Rect
.
makeXYWH
(
left
,
top
,
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
SamplingMode
.
Companion
.
DEFAULT
,
SamplingMode
.
DEFAULT
,
paint
,
true
)
}
fun
drawImageRect
(
image
:
Image
,
dst
:
Rect
):
Canvas
{
fun
drawImageRect
(
image
:
Image
,
dst
:
Rect
):
Canvas
{
return
drawImageRect
(
image
,
Rect
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
dst
,
SamplingMode
.
Companion
.
DEFAULT
,
SamplingMode
.
DEFAULT
,
null
,
true
)
}
fun
drawImageRect
(
image
:
Image
,
dst
:
Rect
,
paint
:
Paint
?):
Canvas
{
fun
drawImageRect
(
image
:
Image
,
dst
:
Rect
,
paint
:
Paint
?):
Canvas
{
return
drawImageRect
(
image
,
Rect
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
()),
...
...
@@ -559,34 +591,34 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
)
}
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
):
Canvas
{
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
):
Canvas
{
return
drawImageRect
(
image
,
src
,
dst
,
SamplingMode
.
DEFAULT
,
null
,
true
)
}
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
,
paint
:
Paint
?):
Canvas
{
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
,
paint
:
Paint
?):
Canvas
{
return
drawImageRect
(
image
,
src
,
dst
,
SamplingMode
.
DEFAULT
,
paint
,
true
)
}
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
,
paint
:
Paint
?,
strict
:
Boolean
):
Canvas
{
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
,
paint
:
Paint
?,
strict
:
Boolean
):
Canvas
{
return
drawImageRect
(
image
,
src
,
dst
,
SamplingMode
.
DEFAULT
,
paint
,
strict
)
}
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
,
samplingMode
:
SamplingMode
,
paint
:
Paint
?,
strict
:
Boolean
fun
drawImageRect
(
image
:
Image
,
src
:
Rect
,
dst
:
Rect
,
samplingMode
:
SamplingMode
,
paint
:
Paint
?,
strict
:
Boolean
):
Canvas
{
assert
(
image
!=
null
)
{
"Can’t drawImageRect with image == null"
}
assert
(
src
!=
null
)
{
"Can’t drawImageRect with src == null"
}
assert
(
dst
!=
null
)
{
"Can’t drawImageRect with dst == null"
}
assert
(
samplingMode
!=
null
)
{
"Can’t drawImageRect with samplingMode == null"
}
require
(
image
!=
null
)
{
"Can’t drawImageRect with image == null"
}
require
(
src
!=
null
)
{
"Can’t drawImageRect with src == null"
}
require
(
dst
!=
null
)
{
"Can’t drawImageRect with dst == null"
}
require
(
samplingMode
!=
null
)
{
"Can’t drawImageRect with samplingMode == null"
}
Stats
.
onNativeCall
()
_nDrawImageRect
(
_ptr
,
Native
.
Companion
.
getPtr
(
image
),
getPtr
(
image
),
src
.
left
,
src
.
top
,
src
.
right
,
...
...
@@ -596,23 +628,23 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
dst
.
right
,
dst
.
bottom
,
samplingMode
.
_pack
(),
Native
.
Companion
.
getPtr
(
paint
),
getPtr
(
paint
),
strict
)
Reference
.
reachabilityFence
(
image
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
image
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawImageNine
(
image
:
Image
,
center
:
IRect
,
dst
:
Rect
,
filterMode
:
FilterMode
,
paint
:
Paint
?):
Canvas
{
assert
(
image
!=
null
)
{
"Can’t drawImageNine with image == null"
}
assert
(
center
!=
null
)
{
"Can’t drawImageNine with center == null"
}
assert
(
dst
!=
null
)
{
"Can’t drawImageNine with dst == null"
}
assert
(
filterMode
!=
null
)
{
"Can’t drawImageNine with filterMode == null"
}
fun
drawImageNine
(
image
:
Image
,
center
:
IRect
,
dst
:
Rect
,
filterMode
:
FilterMode
,
paint
:
Paint
?):
Canvas
{
require
(
image
!=
null
)
{
"Can’t drawImageNine with image == null"
}
require
(
center
!=
null
)
{
"Can’t drawImageNine with center == null"
}
require
(
dst
!=
null
)
{
"Can’t drawImageNine with dst == null"
}
require
(
filterMode
!=
null
)
{
"Can’t drawImageNine with filterMode == null"
}
Stats
.
onNativeCall
()
_nDrawImageNine
(
_ptr
,
Native
.
getPtr
(
image
),
getPtr
(
image
),
center
.
left
,
center
.
top
,
center
.
right
,
...
...
@@ -622,47 +654,47 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
dst
.
right
,
dst
.
bottom
,
filterMode
.
ordinal
,
Native
.
getPtr
(
paint
)
getPtr
(
paint
)
)
Reference
.
reachabilityFence
(
image
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
image
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawRegion
(
r
:
Region
,
paint
:
Paint
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t drawRegion with r == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawRegion with paint == null"
}
require
(
r
!=
null
)
{
"Can’t drawRegion with r == null"
}
require
(
paint
!=
null
)
{
"Can’t drawRegion with paint == null"
}
Stats
.
onNativeCall
()
_nDrawRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
),
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
r
)
Reference
.
reachabilityFence
(
paint
)
_nDrawRegion
(
_ptr
,
getPtr
(
r
),
getPtr
(
paint
))
reachabilityBarrier
(
r
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawString
(
s
:
String
,
x
:
Float
,
y
:
Float
,
font
:
Font
?,
paint
:
Paint
):
Canvas
{
assert
(
s
!=
null
)
{
"Can’t drawString with s == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawString with paint == null"
}
require
(
s
!=
null
)
{
"Can’t drawString with s == null"
}
require
(
paint
!=
null
)
{
"Can’t drawString with paint == null"
}
Stats
.
onNativeCall
()
_nDrawString
(
_ptr
,
s
,
x
,
y
,
Native
.
Companion
.
getPtr
(
font
),
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
font
)
Reference
.
reachabilityFence
(
paint
)
_nDrawString
(
_ptr
,
s
,
x
,
y
,
getPtr
(
font
),
getPtr
(
paint
))
reachabilityBarrier
(
font
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawTextBlob
(
blob
:
TextBlob
,
x
:
Float
,
y
:
Float
,
paint
:
Paint
):
Canvas
{
assert
(
blob
!=
null
)
{
"Can’t drawTextBlob with blob == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawTextBlob with paint == null"
}
require
(
blob
!=
null
)
{
"Can’t drawTextBlob with blob == null"
}
require
(
paint
!=
null
)
{
"Can’t drawTextBlob with paint == null"
}
Stats
.
onNativeCall
()
_nDrawTextBlob
(
_ptr
,
Native
.
Companion
.
getPtr
(
blob
),
x
,
y
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
blob
)
Reference
.
reachabilityFence
(
paint
)
_nDrawTextBlob
(
_ptr
,
getPtr
(
blob
),
x
,
y
,
getPtr
(
paint
))
reachabilityBarrier
(
blob
)
reachabilityBarrier
(
paint
)
return
this
}
fun
drawTextLine
(
line
:
TextLine
,
x
:
Float
,
y
:
Float
,
paint
:
Paint
):
Canvas
{
assert
(
line
!=
null
)
{
"Can’t drawTextLine with line == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawTextLine with paint == null"
}
line
.
textBlob
.
use
{
blob
->
blob
?.
let
{
drawTextBlob
(
it
,
x
,
y
,
paint
)
}
}
require
(
line
!=
null
)
{
"Can’t drawTextLine with line == null"
}
require
(
paint
!=
null
)
{
"Can’t drawTextLine with paint == null"
}
line
.
textBlob
?.
use
{
blob
->
drawTextBlob
(
blob
,
x
,
y
,
paint
)
}
return
this
}
...
...
@@ -671,11 +703,10 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun
drawPicture
(
picture
:
Picture
,
matrix
:
Matrix33
?,
paint
:
Paint
?):
Canvas
{
assert
(
picture
!=
null
)
{
"Can’t drawPicture with picture == null"
}
Stats
.
onNativeCall
()
_nDrawPicture
(
_ptr
,
Native
.
Companion
.
getPtr
(
picture
),
matrix
?.
mat
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
picture
)
Reference
.
reachabilityFence
(
paint
)
_nDrawPicture
(
_ptr
,
getPtr
(
picture
),
matrix
?.
mat
,
getPtr
(
paint
))
reachabilityBarrier
(
picture
)
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -765,23 +796,23 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
mode
:
BlendMode
,
paint
:
Paint
):
Canvas
{
assert
(
positions
!=
null
)
{
"Can’t drawTriangles with positions == null"
}
assert
(
positions
.
size
%
3
==
0
)
{
"Expected positions.length % 3 == 0, got: "
+
positions
.
size
}
assert
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
assert
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
assert
(
paint
!=
null
)
{
"Can’t drawTriangles with paint == null"
}
require
(
positions
!=
null
)
{
"Can’t drawTriangles with positions == null"
}
require
(
positions
.
size
%
3
==
0
)
{
"Expected positions.length % 3 == 0, got: "
+
positions
.
size
}
require
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
require
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
require
(
paint
!=
null
)
{
"Can’t drawTriangles with paint == null"
}
Stats
.
onNativeCall
()
_nDrawVertices
(
_ptr
,
0
/* kTriangles_VertexMode */
,
Point
.
Companion
.
flattenArray
(
positions
),
Point
.
flattenArray
(
positions
),
colors
,
Point
.
Companion
.
flattenArray
(
texCoords
),
Point
.
flattenArray
(
texCoords
),
indices
,
mode
.
ordinal
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -871,23 +902,23 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
mode
:
BlendMode
,
paint
:
Paint
):
Canvas
{
assert
(
positions
!=
null
)
{
"Can’t drawTriangleStrip with positions == null"
}
assert
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
assert
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
assert
(
mode
!=
null
)
{
"Can’t drawTriangles with mode == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawTriangles with paint == null"
}
require
(
positions
!=
null
)
{
"Can’t drawTriangleStrip with positions == null"
}
require
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
require
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
require
(
mode
!=
null
)
{
"Can’t drawTriangles with mode == null"
}
require
(
paint
!=
null
)
{
"Can’t drawTriangles with paint == null"
}
Stats
.
onNativeCall
()
_nDrawVertices
(
_ptr
,
1
/* kTriangleStrip_VertexMode */
,
Point
.
Companion
.
flattenArray
(
positions
),
Point
.
flattenArray
(
positions
),
colors
,
Point
.
Companion
.
flattenArray
(
texCoords
),
Point
.
flattenArray
(
texCoords
),
indices
,
mode
.
ordinal
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -977,23 +1008,20 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
mode
:
BlendMode
,
paint
:
Paint
):
Canvas
{
assert
(
positions
!=
null
)
{
"Can’t drawTriangleFan with positions == null"
}
assert
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
assert
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
assert
(
mode
!=
null
)
{
"Can’t drawTriangleFan with mode == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawTriangleFan with paint == null"
}
require
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
require
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
Stats
.
onNativeCall
()
_nDrawVertices
(
_ptr
,
2
/* kTriangleFan_VertexMode */
,
Point
.
Companion
.
flattenArray
(
positions
),
Point
.
flattenArray
(
positions
),
colors
,
Point
.
Companion
.
flattenArray
(
texCoords
),
Point
.
flattenArray
(
texCoords
),
indices
,
mode
.
ordinal
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -1024,7 +1052,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445](https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445)
*/
fun
drawPatch
(
cubics
:
Array
<
Point
>,
colors
:
IntArray
,
paint
:
Paint
):
Canvas
{
fun
drawPatch
(
cubics
:
Array
<
Point
>,
colors
:
IntArray
,
paint
:
Paint
):
Canvas
{
return
drawPatch
(
cubics
,
colors
,
null
,
paint
)
}
...
...
@@ -1061,7 +1089,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445](https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445)
*/
fun
drawPatch
(
cubics
:
Array
<
Point
>,
colors
:
IntArray
,
texCoords
:
Array
<
Point
>?,
paint
:
Paint
):
Canvas
{
fun
drawPatch
(
cubics
:
Array
<
Point
>,
colors
:
IntArray
,
texCoords
:
Array
<
Point
>?,
paint
:
Paint
):
Canvas
{
return
drawPatch
(
cubics
,
colors
,
texCoords
,
BlendMode
.
MODULATE
,
paint
)
}
...
...
@@ -1100,30 +1128,30 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445](https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445)
*/
fun
drawPatch
(
fun
drawPatch
(
cubics
:
Array
<
Point
>,
colors
:
IntArray
,
texCoords
:
Array
<
Point
>?,
mode
:
BlendMode
,
paint
:
Paint
):
Canvas
{
assert
(
cubics
!=
null
)
{
"Can’t drawPatch with cubics == null"
}
assert
(
cubics
.
size
==
12
)
{
"Expected cubics.length == 12, got: "
+
cubics
.
size
}
assert
(
colors
!=
null
)
{
"Can’t drawPatch with colors == null"
}
assert
(
colors
.
size
==
4
)
{
"Expected colors.length == 4, got: "
+
colors
.
size
}
assert
(
texCoords
==
null
||
texCoords
.
size
==
4
)
{
"Expected texCoords.length == 4, got: "
+
texCoords
!!
.
size
}
assert
(
mode
!=
null
)
{
"Can’t drawPatch with mode == null"
}
assert
(
paint
!=
null
)
{
"Can’t drawPatch with paint == null"
}
require
(
cubics
!=
null
)
{
"Can’t drawPatch with cubics == null"
}
require
(
cubics
.
size
==
12
)
{
"Expected cubics.length == 12, got: "
+
cubics
.
size
}
require
(
colors
!=
null
)
{
"Can’t drawPatch with colors == null"
}
require
(
colors
.
size
==
4
)
{
"Expected colors.length == 4, got: "
+
colors
.
size
}
require
(
texCoords
==
null
||
texCoords
.
size
==
4
)
{
"Expected texCoords.length == 4, got: "
+
texCoords
!!
.
size
}
require
(
mode
!=
null
)
{
"Can’t drawPatch with mode == null"
}
require
(
paint
!=
null
)
{
"Can’t drawPatch with paint == null"
}
Stats
.
onNativeCall
()
_nDrawPatch
(
_ptr
,
Point
.
Companion
.
flattenArray
(
cubics
),
Point
.
flattenArray
(
cubics
),
colors
,
Point
.
Companion
.
flattenArray
(
texCoords
),
Point
.
flattenArray
(
texCoords
),
mode
.
ordinal
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -1140,7 +1168,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
* @param drawable custom struct encapsulating drawing commands
* @return this
*/
fun
drawDrawable
(
drawable
:
Drawable
):
Canvas
{
fun
drawDrawable
(
drawable
:
Drawable
):
Canvas
{
return
drawDrawable
(
drawable
,
null
)
}
...
...
@@ -1161,8 +1189,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawDrawable_2](https://fiddle.skia.org/c/@Canvas_drawDrawable_2)
*/
fun
drawDrawable
(
drawable
:
Drawable
,
x
:
Float
,
y
:
Float
):
Canvas
{
return
drawDrawable
(
drawable
,
Matrix33
.
Companion
.
makeTranslate
(
x
,
y
))
fun
drawDrawable
(
drawable
:
Drawable
,
x
:
Float
,
y
:
Float
):
Canvas
{
return
drawDrawable
(
drawable
,
Matrix33
.
makeTranslate
(
x
,
y
))
}
/**
...
...
@@ -1182,25 +1210,25 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_drawDrawable](https://fiddle.skia.org/c/@Canvas_drawDrawable)
*/
fun
drawDrawable
(
drawable
:
Drawable
,
matrix
:
Matrix33
?):
Canvas
{
assert
(
drawable
!=
null
)
{
"Can’t drawDrawable with drawable == null"
}
fun
drawDrawable
(
drawable
:
Drawable
,
matrix
:
Matrix33
?):
Canvas
{
require
(
drawable
!=
null
)
{
"Can’t drawDrawable with drawable == null"
}
Stats
.
onNativeCall
()
_nDrawDrawable
(
_ptr
,
Native
.
Companion
.
getPtr
(
drawable
),
matrix
?.
mat
)
Reference
.
reachabilityFence
(
drawable
)
_nDrawDrawable
(
_ptr
,
getPtr
(
drawable
),
matrix
?.
mat
)
reachabilityBarrier
(
drawable
)
return
this
}
fun
clear
(
color
:
Int
):
Canvas
{
fun
clear
(
color
:
Int
):
Canvas
{
Stats
.
onNativeCall
()
_nClear
(
_ptr
,
color
)
return
this
}
fun
drawPaint
(
paint
:
Paint
):
Canvas
{
assert
(
paint
!=
null
)
{
"Can’t drawPaint with paint == null"
}
fun
drawPaint
(
paint
:
Paint
):
Canvas
{
require
(
paint
!=
null
)
{
"Can’t drawPaint with paint == null"
}
Stats
.
onNativeCall
()
_nDrawPaint
(
_ptr
,
Native
.
Companion
.
getPtr
(
paint
))
Reference
.
reachabilityFence
(
paint
)
_nDrawPaint
(
_ptr
,
getPtr
(
paint
))
reachabilityBarrier
(
paint
)
return
this
}
...
...
@@ -1212,8 +1240,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_setMatrix](https://fiddle.skia.org/c/@Canvas_setMatrix)
*/
fun
setMatrix
(
matrix
:
Matrix33
):
Canvas
{
assert
(
matrix
!=
null
)
{
"Can’t setMatrix with matrix == null"
}
fun
setMatrix
(
matrix
:
Matrix33
):
Canvas
{
require
(
matrix
!=
null
)
{
"Can’t setMatrix with matrix == null"
}
Stats
.
onNativeCall
()
_nSetMatrix
(
_ptr
,
matrix
.
mat
)
return
this
...
...
@@ -1225,7 +1253,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*
* @see [https://fiddle.skia.org/c/@Canvas_resetMatrix](https://fiddle.skia.org/c/@Canvas_resetMatrix)
*/
fun
resetMatrix
():
Canvas
{
fun
resetMatrix
():
Canvas
{
Stats
.
onNativeCall
()
_nResetMatrix
(
_ptr
)
return
this
...
...
@@ -1240,115 +1268,115 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
val
mat
=
_nGetLocalToDevice
(
_ptr
)
Matrix44
(*
mat
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
localToDeviceAsMatrix33
:
Matrix33
get
()
=
localToDevice
.
asMatrix33
()
fun
clipRect
(
r
:
Rect
,
mode
:
ClipMode
,
antiAlias
:
Boolean
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t clipRect with r == null"
}
assert
(
mode
!=
null
)
{
"Can’t clipRect with mode == null"
}
fun
clipRect
(
r
:
Rect
,
mode
:
ClipMode
,
antiAlias
:
Boolean
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t clipRect with r == null"
}
require
(
mode
!=
null
)
{
"Can’t clipRect with mode == null"
}
Stats
.
onNativeCall
()
_nClipRect
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
mode
.
ordinal
,
antiAlias
)
return
this
}
fun
clipRect
(
r
:
Rect
,
mode
:
ClipMode
):
Canvas
{
fun
clipRect
(
r
:
Rect
,
mode
:
ClipMode
):
Canvas
{
return
clipRect
(
r
,
mode
,
false
)
}
fun
clipRect
(
r
:
Rect
,
antiAlias
:
Boolean
):
Canvas
{
fun
clipRect
(
r
:
Rect
,
antiAlias
:
Boolean
):
Canvas
{
return
clipRect
(
r
,
ClipMode
.
INTERSECT
,
antiAlias
)
}
fun
clipRect
(
r
:
Rect
):
Canvas
{
fun
clipRect
(
r
:
Rect
):
Canvas
{
return
clipRect
(
r
,
ClipMode
.
INTERSECT
,
false
)
}
fun
clipRRect
(
r
:
RRect
,
mode
:
ClipMode
,
antiAlias
:
Boolean
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t clipRRect with r == null"
}
assert
(
mode
!=
null
)
{
"Can’t clipRRect with mode == null"
}
fun
clipRRect
(
r
:
RRect
,
mode
:
ClipMode
,
antiAlias
:
Boolean
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t clipRRect with r == null"
}
require
(
mode
!=
null
)
{
"Can’t clipRRect with mode == null"
}
Stats
.
onNativeCall
()
_nClipRRect
(
_ptr
,
r
.
left
,
r
.
top
,
r
.
right
,
r
.
bottom
,
r
.
radii
,
mode
.
ordinal
,
antiAlias
)
return
this
}
fun
clipRRect
(
r
:
RRect
,
mode
:
ClipMode
):
Canvas
{
fun
clipRRect
(
r
:
RRect
,
mode
:
ClipMode
):
Canvas
{
return
clipRRect
(
r
,
mode
,
false
)
}
fun
clipRRect
(
r
:
RRect
,
antiAlias
:
Boolean
):
Canvas
{
fun
clipRRect
(
r
:
RRect
,
antiAlias
:
Boolean
):
Canvas
{
return
clipRRect
(
r
,
ClipMode
.
INTERSECT
,
antiAlias
)
}
fun
clipRRect
(
r
:
RRect
):
Canvas
{
fun
clipRRect
(
r
:
RRect
):
Canvas
{
return
clipRRect
(
r
,
ClipMode
.
INTERSECT
,
false
)
}
fun
clipPath
(
p
:
Path
,
mode
:
ClipMode
,
antiAlias
:
Boolean
):
Canvas
{
assert
(
p
!=
null
)
{
"Can’t clipPath with p == null"
}
assert
(
mode
!=
null
)
{
"Can’t clipPath with mode == null"
}
fun
clipPath
(
p
:
Path
,
mode
:
ClipMode
,
antiAlias
:
Boolean
):
Canvas
{
require
(
p
!=
null
)
{
"Can’t clipPath with p == null"
}
require
(
mode
!=
null
)
{
"Can’t clipPath with mode == null"
}
Stats
.
onNativeCall
()
_nClipPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
p
),
mode
.
ordinal
,
antiAlias
)
Reference
.
reachabilityFence
(
p
)
_nClipPath
(
_ptr
,
getPtr
(
p
),
mode
.
ordinal
,
antiAlias
)
reachabilityBarrier
(
p
)
return
this
}
fun
clipPath
(
p
:
Path
,
mode
:
ClipMode
):
Canvas
{
fun
clipPath
(
p
:
Path
,
mode
:
ClipMode
):
Canvas
{
return
clipPath
(
p
,
mode
,
false
)
}
fun
clipPath
(
p
:
Path
,
antiAlias
:
Boolean
):
Canvas
{
fun
clipPath
(
p
:
Path
,
antiAlias
:
Boolean
):
Canvas
{
return
clipPath
(
p
,
ClipMode
.
INTERSECT
,
antiAlias
)
}
fun
clipPath
(
p
:
Path
):
Canvas
{
fun
clipPath
(
p
:
Path
):
Canvas
{
return
clipPath
(
p
,
ClipMode
.
INTERSECT
,
false
)
}
fun
clipRegion
(
r
:
Region
,
mode
:
ClipMode
):
Canvas
{
assert
(
r
!=
null
)
{
"Can’t clipRegion with r == null"
}
assert
(
mode
!=
null
)
{
"Can’t clipRegion with mode == null"
}
fun
clipRegion
(
r
:
Region
,
mode
:
ClipMode
):
Canvas
{
require
(
r
!=
null
)
{
"Can’t clipRegion with r == null"
}
require
(
mode
!=
null
)
{
"Can’t clipRegion with mode == null"
}
Stats
.
onNativeCall
()
_nClipRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
),
mode
.
ordinal
)
Reference
.
reachabilityFence
(
r
)
_nClipRegion
(
_ptr
,
getPtr
(
r
),
mode
.
ordinal
)
reachabilityBarrier
(
r
)
return
this
}
fun
clipRegion
(
r
:
Region
):
Canvas
{
fun
clipRegion
(
r
:
Region
):
Canvas
{
return
clipRegion
(
r
,
ClipMode
.
INTERSECT
)
}
fun
translate
(
dx
:
Float
,
dy
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
Companion
.
makeTranslate
(
dx
,
dy
))
fun
translate
(
dx
:
Float
,
dy
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
makeTranslate
(
dx
,
dy
))
}
fun
scale
(
sx
:
Float
,
sy
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
Companion
.
makeScale
(
sx
,
sy
))
fun
scale
(
sx
:
Float
,
sy
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
makeScale
(
sx
,
sy
))
}
/**
* @param deg angle in degrees
* @return this
*/
fun
rotate
(
deg
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
Companion
.
makeRotate
(
deg
))
fun
rotate
(
deg
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
makeRotate
(
deg
))
}
fun
skew
(
sx
:
Float
,
sy
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
Companion
.
makeSkew
(
sx
,
sy
))
fun
skew
(
sx
:
Float
,
sy
:
Float
):
Canvas
{
return
concat
(
Matrix33
.
makeSkew
(
sx
,
sy
))
}
fun
concat
(
matrix
:
Matrix33
):
Canvas
{
assert
(
matrix
!=
null
)
{
"Can’t concat with matrix == null"
}
fun
concat
(
matrix
:
Matrix33
):
Canvas
{
require
(
matrix
!=
null
)
{
"Can’t concat with matrix == null"
}
Stats
.
onNativeCall
()
_nConcat
(
_ptr
,
matrix
.
mat
)
return
this
}
fun
concat
(
matrix
:
Matrix44
):
Canvas
{
assert
(
matrix
!=
null
)
{
"Can’t concat with matrix == null"
}
fun
concat
(
matrix
:
Matrix44
):
Canvas
{
require
(
matrix
!=
null
)
{
"Can’t concat with matrix == null"
}
Stats
.
onNativeCall
()
_nConcat44
(
_ptr
,
matrix
.
mat
)
return
this
...
...
@@ -1401,17 +1429,17 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*/
fun
readPixels
(
bitmap
:
Bitmap
,
srcX
:
Int
,
srcY
:
Int
):
Boolean
{
return
try
{
assert
(
bitmap
!=
null
)
{
"Can’t readPixels with bitmap == null"
}
require
(
bitmap
!=
null
)
{
"Can’t readPixels with bitmap == null"
}
Stats
.
onNativeCall
()
_nReadPixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
getPtr
(
bitmap
),
srcX
,
srcY
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
bitmap
)
}
}
...
...
@@ -1467,17 +1495,17 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*/
fun
writePixels
(
bitmap
:
Bitmap
,
x
:
Int
,
y
:
Int
):
Boolean
{
return
try
{
assert
(
bitmap
!=
null
)
{
"Can’t writePixels with bitmap == null"
}
require
(
bitmap
!=
null
)
{
"Can’t writePixels with bitmap == null"
}
Stats
.
onNativeCall
()
_nWritePixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
bitmap
),
getPtr
(
bitmap
),
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
bitmap
)
}
}
...
...
@@ -1486,7 +1514,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
Stats
.
onNativeCall
()
_nSave
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -1499,11 +1527,11 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
top
,
right
,
bottom
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
paint
)
}
}
...
...
@@ -1541,18 +1569,18 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
Stats
.
onNativeCall
()
if
(
bounds
==
null
)
_nSaveLayer
(
_ptr
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
else
_nSaveLayerRect
(
_ptr
,
bounds
.
left
,
bounds
.
top
,
bounds
.
right
,
bounds
.
bottom
,
Native
.
getPtr
(
paint
)
getPtr
(
paint
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
paint
)
}
}
...
...
@@ -1561,7 +1589,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
Stats
.
onNativeCall
()
_nGetSaveCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
restore
():
Canvas
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Data.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Data.kt
View file @
f794e4bb
...
...
@@ -4,15 +4,13 @@ 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
java.nio.ByteBuffer
import
org.jetbrains.skia.impl.reachabilityBarrier
/**
* Data holds an immutable data buffer.
*/
class
Data
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
@JvmOverloads
fun
makeFromBytes
(
bytes
:
ByteArray
,
offset
:
Long
=
0
,
length
:
Long
=
bytes
.
size
.
toLong
()):
Data
{
Stats
.
onNativeCall
()
return
Data
(
_nMakeFromBytes
(
bytes
,
offset
,
length
))
...
...
@@ -56,7 +54,7 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
bytes
:
ByteArray
get
()
=
getBytes
(
0
,
size
)
...
...
@@ -66,7 +64,7 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nBytes
(
_ptr
,
offset
,
length
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -77,10 +75,10 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nEquals
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -93,7 +91,7 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
Data
(
_nMakeSubset
(
_ptr
,
offset
,
length
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -102,7 +100,7 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
Data
(
_nMakeSubset
(
_ptr
,
0
,
size
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -111,7 +109,7 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
Stats
.
onNativeCall
()
_nToByteBuffer
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Drawable.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Drawable.kt
View file @
f794e4bb
...
...
@@ -2,9 +2,9 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
/**
*
...
...
@@ -45,7 +45,7 @@ abstract class Drawable : RefCnt(_nMake()) {
* and the current matrix and clip settings will not be changed.
*/
fun
draw
(
canvas
:
Canvas
?,
x
:
Float
,
y
:
Float
):
Drawable
{
return
draw
(
canvas
,
Matrix33
.
Companion
.
makeTranslate
(
x
,
y
))
return
draw
(
canvas
,
Matrix33
.
makeTranslate
(
x
,
y
))
}
/**
...
...
@@ -58,12 +58,12 @@ abstract class Drawable : RefCnt(_nMake()) {
Stats
.
onNativeCall
()
_nDraw
(
_ptr
,
Native
.
Companion
.
getPtr
(
canvas
),
getPtr
(
canvas
),
matrix
?.
mat
)
this
}
finally
{
Reference
.
reachabilityFence
(
canvas
)
reachabilityBarrier
(
canvas
)
}
}
...
...
@@ -72,7 +72,7 @@ abstract class Drawable : RefCnt(_nMake()) {
Stats
.
onNativeCall
()
Picture
(
_nMakePictureSnapshot
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -90,7 +90,7 @@ abstract class Drawable : RefCnt(_nMake()) {
Stats
.
onNativeCall
()
_nGetGenerationId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Expects.kt
0 → 100644
View file @
f794e4bb
package
org.jetbrains.skia
expect
abstract
class
ByteBuffer
expect
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
expect
fun
String
.
intCodePoints
():
IntArray
expect
fun
defaultLanguageTag
():
String
expect
class
Pattern
{
fun
split
(
input
:
CharSequence
):
Array
<
String
?
>?
fun
matcher
(
input
:
CharSequence
):
Matcher
}
expect
class
Matcher
{
fun
group
(
name
:
String
):
String
?
fun
matches
():
Boolean
}
expect
fun
compilePattern
(
regex
:
String
):
Pattern
interface
BooleanSupplier
{
/**
* Gets a result.
*
* @return a result
*/
val
asBoolean
:
Boolean
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Font.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Font.kt
View file @
f794e4bb
...
...
@@ -4,7 +4,8 @@ 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
Font
:
Managed
{
companion
object
{
...
...
@@ -81,18 +82,18 @@ class Font : Managed {
*
* @param typeface typeface and style used to draw and measure text. Pass null for default
*/
constructor
(
typeface
:
Typeface
?)
:
this
(
_nMakeTypeface
(
Native
.
getPtr
(
typeface
)))
{
constructor
(
typeface
:
Typeface
?)
:
this
(
_nMakeTypeface
(
getPtr
(
typeface
)))
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
typeface
)
reachabilityBarrier
(
typeface
)
}
/**
* @param typeface typeface and style used to draw and measure text. Pass null for default
* @param size typographic size of the text
*/
constructor
(
typeface
:
Typeface
?,
size
:
Float
)
:
this
(
_nMakeTypefaceSize
(
Native
.
Companion
.
getPtr
(
typeface
),
size
))
{
constructor
(
typeface
:
Typeface
?,
size
:
Float
)
:
this
(
_nMakeTypefaceSize
(
getPtr
(
typeface
),
size
))
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
typeface
)
reachabilityBarrier
(
typeface
)
}
/**
...
...
@@ -107,11 +108,11 @@ class Font : Managed {
*/
constructor
(
typeface
:
Typeface
?,
size
:
Float
,
scaleX
:
Float
,
skewX
:
Float
)
:
this
(
_nMakeTypefaceSizeScaleSkew
(
Native
.
Companion
.
getPtr
(
typeface
),
size
,
scaleX
,
skewX
getPtr
(
typeface
),
size
,
scaleX
,
skewX
)
)
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
typeface
)
reachabilityBarrier
(
typeface
)
}
/**
...
...
@@ -120,10 +121,10 @@ class Font : Managed {
*/
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
_nEquals
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -138,7 +139,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nIsAutoHintingForced
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -149,7 +150,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nAreBitmapsEmbedded
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -161,7 +162,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nIsSubpixel
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -172,7 +173,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nAreMetricsLinear
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -187,7 +188,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nIsEmboldened
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -201,7 +202,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nIsBaselineSnapped
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -288,7 +289,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
FontEdging
.
values
().
get
(
_nGetEdging
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -309,7 +310,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
FontHinting
.
values
().
get
(
_nGetHinting
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -337,7 +338,7 @@ class Font : Managed {
val
ptr
=
_nGetTypeface
(
_ptr
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -348,7 +349,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
Typeface
(
_nGetTypefaceOrDefault
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -359,7 +360,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -370,7 +371,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetScaleX
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -381,7 +382,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetSkewX
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -392,11 +393,11 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nSetTypeface
(
_ptr
,
Native
.
Companion
.
getPtr
(
typeface
)
getPtr
(
typeface
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
typeface
)
reachabilityBarrier
(
typeface
)
}
}
...
...
@@ -433,7 +434,7 @@ class Font : Managed {
* @return the corresponding glyph ids for each character.
*/
fun
getStringGlyphs
(
s
:
String
):
ShortArray
{
return
getUTF32Glyphs
(
s
.
codePoints
().
toArray
())
return
getUTF32Glyphs
(
s
.
intCodePoints
())
}
/**
...
...
@@ -446,7 +447,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetUTF32Glyphs
(
_ptr
,
uni
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -458,7 +459,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetUTF32Glyph
(
_ptr
,
unichar
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -470,7 +471,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetStringGlyphsCount
(
_ptr
,
s
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
/**
...
...
@@ -480,14 +481,13 @@ class Font : Managed {
/**
* @return the bounding box of text
*/
@JvmOverloads
fun
measureText
(
s
:
String
?,
p
:
Paint
?
=
null
):
Rect
{
return
try
{
Stats
.
onNativeCall
()
_nMeasureText
(
_ptr
,
s
,
Native
.
Companion
.
getPtr
(
p
))
_nMeasureText
(
_ptr
,
s
,
getPtr
(
p
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
p
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
}
}
...
...
@@ -502,11 +502,11 @@ class Font : Managed {
_nMeasureTextWidth
(
_ptr
,
s
,
Native
.
Companion
.
getPtr
(
p
)
getPtr
(
p
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
p
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
}
}
...
...
@@ -518,7 +518,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetWidths
(
_ptr
,
glyphs
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -538,11 +538,11 @@ class Font : Managed {
_nGetBounds
(
_ptr
,
glyphs
,
Native
.
Companion
.
getPtr
(
p
)
getPtr
(
p
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
p
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
}
}
...
...
@@ -554,7 +554,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetPositions
(
_ptr
,
glyphs
,
0f
,
0f
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -566,7 +566,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetPositions
(
_ptr
,
glyphs
,
offset
.
x
,
offset
.
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -578,7 +578,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetXPositions
(
_ptr
,
glyphs
,
0f
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -590,7 +590,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetXPositions
(
_ptr
,
glyphs
,
offset
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -602,9 +602,9 @@ class Font : Managed {
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nGetPath
(
_ptr
,
glyph
)
if
(
ptr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
Path
(
ptr
)
if
(
ptr
==
0L
)
null
else
Path
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -616,7 +616,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetPaths
(
_ptr
,
glyphs
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -629,7 +629,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetMetrics
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -641,7 +641,7 @@ class Font : Managed {
Stats
.
onNativeCall
()
_nGetSpacing
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
private
object
_FinalizerHolder
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontFamilyName.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontFamilyName.kt
View file @
f794e4bb
...
...
@@ -8,10 +8,10 @@ class FontFamilyName(val name: String, val language: String) {
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
val
`
this
$
_name
`
:
Any
=
name
val
`
other
$
_name
`
:
Any
=
other
.
name
if
(
if
(
`
this
$
_name
`
==
null
)
`
other
$
_name
`
!=
null
else
`
this
$
_name
`
!=
`
other
$
_name
`
)
return
false
if
(
`
this
$
_name
`
!=
`
other
$
_name
`
)
return
false
val
`
this
$
_language
`
:
Any
=
language
val
`
other
$
_language
`
:
Any
=
other
.
language
return
if
(
if
(
`
this
$
_language
`
==
null
)
`
other
$
_language
`
!=
null
else
`
this
$
_language
`
!=
`
other
$
_language
`
)
false
else
true
return
`
this
$
_language
`
==
`
other
$
_language
`
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -22,13 +22,13 @@ class FontFamilyName(val name: String, val language: String) {
val
PRIME
=
59
var
result
=
1
val
`$
_name
`
:
Any
=
name
result
=
result
*
PRIME
+
(
`$
_name
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_name
`
.
hashCode
()
)
val
`$
_language
`
:
Any
=
language
result
=
result
*
PRIME
+
(
`$
_language
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_language
`
.
hashCode
()
)
return
result
}
override
fun
toString
():
String
{
return
"FontFamilyName(_name=
"
+
name
+
", _language="
+
language
+
"
)"
return
"FontFamilyName(_name=
$name, _language=$language
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontFeature.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontFeature.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
java.util.regex.Pattern
class
FontFeature
(
val
_tag
:
Int
,
val
value
:
Int
,
val
start
:
Long
,
val
end
:
Long
)
{
constructor
(
feature
:
String
,
value
:
Int
,
start
:
Long
,
end
:
Long
)
:
this
(
FourByteTag
.
Companion
.
fromString
(
feature
),
FourByteTag
.
fromString
(
feature
),
value
,
start
,
end
)
constructor
(
feature
:
String
,
value
:
Int
)
:
this
(
FourByteTag
.
Companion
.
fromString
(
feature
),
FourByteTag
.
fromString
(
feature
),
value
,
GLOBAL_START
,
GLOBAL_END
)
constructor
(
feature
:
String
,
value
:
Boolean
)
:
this
(
FourByteTag
.
Companion
.
fromString
(
feature
),
FourByteTag
.
fromString
(
feature
),
if
(
value
)
1
else
0
,
GLOBAL_START
,
GLOBAL_END
)
constructor
(
feature
:
String
)
:
this
(
FourByteTag
.
Companion
.
fromString
(
feature
),
1
,
GLOBAL_START
,
GLOBAL_END
)
constructor
(
feature
:
String
)
:
this
(
FourByteTag
.
fromString
(
feature
),
1
,
GLOBAL_START
,
GLOBAL_END
)
val
tag
:
String
get
()
=
FourByteTag
.
Companion
.
toString
(
_tag
)
get
()
=
FourByteTag
.
toString
(
_tag
)
override
fun
toString
():
String
{
var
range
=
""
...
...
@@ -48,7 +46,7 @@ class FontFeature(val _tag: Int, val value: Int, val start: Long, val end: Long)
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
val
`
this
$
_tag
`
:
Any
=
_tag
val
`
other
$
_tag
`
:
Any
=
other
.
_tag
if
(
if
(
`
this
$
_tag
`
==
null
)
`
other
$
_tag
`
!=
null
else
`
this
$
_tag
`
!=
`
other
$
_tag
`
)
return
false
if
(
`
this
$
_tag
`
!=
`
other
$
_tag
`
)
return
false
if
(
value
!=
other
.
value
)
return
false
if
(
start
!=
other
.
start
)
return
false
return
if
(
end
!=
other
.
end
)
false
else
true
...
...
@@ -62,7 +60,7 @@ class FontFeature(val _tag: Int, val value: Int, val start: Long, val end: Long)
val
PRIME
=
59
var
result
=
1
val
`$
_tag
`
:
Any
=
_tag
result
=
result
*
PRIME
+
(
`$
_tag
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_tag
`
.
hashCode
()
)
result
=
result
*
PRIME
+
value
val
`$
_start
`
=
start
result
=
result
*
PRIME
+
(
`$
_start
`
ushr
32
xor
`$
_start
`
).
toInt
()
...
...
@@ -75,22 +73,22 @@ class FontFeature(val _tag: Int, val value: Int, val start: Long, val end: Long)
const
val
GLOBAL_START
:
Long
=
0
const
val
GLOBAL_END
=
Long
.
MAX_VALUE
val
EMPTY
=
arrayOfNulls
<
FontFeature
>(
0
)
val
_splitPattern
=
Pattern
.
compile
(
"\\s+"
)
val
_splitPattern
=
compilePattern
(
"\\s+"
)
val
_featurePattern
=
Pattern
.
compile
(
"(?<sign>[-+])?(?<tag>[a-z0-9]{4})(?:\\[(?<start>\\d+)?:(?<end>\\d+)?\\])?(?:=(?<value>\\d+))?"
)
compilePattern
(
"(?<sign>[-+])?(?<tag>[a-z0-9]{4})(?:\\[(?<start>\\d+)?:(?<end>\\d+)?\\])?(?:=(?<value>\\d+))?"
)
fun
parseOne
(
s
:
String
):
FontFeature
{
val
m
=
_featurePattern
.
matcher
(
s
)
require
(
m
.
matches
())
{
"Can’t parse FontFeature: $s"
}
val
value
=
if
(
m
.
group
(
"value"
)
!=
null
)
m
.
group
(
"value"
)
val
value
=
if
(
m
.
group
(
"value"
)
!=
null
)
m
.
group
(
"value"
)
!!
.
toInt
()
else
if
(
m
.
group
(
"sign"
)
==
null
)
1
else
if
(
"-"
==
m
.
group
(
"sign"
))
0
else
1
val
start
=
if
(
m
.
group
(
"start"
)
==
null
)
0
else
m
.
group
(
"start"
).
toLong
()
val
end
=
if
(
m
.
group
(
"end"
)
==
null
)
Long
.
MAX_VALUE
else
m
.
group
(
"end"
).
toLong
()
return
FontFeature
(
m
.
group
(
"tag"
),
value
,
start
,
end
)
val
start
=
if
(
m
.
group
(
"start"
)
==
null
)
0
else
m
.
group
(
"start"
)
!!
.
toLong
()
val
end
=
if
(
m
.
group
(
"end"
)
==
null
)
Long
.
MAX_VALUE
else
m
.
group
(
"end"
)
!!
.
toLong
()
return
FontFeature
(
m
.
group
(
"tag"
)
!!
,
value
,
start
,
end
)
}
fun
parse
(
s
:
String
?
):
Array
<
FontFeature
?
>
{
return
_splitPattern
.
split
(
s
)
.
map
{
s
->
parseOne
(
s
)
}.
toTyped
Array
()
fun
parse
(
s
:
String
):
Array
<
FontFeature
?
>
{
return
_splitPattern
.
split
(
s
)
?.
map
{
s
->
parseOne
(
s
!!
)
}
?.
toTypedArray
()
?:
empty
Array
()
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontMetrics.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontMetrics.kt
View file @
f794e4bb
...
...
@@ -115,17 +115,17 @@ class FontMetrics(
if
(
o
!
is
FontMetrics
)
return
false
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
java
.
lang
.
Float
.
compare
(
top
,
other
.
top
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
ascent
,
other
.
ascent
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
descent
,
other
.
descent
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
bottom
,
other
.
bottom
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
leading
,
other
.
leading
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
avgCharWidth
,
other
.
avgCharWidth
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
maxCharWidth
,
other
.
maxCharWidth
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
xMin
,
other
.
xMin
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
xMax
,
other
.
xMax
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
xHeight
,
other
.
xHeight
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
capHeight
,
other
.
capHeight
)
!=
0
)
return
false
if
(
top
.
compareTo
(
other
.
top
)
!=
0
)
return
false
if
(
ascent
.
compareTo
(
other
.
ascent
)
!=
0
)
return
false
if
(
descent
.
compareTo
(
other
.
descent
)
!=
0
)
return
false
if
(
bottom
.
compareTo
(
other
.
bottom
)
!=
0
)
return
false
if
(
leading
.
compareTo
(
other
.
leading
)
!=
0
)
return
false
if
(
avgCharWidth
.
compareTo
(
other
.
avgCharWidth
)
!=
0
)
return
false
if
(
maxCharWidth
.
compareTo
(
other
.
maxCharWidth
)
!=
0
)
return
false
if
(
xMin
.
compareTo
(
other
.
xMin
)
!=
0
)
return
false
if
(
xMax
.
compareTo
(
other
.
xMax
)
!=
0
)
return
false
if
(
xHeight
.
compareTo
(
other
.
xHeight
)
!=
0
)
return
false
if
(
capHeight
.
compareTo
(
other
.
capHeight
)
!=
0
)
return
false
val
`
this
$
_underlineThickness
`
:
Any
?
=
underlineThickness
val
`
other
$
_underlineThickness
`
:
Any
?
=
other
.
underlineThickness
if
(
if
(
`
this
$
_underlineThickness
`
==
null
)
`
other
$
_underlineThickness
`
!=
null
else
`
this
$
_underlineThickness
`
!=
`
other
$
_underlineThickness
`
)
return
false
...
...
@@ -147,17 +147,17 @@ class FontMetrics(
override
fun
hashCode
():
Int
{
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
top
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
ascent
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
descent
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
bottom
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
leading
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
avgCharWidth
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
maxCharWidth
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
xMin
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
xMax
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
xHeight
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
capHeight
)
result
=
result
*
PRIME
+
top
.
toBits
(
)
result
=
result
*
PRIME
+
ascent
.
toBits
(
)
result
=
result
*
PRIME
+
descent
.
toBits
(
)
result
=
result
*
PRIME
+
bottom
.
toBits
(
)
result
=
result
*
PRIME
+
leading
.
toBits
(
)
result
=
result
*
PRIME
+
avgCharWidth
.
toBits
(
)
result
=
result
*
PRIME
+
maxCharWidth
.
toBits
(
)
result
=
result
*
PRIME
+
xMin
.
toBits
(
)
result
=
result
*
PRIME
+
xMax
.
toBits
(
)
result
=
result
*
PRIME
+
xHeight
.
toBits
(
)
result
=
result
*
PRIME
+
capHeight
.
toBits
(
)
val
`$
_underlineThickness
`
:
Any
?
=
underlineThickness
result
=
result
*
PRIME
+
(
`$
_underlineThickness
`
?.
hashCode
()
?:
43
)
val
`$
_underlinePosition
`
:
Any
?
=
underlinePosition
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontMgr.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontMgr.kt
View file @
f794e4bb
...
...
@@ -2,9 +2,9 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
open
class
FontMgr
:
RefCnt
{
companion
object
{
...
...
@@ -35,7 +35,7 @@ open class FontMgr : RefCnt {
Stats
.
onNativeCall
()
_nGetFamiliesCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
getFamilyName
(
index
:
Int
):
String
{
...
...
@@ -43,7 +43,7 @@ open class FontMgr : RefCnt {
Stats
.
onNativeCall
()
_nGetFamilyName
(
_ptr
,
index
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -53,7 +53,7 @@ open class FontMgr : RefCnt {
val
ptr
=
_nMakeStyleSet
(
_ptr
,
index
)
if
(
ptr
==
0L
)
null
else
FontStyleSet
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -73,7 +73,7 @@ open class FontMgr : RefCnt {
Stats
.
onNativeCall
()
FontStyleSet
(
_nMatchFamily
(
_ptr
,
familyName
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -95,7 +95,7 @@ open class FontMgr : RefCnt {
val
ptr
=
_nMatchFamilyStyle
(
_ptr
,
familyName
,
style
.
_value
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -133,7 +133,7 @@ open class FontMgr : RefCnt {
val
ptr
=
_nMatchFamilyStyleCharacter
(
_ptr
,
familyName
,
style
.
_value
,
bcp47
,
character
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -155,16 +155,15 @@ open class FontMgr : RefCnt {
* or null if the data is not recognized. The caller must call [.close] on
* the returned object if it is not null.
*/
@JvmOverloads
fun
makeFromData
(
data
:
Data
?,
ttcIndex
:
Int
=
0
):
Typeface
?
{
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromData
(
_ptr
,
Native
.
Companion
.
getPtr
(
data
),
ttcIndex
)
_nMakeFromData
(
_ptr
,
getPtr
(
data
),
ttcIndex
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
data
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontStyle.kt
View file @
f794e4bb
...
...
@@ -56,9 +56,9 @@ class FontStyle {
}
companion
object
{
val
NORMAL
=
FontStyle
(
FontWeight
.
Companion
.
NORMAL
,
FontWidth
.
Companion
.
NORMAL
,
FontSlant
.
UPRIGHT
)
val
BOLD
=
FontStyle
(
FontWeight
.
Companion
.
BOLD
,
FontWidth
.
Companion
.
NORMAL
,
FontSlant
.
UPRIGHT
)
val
ITALIC
=
FontStyle
(
FontWeight
.
Companion
.
NORMAL
,
FontWidth
.
Companion
.
NORMAL
,
FontSlant
.
ITALIC
)
val
BOLD_ITALIC
=
FontStyle
(
FontWeight
.
Companion
.
BOLD
,
FontWidth
.
Companion
.
NORMAL
,
FontSlant
.
ITALIC
)
val
NORMAL
=
FontStyle
(
FontWeight
.
NORMAL
,
FontWidth
.
NORMAL
,
FontSlant
.
UPRIGHT
)
val
BOLD
=
FontStyle
(
FontWeight
.
BOLD
,
FontWidth
.
NORMAL
,
FontSlant
.
UPRIGHT
)
val
ITALIC
=
FontStyle
(
FontWeight
.
NORMAL
,
FontWidth
.
NORMAL
,
FontSlant
.
ITALIC
)
val
BOLD_ITALIC
=
FontStyle
(
FontWeight
.
BOLD
,
FontWidth
.
NORMAL
,
FontSlant
.
ITALIC
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontStyleSet.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontStyleSet.kt
View file @
f794e4bb
...
...
@@ -3,7 +3,8 @@ package org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
FontStyleSet
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -29,16 +30,16 @@ class FontStyleSet internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
fun
getStyle
(
index
:
Int
):
FontStyle
{
return
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
FontStyle
(
_nGetStyle
(
_ptr
,
index
))
FontStyle
(
_nGetStyle
(
_ptr
,
index
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -47,7 +48,7 @@ class FontStyleSet internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetStyleName
(
_ptr
,
index
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -57,7 +58,7 @@ class FontStyleSet internal constructor(ptr: Long) : RefCnt(ptr) {
val
ptr
=
_nGetTypeface
(
_ptr
,
index
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -67,7 +68,7 @@ class FontStyleSet internal constructor(ptr: Long) : RefCnt(ptr) {
val
ptr
=
_nMatchStyle
(
_ptr
,
style
.
_value
)
if
(
ptr
==
0L
)
null
else
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontVariation.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontVariation.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
java.util.regex.Pattern
class
FontVariation
(
val
_tag
:
Int
,
val
value
:
Float
)
{
constructor
(
feature
:
String
,
value
:
Float
)
:
this
(
FourByteTag
.
fromString
(
feature
),
value
)
{}
...
...
@@ -20,8 +18,8 @@ class FontVariation(val _tag: Int, val value: Float) {
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
val
`
this
$
_tag
`
:
Any
=
_tag
val
`
other
$
_tag
`
:
Any
=
other
.
_tag
if
(
if
(
`
this
$
_tag
`
==
null
)
`
other
$
_tag
`
!=
null
else
`
this
$
_tag
`
!=
`
other
$
_tag
`
)
return
false
return
if
(
java
.
lang
.
Float
.
compare
(
value
,
other
.
value
)
!=
0
)
false
else
true
if
(
`
this
$
_tag
`
!=
`
other
$
_tag
`
)
return
false
return
value
.
compareTo
(
other
.
value
)
==
0
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -33,25 +31,26 @@ class FontVariation(val _tag: Int, val value: Float) {
var
result
=
1
val
`$
_tag
`
:
Any
=
_tag
result
=
result
*
PRIME
+
(
`$
_tag
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
value
)
result
=
result
*
PRIME
+
value
.
toBits
(
)
return
result
}
companion
object
{
val
EMPTY
=
arrayOfNulls
<
FontVariation
>(
0
)
internal
val
_splitPattern
=
Pattern
.
compile
(
"\\s+"
)
internal
val
_splitPattern
=
compilePattern
(
"\\s+"
)
internal
val
_variationPattern
=
compilePattern
(
"(?<tag>[a-z0-9]{4})=(?<value>\\d+)"
)
internal
val
_variationPattern
=
Pattern
.
compile
(
"(?<tag>[a-z0-9]{4})=(?<value>\\d+)"
)
fun
parseOne
(
s
:
String
):
FontVariation
{
val
m
=
_variationPattern
.
matcher
(
s
)
require
(
m
.
matches
())
{
"Can’t parse FontVariation: $s"
}
val
value
=
m
.
group
(
"value"
).
toFloat
()
return
FontVariation
(
m
.
group
(
"tag"
),
value
)
val
value
=
m
.
group
(
"value"
)
!!
.
toFloat
()
return
FontVariation
(
m
.
group
(
"tag"
)
!!
,
value
)
}
fun
parse
(
s
:
String
?):
Array
<
FontVariation
>
{
return
_splitPattern
.
split
(
s
).
map
{
s
:
String
->
parseOne
(
s
)
}
return
_splitPattern
.
split
(
s
!!
)
!!
.
map
{
s
->
parseOne
(
s
!!
)
}
.
toTypedArray
()
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/FontVariationAxis.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/FontVariationAxis.kt
View file @
f794e4bb
...
...
@@ -21,7 +21,7 @@ class FontVariationAxis(
}
constructor
(
tag
:
String
,
min
:
Float
,
def
:
Float
,
max
:
Float
)
:
this
(
FourByteTag
.
Companion
.
fromString
(
tag
),
FourByteTag
.
fromString
(
tag
),
min
,
def
,
max
,
...
...
@@ -36,11 +36,11 @@ class FontVariationAxis(
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
val
`
this
$
_tag
`
:
Any
=
_tag
val
`
other
$
_tag
`
:
Any
=
other
.
_tag
if
(
if
(
`
this
$
_tag
`
==
null
)
`
other
$
_tag
`
!=
null
else
`
this
$
_tag
`
!=
`
other
$
_tag
`
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
minValue
,
other
.
minValue
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
defaultValue
,
other
.
defaultValue
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
maxValue
,
other
.
maxValue
)
!=
0
)
return
false
return
i
f
(
isHidden
!=
other
.
isHidden
)
false
else
true
if
(
`
this
$
_tag
`
!=
`
other
$
_tag
`
)
return
false
if
(
minValue
.
compareTo
(
other
.
minValue
)
!=
0
)
return
false
if
(
defaultValue
.
compareTo
(
other
.
defaultValue
)
!=
0
)
return
false
if
(
maxValue
.
compareTo
(
other
.
maxValue
)
!=
0
)
return
false
return
i
sHidden
==
other
.
isHidden
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -51,15 +51,15 @@ class FontVariationAxis(
val
PRIME
=
59
var
result
=
1
val
`$
_tag
`
:
Any
=
_tag
result
=
result
*
PRIME
+
(
`$
_tag
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
minValue
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
defaultValue
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
maxValue
)
result
=
result
*
PRIME
+
(
`$
_tag
`
.
hashCode
()
)
result
=
result
*
PRIME
+
minValue
.
toBits
(
)
result
=
result
*
PRIME
+
defaultValue
.
toBits
(
)
result
=
result
*
PRIME
+
maxValue
.
toBits
(
)
result
=
result
*
PRIME
+
if
(
isHidden
)
79
else
97
return
result
}
override
fun
toString
():
String
{
return
"FontVariationAxis(_tag=
"
+
_tag
+
", _minValue="
+
minValue
+
", _defaultValue="
+
defaultValue
+
", _maxValue="
+
maxValue
+
", _hidden="
+
isHidden
+
"
)"
return
"FontVariationAxis(_tag=
$_tag, _minValue=$minValue, _defaultValue=$defaultValue, _maxValue=$maxValue, _hidden=$isHidden
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/GradientStyle.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/GradientStyle.kt
View file @
f794e4bb
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/IHasImageInfo.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/IHasImageInfo.kt
View file @
f794e4bb
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Image.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Image.kt
View file @
f794e4bb
...
...
@@ -2,11 +2,9 @@ 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.RuntimeException
import
java.lang.ref.Reference
import
java.nio.ByteBuffer
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Image
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
),
IHasImageInfo
{
companion
object
{
...
...
@@ -39,14 +37,14 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
Companion
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
bytes
,
rowBytes
)
if
(
ptr
==
0L
)
throw
RuntimeException
(
"Failed to makeRaster $imageInfo $bytes $rowBytes"
)
Image
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -77,15 +75,15 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
imageInfo
.
height
,
imageInfo
.
colorInfo
.
colorType
.
ordinal
,
imageInfo
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
Native
.
getPtr
(
data
),
getPtr
(
imageInfo
.
colorInfo
.
colorSpace
),
getPtr
(
data
),
rowBytes
)
if
(
ptr
==
0L
)
throw
RuntimeException
(
"Failed to makeRaster $imageInfo $data $rowBytes"
)
Image
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
imageInfo
.
colorInfo
.
colorSpace
)
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
imageInfo
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
data
)
}
}
...
...
@@ -112,27 +110,27 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
*/
fun
makeFromBitmap
(
bitmap
:
Bitmap
):
Image
{
return
try
{
assert
(
bitmap
!=
null
)
{
"Can’t makeFromBitmap with bitmap == null"
}
require
(
bitmap
!=
null
)
{
"Can’t makeFromBitmap with bitmap == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromBitmap
(
Native
.
Companion
.
getPtr
(
bitmap
))
_nMakeFromBitmap
(
getPtr
(
bitmap
))
if
(
ptr
==
0L
)
throw
RuntimeException
(
"Failed to Image::makeFromBitmap $bitmap"
)
Image
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
bitmap
)
reachabilityBarrier
(
bitmap
)
}
}
fun
makeFromPixmap
(
pixmap
:
Pixmap
):
Image
{
return
try
{
assert
(
pixmap
!=
null
)
{
"Can’t makeFromPixmap with pixmap == null"
}
require
(
pixmap
!=
null
)
{
"Can’t makeFromPixmap with pixmap == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromPixmap
(
Native
.
Companion
.
getPtr
(
pixmap
))
_nMakeFromPixmap
(
getPtr
(
pixmap
))
if
(
ptr
==
0L
)
throw
RuntimeException
(
"Failed to Image::makeFromRaster $pixmap"
)
Image
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -199,7 +197,7 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
override
val
imageInfo
:
ImageInfo
get
()
=
try
{
if
(
_imageInfo
==
null
)
{
s
ynchronized
(
this
)
{
commonS
ynchronized
(
this
)
{
if
(
_imageInfo
==
null
)
{
Stats
.
onNativeCall
()
_imageInfo
=
_nGetImageInfo
(
_ptr
)
...
...
@@ -208,7 +206,7 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
}
_imageInfo
!!
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
* Encodes Image pixels, returning result as Data.
...
...
@@ -240,14 +238,13 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
*
* @see [https://fiddle.skia.org/c/@Image_encodeToData_2](https://fiddle.skia.org/c/@Image_encodeToData_2)
*/
@JvmOverloads
fun
encodeToData
(
format
:
EncodedImageFormat
=
EncodedImageFormat
.
PNG
,
quality
:
Int
=
100
):
Data
?
{
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nEncodeToData
(
_ptr
,
format
.
ordinal
,
quality
)
if
(
ptr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
Data
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -263,17 +260,16 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
return
makeShader
(
tmx
,
tmy
,
SamplingMode
.
DEFAULT
,
localMatrix
)
}
@JvmOverloads
fun
makeShader
(
tmx
:
FilterTileMode
=
FilterTileMode
.
CLAMP
,
tmy
:
FilterTileMode
=
FilterTileMode
.
CLAMP
,
sampling
:
SamplingMode
=
SamplingMode
.
Companion
.
DEFAULT
,
sampling
:
SamplingMode
=
SamplingMode
.
DEFAULT
,
localMatrix
:
Matrix33
?
=
null
):
Shader
{
return
try
{
assert
(
tmx
!=
null
)
{
"Can’t Bitmap.makeShader with tmx == null"
}
assert
(
tmy
!=
null
)
{
"Can’t Bitmap.makeShader with tmy == null"
}
assert
(
sampling
!=
null
)
{
"Can’t Bitmap.makeShader with sampling == null"
}
require
(
tmx
!=
null
)
{
"Can’t Bitmap.makeShader with tmx == null"
}
require
(
tmy
!=
null
)
{
"Can’t Bitmap.makeShader with tmy == null"
}
require
(
sampling
!=
null
)
{
"Can’t Bitmap.makeShader with sampling == null"
}
Stats
.
onNativeCall
()
Shader
(
_nMakeShader
(
...
...
@@ -285,7 +281,7 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -302,7 +298,7 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
Stats
.
onNativeCall
()
_nPeekPixels
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -311,11 +307,11 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
Stats
.
onNativeCall
()
_nPeekPixelsToPixmap
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixmap
)
getPtr
(
pixmap
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -368,50 +364,50 @@ class Image internal constructor(ptr: Long) : RefCnt(ptr), IHasImageInfo {
*/
fun
readPixels
(
context
:
DirectContext
?,
dst
:
Bitmap
,
srcX
:
Int
,
srcY
:
Int
,
cache
:
Boolean
):
Boolean
{
return
try
{
assert
(
dst
!=
null
)
{
"Can’t readPixels with dst == null"
}
require
(
dst
!=
null
)
{
"Can’t readPixels with dst == null"
}
_nReadPixelsBitmap
(
_ptr
,
Native
.
Companion
.
getPtr
(
context
),
Native
.
Companion
.
getPtr
(
dst
),
getPtr
(
context
),
getPtr
(
dst
),
srcX
,
srcY
,
cache
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
context
)
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
context
)
reachabilityBarrier
(
dst
)
}
}
fun
readPixels
(
dst
:
Pixmap
,
srcX
:
Int
,
srcY
:
Int
,
cache
:
Boolean
):
Boolean
{
return
try
{
assert
(
dst
!=
null
)
{
"Can’t readPixels with dst == null"
}
require
(
dst
!=
null
)
{
"Can’t readPixels with dst == null"
}
_nReadPixelsPixmap
(
_ptr
,
Native
.
Companion
.
getPtr
(
dst
),
getPtr
(
dst
),
srcX
,
srcY
,
cache
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dst
)
}
}
fun
scalePixels
(
dst
:
Pixmap
,
samplingMode
:
SamplingMode
,
cache
:
Boolean
):
Boolean
{
return
try
{
assert
(
dst
!=
null
)
{
"Can’t scalePixels with dst == null"
}
require
(
dst
!=
null
)
{
"Can’t scalePixels with dst == null"
}
_nScalePixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
dst
),
getPtr
(
dst
),
samplingMode
.
_pack
(),
cache
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dst
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/ImageFilter.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/ImageFilter.kt
View file @
f794e4bb
...
...
@@ -4,8 +4,8 @@ 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.ref.Reference
import
java.util.*
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
ImageFilter
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -20,14 +20,14 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
ImageFilter
(
_nMakeAlphaThreshold
(
Native
.
Companion
.
getPtr
(
getPtr
(
r
),
innerMin
,
outerMax
,
Native
.
Companion
.
getPtr
(
input
),
crop
),
innerMin
,
outerMax
,
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
r
)
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
r
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -50,14 +50,14 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
k3
,
k4
,
enforcePMColor
,
Native
.
Companion
.
getPtr
(
bg
),
Native
.
Companion
.
getPtr
(
fg
),
getPtr
(
bg
),
getPtr
(
fg
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
bg
)
Reference
.
reachabilityFence
(
fg
)
reachabilityBarrier
(
bg
)
reachabilityBarrier
(
fg
)
}
}
...
...
@@ -67,18 +67,17 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
ImageFilter
(
_nMakeBlend
(
blendMode
.
ordinal
,
Native
.
Companion
.
getPtr
(
bg
),
Native
.
Companion
.
getPtr
(
fg
),
getPtr
(
bg
),
getPtr
(
fg
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
bg
)
Reference
.
reachabilityFence
(
fg
)
reachabilityBarrier
(
bg
)
reachabilityBarrier
(
fg
)
}
}
@JvmOverloads
fun
makeBlur
(
sigmaX
:
Float
,
sigmaY
:
Float
,
...
...
@@ -93,12 +92,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
sigmaX
,
sigmaY
,
mode
.
ordinal
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -107,14 +106,14 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
ImageFilter
(
_nMakeColorFilter
(
Native
.
Companion
.
getPtr
(
getPtr
(
f
),
Native
.
Companion
.
getPtr
(
input
),
crop
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
f
)
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
f
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -123,14 +122,14 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
ImageFilter
(
_nMakeCompose
(
Native
.
Companion
.
getPtr
(
getPtr
(
outer
),
Native
.
Companion
.
getPtr
(
inner
)
),
getPtr
(
inner
)
)
)
}
finally
{
Reference
.
reachabilityFence
(
outer
)
Reference
.
reachabilityFence
(
inner
)
reachabilityBarrier
(
outer
)
reachabilityBarrier
(
inner
)
}
}
...
...
@@ -149,18 +148,17 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
x
.
ordinal
,
y
.
ordinal
,
scale
,
Native
.
Companion
.
getPtr
(
displacement
),
Native
.
Companion
.
getPtr
(
color
),
getPtr
(
displacement
),
getPtr
(
color
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
displacement
)
Reference
.
reachabilityFence
(
color
)
reachabilityBarrier
(
displacement
)
reachabilityBarrier
(
color
)
}
}
@JvmOverloads
fun
makeDropShadow
(
dx
:
Float
,
dy
:
Float
,
...
...
@@ -179,16 +177,15 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
sigmaX
,
sigmaY
,
color
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
@JvmOverloads
fun
makeDropShadowOnly
(
dx
:
Float
,
dy
:
Float
,
...
...
@@ -207,18 +204,18 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
sigmaX
,
sigmaY
,
color
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
fun
makeImage
(
image
:
Image
):
ImageFilter
{
val
r
:
Rect
=
Rect
.
Companion
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
())
return
makeImage
(
image
,
r
,
r
,
SamplingMode
.
Companion
.
DEFAULT
)
val
r
:
Rect
=
Rect
.
makeWH
(
image
.
width
.
toFloat
(),
image
.
height
.
toFloat
())
return
makeImage
(
image
,
r
,
r
,
SamplingMode
.
DEFAULT
)
}
fun
makeImage
(
image
:
Image
?,
src
:
Rect
,
dst
:
Rect
,
mode
:
SamplingMode
):
ImageFilter
{
...
...
@@ -226,7 +223,7 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
ImageFilter
(
_nMakeImage
(
Native
.
Companion
.
getPtr
(
getPtr
(
image
),
src
.
left
,
...
...
@@ -241,7 +238,7 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
)
)
}
finally
{
Reference
.
reachabilityFence
(
image
)
reachabilityBarrier
(
image
)
}
}
...
...
@@ -255,12 +252,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
r
.
right
,
r
.
bottom
,
inset
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -290,12 +287,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
offsetY
,
tileMode
.
ordinal
,
convolveAlpha
,
Native
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -306,11 +303,11 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
_nMakeMatrixTransform
(
matrix
.
mat
,
mode
.
_pack
(),
Native
.
Companion
.
getPtr
(
input
)
getPtr
(
input
)
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -318,10 +315,10 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
return
try
{
Stats
.
onNativeCall
()
val
filterPtrs
=
LongArray
(
filters
.
size
)
Arrays
.
setAll
(
filterPtrs
)
{
i
:
Int
->
Native
.
Companion
.
getPtr
(
filters
[
i
])
}
filterPtrs
.
forEachIndexed
{
i
:
Int
,
_
:
Long
->
getPtr
(
filters
[
i
])
}
ImageFilter
(
_nMakeMerge
(
filterPtrs
,
crop
))
}
finally
{
Reference
.
reachabilityFence
(
filters
)
reachabilityBarrier
(
filters
)
}
}
...
...
@@ -332,12 +329,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
_nMakeOffset
(
dx
,
dy
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -346,20 +343,16 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
ImageFilter
(
_nMakePaint
(
Native
.
Companion
.
getPtr
(
getPtr
(
paint
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
paint
)
}
}
// public static ImageFilter makePicture(Picture picture, Rect target) {
// Native.onNativeCall();
// return new ImageFilter(_nMakePicture(Native.pointer(picture), target.left, target.top, target.right, target.bottom));
// }
fun
makeTile
(
src
:
Rect
,
dst
:
Rect
,
input
:
ImageFilter
?):
ImageFilter
{
return
try
{
Stats
.
onNativeCall
()
...
...
@@ -373,11 +366,11 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
dst
.
top
,
dst
.
right
,
dst
.
bottom
,
Native
.
Companion
.
getPtr
(
input
)
getPtr
(
input
)
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -388,12 +381,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
_nMakeDilate
(
rx
,
ry
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -404,12 +397,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
_nMakeErode
(
rx
,
ry
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -433,12 +426,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
lightColor
,
surfaceScale
,
kd
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -462,12 +455,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
lightColor
,
surfaceScale
,
kd
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -501,12 +494,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
lightColor
,
surfaceScale
,
kd
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -532,12 +525,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
surfaceScale
,
ks
,
shininess
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -563,12 +556,12 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
surfaceScale
,
ks
,
shininess
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
...
...
@@ -604,16 +597,17 @@ class ImageFilter internal constructor(ptr: Long) : RefCnt(ptr) {
surfaceScale
,
ks
,
shininess
,
Native
.
Companion
.
getPtr
(
input
),
getPtr
(
input
),
crop
)
)
}
finally
{
Reference
.
reachabilityFence
(
input
)
reachabilityBarrier
(
input
)
}
}
@JvmStatic
external
fun
_nMakeAlphaThreshold
(
@JvmStatic
external
fun
_nMakeAlphaThreshold
(
regionPtr
:
Long
,
innerMin
:
Float
,
outerMax
:
Float
,
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/ImageInfo.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/ImageInfo.kt
View file @
f794e4bb
...
...
@@ -87,7 +87,7 @@ class ImageInfo(val colorInfo: ColorInfo, val width: Int, val height: Int) {
* @return integral rectangle from (0, 0) to (getWidth(), getHeight())
*/
val
bounds
:
IRect
get
()
=
IRect
.
Companion
.
makeXYWH
(
0
,
0
,
width
,
height
)
get
()
=
IRect
.
makeXYWH
(
0
,
0
,
width
,
height
)
/**
* @return true if associated ColorSpace is not null, and ColorSpace gamma
...
...
@@ -230,7 +230,7 @@ class ImageInfo(val colorInfo: ColorInfo, val width: Int, val height: Int) {
}
companion
object
{
val
DEFAULT
=
ImageInfo
(
ColorInfo
.
Companion
.
DEFAULT
,
0
,
0
)
val
DEFAULT
=
ImageInfo
(
ColorInfo
.
DEFAULT
,
0
,
0
)
/**
* @return ImageInfo with [ColorType.N32]
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/ManagedString.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/ManagedString.kt
View file @
f794e4bb
...
...
@@ -3,7 +3,8 @@ 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
ManagedString
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -29,7 +30,7 @@ class ManagedString internal constructor(ptr: Long) : Managed(ptr, _FinalizerHol
Stats
.
onNativeCall
()
_nToString
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/MaskFilter.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/MaskFilter.kt
View file @
f794e4bb
...
...
@@ -2,13 +2,12 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
MaskFilter
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
@JvmOverloads
fun
makeBlur
(
mode
:
FilterBlurMode
,
sigma
:
Float
,
respectCTM
:
Boolean
=
true
):
MaskFilter
{
Stats
.
onNativeCall
()
return
MaskFilter
(
_nMakeBlur
(
mode
.
ordinal
,
sigma
,
respectCTM
))
...
...
@@ -17,9 +16,9 @@ class MaskFilter internal constructor(ptr: Long) : RefCnt(ptr) {
fun
makeShader
(
s
:
Shader
?):
MaskFilter
{
return
try
{
Stats
.
onNativeCall
()
MaskFilter
(
_nMakeShader
(
Native
.
Companion
.
getPtr
(
s
)))
MaskFilter
(
_nMakeShader
(
getPtr
(
s
)))
}
finally
{
Reference
.
reachabilityFence
(
s
)
reachabilityBarrier
(
s
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Paint.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Paint.kt
View file @
f794e4bb
...
...
@@ -4,7 +4,9 @@ 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
import
kotlin.math.round
class
Paint
:
Managed
{
companion
object
{
...
...
@@ -133,16 +135,16 @@ class Paint : Managed {
Stats
.
onNativeCall
()
Paint
(
_nMakeClone
(
_ptr
),
true
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
_nEquals
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -168,7 +170,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nIsAntiAlias
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setAntiAlias
(
value
)
...
...
@@ -193,7 +195,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nIsDither
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -216,7 +218,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
PaintMode
.
values
().
get
(
_nGetMode
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setMode
(
value
)
...
...
@@ -230,7 +232,7 @@ class Paint : Managed {
* @see [https://fiddle.skia.org/c/@Stroke_Width](https://fiddle.skia.org/c/@Stroke_Width)
*/
fun
setMode
(
style
:
PaintMode
):
Paint
{
assert
(
style
!=
null
)
{
"Paint::setMode expected style != null"
}
require
(
style
!=
null
)
{
"Paint::setMode expected style != null"
}
Stats
.
onNativeCall
()
_nSetMode
(
_ptr
,
style
.
ordinal
)
return
this
...
...
@@ -258,7 +260,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nGetColor
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setColor
(
value
)
...
...
@@ -275,7 +277,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nGetColor4f
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setColor4f
(
value
)
...
...
@@ -318,7 +320,7 @@ class Paint : Managed {
*/
fun
setColor4f
(
color
:
Color4f
,
colorSpace
:
ColorSpace
?):
Paint
{
return
try
{
assert
(
color
!=
null
)
{
"Paint::setColor4f expected color != null"
}
require
(
color
!=
null
)
{
"Paint::setColor4f expected color != null"
}
Stats
.
onNativeCall
()
_nSetColor4f
(
_ptr
,
...
...
@@ -326,11 +328,11 @@ class Paint : Managed {
color
.
g
,
color
.
b
,
color
.
a
,
Native
.
Companion
.
getPtr
(
colorSpace
)
getPtr
(
colorSpace
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
colorSpace
)
reachabilityBarrier
(
colorSpace
)
}
}
...
...
@@ -348,7 +350,7 @@ class Paint : Managed {
* @return alpha ranging from 0, fully transparent, to 255, fully opaque
*/
val
alpha
:
Int
get
()
=
Math
.
round
(
alphaf
*
255f
)
get
()
=
round
(
alphaf
*
255f
).
toInt
(
)
/**
*
...
...
@@ -409,7 +411,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nGetStrokeWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setStrokeWidth
(
value
)
...
...
@@ -443,7 +445,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nGetStrokeMiter
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setStrokeMiter
(
value
)
...
...
@@ -473,7 +475,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
PaintStrokeCap
.
values
().
get
(
_nGetStrokeCap
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setStrokeCap
(
value
)
...
...
@@ -489,7 +491,7 @@ class Paint : Managed {
* @see [https://fiddle.skia.org/c/@Paint_setStrokeCap_b](https://fiddle.skia.org/c/@Paint_setStrokeCap_b)
*/
fun
setStrokeCap
(
cap
:
PaintStrokeCap
):
Paint
{
assert
(
cap
!=
null
)
{
"Paint::setStrokeCap expected cap != null"
}
require
(
cap
!=
null
)
{
"Paint::setStrokeCap expected cap != null"
}
Stats
.
onNativeCall
()
_nSetStrokeCap
(
_ptr
,
cap
.
ordinal
)
return
this
...
...
@@ -503,7 +505,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
PaintStrokeJoin
.
values
().
get
(
_nGetStrokeJoin
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setStrokeJoin
(
value
)
...
...
@@ -517,7 +519,7 @@ class Paint : Managed {
* @see [https://fiddle.skia.org/c/@Paint_setStrokeJoin](https://fiddle.skia.org/c/@Paint_setStrokeJoin)
*/
fun
setStrokeJoin
(
join
:
PaintStrokeJoin
):
Paint
{
assert
(
join
!=
null
)
{
"Paint::setStrokeJoin expected join != null"
}
require
(
join
!=
null
)
{
"Paint::setStrokeJoin expected join != null"
}
Stats
.
onNativeCall
()
_nSetStrokeJoin
(
_ptr
,
join
.
ordinal
)
return
this
...
...
@@ -544,18 +546,18 @@ class Paint : Managed {
*/
fun
getFillPath
(
src
:
Path
,
cull
:
Rect
?,
resScale
:
Float
):
Path
{
return
try
{
assert
(
src
!=
null
)
{
"Paint::getFillPath expected src != null"
}
require
(
src
!=
null
)
{
"Paint::getFillPath expected src != null"
}
Stats
.
onNativeCall
()
if
(
cull
==
null
)
org
.
jetbrains
.
skia
.
Path
(
_nGetFillPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
src
),
getPtr
(
src
),
resScale
)
)
else
org
.
jetbrains
.
skia
.
Path
(
_nGetFillPathCull
(
_ptr
,
Native
.
Companion
.
getPtr
(
src
),
getPtr
(
src
),
cull
.
left
,
cull
.
top
,
cull
.
right
,
...
...
@@ -564,8 +566,8 @@ class Paint : Managed {
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
src
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
src
)
}
}
...
...
@@ -579,7 +581,7 @@ class Paint : Managed {
val
shaderPtr
=
_nGetShader
(
_ptr
)
if
(
shaderPtr
==
0L
)
null
else
Shader
(
shaderPtr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setShader
(
value
)
...
...
@@ -595,10 +597,10 @@ class Paint : Managed {
fun
setShader
(
shader
:
Shader
?):
Paint
{
return
try
{
Stats
.
onNativeCall
()
_nSetShader
(
_ptr
,
Native
.
Companion
.
getPtr
(
shader
))
_nSetShader
(
_ptr
,
getPtr
(
shader
))
this
}
finally
{
Reference
.
reachabilityFence
(
shader
)
reachabilityBarrier
(
shader
)
}
}
...
...
@@ -612,7 +614,7 @@ class Paint : Managed {
val
colorFilterPtr
=
_nGetColorFilter
(
_ptr
)
if
(
colorFilterPtr
==
0L
)
null
else
ColorFilter
(
colorFilterPtr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setColorFilter
(
value
)
...
...
@@ -630,11 +632,11 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nSetColorFilter
(
_ptr
,
Native
.
Companion
.
getPtr
(
colorFilter
)
getPtr
(
colorFilter
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
colorFilter
)
reachabilityBarrier
(
colorFilter
)
}
}
...
...
@@ -643,12 +645,12 @@ class Paint : Managed {
*
* @return mode used to combine source color with destination color
*/
var
blendMode
:
BlendMode
?
var
blendMode
:
BlendMode
get
()
=
try
{
Stats
.
onNativeCall
()
BlendMode
.
values
().
get
(
_nGetBlendMode
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setBlendMode
(
value
)
...
...
@@ -666,10 +668,9 @@ class Paint : Managed {
* @param mode BlendMode used to combine source color and destination
* @return this
*/
fun
setBlendMode
(
mode
:
BlendMode
?):
Paint
{
assert
(
mode
!=
null
)
{
"Paint::setBlendMode expected mode != null"
}
fun
setBlendMode
(
mode
:
BlendMode
):
Paint
{
Stats
.
onNativeCall
()
_nSetBlendMode
(
_ptr
,
mode
!!
.
ordinal
)
_nSetBlendMode
(
_ptr
,
mode
.
ordinal
)
return
this
}
...
...
@@ -683,7 +684,7 @@ class Paint : Managed {
val
pathEffectPtr
=
_nGetPathEffect
(
_ptr
)
if
(
pathEffectPtr
==
0L
)
null
else
PathEffect
(
pathEffectPtr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setPathEffect
(
value
)
...
...
@@ -699,10 +700,10 @@ class Paint : Managed {
fun
setPathEffect
(
p
:
PathEffect
?):
Paint
{
return
try
{
Stats
.
onNativeCall
()
_nSetPathEffect
(
_ptr
,
Native
.
Companion
.
getPtr
(
p
))
_nSetPathEffect
(
_ptr
,
getPtr
(
p
))
this
}
finally
{
Reference
.
reachabilityFence
(
p
)
reachabilityBarrier
(
p
)
}
}
...
...
@@ -716,7 +717,7 @@ class Paint : Managed {
val
maskFilterPtr
=
_nGetMaskFilter
(
_ptr
)
if
(
maskFilterPtr
==
0L
)
null
else
MaskFilter
(
maskFilterPtr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -732,11 +733,11 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nSetMaskFilter
(
_ptr
,
Native
.
Companion
.
getPtr
(
maskFilter
)
getPtr
(
maskFilter
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
maskFilter
)
reachabilityBarrier
(
maskFilter
)
}
}
...
...
@@ -750,7 +751,7 @@ class Paint : Managed {
val
imageFilterPtr
=
_nGetImageFilter
(
_ptr
)
if
(
imageFilterPtr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
ImageFilter
(
imageFilterPtr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -765,11 +766,11 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nSetImageFilter
(
_ptr
,
Native
.
Companion
.
getPtr
(
imageFilter
)
getPtr
(
imageFilter
)
)
this
}
finally
{
Reference
.
reachabilityFence
(
imageFilter
)
reachabilityBarrier
(
imageFilter
)
}
}
...
...
@@ -791,7 +792,7 @@ class Paint : Managed {
Stats
.
onNativeCall
()
_nHasNothingToDraw
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Path.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Path.kt
View file @
f794e4bb
...
...
@@ -4,8 +4,8 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
/**
*
...
...
@@ -165,14 +165,14 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeCombining
(
Native
.
Companion
.
getPtr
(
one
),
Native
.
Companion
.
getPtr
(
two
),
getPtr
(
one
),
getPtr
(
two
),
op
.
ordinal
)
if
(
ptr
==
0L
)
null
else
Path
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
one
)
Reference
.
reachabilityFence
(
two
)
reachabilityBarrier
(
one
)
reachabilityBarrier
(
two
)
}
}
...
...
@@ -199,7 +199,8 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
return
Path
(
_nMakeFromBytes
(
data
))
}
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMake
():
Long
@JvmStatic
external
fun
_nMakeFromSVGString
(
s
:
String
?):
Long
@JvmStatic
external
fun
_nEquals
(
aPtr
:
Long
,
bPtr
:
Long
):
Boolean
...
...
@@ -370,10 +371,10 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*/
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
_nEquals
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -397,11 +398,11 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsInterpolatable
(
_ptr
,
Native
.
Companion
.
getPtr
(
compare
)
getPtr
(
compare
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
compare
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
compare
)
}
}
...
...
@@ -436,14 +437,14 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
val
ptr
=
_nMakeLerp
(
_ptr
,
Native
.
Companion
.
getPtr
(
ending
),
getPtr
(
ending
),
weight
)
require
(
ptr
!=
0L
)
{
"Point array is not the same size as ending Point array"
}
Path
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
ending
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
ending
)
}
}
...
...
@@ -452,7 +453,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
PathFillMode
.
values
().
get
(
_nGetFillMode
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setFillMode
(
value
)
...
...
@@ -474,7 +475,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsConvex
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -489,7 +490,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsOval
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -504,7 +505,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsRRect
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -560,7 +561,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsEmpty
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -580,7 +581,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsLastContourClosed
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -595,7 +596,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsFinite
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -611,7 +612,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsVolatile
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -655,7 +656,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nMaybeGetAsLine
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -671,7 +672,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nGetPointsCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -692,7 +693,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nGetPoint
(
_ptr
,
index
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -727,11 +728,11 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*/
fun
getPoints
(
points
:
Array
<
Point
?
>?,
max
:
Int
):
Int
{
return
try
{
assert
(
if
(
points
==
null
)
max
==
0
else
true
)
require
(
if
(
points
==
null
)
max
==
0
else
true
)
Stats
.
onNativeCall
()
_nGetPoints
(
_ptr
,
points
,
max
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -748,7 +749,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nCountVerbs
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
verbs
:
Array
<
PathVerb
?>
get
()
{
...
...
@@ -768,16 +769,16 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*/
fun
getVerbs
(
verbs
:
Array
<
PathVerb
?
>?,
max
:
Int
):
Int
{
return
try
{
assert
(
if
(
verbs
==
null
)
max
==
0
else
true
)
require
(
if
(
verbs
==
null
)
max
==
0
else
true
)
Stats
.
onNativeCall
()
val
out
=
if
(
verbs
==
null
)
null
else
ByteArray
(
max
)
val
count
=
_nGetVerbs
(
_ptr
,
out
,
max
)
if
(
verbs
!=
null
)
for
(
i
in
0
until
Math
.
min
(
count
,
max
))
verbs
[
i
]
=
PathVerb
.
values
().
get
(
if
(
verbs
!=
null
)
for
(
i
in
0
until
minOf
(
count
,
max
))
verbs
[
i
]
=
PathVerb
.
values
().
get
(
out
!!
[
i
].
toInt
()
)
count
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -791,7 +792,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nApproximateBytesUsed
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -808,10 +809,10 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
fun
swap
(
other
:
Path
?):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nSwap
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nSwap
(
_ptr
,
getPtr
(
other
))
this
}
finally
{
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -834,7 +835,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nGetBounds
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -882,7 +883,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nComputeTightBounds
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -913,7 +914,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
rect
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -1572,7 +1573,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsRect
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
* Adds Rect to Path, appending [PathVerb.MOVE], three [PathVerb.LINE], and [PathVerb.CLOSE].
...
...
@@ -1609,7 +1610,6 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*
* @see [https://fiddle.skia.org/c/@Path_addRect](https://fiddle.skia.org/c/@Path_addRect)
*/
@JvmOverloads
fun
addRect
(
rect
:
Rect
,
dir
:
PathDirection
=
PathDirection
.
CLOCKWISE
,
start
:
Int
=
0
):
Path
{
Stats
.
onNativeCall
()
_nAddRect
(
_ptr
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
,
dir
.
ordinal
,
start
)
...
...
@@ -1657,7 +1657,6 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*
* @see [https://fiddle.skia.org/c/@Path_addOval](https://fiddle.skia.org/c/@Path_addOval)
*/
@JvmOverloads
fun
addOval
(
oval
:
Rect
,
dir
:
PathDirection
=
PathDirection
.
CLOCKWISE
,
start
:
Int
=
1
):
Path
{
Stats
.
onNativeCall
()
_nAddOval
(
_ptr
,
oval
.
left
,
oval
.
top
,
oval
.
right
,
oval
.
bottom
,
dir
.
ordinal
,
start
)
...
...
@@ -1691,7 +1690,6 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
* @param radius distance from center to edge
* @return reference to Path
*/
@JvmOverloads
fun
addCircle
(
x
:
Float
,
y
:
Float
,
radius
:
Float
,
dir
:
PathDirection
=
PathDirection
.
CLOCKWISE
):
Path
{
Stats
.
onNativeCall
()
_nAddCircle
(
_ptr
,
x
,
y
,
radius
,
dir
.
ordinal
)
...
...
@@ -1750,7 +1748,6 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*
* @see [https://fiddle.skia.org/c/@Path_addRRect](https://fiddle.skia.org/c/@Path_addRRect)
*/
@JvmOverloads
fun
addRRect
(
rrect
:
RRect
,
dir
:
PathDirection
=
PathDirection
.
CLOCKWISE
,
start
:
Int
=
6
):
Path
{
Stats
.
onNativeCall
()
_nAddRRect
(
_ptr
,
rrect
.
left
,
rrect
.
top
,
rrect
.
right
,
rrect
.
bottom
,
rrect
.
radii
,
dir
.
ordinal
,
start
)
...
...
@@ -1799,7 +1796,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
* @see [https://fiddle.skia.org/c/@Path_addPoly](https://fiddle.skia.org/c/@Path_addPoly)
*/
fun
addPoly
(
pts
:
FloatArray
,
close
:
Boolean
):
Path
{
assert
(
pts
.
size
%
2
==
0
)
{
"Expected even amount of pts, got "
+
pts
.
size
}
require
(
pts
.
size
%
2
==
0
)
{
"Expected even amount of pts, got "
+
pts
.
size
}
Stats
.
onNativeCall
()
_nAddPoly
(
_ptr
,
pts
,
close
)
return
this
...
...
@@ -1828,18 +1825,17 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
* @param src Path verbs, Point, and conic weights to add
* @return reference to Path
*/
@JvmOverloads
fun
addPath
(
src
:
Path
?,
extend
:
Boolean
=
false
):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nAddPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
src
),
getPtr
(
src
),
extend
)
this
}
finally
{
Reference
.
reachabilityFence
(
src
)
reachabilityBarrier
(
src
)
}
}
/**
...
...
@@ -1870,20 +1866,19 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
* @param dy offset added to src Point array y-axis coordinates
* @return reference to Path
*/
@JvmOverloads
fun
addPath
(
src
:
Path
?,
dx
:
Float
,
dy
:
Float
,
extend
:
Boolean
=
false
):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nAddPathOffset
(
_ptr
,
Native
.
Companion
.
getPtr
(
src
),
getPtr
(
src
),
dx
,
dy
,
extend
)
this
}
finally
{
Reference
.
reachabilityFence
(
src
)
reachabilityBarrier
(
src
)
}
}
/**
...
...
@@ -1914,19 +1909,18 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
* @param matrix transform applied to src
* @return reference to Path
*/
@JvmOverloads
fun
addPath
(
src
:
Path
?,
matrix
:
Matrix33
,
extend
:
Boolean
=
false
):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nAddPathTransform
(
_ptr
,
Native
.
Companion
.
getPtr
(
src
),
getPtr
(
src
),
matrix
.
mat
,
extend
)
this
}
finally
{
Reference
.
reachabilityFence
(
src
)
reachabilityBarrier
(
src
)
}
}
...
...
@@ -1942,10 +1936,10 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
fun
reverseAddPath
(
src
:
Path
?):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nReverseAddPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
src
))
_nReverseAddPath
(
_ptr
,
getPtr
(
src
))
this
}
finally
{
Reference
.
reachabilityFence
(
src
)
reachabilityBarrier
(
src
)
}
}
/**
...
...
@@ -1966,14 +1960,13 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
* @param dy offset added to Point array y-axis coordinates
* @return this
*/
@JvmOverloads
fun
offset
(
dx
:
Float
,
dy
:
Float
,
dst
:
Path
?
=
null
):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nOffset
(
_ptr
,
dx
,
dy
,
Native
.
Companion
.
getPtr
(
dst
))
_nOffset
(
_ptr
,
dx
,
dy
,
getPtr
(
dst
))
this
}
finally
{
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
dst
)
}
}
...
...
@@ -2022,19 +2015,18 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*
* @see [https://fiddle.skia.org/c/@Path_transform](https://fiddle.skia.org/c/@Path_transform)
*/
@JvmOverloads
fun
transform
(
matrix
:
Matrix33
,
dst
:
Path
?
=
null
,
applyPerspectiveClip
:
Boolean
=
true
):
Path
{
return
try
{
Stats
.
onNativeCall
()
_nTransform
(
_ptr
,
matrix
.
mat
,
Native
.
Companion
.
getPtr
(
dst
),
getPtr
(
dst
),
applyPerspectiveClip
)
this
}
finally
{
Reference
.
reachabilityFence
(
dst
)
reachabilityBarrier
(
dst
)
}
}
...
...
@@ -2050,7 +2042,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nGetLastPt
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -2106,7 +2098,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nGetSegmentMasks
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
override
fun
iterator
():
PathSegmentIterator
{
...
...
@@ -2132,7 +2124,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nContains
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -2206,7 +2198,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nSerializeToBytes
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -2233,7 +2225,7 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nGetGenerationId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -2248,6 +2240,6 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
Stats
.
onNativeCall
()
_nIsValid
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PathEffect.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PathEffect.kt
View file @
f794e4bb
...
...
@@ -2,9 +2,9 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
PathEffect
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -13,14 +13,14 @@ class PathEffect internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
PathEffect
(
_nMakePath1D
(
Native
.
Companion
.
getPtr
(
path
),
getPtr
(
path
),
advance
,
phase
,
style
.
ordinal
)
)
}
finally
{
Reference
.
reachabilityFence
(
path
)
reachabilityBarrier
(
path
)
}
}
...
...
@@ -30,11 +30,11 @@ class PathEffect internal constructor(ptr: Long) : RefCnt(ptr) {
PathEffect
(
_nMakePath2D
(
matrix
.
mat
,
Native
.
Companion
.
getPtr
(
path
)
getPtr
(
path
)
)
)
}
finally
{
Reference
.
reachabilityFence
(
path
)
reachabilityBarrier
(
path
)
}
}
...
...
@@ -86,20 +86,20 @@ class PathEffect internal constructor(ptr: Long) : RefCnt(ptr) {
fun
makeSum
(
second
:
PathEffect
?):
PathEffect
{
return
try
{
Stats
.
onNativeCall
()
PathEffect
(
_nMakeSum
(
_ptr
,
Native
.
Companion
.
getPtr
(
second
)))
PathEffect
(
_nMakeSum
(
_ptr
,
getPtr
(
second
)))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
second
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
second
)
}
}
fun
makeCompose
(
inner
:
PathEffect
?):
PathEffect
{
return
try
{
Stats
.
onNativeCall
()
PathEffect
(
_nMakeCompose
(
_ptr
,
Native
.
Companion
.
getPtr
(
inner
)))
PathEffect
(
_nMakeCompose
(
_ptr
,
getPtr
(
inner
)))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
inner
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
inner
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PathSegment.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PathSegment.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
java.lang.RuntimeException
import
java.util.*
class
PathSegment
@JvmOverloads
constructor
(
class
PathSegment
constructor
(
val
verb
:
PathVerb
=
PathVerb
.
DONE
,
val
p0
:
Point
?
=
null
,
val
p1
:
Point
?
=
null
,
...
...
@@ -17,9 +14,9 @@ class PathSegment @JvmOverloads constructor(
constructor
(
verbOrdinal
:
Int
,
x0
:
Float
,
y0
:
Float
,
isClosedContour
:
Boolean
)
:
this
(
PathVerb
.
values
().
get
(
verbOrdinal
),
org
.
jetbrains
.
skia
.
Point
(
x0
,
y0
),
null
,
null
,
null
,
0.0f
,
false
,
isClosedContour
),
Point
(
x0
,
y0
),
null
,
null
,
null
,
0.0f
,
false
,
isClosedContour
)
{
assert
(
verbOrdinal
==
PathVerb
.
MOVE
.
ordinal
||
verbOrdinal
==
PathVerb
.
CLOSE
.
ordinal
)
{
require
(
verbOrdinal
==
PathVerb
.
MOVE
.
ordinal
||
verbOrdinal
==
PathVerb
.
CLOSE
.
ordinal
)
{
"Expected MOVE or CLOSE, got "
+
PathVerb
.
values
().
get
(
verbOrdinal
)
...
...
@@ -28,8 +25,8 @@ class PathSegment @JvmOverloads constructor(
constructor
(
x0
:
Float
,
y0
:
Float
,
x1
:
Float
,
y1
:
Float
,
isCloseLine
:
Boolean
,
isClosedContour
:
Boolean
)
:
this
(
PathVerb
.
LINE
,
org
.
jetbrains
.
skia
.
Point
(
x0
,
y0
),
org
.
jetbrains
.
skia
.
Point
(
x1
,
y1
),
Point
(
x0
,
y0
),
Point
(
x1
,
y1
),
null
,
null
,
0.0f
,
...
...
@@ -40,9 +37,9 @@ class PathSegment @JvmOverloads constructor(
constructor
(
x0
:
Float
,
y0
:
Float
,
x1
:
Float
,
y1
:
Float
,
x2
:
Float
,
y2
:
Float
,
isClosedContour
:
Boolean
)
:
this
(
PathVerb
.
QUAD
,
org
.
jetbrains
.
skia
.
Point
(
x0
,
y0
),
org
.
jetbrains
.
skia
.
Point
(
x1
,
y1
),
org
.
jetbrains
.
skia
.
Point
(
x2
,
y2
),
Point
(
x0
,
y0
),
Point
(
x1
,
y1
),
Point
(
x2
,
y2
),
null
,
0.0f
,
false
,
...
...
@@ -61,9 +58,9 @@ class PathSegment @JvmOverloads constructor(
isClosedContour
:
Boolean
)
:
this
(
PathVerb
.
CONIC
,
org
.
jetbrains
.
skia
.
Point
(
x0
,
y0
),
org
.
jetbrains
.
skia
.
Point
(
x1
,
y1
),
org
.
jetbrains
.
skia
.
Point
(
x2
,
y2
),
Point
(
x0
,
y0
),
Point
(
x1
,
y1
),
Point
(
x2
,
y2
),
null
,
conicWeight
,
false
,
...
...
@@ -83,10 +80,10 @@ class PathSegment @JvmOverloads constructor(
isClosedContour
:
Boolean
)
:
this
(
PathVerb
.
CUBIC
,
org
.
jetbrains
.
skia
.
Point
(
x0
,
y0
),
org
.
jetbrains
.
skia
.
Point
(
x1
,
y1
),
org
.
jetbrains
.
skia
.
Point
(
x2
,
y2
),
org
.
jetbrains
.
skia
.
Point
(
x3
,
y3
),
Point
(
x0
,
y0
),
Point
(
x1
,
y1
),
Point
(
x2
,
y2
),
Point
(
x3
,
y3
),
0.0f
,
false
,
isClosedContour
...
...
@@ -94,26 +91,30 @@ class PathSegment @JvmOverloads constructor(
}
override
fun
toString
():
String
{
return
"Segment("
+
"verb="
+
verb
+
(
if
(
verb
!=
PathVerb
.
DONE
)
", p0=
"
+
p0
else
""
)
+
(
if
(
verb
==
PathVerb
.
LINE
||
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
", p1="
+
p1
else
""
)
+
(
if
(
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
", p2="
+
p2
else
""
)
+
(
if
(
verb
==
PathVerb
.
CUBIC
)
", p3="
+
p3
else
""
)
+
(
if
(
verb
==
PathVerb
.
CONIC
)
", conicWeight="
+
conicWeight
else
""
)
+
(
if
(
verb
==
PathVerb
.
LINE
)
", closeLine="
+
isCloseLine
else
""
)
+
(
if
(
verb
!=
PathVerb
.
DONE
)
", closedContour="
+
isClosedContour
else
""
)
+
")"
return
"Segment("
+
"verb="
+
verb
+
(
if
(
verb
!=
PathVerb
.
DONE
)
", p0=
$p0"
else
""
)
+
(
if
(
verb
==
PathVerb
.
LINE
||
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
", p1="
+
p1
else
""
)
+
(
if
(
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
", p2="
+
p2
else
""
)
+
(
if
(
verb
==
PathVerb
.
CUBIC
)
", p3="
+
p3
else
""
)
+
(
if
(
verb
==
PathVerb
.
CONIC
)
", conicWeight="
+
conicWeight
else
""
)
+
(
if
(
verb
==
PathVerb
.
LINE
)
", closeLine="
+
isCloseLine
else
""
)
+
(
if
(
verb
!=
PathVerb
.
DONE
)
", closedContour="
+
isClosedContour
else
""
)
+
")"
}
override
fun
equals
(
o
:
Any
?):
Boolean
{
if
(
this
===
o
)
return
true
if
(
o
==
null
||
javaClass
!=
o
.
javaClass
)
return
false
val
segment
=
o
as
PathSegment
return
verb
==
segment
.
verb
&&
(
if
(
verb
!=
PathVerb
.
DONE
)
p0
==
segment
.
p0
else
true
)
&&
(
if
(
verb
==
PathVerb
.
LINE
||
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
p1
==
segment
.
p1
else
true
)
&&
(
if
(
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
p2
==
segment
.
p2
else
true
)
&&
(
if
(
verb
==
PathVerb
.
CUBIC
)
p3
==
segment
.
p3
else
true
)
&&
(
if
(
verb
==
PathVerb
.
CONIC
)
java
.
lang
.
Float
.
compare
(
segment
.
conicWeight
,
conicWeight
)
==
0
else
true
)
&&
(
if
(
verb
==
PathVerb
.
LINE
)
isCloseLine
==
segment
.
isCloseLine
else
true
)
&&
if
(
verb
!=
PathVerb
.
DONE
)
isClosedContour
==
segment
.
isClosedContour
else
true
if
(
o
==
null
||
o
!
is
PathSegment
)
return
false
val
segment
=
o
return
verb
==
segment
.
verb
&&
(
if
(
verb
!=
PathVerb
.
DONE
)
p0
==
segment
.
p0
else
true
)
&&
(
if
(
verb
==
PathVerb
.
LINE
||
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
p1
==
segment
.
p1
else
true
)
&&
(
if
(
verb
==
PathVerb
.
QUAD
||
verb
==
PathVerb
.
CONIC
||
verb
==
PathVerb
.
CUBIC
)
p2
==
segment
.
p2
else
true
)
&&
(
if
(
verb
==
PathVerb
.
CUBIC
)
p3
==
segment
.
p3
else
true
)
&&
(
if
(
verb
==
PathVerb
.
CONIC
)
segment
.
conicWeight
.
compareTo
(
conicWeight
)
==
0
else
true
)
&&
(
if
(
verb
==
PathVerb
.
LINE
)
isCloseLine
==
segment
.
isCloseLine
else
true
)
&&
if
(
verb
!=
PathVerb
.
DONE
)
isClosedContour
==
segment
.
isClosedContour
else
true
}
override
fun
hashCode
():
Int
{
return
when
(
verb
)
{
PathVerb
.
DONE
->
Objects
.
hash
(
verb
)
PathVerb
.
MOVE
->
Objects
.
hash
(
verb
,
p0
,
isClosedContour
)
PathVerb
.
LINE
->
Objects
.
hash
(
verb
,
p0
,
p1
,
isCloseLine
,
isClosedContour
)
PathVerb
.
QUAD
->
Objects
.
hash
(
verb
,
p0
,
p1
,
p2
,
isClosedContour
)
PathVerb
.
CONIC
->
Objects
.
hash
(
PathVerb
.
DONE
->
objectHashes
(
verb
)
PathVerb
.
MOVE
->
objectHashes
(
verb
,
p0
,
isClosedContour
)
PathVerb
.
LINE
->
objectHashes
(
verb
,
p0
,
p1
,
isCloseLine
,
isClosedContour
)
PathVerb
.
QUAD
->
objectHashes
(
verb
,
p0
,
p1
,
p2
,
isClosedContour
)
PathVerb
.
CONIC
->
objectHashes
(
verb
,
p0
,
p1
,
...
...
@@ -121,8 +122,12 @@ class PathSegment @JvmOverloads constructor(
conicWeight
,
isClosedContour
)
PathVerb
.
CUBIC
->
Objects
.
hash
(
verb
,
p0
,
p1
,
p2
,
p3
,
isClosedContour
)
PathVerb
.
CUBIC
->
objectHashes
(
verb
,
p0
,
p1
,
p2
,
p3
,
isClosedContour
)
else
->
throw
RuntimeException
(
"Unreachable"
)
}
}
}
internal
fun
objectHashes
(
vararg
args
:
Any
?):
Int
{
return
args
.
contentHashCode
()
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PathSegmentIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PathSegmentIterator.kt
View file @
f794e4bb
...
...
@@ -2,10 +2,8 @@ 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
java.util.NoSuchElementException
import
org.jetbrains.skia.impl.reachabilityBarrier
class
PathSegmentIterator
internal
constructor
(
val
_path
:
Path
?,
ptr
:
Long
)
:
Managed
(
ptr
,
_nGetFinalizer
()),
MutableIterator
<
PathSegment
?>
{
...
...
@@ -13,12 +11,12 @@ class PathSegmentIterator internal constructor(val _path: Path?, ptr: Long) : Ma
fun
make
(
path
:
Path
?,
forceClose
:
Boolean
):
PathSegmentIterator
{
return
try
{
val
ptr
=
_nMake
(
Native
.
Companion
.
getPtr
(
path
),
forceClose
)
_nMake
(
getPtr
(
path
),
forceClose
)
val
i
=
PathSegmentIterator
(
path
,
ptr
)
i
.
_nextSegment
=
_nNext
(
ptr
)
i
}
finally
{
Reference
.
reachabilityFence
(
path
)
reachabilityBarrier
(
path
)
}
}
...
...
@@ -39,7 +37,7 @@ class PathSegmentIterator internal constructor(val _path: Path?, ptr: Long) : Ma
_nextSegment
=
_nNext
(
_ptr
)
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Picture.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Picture.kt
View file @
f794e4bb
...
...
@@ -2,10 +2,9 @@ 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.ref.Reference
import
java.util.function.BooleanSupplier
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Picture
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -17,10 +16,10 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
fun
makeFromData
(
data
:
Data
?):
Picture
?
{
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromData
(
Native
.
getPtr
(
data
))
val
ptr
=
_nMakeFromData
(
getPtr
(
data
))
if
(
ptr
==
0L
)
null
else
Picture
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
data
)
}
}
...
...
@@ -94,14 +93,13 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
*
* @see [https://fiddle.skia.org/c/@Picture_playback](https://fiddle.skia.org/c/@Picture_playback)
*/
@JvmOverloads
fun
playback
(
canvas
:
Canvas
?,
abort
:
BooleanSupplier
?
=
null
):
Picture
{
return
try
{
Stats
.
onNativeCall
()
_nPlayback
(
_ptr
,
Native
.
Companion
.
getPtr
(
canvas
),
abort
)
_nPlayback
(
_ptr
,
getPtr
(
canvas
),
abort
)
this
}
finally
{
Reference
.
reachabilityFence
(
canvas
)
reachabilityBarrier
(
canvas
)
}
}
...
...
@@ -123,7 +121,7 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetCullRect
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -136,7 +134,7 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetUniqueId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -147,9 +145,9 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
fun
serializeToData
():
Data
{
return
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
Data
(
_nSerializeToData
(
_ptr
))
Data
(
_nSerializeToData
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -168,7 +166,7 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetApproximateOpCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -184,7 +182,7 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetApproximateBytesUsed
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
* Return a new shader that will draw with this picture.
...
...
@@ -219,7 +217,6 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
* @param localMatrix Optional matrix used when sampling
* @return Returns a new shader object. Note: this function never returns null.
*/
@JvmOverloads
fun
makeShader
(
tmx
:
FilterTileMode
,
tmy
:
FilterTileMode
,
...
...
@@ -232,7 +229,7 @@ class Picture internal constructor(ptr: Long) : RefCnt(ptr) {
val
arr
=
localMatrix
?.
mat
Shader
(
_nMakeShader
(
_ptr
,
tmx
.
ordinal
,
tmy
.
ordinal
,
mode
.
ordinal
,
arr
,
tileRect
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/PixelRef.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/PixelRef.kt
View file @
f794e4bb
...
...
@@ -3,7 +3,8 @@ package org.jetbrains.skia
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
PixelRef
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -25,21 +26,21 @@ class PixelRef internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
height
:
Int
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
rowBytes
:
Long
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetRowBytes
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -52,7 +53,7 @@ class PixelRef internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetGenerationId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -75,7 +76,7 @@ class PixelRef internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nIsImmutable
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Pixmap.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Pixmap.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.*
import
java.lang.ref.Reference
import
java.nio.ByteBuffer
import
kotlin.jvm.JvmStatic
class
Pixmap
internal
constructor
(
ptr
:
Long
,
managed
:
Boolean
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
,
managed
)
{
...
...
@@ -13,7 +12,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
fun
reset
()
{
Stats
.
onNativeCall
()
_nReset
(
_ptr
)
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
reset
(
info
:
ImageInfo
,
addr
:
Long
,
rowBytes
:
Int
)
{
...
...
@@ -23,10 +22,10 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
info
.
width
,
info
.
height
,
info
.
colorInfo
.
colorType
.
ordinal
,
info
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
)
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
info
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
info
.
colorInfo
.
colorSpace
)
}
fun
reset
(
info
:
ImageInfo
,
buffer
:
ByteBuffer
,
rowBytes
:
Int
)
{
...
...
@@ -35,9 +34,9 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
fun
setColorSpace
(
colorSpace
:
ColorSpace
?)
{
Stats
.
onNativeCall
()
_nSetColorSpace
(
_ptr
,
Native
.
Companion
.
getPtr
(
colorSpace
))
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
colorSpace
)
_nSetColorSpace
(
_ptr
,
getPtr
(
colorSpace
))
reachabilityBarrier
(
this
)
reachabilityBarrier
(
colorSpace
)
}
fun
extractSubset
(
subsetPtr
:
Long
,
area
:
IRect
):
Boolean
{
...
...
@@ -52,7 +51,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
area
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -66,7 +65,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetInfo
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
rowBytes
:
Int
...
...
@@ -75,7 +74,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetRowBytes
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
addr
:
Long
...
...
@@ -84,7 +83,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetAddr
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
rowBytesAsPixels
:
Int
...
...
@@ -93,7 +92,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetRowBytesAsPixels
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -102,7 +101,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nComputeByteSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -111,7 +110,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nComputeIsOpaque
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -120,7 +119,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetColor
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -129,7 +128,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetAlphaF
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -138,7 +137,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nGetAddrAt
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -150,11 +149,11 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
info
.
width
,
info
.
height
,
info
.
colorInfo
.
colorType
.
ordinal
,
info
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
info
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
info
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -166,12 +165,12 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
info
.
width
,
info
.
height
,
info
.
colorInfo
.
colorType
.
ordinal
,
info
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
,
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
,
srcX
,
srcY
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
info
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
info
.
colorInfo
.
colorSpace
)
}
}
...
...
@@ -180,11 +179,11 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nReadPixelsToPixmap
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixmap
)
getPtr
(
pixmap
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -193,13 +192,13 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nReadPixelsToPixmapFromPoint
(
_ptr
,
Native
.
Companion
.
getPtr
(
pixmap
),
getPtr
(
pixmap
),
srcX
,
srcY
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
pixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
pixmap
)
}
}
...
...
@@ -208,12 +207,12 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nScalePixels
(
_ptr
,
Native
.
Companion
.
getPtr
(
dstPixmap
),
getPtr
(
dstPixmap
),
samplingMode
.
_pack
()
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
dstPixmap
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
dstPixmap
)
}
}
...
...
@@ -222,7 +221,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
return
try
{
_nErase
(
_ptr
,
color
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -238,7 +237,7 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
subset
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -260,12 +259,12 @@ class Pixmap internal constructor(ptr: Long, managed: Boolean) :
info
.
width
,
info
.
height
,
info
.
colorInfo
.
colorType
.
ordinal
,
info
.
colorInfo
.
alphaType
.
ordinal
,
Native
.
Companion
.
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
getPtr
(
info
.
colorInfo
.
colorSpace
),
addr
,
rowBytes
)
require
(
ptr
!=
0L
)
{
"Failed to create Pixmap."
}
Pixmap
(
ptr
,
true
)
}
finally
{
Reference
.
reachabilityFence
(
info
.
colorInfo
.
colorSpace
)
reachabilityBarrier
(
info
.
colorInfo
.
colorSpace
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/RSXform.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/RSXform.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
kotlin.math.cos
import
kotlin.math.sin
/**
*
* A compressed form of a rotation+scale matrix.
...
...
@@ -20,10 +23,10 @@ class RSXform(
if
(
o
!
is
RSXform
)
return
false
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
java
.
lang
.
Float
.
compare
(
scos
,
other
.
scos
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
ssin
,
other
.
ssin
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
tx
,
other
.
tx
)
!=
0
)
return
false
return
if
(
java
.
lang
.
Float
.
compare
(
ty
,
other
.
ty
)
!=
0
)
false
else
true
if
(
scos
.
compareTo
(
other
.
scos
)
!=
0
)
return
false
if
(
ssin
.
compareTo
(
other
.
ssin
)
!=
0
)
return
false
if
(
tx
.
compareTo
(
other
.
tx
)
!=
0
)
return
false
return
ty
.
compareTo
(
other
.
ty
)
==
0
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -33,15 +36,15 @@ class RSXform(
override
fun
hashCode
():
Int
{
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
scos
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
ssin
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
tx
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
ty
)
result
=
result
*
PRIME
+
scos
.
toBits
(
)
result
=
result
*
PRIME
+
ssin
.
toBits
(
)
result
=
result
*
PRIME
+
tx
.
toBits
(
)
result
=
result
*
PRIME
+
ty
.
toBits
(
)
return
result
}
override
fun
toString
():
String
{
return
"RSXform(_scos=
"
+
scos
+
", _ssin="
+
ssin
+
", _tx="
+
tx
+
", _ty="
+
ty
+
"
)"
return
"RSXform(_scos=
$scos, _ssin=$ssin, _tx=$tx, _ty=$ty
)"
}
companion
object
{
...
...
@@ -52,8 +55,8 @@ class RSXform(
* Note: the anchor point is not normalized (e.g. 0...1) but is in pixels of the src image.
*/
fun
makeFromRadians
(
scale
:
Float
,
radians
:
Float
,
tx
:
Float
,
ty
:
Float
,
ax
:
Float
,
ay
:
Float
):
RSXform
{
val
s
=
Math
.
sin
(
radians
.
toDouble
()).
toFloat
()
*
scale
val
c
=
Math
.
cos
(
radians
.
toDouble
()).
toFloat
()
*
scale
val
s
=
sin
(
radians
.
toDouble
()).
toFloat
()
*
scale
val
c
=
cos
(
radians
.
toDouble
()).
toFloat
()
*
scale
return
RSXform
(
c
,
s
,
tx
+
-
c
*
ax
+
s
*
ay
,
ty
+
-
s
*
ax
-
c
*
ay
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Region.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Region.kt
View file @
f794e4bb
...
...
@@ -2,9 +2,9 @@ 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
Region
:
Managed
(
_nMake
(),
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -71,10 +71,10 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
fun
set
(
r
:
Region
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nSet
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
))
_nSet
(
_ptr
,
getPtr
(
r
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -83,28 +83,28 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nIsEmpty
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
isRect
:
Boolean
get
()
=
try
{
Stats
.
onNativeCall
()
_nIsRect
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
isComplex
:
Boolean
get
()
=
try
{
Stats
.
onNativeCall
()
_nIsComplex
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
bounds
:
IRect
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetBounds
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
computeRegionComplexity
():
Int
{
...
...
@@ -112,7 +112,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nComputeRegionComplexity
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -121,11 +121,11 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nGetBoundaryPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
p
)
getPtr
(
p
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
p
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
}
}
...
...
@@ -134,7 +134,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nSetEmpty
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -143,7 +143,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nSetRect
(
_ptr
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -159,17 +159,17 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nSetRects
(
_ptr
,
arr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
fun
setRegion
(
r
:
Region
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nSetRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
))
_nSetRegion
(
_ptr
,
getPtr
(
r
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -178,13 +178,13 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nSetPath
(
_ptr
,
Native
.
Companion
.
getPtr
(
path
),
Native
.
Companion
.
getPtr
(
clip
)
getPtr
(
path
),
getPtr
(
clip
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
path
)
Reference
.
reachabilityFence
(
clip
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
path
)
reachabilityBarrier
(
clip
)
}
}
...
...
@@ -193,7 +193,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nIntersectsIRect
(
_ptr
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -202,11 +202,11 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nIntersectsRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
)
getPtr
(
r
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -215,7 +215,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nContainsIPoint
(
_ptr
,
x
,
y
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -224,17 +224,17 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nContainsIRect
(
_ptr
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
operator
fun
contains
(
r
:
Region
?):
Boolean
{
return
try
{
Stats
.
onNativeCall
()
_nContainsRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
))
_nContainsRegion
(
_ptr
,
getPtr
(
r
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -243,7 +243,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nQuickContains
(
_ptr
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -252,7 +252,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nQuickRejectIRect
(
_ptr
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -261,11 +261,11 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nQuickRejectRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
)
getPtr
(
r
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -274,7 +274,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nTranslate
(
_ptr
,
dx
,
dy
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -290,7 +290,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
op
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -299,12 +299,12 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nOpRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
),
getPtr
(
r
),
op
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -317,12 +317,12 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
rect
.
top
,
rect
.
right
,
rect
.
bottom
,
Native
.
Companion
.
getPtr
(
r
),
getPtr
(
r
),
op
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -331,7 +331,7 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nOpRegionIRect
(
_ptr
,
Native
.
Companion
.
getPtr
(
r
),
getPtr
(
r
),
rect
.
left
,
rect
.
top
,
rect
.
right
,
...
...
@@ -339,8 +339,8 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
op
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
r
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
r
)
}
}
...
...
@@ -349,14 +349,14 @@ class Region : Managed(_nMake(), _FinalizerHolder.PTR) {
Stats
.
onNativeCall
()
_nOpRegionRegion
(
_ptr
,
Native
.
Companion
.
getPtr
(
a
),
Native
.
Companion
.
getPtr
(
b
),
getPtr
(
a
),
getPtr
(
b
),
op
.
ordinal
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
a
)
Reference
.
reachabilityFence
(
b
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
a
)
reachabilityBarrier
(
b
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Shader.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Shader.kt
View file @
f794e4bb
...
...
@@ -2,9 +2,9 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Shader
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -27,7 +27,6 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
return
makeLinearGradient
(
p0
.
x
,
p0
.
y
,
p1
.
x
,
p1
.
y
,
colors
,
positions
,
style
)
}
@JvmOverloads
fun
makeLinearGradient
(
x0
:
Float
,
y0
:
Float
,
...
...
@@ -37,7 +36,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
positions
:
FloatArray
?
=
null
,
style
:
GradientStyle
=
GradientStyle
.
Companion
.
DEFAULT
):
Shader
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
return
Shader
(
_nMakeLinearGradient
(
...
...
@@ -76,7 +75,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
style
:
GradientStyle
):
Shader
{
return
try
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
Shader
(
_nMakeLinearGradientCS
(
...
...
@@ -84,8 +83,8 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
y0
,
x1
,
y1
,
Color4f
.
Companion
.
flattenArray
(
colors
),
Native
.
Companion
.
getPtr
(
cs
),
Color4f
.
flattenArray
(
colors
),
getPtr
(
cs
),
positions
,
style
.
tileMode
.
ordinal
,
style
.
_getFlags
(),
...
...
@@ -93,7 +92,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
)
)
}
finally
{
Reference
.
reachabilityFence
(
cs
)
reachabilityBarrier
(
cs
)
}
}
...
...
@@ -116,7 +115,6 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
return
makeRadialGradient
(
center
.
x
,
center
.
y
,
r
,
colors
,
positions
,
style
)
}
@JvmOverloads
fun
makeRadialGradient
(
x
:
Float
,
y
:
Float
,
...
...
@@ -125,7 +123,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
positions
:
FloatArray
?
=
null
,
style
:
GradientStyle
=
GradientStyle
.
Companion
.
DEFAULT
):
Shader
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
return
Shader
(
_nMakeRadialGradient
(
...
...
@@ -162,15 +160,15 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
style
:
GradientStyle
):
Shader
{
return
try
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
Shader
(
_nMakeRadialGradientCS
(
x
,
y
,
r
,
Color4f
.
Companion
.
flattenArray
(
colors
),
Native
.
Companion
.
getPtr
(
cs
),
Color4f
.
flattenArray
(
colors
),
getPtr
(
cs
),
positions
,
style
.
tileMode
.
ordinal
,
style
.
_getFlags
(),
...
...
@@ -178,7 +176,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
)
)
}
finally
{
Reference
.
reachabilityFence
(
cs
)
reachabilityBarrier
(
cs
)
}
}
...
...
@@ -210,7 +208,6 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
return
makeTwoPointConicalGradient
(
p0
.
x
,
p0
.
y
,
r0
,
p1
.
x
,
p1
.
y
,
r1
,
colors
,
positions
,
style
)
}
@JvmOverloads
fun
makeTwoPointConicalGradient
(
x0
:
Float
,
y0
:
Float
,
...
...
@@ -222,7 +219,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
positions
:
FloatArray
?
=
null
,
style
:
GradientStyle
=
GradientStyle
.
Companion
.
DEFAULT
):
Shader
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
return
Shader
(
_nMakeTwoPointConicalGradient
(
...
...
@@ -267,7 +264,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
style
:
GradientStyle
):
Shader
{
return
try
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
Shader
(
_nMakeTwoPointConicalGradientCS
(
...
...
@@ -277,8 +274,8 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
x1
,
y1
,
r1
,
Color4f
.
Companion
.
flattenArray
(
colors
),
Native
.
Companion
.
getPtr
(
cs
),
Color4f
.
flattenArray
(
colors
),
getPtr
(
cs
),
positions
,
style
.
tileMode
.
ordinal
,
style
.
_getFlags
(),
...
...
@@ -286,7 +283,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
)
)
}
finally
{
Reference
.
reachabilityFence
(
cs
)
reachabilityBarrier
(
cs
)
}
}
...
...
@@ -341,7 +338,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
positions
:
FloatArray
?,
style
:
GradientStyle
):
Shader
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
return
Shader
(
_nMakeSweepGradient
(
...
...
@@ -381,7 +378,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
style
:
GradientStyle
):
Shader
{
return
try
{
assert
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
require
(
positions
==
null
||
colors
.
size
==
positions
.
size
)
{
"colors.length "
+
colors
.
size
+
"!= positions.length "
+
positions
!!
.
size
}
Stats
.
onNativeCall
()
Shader
(
_nMakeSweepGradientCS
(
...
...
@@ -389,8 +386,8 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
y
,
startAngle
,
endAngle
,
Color4f
.
Companion
.
flattenArray
(
colors
),
Native
.
Companion
.
getPtr
(
cs
),
Color4f
.
flattenArray
(
colors
),
getPtr
(
cs
),
positions
,
style
.
tileMode
.
ordinal
,
style
.
_getFlags
(),
...
...
@@ -398,7 +395,7 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
)
)
}
finally
{
Reference
.
reachabilityFence
(
cs
)
reachabilityBarrier
(
cs
)
}
}
...
...
@@ -422,11 +419,11 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
color
.
g
,
color
.
b
,
color
.
a
,
Native
.
Companion
.
getPtr
(
space
)
getPtr
(
space
)
)
)
}
finally
{
Reference
.
reachabilityFence
(
space
)
reachabilityBarrier
(
space
)
}
}
...
...
@@ -436,13 +433,13 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
Shader
(
_nMakeBlend
(
mode
.
ordinal
,
Native
.
Companion
.
getPtr
(
dst
),
Native
.
Companion
.
getPtr
(
src
)
getPtr
(
dst
),
getPtr
(
src
)
)
)
}
finally
{
Reference
.
reachabilityFence
(
dst
)
Reference
.
reachabilityFence
(
src
)
reachabilityBarrier
(
dst
)
reachabilityBarrier
(
src
)
}
}
...
...
@@ -561,10 +558,10 @@ class Shader internal constructor(ptr: Long) : RefCnt(ptr) {
fun
makeWithColorFilter
(
f
:
ColorFilter
?):
Shader
{
return
try
{
Shader
(
_nMakeWithColorFilter
(
_ptr
,
Native
.
Companion
.
getPtr
(
f
)))
Shader
(
_nMakeWithColorFilter
(
_ptr
,
getPtr
(
f
)))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
f
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
f
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/SurfaceProps.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/SurfaceProps.kt
View file @
f794e4bb
package
org.jetbrains.skia
class
SurfaceProps
@JvmOverloads
constructor
(
class
SurfaceProps
constructor
(
internal
val
isDeviceIndependentFonts
:
Boolean
=
false
,
internal
val
pixelGeometry
:
PixelGeometry
=
PixelGeometry
.
UNKNOWN
)
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/TextBlob.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/TextBlob.kt
View file @
f794e4bb
...
...
@@ -2,10 +2,9 @@ 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.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
TextBlob
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -21,17 +20,17 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
*/
fun
makeFromPosH
(
glyphs
:
ShortArray
,
xpos
:
FloatArray
,
ypos
:
Float
,
font
:
Font
?):
TextBlob
?
{
return
try
{
assert
(
glyphs
.
size
==
xpos
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != xpos.length "
+
xpos
.
size
}
require
(
glyphs
.
size
==
xpos
.
size
)
{
"glyphs.length "
+
glyphs
.
size
+
" != xpos.length "
+
xpos
.
size
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromPosH
(
glyphs
,
xpos
,
ypos
,
Native
.
Companion
.
getPtr
(
font
)
getPtr
(
font
)
)
if
(
ptr
==
0L
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
...
...
@@ -46,7 +45,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
*/
fun
makeFromPos
(
glyphs
:
ShortArray
,
pos
:
Array
<
Point
>,
font
:
Font
?):
TextBlob
?
{
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
...
...
@@ -54,16 +53,16 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
}
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromPos
(
glyphs
,
floatPos
,
Native
.
Companion
.
getPtr
(
font
))
_nMakeFromPos
(
glyphs
,
floatPos
,
getPtr
(
font
))
if
(
ptr
==
0L
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
fun
makeFromRSXform
(
glyphs
:
ShortArray
,
xform
:
Array
<
RSXform
>,
font
:
Font
?):
TextBlob
?
{
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
...
...
@@ -75,21 +74,21 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
ptr
=
_nMakeFromRSXform
(
glyphs
,
floatXform
,
Native
.
Companion
.
getPtr
(
font
)
getPtr
(
font
)
)
if
(
ptr
==
0L
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
fun
makeFromData
(
data
:
Data
?):
TextBlob
?
{
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromData
(
Native
.
Companion
.
getPtr
(
data
))
val
ptr
=
_nMakeFromData
(
getPtr
(
data
))
if
(
ptr
==
0L
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
data
)
}
}
...
...
@@ -127,7 +126,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nBounds
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -140,7 +139,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nGetUniqueId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -183,20 +182,20 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
_ptr
,
lowerBound
,
upperBound
,
Native
.
Companion
.
getPtr
(
paint
)
getPtr
(
paint
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
paint
)
}
}
fun
serializeToData
():
Data
{
return
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
Data
(
_nSerializeToData
(
_ptr
))
Data
(
_nSerializeToData
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -208,7 +207,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nGetGlyphs
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -230,7 +229,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nGetPositions
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -245,7 +244,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
res
=
_nGetClusters
(
_ptr
)
?:
throw
IllegalArgumentException
()
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -260,7 +259,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
res
=
_nGetTightBounds
(
_ptr
)
?:
throw
IllegalArgumentException
()
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -275,7 +274,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
res
=
_nGetBlockBounds
(
_ptr
)
?:
throw
IllegalArgumentException
()
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -290,7 +289,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
res
=
_nGetFirstBaseline
(
_ptr
)
?:
throw
IllegalArgumentException
()
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -305,7 +304,7 @@ class TextBlob internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
res
=
_nGetLastBaseline
(
_ptr
)
?:
throw
IllegalArgumentException
()
res
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
private
object
_FinalizerHolder
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/TextLine.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/TextLine.kt
View file @
f794e4bb
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.Library
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.*
import
org.jetbrains.skia.shaper.*
import
java.lang.ref.Reference
import
kotlin.jvm.JvmStatic
class
TextLine
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -13,7 +11,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
}
fun
make
(
text
:
String
?,
font
:
Font
?,
opts
:
ShapingOptions
?):
TextLine
{
Shaper
.
makeShapeDontWrapOrReorder
().
use
{
shaper
->
return
shaper
.
shapeLine
(
text
,
font
,
opts
!!
)
}
return
Shaper
.
makeShapeDontWrapOrReorder
().
use
{
shaper
->
shaper
.
shapeLine
(
text
,
font
,
opts
!!
)
}
}
@JvmStatic
external
fun
_nGetFinalizer
():
Long
...
...
@@ -49,7 +47,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetAscent
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
capHeight
:
Float
...
...
@@ -58,7 +56,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetCapHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
xHeight
:
Float
...
...
@@ -67,7 +65,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetXHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
descent
:
Float
...
...
@@ -76,7 +74,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetDescent
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
leading
:
Float
...
...
@@ -85,7 +83,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetLeading
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
width
:
Float
...
...
@@ -94,7 +92,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
height
:
Float
...
...
@@ -103,7 +101,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
textBlob
:
TextBlob
?
...
...
@@ -113,7 +111,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
val
res
=
_nGetTextBlob
(
_ptr
)
if
(
res
==
0L
)
null
else
TextBlob
(
res
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
val
glyphs
:
ShortArray
...
...
@@ -122,7 +120,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetGlyphs
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -135,7 +133,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
return
try
{
_nGetPositions
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -148,7 +146,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nGetOffsetAtCoord
(
_ptr
,
x
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -161,7 +159,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nGetLeftOffsetAtCoord
(
_ptr
,
x
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -174,7 +172,7 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
Stats
.
onNativeCall
()
_nGetCoordAtOffset
(
_ptr
,
offset
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -207,10 +205,10 @@ class TextLine internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.P
*/
fun
getIntercepts
(
lowerBound
:
Float
,
upperBound
:
Float
,
paint
:
Paint
?):
FloatArray
?
{
try
{
textBlob
.
use
{
blob
->
return
blob
?
.
getIntercepts
(
lowerBound
,
upperBound
,
paint
)
}
textBlob
!!
.
use
{
blob
->
return
blob
.
getIntercepts
(
lowerBound
,
upperBound
,
paint
)
}
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
paint
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
paint
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/Typeface.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/Typeface.kt
View file @
f794e4bb
...
...
@@ -4,9 +4,8 @@ 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.ref.Reference
import
java.util.*
import
kotlin.streams.toList
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Typeface
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
...
...
@@ -38,7 +37,6 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
* @return a new typeface given a file
* @throws IllegalArgumentException If the file does not exist, or is not a valid font file
*/
@JvmOverloads
fun
makeFromFile
(
path
:
String
,
index
:
Int
=
0
):
Typeface
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromFile
(
path
,
index
)
...
...
@@ -53,15 +51,14 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
* @return a new typeface given a Data
* @throws IllegalArgumentException If the data is null, or is not a valid font file
*/
@JvmOverloads
fun
makeFromData
(
data
:
Data
,
index
:
Int
=
0
):
Typeface
{
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromData
(
Native
.
Companion
.
getPtr
(
data
),
index
)
val
ptr
=
_nMakeFromData
(
getPtr
(
data
),
index
)
require
(
ptr
!=
0L
)
{
"Failed to create Typeface from data $data"
}
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
data
)
}
}
...
...
@@ -102,14 +99,14 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
FontStyle
(
_nGetFontStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
* @return true if [.getFontStyle] has the bold bit set
*/
val
isBold
:
Boolean
get
()
=
fontStyle
.
weight
>=
FontWeight
.
Companion
.
SEMI_BOLD
get
()
=
fontStyle
.
weight
>=
FontWeight
.
SEMI_BOLD
/**
* @return true if [.getFontStyle] has the italic bit set
...
...
@@ -126,7 +123,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nIsFixedPitch
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -138,7 +135,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetVariations
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -150,7 +147,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetVariationAxes
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -161,7 +158,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetUniqueId
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -169,10 +166,10 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
*/
override
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
try
{
_nEquals
(
_ptr
,
Native
.
Companion
.
getPtr
(
other
))
_nEquals
(
_ptr
,
getPtr
(
other
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
other
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
other
)
}
}
...
...
@@ -200,20 +197,17 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
* @return same typeface if all variation already match, new typeface otherwise
* @throws IllegalArgumentException on failure
*/
@JvmOverloads
fun
makeClone
(
variations
:
Array
<
FontVariation
>,
collectionIndex
:
Int
=
0
):
Typeface
{
return
try
{
if
(
variations
.
size
==
0
)
return
this
Stats
.
onNativeCall
()
val
ptr
=
_nMakeClone
(
_ptr
,
variations
,
collectionIndex
)
require
(
ptr
!=
0L
)
{
"Failed to clone Typeface $this with "
+
Arrays
.
toString
(
variations
)
"Failed to clone Typeface $this with $variations"
}
Typeface
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -223,7 +217,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
* @return the corresponding glyph ids for each character.
*/
fun
getStringGlyphs
(
s
:
String
):
ShortArray
{
return
getUTF32Glyphs
(
s
.
codePoints
().
toArray
())
return
getUTF32Glyphs
(
s
.
intCodePoints
())
}
/**
...
...
@@ -236,7 +230,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetUTF32Glyphs
(
_ptr
,
uni
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -249,7 +243,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetUTF32Glyph
(
_ptr
,
unichar
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -261,7 +255,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetGlyphsCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -272,7 +266,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetTablesCount
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -281,11 +275,9 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
val
tableTags
:
Array
<
String
>
get
()
=
try
{
Stats
.
onNativeCall
()
Arrays
.
stream
(
_nGetTableTags
(
_ptr
))
.
mapToObj
{
tag
:
Int
->
FourByteTag
.
toString
(
tag
)
}
.
toList
().
toTypedArray
()
_nGetTableTags
(
_ptr
)
!!
.
map
{
tag
->
FourByteTag
.
toString
(
tag
)
}.
toTypedArray
()
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -294,9 +286,9 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
fun
getTableSize
(
tag
:
String
):
Long
{
return
try
{
Stats
.
onNativeCall
()
_nGetTableSize
(
_ptr
,
FourByteTag
.
Companion
.
fromString
(
tag
))
_nGetTableSize
(
_ptr
,
FourByteTag
.
fromString
(
tag
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -310,10 +302,10 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
fun
getTableData
(
tag
:
String
):
Data
?
{
return
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nGetTableData
(
_ptr
,
FourByteTag
.
Companion
.
fromString
(
tag
))
if
(
ptr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
Data
(
ptr
)
val
ptr
=
_nGetTableData
(
_ptr
,
FourByteTag
.
fromString
(
tag
))
if
(
ptr
==
0L
)
null
else
Data
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -325,7 +317,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetUnitsPerEm
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -345,7 +337,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetKerningPairAdjustments
(
_ptr
,
glyphs
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -357,7 +349,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetFamilyNames
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -368,7 +360,7 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetFamilyName
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -381,6 +373,6 @@ class Typeface internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
_nGetBounds
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/WStream.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/WStream.kt
View file @
f794e4bb
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/impl/BufferUtil.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/impl/BufferUtil.kt
View file @
f794e4bb
package
org.jetbrains.skia.impl
import
java.nio.ByteBuffer
import
org.jetbrains.skia.ByteBuffer
import
kotlin.jvm.JvmStatic
object
BufferUtil
{
fun
getByteBufferFromPointer
(
ptr
:
Long
,
size
:
Int
):
ByteBuffer
{
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Managed.kt
View file @
f794e4bb
package
org.jetbrains.skia.impl
expect
abstract
class
Managed
(
ptr
:
Long
,
finalizer
:
Long
,
managed
:
Boolean
=
true
)
:
Native
{
open
fun
close
()
open
fun
close
():
Unit
}
inline
fun
<
T
:
Managed
,
R
>
T
.
use
(
block
:
(
T
)
->
R
):
R
{
return
try
{
block
(
this
)
}
finally
{
this
.
close
()
}
}
\ No newline at end of file
skiko/src/commonMain/kotlin/org/jetbrains/skia/impl/Native.kt
View file @
f794e4bb
...
...
@@ -6,6 +6,8 @@ expect abstract class Native(ptr: Long) {
companion
object
{
fun
getPtr
(
n
:
Native
?):
Long
}
open
fun
_nativeEquals
(
other
:
Native
?):
Boolean
}
expect
fun
reachabilityBarrier
(
obj
:
Any
?)
\ No newline at end of file
expect
fun
reachabilityBarrier
(
obj
:
Any
?)
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/BidiRun.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/BidiRun.kt
View file @
f794e4bb
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/FontMgrRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/FontMgrRunIterator.kt
View file @
f794e4bb
...
...
@@ -4,7 +4,8 @@ import org.jetbrains.skia.impl.Library.Companion.staticLoad
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
FontMgrRunIterator
(
text
:
ManagedString
?,
manageText
:
Boolean
,
font
:
Font
?,
opts
:
ShapingOptions
)
:
ManagedRunIterator
<
FontRun
?
>(
...
...
@@ -25,17 +26,17 @@ class FontMgrRunIterator(text: ManagedString?, manageText: Boolean, font: Font?,
override
operator
fun
next
():
FontRun
{
return
try
{
_nConsume
(
_ptr
)
FontRun
(
_getEndOfCurrentRun
(),
org
.
jetbrains
.
skia
.
Font
(
_nGetCurrentFont
(
_ptr
)))
FontRun
(
_getEndOfCurrentRun
(),
Font
(
_nGetCurrentFont
(
_ptr
)))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
init
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
text
)
Reference
.
reachabilityFence
(
font
)
Reference
.
reachabilityFence
(
opts
)
reachabilityBarrier
(
text
)
reachabilityBarrier
(
font
)
reachabilityBarrier
(
opts
)
}
override
fun
remove
()
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/FontRun.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/FontRun.kt
View file @
f794e4bb
...
...
@@ -2,14 +2,14 @@ package org.jetbrains.skia.shaper
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Native
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
class
FontRun
(
internal
val
end
:
Int
,
internal
val
font
:
Font
)
{
private
fun
_getFontPtr
():
Long
{
return
try
{
Native
.
Companion
.
getPtr
(
font
)
}
finally
{
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
font
)
}
}
...
...
@@ -21,7 +21,7 @@ class FontRun(internal val end: Int, internal val font: Font) {
if
(
end
!=
other
.
end
)
return
false
val
`
this
$
_font
`
:
Any
=
font
val
`
other
$
_font
`
:
Any
=
other
.
font
return
if
(
if
(
`
this
$
_font
`
==
null
)
`
other
$
_font
`
!=
null
else
`
this
$
_font
`
!=
`
other
$
_font
`
)
false
else
true
return
`
this
$
_font
`
==
`
other
$
_font
`
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -33,11 +33,11 @@ class FontRun(internal val end: Int, internal val font: Font) {
var
result
=
1
result
=
result
*
PRIME
+
end
val
`$
_font
`
:
Any
=
font
result
=
result
*
PRIME
+
(
`$
_font
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
`$
_font
`
.
hashCode
(
)
return
result
}
override
fun
toString
():
String
{
return
"FontRun(_end=
"
+
end
+
", _font="
+
font
+
"
)"
return
"FontRun(_end=
$end, _font=$font
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/HbIcuScriptRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/HbIcuScriptRunIterator.kt
View file @
f794e4bb
...
...
@@ -2,13 +2,13 @@ package org.jetbrains.skia.shaper
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.ManagedString
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
HbIcuScriptRunIterator
(
text
:
ManagedString
?,
manageText
:
Boolean
)
:
ManagedRunIterator
<
ScriptRun
?
>(
_nMake
(
Native
.
getPtr
(
text
)
getPtr
(
text
)
),
text
,
manageText
)
{
companion
object
{
...
...
@@ -27,13 +27,13 @@ class HbIcuScriptRunIterator(text: ManagedString?, manageText: Boolean) : Manage
_nConsume
(
_ptr
)
ScriptRun
(
_getEndOfCurrentRun
(),
_nGetCurrentScriptTag
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
init
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
text
)
reachabilityBarrier
(
text
)
}
override
fun
remove
()
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/IcuBidiRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/IcuBidiRunIterator.kt
View file @
f794e4bb
...
...
@@ -2,12 +2,12 @@ package org.jetbrains.skia.shaper
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.ManagedString
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
IcuBidiRunIterator
(
text
:
ManagedString
?,
manageText
:
Boolean
,
bidiLevel
:
Int
)
:
ManagedRunIterator
<
BidiRun
?
>(
_nMake
(
Native
.
Companion
.
getPtr
(
text
),
bidiLevel
),
text
,
manageText
_nMake
(
getPtr
(
text
),
bidiLevel
),
text
,
manageText
)
{
companion
object
{
@JvmStatic
external
fun
_nMake
(
textPtr
:
Long
,
bidiLevel
:
Int
):
Long
...
...
@@ -25,13 +25,13 @@ class IcuBidiRunIterator(text: ManagedString?, manageText: Boolean, bidiLevel: I
_nConsume
(
_ptr
)
BidiRun
(
_getEndOfCurrentRun
(),
_nGetCurrentLevel
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
init
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
text
)
reachabilityBarrier
(
text
)
}
override
fun
remove
()
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/LanguageRun.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/LanguageRun.kt
View file @
f794e4bb
...
...
@@ -18,7 +18,7 @@ class LanguageRun(
if
(
end
!=
other
.
end
)
return
false
val
`
this
$
_language
`
:
Any
=
language
val
`
other
$
_language
`
:
Any
=
other
.
language
return
if
(
if
(
`
this
$
_language
`
==
null
)
`
other
$
_language
`
!=
null
else
`
this
$
_language
`
!=
`
other
$
_language
`
)
false
else
true
return
`
this
$
_language
`
==
`
other
$
_language
`
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -30,11 +30,11 @@ class LanguageRun(
var
result
=
1
result
=
result
*
PRIME
+
end
val
`$
_language
`
:
Any
=
language
result
=
result
*
PRIME
+
(
`$
_language
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
`$
_language
`
.
hashCode
(
)
return
result
}
override
fun
toString
():
String
{
return
"LanguageRun(_end=
"
+
end
+
", _language="
+
language
+
"
)"
return
"LanguageRun(_end=
$end, _language=$language
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/ManagedRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/ManagedRunIterator.kt
View file @
f794e4bb
...
...
@@ -3,8 +3,8 @@ package org.jetbrains.skia.shaper
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
java.lang.ref.Reference
import
org.jetbrains.skia.impl.
reachabilityBarrier
import
kotlin.jvm.JvmStatic
abstract
class
ManagedRunIterator
<
T
>
internal
constructor
(
ptr
:
Long
,
...
...
@@ -30,10 +30,10 @@ abstract class ManagedRunIterator<T> internal constructor(
internal
fun
_getEndOfCurrentRun
():
Int
{
return
try
{
_nGetEndOfCurrentRun
(
_ptr
,
Native
.
Companion
.
getPtr
(
_text
))
_nGetEndOfCurrentRun
(
_ptr
,
getPtr
(
_text
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
_text
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
_text
)
}
}
...
...
@@ -41,7 +41,7 @@ abstract class ManagedRunIterator<T> internal constructor(
return
try
{
!
_nIsAtEnd
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/RunHandler.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/RunHandler.kt
View file @
f794e4bb
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/RunInfo.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/RunInfo.kt
View file @
f794e4bb
...
...
@@ -45,11 +45,11 @@ class RunInfo(
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
_fontPtr
!=
other
.
_fontPtr
)
return
false
if
(
bidiLevel
!=
other
.
bidiLevel
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
advanceX
,
other
.
advanceX
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
advanceY
,
other
.
advanceY
)
!=
0
)
return
false
if
(
advanceX
.
compareTo
(
other
.
advanceX
)
!=
0
)
return
false
if
(
advanceY
.
compareTo
(
other
.
advanceY
)
!=
0
)
return
false
if
(
glyphCount
!=
other
.
glyphCount
)
return
false
if
(
rangeBegin
!=
other
.
rangeBegin
)
return
false
return
if
(
rangeSize
!=
other
.
rangeSize
)
false
else
tru
e
return
rangeSize
==
other
.
rangeSiz
e
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -62,8 +62,8 @@ class RunInfo(
val
`$
_fontPtr
`
=
_fontPtr
result
=
result
*
PRIME
+
(
`$
_fontPtr
`
ushr
32
xor
`$
_fontPtr
`
).
toInt
()
result
=
result
*
PRIME
+
bidiLevel
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
advanceX
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
advanceY
)
result
=
result
*
PRIME
+
advanceX
.
toBits
(
)
result
=
result
*
PRIME
+
advanceY
.
toBits
(
)
val
`$
_glyphCount
`
=
glyphCount
result
=
result
*
PRIME
+
(
`$
_glyphCount
`
ushr
32
xor
`$
_glyphCount
`
).
toInt
()
result
=
result
*
PRIME
+
rangeBegin
...
...
@@ -72,6 +72,6 @@ class RunInfo(
}
override
fun
toString
():
String
{
return
"RunInfo(_fontPtr=
"
+
_fontPtr
+
", _bidiLevel="
+
bidiLevel
+
", _advanceX="
+
advanceX
+
", _advanceY="
+
advanceY
+
", _glyphCount="
+
glyphCount
+
", _rangeBegin="
+
rangeBegin
+
", _rangeSize="
+
rangeSize
+
"
)"
return
"RunInfo(_fontPtr=
$_fontPtr, _bidiLevel=$bidiLevel, _advanceX=$advanceX, _advanceY=$advanceY, _glyphCount=$glyphCount, _rangeBegin=$rangeBegin, _rangeSize=$rangeSize
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/ScriptRun.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/ScriptRun.kt
View file @
f794e4bb
...
...
@@ -10,7 +10,7 @@ class ScriptRun(internal val end: Int, internal val scriptTag: Int) {
* Should be iso15924 codes.
*/
val
script
:
String
get
()
=
FourByteTag
.
Companion
.
toString
(
scriptTag
)
get
()
=
FourByteTag
.
toString
(
scriptTag
)
override
fun
equals
(
o
:
Any
?):
Boolean
{
if
(
o
===
this
)
return
true
...
...
@@ -18,7 +18,7 @@ class ScriptRun(internal val end: Int, internal val scriptTag: Int) {
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
end
!=
other
.
end
)
return
false
return
if
(
scriptTag
!=
other
.
scriptTag
)
false
else
true
return
scriptTag
==
other
.
scriptTag
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -34,6 +34,6 @@ class ScriptRun(internal val end: Int, internal val scriptTag: Int) {
}
override
fun
toString
():
String
{
return
"ScriptRun(_end=
"
+
end
+
", _scriptTag="
+
scriptTag
+
"
)"
return
"ScriptRun(_end=
$end, _scriptTag=$scriptTag
)"
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/Shaper.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/Shaper.kt
View file @
f794e4bb
...
...
@@ -3,12 +3,10 @@ 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
java.text.Bidi
import
java.util.*
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.use
import
kotlin.jvm.JvmStatic
/**
* Shapes text using HarfBuzz and places the shaped text into a
...
...
@@ -28,9 +26,9 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
fun
makeShaperDrivenWrapper
(
fontMgr
:
FontMgr
?):
Shaper
{
return
try
{
Stats
.
onNativeCall
()
Shaper
(
_nMakeShaperDrivenWrapper
(
Native
.
Companion
.
getPtr
(
fontMgr
)))
Shaper
(
_nMakeShaperDrivenWrapper
(
getPtr
(
fontMgr
)))
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -41,9 +39,9 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
fun
makeShapeThenWrap
(
fontMgr
:
FontMgr
?):
Shaper
{
return
try
{
Stats
.
onNativeCall
()
Shaper
(
_nMakeShapeThenWrap
(
Native
.
Companion
.
getPtr
(
fontMgr
)))
Shaper
(
_nMakeShapeThenWrap
(
getPtr
(
fontMgr
)))
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -54,9 +52,9 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
fun
makeShapeDontWrapOrReorder
(
fontMgr
:
FontMgr
?):
Shaper
{
return
try
{
Stats
.
onNativeCall
()
Shaper
(
_nMakeShapeDontWrapOrReorder
(
Native
.
Companion
.
getPtr
(
fontMgr
)))
Shaper
(
_nMakeShapeDontWrapOrReorder
(
getPtr
(
fontMgr
)))
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -83,9 +81,9 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
fun
make
(
fontMgr
:
FontMgr
?):
Shaper
{
return
try
{
Stats
.
onNativeCall
()
Shaper
(
_nMake
(
Native
.
Companion
.
getPtr
(
fontMgr
)))
Shaper
(
_nMake
(
getPtr
(
fontMgr
)))
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -148,12 +146,11 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
fun
shape
(
text
:
String
?,
font
:
Font
?,
opts
:
ShapingOptions
,
width
:
Float
,
offset
:
Point
):
TextBlob
?
{
return
try
{
assert
(
opts
!=
null
)
{
"Can’t Shaper::shape with opts == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nShapeBlob
(
_ptr
,
text
,
Native
.
Companion
.
getPtr
(
font
),
getPtr
(
font
),
opts
,
width
,
offset
.
x
,
...
...
@@ -161,8 +158,8 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
)
if
(
0L
==
ptr
)
null
else
TextBlob
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
font
)
}
}
...
...
@@ -178,11 +175,11 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
IcuBidiRunIterator
(
textUtf8
,
false
,
if
(
opts
.
isLeftToRight
)
Bidi
.
DIRECTION_LEFT_TO_RIGHT
else
Bidi
.
DIRECTION_RIGHT_TO_LEFT
if
(
opts
.
isLeftToRight
)
-
2
/* Bidi.DIRECTION_LEFT_TO_RIGHT */
else
-
1
/* Bidi.DIRECTION_RIGHT_TO_LEFT */
).
use
{
bidiIter
->
HbIcuScriptRunIterator
(
textUtf8
,
false
).
use
{
scriptIter
->
val
langIter
=
TrivialLanguageRunIterator
(
text
,
Locale
.
getDefault
().
to
LanguageTag
())
TrivialLanguageRunIterator
(
text
,
default
LanguageTag
())
return
shape
(
textUtf8
,
fontIter
,
bidiIter
,
scriptIter
,
langIter
,
opts
,
width
,
runHandler
)
}
}
...
...
@@ -224,15 +221,10 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
width
:
Float
,
runHandler
:
RunHandler
):
Shaper
{
assert
(
fontIter
!=
null
)
{
"FontRunIterator == null"
}
assert
(
bidiIter
!=
null
)
{
"BidiRunIterator == null"
}
assert
(
scriptIter
!=
null
)
{
"ScriptRunIterator == null"
}
assert
(
langIter
!=
null
)
{
"LanguageRunIterator == null"
}
assert
(
opts
!=
null
)
{
"Can’t Shaper::shape with opts == null"
}
Stats
.
onNativeCall
()
_nShape
(
_ptr
,
Native
.
Companion
.
getPtr
(
textUtf8
),
getPtr
(
textUtf8
),
fontIter
,
bidiIter
,
scriptIter
,
...
...
@@ -246,19 +238,18 @@ class Shaper internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR
fun
shapeLine
(
text
:
String
?,
font
:
Font
?,
opts
:
ShapingOptions
):
TextLine
{
return
try
{
assert
(
opts
!=
null
)
{
"Can’t Shaper::shapeLine with opts == null"
}
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
TextLine
(
TextLine
(
_nShapeLine
(
_ptr
,
text
,
Native
.
Companion
.
getPtr
(
font
),
getPtr
(
font
),
opts
)
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
Reference
.
reachabilityFence
(
font
)
reachabilityBarrier
(
this
)
reachabilityBarrier
(
font
)
}
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/ShapingOptions.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/ShapingOptions.kt
View file @
f794e4bb
...
...
@@ -2,7 +2,6 @@ package org.jetbrains.skia.shaper
import
org.jetbrains.skia.FontFeature
import
org.jetbrains.skia.FontMgr
import
java.util.*
class
ShapingOptions
(
internal
val
fontMgr
:
FontMgr
?,
...
...
@@ -47,7 +46,7 @@ class ShapingOptions(
val
`
this
$
_fontMgr
`
:
Any
?
=
fontMgr
val
`
other
$
_fontMgr
`
:
Any
?
=
other
.
fontMgr
if
(
if
(
`
this
$
_fontMgr
`
==
null
)
`
other
$
_fontMgr
`
!=
null
else
`
this
$
_fontMgr
`
!=
`
other
$
_fontMgr
`
)
return
false
return
if
(!
Arrays
.
deepEquals
(
features
,
other
.
features
))
false
else
true
return
features
.
contentDeepEquals
(
other
.
features
)
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -62,12 +61,12 @@ class ShapingOptions(
result
=
result
*
PRIME
+
if
(
isApproximatePunctuation
)
79
else
97
val
`$
_fontMgr
`
:
Any
?
=
fontMgr
result
=
result
*
PRIME
+
(
`$
_fontMgr
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
Arrays
.
deepHashCode
(
features
)
result
=
result
*
PRIME
+
features
.
contentDeepHashCode
(
)
return
result
}
override
fun
toString
():
String
{
return
"ShapingOptions(_fontMgr="
+
fontMgr
+
", _features="
+
Arrays
.
deepToString
(
features
)
+
", _leftToRight="
+
isLeftToRight
+
", _approximateSpaces="
+
isApproximateSpaces
+
", _approximatePunctuation="
+
isApproximatePunctuation
+
")"
return
"ShapingOptions(_fontMgr="
+
fontMgr
+
", _features="
+
features
.
contentDeepToString
(
)
+
", _leftToRight="
+
isLeftToRight
+
", _approximateSpaces="
+
isApproximateSpaces
+
", _approximatePunctuation="
+
isApproximatePunctuation
+
")"
}
fun
withFontMgr
(
_fontMgr
:
FontMgr
?):
ShapingOptions
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/shaper/TrivialLanguageRunIterator.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/shaper/TrivialLanguageRunIterator.kt
View file @
f794e4bb
File moved
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Actuals.jvm.kt
0 → 100644
View file @
f794e4bb
package
org.jetbrains.skia
import
java.util.*
actual
typealias
ByteBuffer
=
java
.
nio
.
ByteBuffer
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
synchronized
(
lock
,
block
)
}
actual
fun
String
.
intCodePoints
():
IntArray
=
this
.
codePoints
().
toArray
()
actual
typealias
Pattern
=
java
.
util
.
regex
.
Pattern
actual
typealias
Matcher
=
java
.
util
.
regex
.
Matcher
actual
fun
defaultLanguageTag
():
String
=
Locale
.
getDefault
().
toLanguageTag
()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
Pattern
.
compile
(
regex
)
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Codec.kt
View file @
f794e4bb
...
...
@@ -99,7 +99,7 @@ class Codec internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
* @return decoded bitmap
*/
fun
readPixels
():
Bitmap
{
val
bitmap
=
org
.
jetbrains
.
skia
.
Bitmap
()
val
bitmap
=
Bitmap
()
bitmap
.
allocPixels
(
imageInfo
)
readPixels
(
bitmap
)
return
bitmap
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/PaintFilterCanvas.kt
View file @
f794e4bb
...
...
@@ -29,7 +29,7 @@ abstract class PaintFilterCanvas(canvas: Canvas, unrollDrawable: Boolean) :
*/
abstract
fun
onFilter
(
paint
:
Paint
):
Boolean
fun
onFilter
(
paintPtr
:
Long
):
Boolean
{
val
paint
=
org
.
jetbrains
.
skia
.
Paint
(
paintPtr
,
false
)
val
paint
=
Paint
(
paintPtr
,
false
)
return
onFilter
(
paint
)
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/PictureRecorder.kt
View file @
f794e4bb
...
...
@@ -62,7 +62,7 @@ class PictureRecorder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
fun
beginRecording
(
bounds
:
Rect
):
Canvas
{
return
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
Canvas
(
Canvas
(
_nBeginRecording
(
_ptr
,
bounds
.
left
,
...
...
@@ -83,7 +83,7 @@ class PictureRecorder internal constructor(ptr: Long) : Managed(ptr, _FinalizerH
get
()
=
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nGetRecordingCanvas
(
_ptr
)
if
(
ptr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
Canvas
(
ptr
,
false
,
this
)
if
(
ptr
==
0L
)
null
else
Canvas
(
ptr
,
false
,
this
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/RuntimeEffect.kt
View file @
f794e4bb
...
...
@@ -39,6 +39,6 @@ class RuntimeEffect internal constructor(ptr: Long) : RefCnt(ptr) {
val
childrenPtrs
=
LongArray
(
childCount
)
for
(
i
in
0
until
childCount
)
childrenPtrs
[
i
]
=
Native
.
Companion
.
getPtr
(
children
!!
[
i
])
val
matrix
=
localMatrix
?.
mat
return
Shader
(
_nMakeShader
(
_ptr
,
Native
.
Companion
.
getPtr
(
uniforms
),
childrenPtrs
,
matrix
,
isOpaque
))
return
Shader
(
_nMakeShader
(
_ptr
,
getPtr
(
uniforms
),
childrenPtrs
,
matrix
,
isOpaque
))
}
}
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skia/Surface.kt
View file @
f794e4bb
...
...
@@ -860,7 +860,7 @@ class Surface : RefCnt {
fun
makeImageSnapshot
():
Image
{
return
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
Image
(
_nMakeImageSnapshot
(
_ptr
))
Image
(
_nMakeImageSnapshot
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
}
...
...
@@ -886,7 +886,7 @@ class Surface : RefCnt {
fun
makeImageSnapshot
(
area
:
IRect
):
Image
?
{
return
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
Image
(
Image
(
_nMakeImageSnapshotR
(
_ptr
,
area
.
left
,
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/impl/Native.jvm.kt
View file @
f794e4bb
...
...
@@ -21,7 +21,7 @@ actual abstract class Native actual constructor(ptr: Long) {
}
}
open
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
actual
open
fun
_nativeEquals
(
other
:
Native
?):
Boolean
{
return
false
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/paragraph/StrutStyle.kt
View file @
f794e4bb
...
...
@@ -65,7 +65,7 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
val
fontStyle
:
FontStyle
get
()
=
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
FontStyle
(
_nGetFontStyle
(
_ptr
))
FontStyle
(
_nGetFontStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skia/paragraph/TextStyle.kt
View file @
f794e4bb
...
...
@@ -113,7 +113,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
get
()
=
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nGetForeground
(
_ptr
)
if
(
ptr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
Paint
(
ptr
,
true
)
if
(
ptr
==
0L
)
null
else
Paint
(
ptr
,
true
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
}
...
...
@@ -135,7 +135,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
get
()
=
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nGetBackground
(
_ptr
)
if
(
ptr
==
0L
)
null
else
org
.
jetbrains
.
skia
.
Paint
(
ptr
,
true
)
if
(
ptr
==
0L
)
null
else
Paint
(
ptr
,
true
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
}
...
...
@@ -179,7 +179,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
val
fontStyle
:
FontStyle
get
()
=
try
{
Stats
.
onNativeCall
()
org
.
jetbrains
.
skia
.
FontStyle
(
_nGetFontStyle
(
_ptr
))
FontStyle
(
_nGetFontStyle
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
View file @
f794e4bb
package
org.jetbrains.skiko
import
org.jetbrains.skia.Bitmap
import
java.io.BufferedReader
import
java.io.File
import
java.io.InputStreamReader
...
...
@@ -102,7 +103,7 @@ object Library {
// We have to keep this tiny class in Skiko for testing purposes.
internal
class
LibraryTestImpl
()
{
fun
run
():
Long
{
val
bitmap
=
org
.
jetbrains
.
skia
.
Bitmap
()
val
bitmap
=
Bitmap
()
return
bitmap
.
_ptr
}
}
\ No newline at end of file
skiko/src/macosX64Main/kotlin/org/jetbrains/skia/Actuals.native.kt
0 → 100644
View file @
f794e4bb
package
org.jetbrains.skia
actual
abstract
class
ByteBuffer
actual
fun
<
R
>
commonSynchronized
(
lock
:
Any
,
block
:
()
->
R
)
{
block
()
}
actual
fun
String
.
intCodePoints
():
IntArray
=
TODO
()
actual
class
Pattern
{
actual
fun
split
(
input
:
CharSequence
):
Array
<
String
?
>?
=
TODO
()
actual
fun
matcher
(
input
:
CharSequence
):
Matcher
=
TODO
()
}
actual
class
Matcher
{
actual
fun
group
(
name
:
String
):
String
?
=
TODO
()
actual
fun
matches
():
Boolean
=
TODO
()
}
actual
fun
defaultLanguageTag
():
String
=
TODO
()
actual
fun
compilePattern
(
regex
:
String
):
Pattern
=
TODO
()
\ No newline at end of file
skiko/src/macosX64Main/kotlin/org/jetbrains/skia/impl/Managed.native.kt
View file @
f794e4bb
package
org.jetbrains.skia.impl
actual
abstract
class
Managed
actual
constructor
(
ptr
:
Long
,
finalizer
:
Long
,
managed
:
Boolean
)
:
Native
(
ptr
)
{
actual
open
fun
close
()
{
TODO
()
}
actual
open
fun
close
():
Unit
=
TODO
()
}
\ No newline at end of file
skiko/src/macosX64Main/kotlin/org/jetbrains/skia/impl/Native.native.kt
View file @
f794e4bb
...
...
@@ -3,6 +3,8 @@ package org.jetbrains.skia.impl
actual
abstract
class
Native
actual
constructor
(
ptr
:
Long
)
{
actual
var
_ptr
:
Long
actual
open
fun
_nativeEquals
(
other
:
Native
?):
Boolean
=
TODO
()
actual
companion
object
{
actual
fun
getPtr
(
n
:
Native
?):
Long
{
return
n
?.
_ptr
?:
0
...
...
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