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
3a68bff4
Unverified
Commit
3a68bff4
authored
Sep 06, 2021
by
Nikolay Igotti
Committed by
GitHub
Sep 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete commonization. (#168)
parent
a8dbcb11
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
149 additions
and
93 deletions
+149
-93
build.gradle.kts
skiko/build.gradle.kts
+0
-1
Animation.kt
...commonMain/kotlin/org/jetbrains/skia/skottie/Animation.kt
+19
-19
AnimationBuilder.kt
...ain/kotlin/org/jetbrains/skia/skottie/AnimationBuilder.kt
+13
-14
AnimationBuilderFlag.kt
...kotlin/org/jetbrains/skia/skottie/AnimationBuilderFlag.kt
+0
-1
LogLevel.kt
.../commonMain/kotlin/org/jetbrains/skia/skottie/LogLevel.kt
+0
-0
Logger.kt
...rc/commonMain/kotlin/org/jetbrains/skia/skottie/Logger.kt
+4
-1
RenderFlag.kt
...ommonMain/kotlin/org/jetbrains/skia/skottie/RenderFlag.kt
+0
-0
InvalidationController.kt
.../kotlin/org/jetbrains/skia/sksg/InvalidationController.kt
+7
-4
SVGCanvas.kt
...src/commonMain/kotlin/org/jetbrains/skia/svg/SVGCanvas.kt
+4
-1
SVGContainer.kt
.../commonMain/kotlin/org/jetbrains/skia/svg/SVGContainer.kt
+0
-0
SVGDOM.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/svg/SVGDOM.kt
+12
-10
SVGLength.kt
...src/commonMain/kotlin/org/jetbrains/skia/svg/SVGLength.kt
+2
-2
SVGLengthContext.kt
...monMain/kotlin/org/jetbrains/skia/svg/SVGLengthContext.kt
+12
-11
SVGNode.kt
...o/src/commonMain/kotlin/org/jetbrains/skia/svg/SVGNode.kt
+6
-3
SVGPreserveAspectRatio.kt
...n/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatio.kt
+4
-4
SVGPreserveAspectRatioAlign.kt
...lin/org/jetbrains/skia/svg/SVGPreserveAspectRatioAlign.kt
+10
-6
SVGPreserveAspectRatioScale.kt
...lin/org/jetbrains/skia/svg/SVGPreserveAspectRatioScale.kt
+0
-0
SVGSVG.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/svg/SVGSVG.kt
+18
-15
SVGTag.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/svg/SVGTag.kt
+38
-1
SVGTransformableNode.kt
...ain/kotlin/org/jetbrains/skia/svg/SVGTransformableNode.kt
+0
-0
No files found.
skiko/build.gradle.kts
View file @
3a68bff4
...
...
@@ -419,7 +419,6 @@ project.tasks.register<Exec>("nativeBridgesLink") {
val
srcs
=
inputs
.
files
.
files
.
map
{
it
.
absolutePath
}
.
toTypedArray
()
println
(
"SRCS: $srcs"
)
val
staticLib
=
"$outDir/skiko-native-bridges-$target.a"
workingDir
=
File
(
outDir
)
commandLine
=
listOf
(
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/skottie/Animation.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/skottie/Animation.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.skottie
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.sksg.InvalidationController
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
Animation
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -26,12 +27,13 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
fun
makeFromData
(
data
:
Data
):
Animation
{
Stats
.
onNativeCall
()
val
ptr
=
_nMakeFromData
(
Native
.
Companion
.
getPtr
(
data
))
val
ptr
=
_nMakeFromData
(
getPtr
(
data
))
require
(
ptr
!=
0L
)
{
"Failed to create Animation from data."
}
return
Animation
(
ptr
)
}
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMakeFromString
(
data
:
String
?):
Long
@JvmStatic
external
fun
_nMakeFromFile
(
path
:
String
?):
Long
@JvmStatic
external
fun
_nMakeFromData
(
dataPtr
:
Long
):
Long
...
...
@@ -127,15 +129,13 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
*/
fun
render
(
canvas
:
Canvas
,
dst
:
Rect
,
vararg
renderFlags
:
RenderFlag
):
Animation
{
return
try
{
assert
(
canvas
!=
null
)
{
"Can’t Animation::render with canvas == null"
}
assert
(
dst
!=
null
)
{
"Can’t Animation::render with dst == null"
}
Stats
.
onNativeCall
()
var
flags
=
0
for
(
flag
in
renderFlags
)
flags
=
flags
or
flag
.
_flag
_nRender
(
_ptr
,
Native
.
Companion
.
getPtr
(
canvas
),
dst
.
left
,
dst
.
top
,
dst
.
right
,
dst
.
bottom
,
flags
)
_nRender
(
_ptr
,
getPtr
(
canvas
),
dst
.
left
,
dst
.
top
,
dst
.
right
,
dst
.
bottom
,
flags
)
this
}
finally
{
Reference
.
reachabilityFence
(
canvas
)
reachabilityBarrier
(
canvas
)
}
}
...
...
@@ -161,10 +161,10 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
fun
seek
(
t
:
Float
,
ic
:
InvalidationController
?):
Animation
{
return
try
{
Stats
.
onNativeCall
()
_nSeek
(
_ptr
,
t
,
Native
.
Companion
.
getPtr
(
ic
))
_nSeek
(
_ptr
,
t
,
getPtr
(
ic
))
this
}
finally
{
Reference
.
reachabilityFence
(
ic
)
reachabilityBarrier
(
ic
)
}
}
...
...
@@ -200,10 +200,10 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
fun
seekFrame
(
t
:
Float
,
ic
:
InvalidationController
?):
Animation
{
return
try
{
Stats
.
onNativeCall
()
_nSeekFrame
(
_ptr
,
t
,
Native
.
Companion
.
getPtr
(
ic
))
_nSeekFrame
(
_ptr
,
t
,
getPtr
(
ic
))
this
}
finally
{
Reference
.
reachabilityFence
(
ic
)
reachabilityBarrier
(
ic
)
}
}
...
...
@@ -231,10 +231,10 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
fun
seekFrameTime
(
t
:
Float
,
ic
:
InvalidationController
?):
Animation
{
return
try
{
Stats
.
onNativeCall
()
_nSeekFrameTime
(
_ptr
,
t
,
Native
.
Companion
.
getPtr
(
ic
))
_nSeekFrameTime
(
_ptr
,
t
,
getPtr
(
ic
))
this
}
finally
{
Reference
.
reachabilityFence
(
ic
)
reachabilityBarrier
(
ic
)
}
}
...
...
@@ -246,7 +246,7 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetDuration
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -257,7 +257,7 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetFPS
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -268,7 +268,7 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetInPoint
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -279,14 +279,14 @@ class Animation internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
Stats
.
onNativeCall
()
_nGetOutPoint
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
val
version
:
String
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetVersion
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
private
var
_size
:
Point
?
=
null
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/skottie/AnimationBuilder.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/skottie/AnimationBuilder.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.skottie
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
AnimationBuilder
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
...
...
@@ -15,7 +16,8 @@ class AnimationBuilder internal constructor(ptr: Long) : Managed(ptr, _Finalizer
return
flags
}
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMake
(
flags
:
Int
):
Long
@JvmStatic
external
fun
_nSetFontManager
(
ptr
:
Long
,
fontMgrPtr
:
Long
)
@JvmStatic
external
fun
_nSetLogger
(
ptr
:
Long
,
loggerPtr
:
Long
)
...
...
@@ -44,10 +46,10 @@ class AnimationBuilder internal constructor(ptr: Long) : Managed(ptr, _Finalizer
fun
setFontManager
(
fontMgr
:
FontMgr
?):
AnimationBuilder
{
return
try
{
Stats
.
onNativeCall
()
_nSetFontManager
(
_ptr
,
Native
.
Companion
.
getPtr
(
fontMgr
))
_nSetFontManager
(
_ptr
,
getPtr
(
fontMgr
))
this
}
finally
{
Reference
.
reachabilityFence
(
fontMgr
)
reachabilityBarrier
(
fontMgr
)
}
}
...
...
@@ -58,47 +60,44 @@ class AnimationBuilder internal constructor(ptr: Long) : Managed(ptr, _Finalizer
fun
setLogger
(
logger
:
Logger
?):
AnimationBuilder
{
return
try
{
Stats
.
onNativeCall
()
_nSetLogger
(
_ptr
,
Native
.
Companion
.
getPtr
(
logger
))
_nSetLogger
(
_ptr
,
getPtr
(
logger
))
this
}
finally
{
Reference
.
reachabilityFence
(
logger
)
reachabilityBarrier
(
logger
)
}
}
fun
buildFromString
(
data
:
String
):
Animation
{
return
try
{
assert
(
data
!=
null
)
{
"Can’t buildFromString with data == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nBuildFromString
(
_ptr
,
data
)
require
(
ptr
!=
0L
)
{
"Failed to create Animation from string: \"$data\""
}
Animation
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
fun
buildFromFile
(
path
:
String
):
Animation
{
return
try
{
assert
(
path
!=
null
)
{
"Can’t buildFromFile with path == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nBuildFromFile
(
_ptr
,
path
)
require
(
ptr
!=
0L
)
{
"Failed to create Animation from path: $path"
}
Animation
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
fun
buildFromData
(
data
:
Data
):
Animation
{
return
try
{
assert
(
data
!=
null
)
{
"Can’t buildFromData with data == null"
}
Stats
.
onNativeCall
()
val
ptr
=
_nBuildFromData
(
_ptr
,
Native
.
Companion
.
getPtr
(
data
))
_nBuildFromData
(
_ptr
,
getPtr
(
data
))
require
(
ptr
!=
0L
)
{
"Failed to create Animation from data"
}
Animation
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/skottie/AnimationBuilderFlag.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/skottie/AnimationBuilderFlag.kt
View file @
3a68bff4
package
org.jetbrains.skia.skottie
enum
class
AnimationBuilderFlag
(
internal
val
_flag
:
Int
)
{
/**
* Normally, all static image frames are resolved at
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/skottie/LogLevel.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/skottie/LogLevel.kt
View file @
3a68bff4
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/skottie/Logger.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/skottie/Logger.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.skottie
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Stats
import
kotlin.jvm.JvmStatic
/**
*
...
...
@@ -11,7 +13,8 @@ import org.jetbrains.skia.impl.Stats
*/
abstract
class
Logger
:
RefCnt
(
_nMake
())
{
companion
object
{
@JvmStatic
external
fun
_nMake
():
Long
@JvmStatic
external
fun
_nMake
():
Long
init
{
staticLoad
()
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/skottie/RenderFlag.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/skottie/RenderFlag.kt
View file @
3a68bff4
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/sksg/InvalidationController.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/sksg/InvalidationController.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.sksg
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.*
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
/**
*
...
...
@@ -14,7 +16,8 @@ import java.lang.ref.Reference
*/
class
InvalidationController
internal
constructor
(
ptr
:
Long
)
:
Managed
(
ptr
,
_FinalizerHolder
.
PTR
)
{
companion
object
{
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nGetFinalizer
():
Long
@JvmStatic
external
fun
_nMake
():
Long
@JvmStatic
external
fun
_nInvalidate
(
ptr
:
Long
,
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
matrix
:
FloatArray
?)
@JvmStatic
external
fun
_nGetBounds
(
ptr
:
Long
):
Rect
...
...
@@ -39,7 +42,7 @@ class InvalidationController internal constructor(ptr: Long) : Managed(ptr, _Fin
top
,
right
,
bottom
,
if
(
matrix
==
null
)
Matrix33
.
Companion
.
IDENTITY
.
mat
else
matrix
.
mat
matrix
?.
mat
?:
Matrix33
.
IDENTITY
.
mat
)
return
this
}
...
...
@@ -49,7 +52,7 @@ class InvalidationController internal constructor(ptr: Long) : Managed(ptr, _Fin
Stats
.
onNativeCall
()
_nGetBounds
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
reset
():
InvalidationController
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGCanvas.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGCanvas.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.svg
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
kotlin.jvm.JvmStatic
object
SVGCanvas
{
/**
...
...
@@ -49,7 +51,8 @@ object SVGCanvas {
return
Canvas
(
ptr
,
true
,
out
)
}
@JvmStatic
external
fun
_nMake
(
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
wstreamPtr
:
Long
,
flags
:
Int
):
Long
@JvmStatic
external
fun
_nMake
(
left
:
Float
,
top
:
Float
,
right
:
Float
,
bottom
:
Float
,
wstreamPtr
:
Long
,
flags
:
Int
):
Long
init
{
staticLoad
()
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGContainer.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGContainer.kt
View file @
3a68bff4
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGDOM.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGDOM.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.svg
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
SVGDOM
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
@JvmStatic
external
fun
_nMakeFromData
(
dataPtr
:
Long
):
Long
@JvmStatic
external
fun
_nMakeFromData
(
dataPtr
:
Long
):
Long
@JvmStatic
external
fun
_nGetRoot
(
ptr
:
Long
):
Long
@JvmStatic
external
fun
_nGetContainerSize
(
ptr
:
Long
):
Point
@JvmStatic
external
fun
_nSetContainerSize
(
ptr
:
Long
,
width
:
Float
,
height
:
Float
)
...
...
@@ -20,18 +22,18 @@ class SVGDOM internal constructor(ptr: Long) : RefCnt(ptr) {
}
}
constructor
(
data
:
Data
)
:
this
(
_nMakeFromData
(
Native
.
getPtr
(
data
)))
{
constructor
(
data
:
Data
)
:
this
(
_nMakeFromData
(
getPtr
(
data
)))
{
Stats
.
onNativeCall
()
Reference
.
reachabilityFence
(
data
)
reachabilityBarrier
(
data
)
}
val
root
:
org
.
jetbrains
.
skia
.
svg
.
SVGSVG
?
val
root
:
SVGSVG
?
get
()
=
try
{
Stats
.
onNativeCall
()
val
ptr
=
_nGetRoot
(
_ptr
)
if
(
ptr
==
0L
)
null
else
SVGSVG
(
ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
/**
...
...
@@ -42,7 +44,7 @@ class SVGDOM internal constructor(ptr: Long) : RefCnt(ptr) {
get
()
=
try
{
_nGetContainerSize
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
fun
setContainerSize
(
width
:
Float
,
height
:
Float
):
SVGDOM
{
...
...
@@ -61,10 +63,10 @@ class SVGDOM internal constructor(ptr: Long) : RefCnt(ptr) {
fun
render
(
canvas
:
Canvas
):
SVGDOM
{
return
try
{
Stats
.
onNativeCall
()
_nRender
(
_ptr
,
Native
.
Companion
.
getPtr
(
canvas
))
_nRender
(
_ptr
,
getPtr
(
canvas
))
this
}
finally
{
Reference
.
reachabilityFence
(
canvas
)
reachabilityBarrier
(
canvas
)
}
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGLength.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGLength.kt
View file @
3a68bff4
...
...
@@ -29,9 +29,9 @@ class SVGLength(val value: Float, unit: SVGLengthUnit) {
override
fun
hashCode
():
Int
{
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
value
)
result
=
result
*
PRIME
+
value
.
toBits
(
)
val
`$
_unit
`
:
Any
=
unit
result
=
result
*
PRIME
+
(
`$
_unit
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_unit
`
.
hashCode
()
)
return
result
}
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGLengthContext.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGLengthContext.kt
View file @
3a68bff4
package
org.jetbrains.skia.svg
import
org.jetbrains.skia.*
import
java.lang.IllegalArgumentException
import
kotlin.math.hypot
import
kotlin.math.sqrt
class
SVGLengthContext
@JvmOverloads
constructor
(
class
SVGLengthContext
constructor
(
internal
val
width
:
Float
,
internal
val
height
:
Float
,
internal
val
dpi
:
Float
=
90f
...
...
@@ -20,10 +21,10 @@ class SVGLengthContext @JvmOverloads constructor(
SVGLengthType
.
HORIZONTAL
->
return
length
.
value
*
width
/
100.0f
SVGLengthType
.
VERTICAL
->
return
length
.
value
*
height
/
100.0f
SVGLengthType
.
OTHER
->
// https://www.w3.org/TR/SVG11/coords.html#Units_viewport_percentage
return
(
length
.
value
*
Math
.
hypot
(
return
(
length
.
value
*
hypot
(
width
.
toDouble
(),
height
.
toDouble
()
)
/
Math
.
sqrt
(
2.0
)
/
100.0
).
toFloat
()
)
/
sqrt
(
2.0
)
/
100.0
).
toFloat
()
}
}
SVGLengthUnit
.
CM
->
length
.
value
*
dpi
/
2.54f
...
...
@@ -49,9 +50,9 @@ class SVGLengthContext @JvmOverloads constructor(
if
(
o
!
is
SVGLengthContext
)
return
false
val
other
=
o
if
(!
other
.
canEqual
(
this
as
Any
))
return
false
if
(
java
.
lang
.
Float
.
compare
(
width
,
other
.
width
)
!=
0
)
return
false
if
(
java
.
lang
.
Float
.
compare
(
height
,
other
.
height
)
!=
0
)
return
false
return
if
(
java
.
lang
.
Float
.
compare
(
dpi
,
other
.
dpi
)
!=
0
)
false
else
true
if
(
width
.
compareTo
(
other
.
width
)
!=
0
)
return
false
if
(
height
.
compareTo
(
other
.
height
)
!=
0
)
return
false
return
dpi
.
compareTo
(
other
.
dpi
)
==
0
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -61,14 +62,14 @@ class SVGLengthContext @JvmOverloads constructor(
override
fun
hashCode
():
Int
{
val
PRIME
=
59
var
result
=
1
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
width
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
height
)
result
=
result
*
PRIME
+
java
.
lang
.
Float
.
floatToIntBits
(
dpi
)
result
=
result
*
PRIME
+
width
.
toBits
(
)
result
=
result
*
PRIME
+
height
.
toBits
(
)
result
=
result
*
PRIME
+
dpi
.
toBits
(
)
return
result
}
override
fun
toString
():
String
{
return
"SVGLengthContext(_width=
"
+
width
+
", _height="
+
height
+
", _dpi="
+
dpi
+
"
)"
return
"SVGLengthContext(_width=
$width, _height=$height, _dpi=$dpi
)"
}
fun
withWidth
(
_width
:
Float
):
SVGLengthContext
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGNode.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGNode.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.svg
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
abstract
class
SVGNode
internal
constructor
(
ptr
:
Long
)
:
RefCnt
(
ptr
)
{
companion
object
{
@JvmStatic
external
fun
_nGetTag
(
ptr
:
Long
):
Int
@JvmStatic
external
fun
_nGetTag
(
ptr
:
Long
):
Int
init
{
staticLoad
()
...
...
@@ -19,6 +22,6 @@ abstract class SVGNode internal constructor(ptr: Long) : RefCnt(ptr) {
Stats
.
onNativeCall
()
SVGTag
.
values
().
get
(
_nGetTag
(
_ptr
))
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatio.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatio.kt
View file @
3a68bff4
...
...
@@ -29,7 +29,7 @@ class SVGPreserveAspectRatio(align: SVGPreserveAspectRatioAlign, scale: SVGPrese
if
(
if
(
`
this
$
_align
`
==
null
)
`
other
$
_align
`
!=
null
else
`
this
$
_align
`
!=
`
other
$
_align
`
)
return
false
val
`
this
$
_scale
`
:
Any
=
scale
val
`
other
$
_scale
`
:
Any
=
other
.
scale
return
if
(
if
(
`
this
$
_scale
`
==
null
)
`
other
$
_scale
`
!=
null
else
`
this
$
_scale
`
!=
`
other
$
_scale
`
)
false
else
true
return
!
if
(
`
this
$
_scale
`
==
null
)
true
else
`
this
$
_scale
`
!=
`
other
$
_scale
`
}
protected
fun
canEqual
(
other
:
Any
?):
Boolean
{
...
...
@@ -40,14 +40,14 @@ class SVGPreserveAspectRatio(align: SVGPreserveAspectRatioAlign, scale: SVGPrese
val
PRIME
=
59
var
result
=
1
val
`$
_align
`
:
Any
=
align
result
=
result
*
PRIME
+
(
`$
_align
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_align
`
.
hashCode
()
)
val
`$
_scale
`
:
Any
=
scale
result
=
result
*
PRIME
+
(
`$
_scale
`
?.
hashCode
()
?:
43
)
result
=
result
*
PRIME
+
(
`$
_scale
`
.
hashCode
()
)
return
result
}
override
fun
toString
():
String
{
return
"SVGPreserveAspectRatio(_align=
"
+
align
+
", _scale="
+
scale
+
"
)"
return
"SVGPreserveAspectRatio(_align=
$align, _scale=$scale
)"
}
fun
withAlign
(
_align
:
SVGPreserveAspectRatioAlign
):
SVGPreserveAspectRatio
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatioAlign.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatioAlign.kt
View file @
3a68bff4
package
org.jetbrains.skia.svg
import
java.lang.IllegalArgumentException
enum
class
SVGPreserveAspectRatioAlign
constructor
(
internal
val
_value
:
Int
)
{
// These values are chosen such that bits [0,1] encode X alignment, and
// bits [2,3] encode Y alignment.
XMIN_YMIN
(
0
x00
),
XMID_YMIN
(
0
x01
),
XMAX_YMIN
(
0
x02
),
XMIN_YMID
(
0
x04
),
XMID_YMID
(
0
x05
),
XMAX_YMID
(
0
x06
),
XMIN_YMAX
(
0
x08
),
XMID_YMAX
(
0
x09
),
XMAX_YMAX
(
0
x0a
),
NONE
(
0
x10
);
XMIN_YMIN
(
0
x00
),
XMID_YMIN
(
0
x01
),
XMAX_YMIN
(
0
x02
),
XMIN_YMID
(
0
x04
),
XMID_YMID
(
0
x05
),
XMAX_YMID
(
0
x06
),
XMIN_YMAX
(
0
x08
),
XMID_YMAX
(
0
x09
),
XMAX_YMAX
(
0
x0a
),
NONE
(
0
x10
);
companion
object
{
internal
fun
valueOf
(
value
:
Int
):
SVGPreserveAspectRatioAlign
{
...
...
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatioScale.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGPreserveAspectRatioScale.kt
View file @
3a68bff4
File moved
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGSVG.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGSVG.kt
View file @
3a68bff4
@file
:
Suppress
(
"NESTED_EXTERNAL_DECLARATION"
)
package
org.jetbrains.skia.svg
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.*
import
org.jetbrains.skia.impl.Stats
import
java.lang.ref.Reference
import
org.jetbrains.skia.impl.reachabilityBarrier
import
kotlin.jvm.JvmStatic
class
SVGSVG
internal
constructor
(
ptr
:
Long
)
:
SVGContainer
(
ptr
)
{
companion
object
{
@JvmStatic
external
fun
_nGetX
(
ptr
:
Long
):
SVGLength
@JvmStatic
external
fun
_nGetX
(
ptr
:
Long
):
SVGLength
@JvmStatic
external
fun
_nGetY
(
ptr
:
Long
):
SVGLength
@JvmStatic
external
fun
_nGetWidth
(
ptr
:
Long
):
SVGLength
@JvmStatic
external
fun
_nGetHeight
(
ptr
:
Long
):
SVGLength
...
...
@@ -31,7 +34,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetX
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setX
(
value
)
...
...
@@ -43,7 +46,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
_nSetX
(
_ptr
,
length
.
value
,
length
.
_unit
.
ordinal
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -52,7 +55,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetY
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setY
(
value
)
...
...
@@ -64,7 +67,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
_nSetY
(
_ptr
,
length
.
value
,
length
.
_unit
.
ordinal
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -73,7 +76,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetWidth
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setWidth
(
value
)
...
...
@@ -85,7 +88,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
_nSetWidth
(
_ptr
,
length
.
value
,
length
.
_unit
.
ordinal
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -94,7 +97,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetHeight
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setHeight
(
value
)
...
...
@@ -106,7 +109,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
_nSetHeight
(
_ptr
,
length
.
value
,
length
.
_unit
.
ordinal
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -115,7 +118,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetPreserveAspectRatio
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
setPreserveAspectRatio
(
value
)
...
...
@@ -127,7 +130,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
_nSetPreserveAspectRatio
(
_ptr
,
ratio
.
_align
.
_value
,
ratio
.
_scale
.
ordinal
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -136,7 +139,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetViewBox
(
_ptr
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
set
(
value
)
{
require
(
value
!=
null
)
{
"Can't set viewBox with value == null"
}
...
...
@@ -149,7 +152,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
_nSetViewBox
(
_ptr
,
viewBox
.
left
,
viewBox
.
top
,
viewBox
.
right
,
viewBox
.
bottom
)
this
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
...
...
@@ -158,7 +161,7 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
Stats
.
onNativeCall
()
_nGetIntrinsicSize
(
_ptr
,
lc
.
width
,
lc
.
height
,
lc
.
dpi
)
}
finally
{
Reference
.
reachabilityFence
(
this
)
reachabilityBarrier
(
this
)
}
}
}
\ No newline at end of file
skiko/src/commonMain/kotlin/org/jetbrains/skia/svg/SVGTag.kt
View file @
3a68bff4
package
org.jetbrains.skia.svg
enum
class
SVGTag
{
CIRCLE
,
CLIP_PATH
,
DEFS
,
ELLIPSE
,
FE_BLEND
,
FE_COLOR_MATRIX
,
FE_COMPOSITE
,
FE_DIFFUSE_LIGHTING
,
FE_DISPLACEMENT_MAP
,
FE_DISTANT_LIGHT
,
FE_FLOOD
,
FE_GAUSSIAN_BLUR
,
FE_IMAGE
,
FE_MORPHOLOGY
,
FE_OFFSET
,
FE_POINT_LIGHT
,
FE_SPECULAR_LIGHTING
,
FE_SPOT_LIGHT
,
FE_TURBULENCE
,
FILTER
,
G
,
IMAGE
,
LINE
,
LINEAR_GRADIENT
,
MASK
,
PATH
,
PATTERN
,
POLYGON
,
POLYLINE
,
RADIAL_GRADIENT
,
RECT
,
STOP
,
SVG
,
TEXT
,
TEXT_LITERAL
,
TEXTPATH
,
TSPAN
,
USE
;
CIRCLE
,
CLIP_PATH
,
DEFS
,
ELLIPSE
,
FE_BLEND
,
FE_COLOR_MATRIX
,
FE_COMPOSITE
,
FE_DIFFUSE_LIGHTING
,
FE_DISPLACEMENT_MAP
,
FE_DISTANT_LIGHT
,
FE_FLOOD
,
FE_GAUSSIAN_BLUR
,
FE_IMAGE
,
FE_MORPHOLOGY
,
FE_OFFSET
,
FE_POINT_LIGHT
,
FE_SPECULAR_LIGHTING
,
FE_SPOT_LIGHT
,
FE_TURBULENCE
,
FILTER
,
G
,
IMAGE
,
LINE
,
LINEAR_GRADIENT
,
MASK
,
PATH
,
PATTERN
,
POLYGON
,
POLYLINE
,
RADIAL_GRADIENT
,
RECT
,
STOP
,
SVG
,
TEXT
,
TEXT_LITERAL
,
TEXTPATH
,
TSPAN
,
USE
;
}
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skia/svg/SVGTransformableNode.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skia/svg/SVGTransformableNode.kt
View file @
3a68bff4
File moved
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