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
d0a425f4
Unverified
Commit
d0a425f4
authored
Oct 04, 2021
by
Nikolay Igotti
Committed by
GitHub
Oct 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commonize more of Skiko (#234)
parent
af035822
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
199 additions
and
95 deletions
+199
-95
build.gradle.kts
samples/SkiaNativeSample/build.gradle.kts
+19
-11
build.gradle.kts
skiko/build.gradle.kts
+42
-24
GraphicsApi.kt
.../src/commonMain/kotlin/org/jetbrains/skiko/GraphicsApi.kt
+13
-0
OsArch.kt
skiko/src/commonMain/kotlin/org/jetbrains/skiko/OsArch.kt
+39
-0
Redrawer.kt
...ommonMain/kotlin/org/jetbrains/skiko/redrawer/Redrawer.kt
+0
-0
OsArch.js.kt
skiko/src/jsMain/kotlin/org/jetbrains/skiko/OsArch.js.kt
+12
-0
GraphicsApi.jvm.kt
...src/jvmMain/kotlin/org/jetbrains/skiko/GraphicsApi.jvm.kt
+0
-16
OsArch.jvm.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/OsArch.jvm.kt
+6
-24
PlatformOperations.kt
.../jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
+3
-0
RenderFactory.kt
...o/src/jvmMain/kotlin/org/jetbrains/skiko/RenderFactory.kt
+3
-0
SkikoProperties.kt
...src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
+2
-0
AbstractDirectSoftwareRedrawer.kt
...etbrains/skiko/redrawer/AbstractDirectSoftwareRedrawer.kt
+0
-1
PlatformOperations.macos.kt
...in/org/jetbrains/skiko/native/PlatformOperations.macos.kt
+14
-0
MacOsOpenGLRedrawer.kt
...otlin/org/jetbrains/skiko/redrawer/MacOsOpenGLRedrawer.kt
+1
-0
GraphicsApi.kt
.../src/nativeMain/kotlin/org/jetbrains/skiko/GraphicsApi.kt
+0
-6
OsArch.native.kt
...rc/nativeMain/kotlin/org/jetbrains/skiko/OsArch.native.kt
+25
-0
HardwareLayer.kt
...veMain/kotlin/org/jetbrains/skiko/native/HardwareLayer.kt
+0
-0
PlatformOperations.kt
...n/kotlin/org/jetbrains/skiko/native/PlatformOperations.kt
+15
-0
SkiaLayer.kt
...nativeMain/kotlin/org/jetbrains/skiko/native/SkiaLayer.kt
+3
-4
SkiaLayerProperties.kt
.../kotlin/org/jetbrains/skiko/native/SkiaLayerProperties.kt
+0
-0
SkiaWindow.kt
...ativeMain/kotlin/org/jetbrains/skiko/native/SkiaWindow.kt
+0
-0
SkikoProperties.kt
...Main/kotlin/org/jetbrains/skiko/native/SkikoProperties.kt
+2
-0
Redrawer.kt
...ativeMain/kotlin/org/jetbrains/skiko/redrawer/Redrawer.kt
+0
-9
No files found.
samples/SkiaNativeSample/build.gradle.kts
View file @
d0a425f4
...
@@ -2,6 +2,8 @@ plugins {
...
@@ -2,6 +2,8 @@ plugins {
kotlin
(
"multiplatform"
)
version
"1.5.31"
kotlin
(
"multiplatform"
)
version
"1.5.31"
}
}
val
coroutinesVersion
=
"1.5.2"
repositories
{
repositories
{
mavenLocal
()
mavenLocal
()
jcenter
()
jcenter
()
...
@@ -32,11 +34,9 @@ if (project.hasProperty("skiko.version")) {
...
@@ -32,11 +34,9 @@ if (project.hasProperty("skiko.version")) {
}
}
kotlin
{
kotlin
{
val
nativeTarget
=
when
(
target
)
{
val
nativeTarget
=
when
{
"macos-x64"
->
macosX64
()
osName
==
"Mac OS X"
->
macosX64
()
"macos-arm64"
->
macosArm64
()
osName
.
startsWith
(
"Win"
)
->
mingwX64
()
osName
.
startsWith
(
"Linux"
)
->
linuxX64
()
else
->
throw
GradleException
(
"Host OS is not supported in Kotlin/Native."
)
else
->
throw
GradleException
(
"Host OS is not supported in Kotlin/Native."
)
}
}
...
@@ -53,20 +53,28 @@ kotlin {
...
@@ -53,20 +53,28 @@ kotlin {
val
commonMain
by
getting
{
val
commonMain
by
getting
{
dependencies
{
dependencies
{
implementation
(
"org.jetbrains.skiko:skiko:$version"
)
implementation
(
"org.jetbrains.skiko:skiko:$version"
)
implementation
(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
)
}
}
}
}
val
nativeMain
by
creating
{
val
nativeMain
by
creating
{
dependsOn
(
commonMain
)
dependsOn
(
commonMain
)
dependencies
{
}
}
}
val
macosX64Main
by
getting
{
val
archTargetMain
=
when
(
target
)
{
dependsOn
(
nativeMain
)
"macos-x64"
->
{
dependencies
{
val
macosX64Main
by
getting
{
implementation
(
"org.jetbrains.kotlinx:kotlinx-coroutines-core-macosx64:1.5.2"
)
dependsOn
(
nativeMain
)
}
macosX64Main
}
"macos-arm64"
->
{
val
macosArm64Main
by
getting
{
dependsOn
(
nativeMain
)
}
macosArm64Main
}
}
else
->
throw
GradleException
(
"Host OS is not supported in Kotlin/Native."
)
}
}
}
}
}
}
skiko/build.gradle.kts
View file @
d0a425f4
...
@@ -207,26 +207,28 @@ kotlin {
...
@@ -207,26 +207,28 @@ kotlin {
}
}
if
(
supportNative
)
{
if
(
supportNative
)
{
val
targetString
=
target
val
skiaDir
=
skiaDir
.
get
().
absolutePath
val
skiaDir
=
skiaDir
.
get
().
absolutePath
val
nativeTarget
=
when
(
targetString
)
{
val
nativeTarget
=
when
(
target
)
{
"macos-x64"
,
"macos-arm64"
->
macosX64
{
"macos-x64"
->
macosX64
{}
compilations
.
all
{
"macos-arm64"
->
macosArm64
{}
kotlinOptions
{
else
->
null
freeCompilerArgs
+=
listOf
(
}
"-include-binary"
,
val
targetString
=
target
"$skiaDir/$skiaBinSubdir/libskia.a"
,
nativeTarget
?.
let
{
"-include-binary"
,
it
.
compilations
.
all
{
"$skiaDir/$skiaBinSubdir/libskshaper.a"
,
kotlinOptions
{
"-include-binary"
,
freeCompilerArgs
+=
listOf
(
"$skiaDir/$skiaBinSubdir/libskparagraph.a"
,
"-include-binary"
,
"-include-binary"
,
"$skiaDir/$skiaBinSubdir/libskia.a"
,
"$buildDir/nativeBridges/static/$targetString/skiko-native-bridges-$targetString.a"
"-include-binary"
,
)
"$skiaDir/$skiaBinSubdir/libskshaper.a"
,
}
"-include-binary"
,
"$skiaDir/$skiaBinSubdir/libskparagraph.a"
,
"-include-binary"
,
"$buildDir/nativeBridges/static/$targetString/skiko-native-bridges-$targetString.a"
)
}
}
}
}
else
->
null
}
}
}
}
...
@@ -267,14 +269,30 @@ kotlin {
...
@@ -267,14 +269,30 @@ kotlin {
if
(
supportNative
)
{
if
(
supportNative
)
{
// See https://kotlinlang.org/docs/mpp-share-on-platforms.html#configure-the-hierarchical-structure-manually
// See https://kotlinlang.org/docs/mpp-share-on-platforms.html#configure-the-hierarchical-structure-manually
val
nativeMain
by
creating
{}
val
nativeMain
by
creating
{
val
macosMain
by
creating
{
dependsOn
(
commonMain
)
dependsOn
(
nativeMain
)
}
val
macosX64Main
by
getting
{
dependsOn
(
macosMain
)
dependencies
{
dependencies
{
implementation
(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
)
implementation
(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
)
}
}
if
(
targetOs
==
OS
.
MacOS
)
{
val
macosMain
by
creating
{
dependsOn
(
nativeMain
)
}
val
macosArchMain
=
when
(
targetArch
)
{
Arch
.
X64
->
{
val
macosX64Main
by
getting
{
dependsOn
(
macosMain
)
}
macosX64Main
}
Arch
.
Arm64
->
{
val
macosArm64Main
by
getting
{
dependsOn
(
macosMain
)
}
macosArm64Main
}
else
->
throw
GradleException
(
"Unsupported arch $targetArch for macOS"
)
}
}
}
}
}
}
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skiko/GraphicsApi.kt
0 → 100644
View file @
d0a425f4
package
org.jetbrains.skiko
enum
class
GraphicsApi
{
UNKNOWN
,
SOFTWARE
,
DIRECT_SOFTWARE
,
OPENGL
,
DIRECT3D
,
VULKAN
,
METAL
,
WEBGL
}
enum
class
GpuPriority
(
val
value
:
String
)
{
Auto
(
"auto"
),
Integrated
(
"integrated"
),
Discrete
(
"discrete"
);
companion
object
{
fun
parse
(
value
:
String
?):
GpuPriority
?
=
GpuPriority
.
values
().
find
{
it
.
value
==
value
}
}
}
skiko/src/commonMain/kotlin/org/jetbrains/skiko/OsArch.kt
0 → 100644
View file @
d0a425f4
package
org.jetbrains.skiko
enum
class
OS
(
val
id
:
String
)
{
Linux
(
"linux"
),
Windows
(
"windows"
),
MacOS
(
"macos"
),
JS
(
"js"
)
;
val
isLinux
get
()
=
this
==
Linux
val
isWindows
get
()
=
this
==
Windows
val
isMacOS
get
()
=
this
==
MacOS
}
enum
class
Arch
(
val
id
:
String
)
{
X64
(
"x64"
),
Arm64
(
"arm64"
),
JS
(
"js"
),
WASM
(
"wasm"
)
}
enum
class
KotlinBackend
(
val
id
:
String
)
{
JVM
(
"jvm"
),
JS
(
"js"
),
Native
(
"native"
)
}
expect
val
hostOs
:
OS
expect
val
hostArch
:
Arch
expect
val
hostId
:
String
expect
val
kotlinBackend
:
KotlinBackend
\ No newline at end of file
skiko/src/
jvm
Main/kotlin/org/jetbrains/skiko/redrawer/Redrawer.kt
→
skiko/src/
common
Main/kotlin/org/jetbrains/skiko/redrawer/Redrawer.kt
View file @
d0a425f4
File moved
skiko/src/jsMain/kotlin/org/jetbrains/skiko/OsArch.js.kt
0 → 100644
View file @
d0a425f4
package
org.jetbrains.skiko
actual
val
hostOs
:
OS
=
OS
.
JS
actual
val
hostArch
:
Arch
=
Arch
.
JS
actual
val
hostId
by
lazy
{
"${hostOs.id}-${hostArch.id}"
}
actual
val
kotlinBackend
:
KotlinBackend
get
()
=
KotlinBackend
.
JS
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/GraphicsApi.kt
→
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/GraphicsApi.
jvm.
kt
View file @
d0a425f4
package
org.jetbrains.skiko
package
org.jetbrains.skiko
import
org.jetbrains.skiko.redrawer.Redrawer
import
org.jetbrains.skiko.redrawer.WindowsOpenGLRedrawer
import
org.jetbrains.skiko.redrawer.LinuxOpenGLRedrawer
enum
class
GraphicsApi
{
UNKNOWN
,
SOFTWARE
,
DIRECT_SOFTWARE
,
OPENGL
,
DIRECT3D
,
VULKAN
,
METAL
}
enum
class
GpuPriority
(
val
value
:
String
)
{
Auto
(
"auto"
),
Integrated
(
"integrated"
),
Discrete
(
"discrete"
);
companion
object
{
fun
parse
(
value
:
String
?):
GpuPriority
?
=
GpuPriority
.
values
().
find
{
it
.
value
==
value
}
}
}
private
val
notSupportedAdapters
by
lazy
{
private
val
notSupportedAdapters
by
lazy
{
val
resource
=
SkiaLayer
::
class
.
java
.
getResource
(
"/not-supported-adapter.list"
).
readText
()
val
resource
=
SkiaLayer
::
class
.
java
.
getResource
(
"/not-supported-adapter.list"
).
readText
()
resource
.
split
(
";"
).
map
{
it
.
trim
()
}
resource
.
split
(
";"
).
map
{
it
.
trim
()
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/OsArch.kt
→
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/OsArch.
jvm.
kt
View file @
d0a425f4
package
org.jetbrains.skiko
package
org.jetbrains.skiko
enum
class
OS
(
val
id
:
String
)
{
actual
val
hostOs
:
OS
by
lazy
{
Linux
(
"linux"
),
Windows
(
"windows"
),
MacOS
(
"macos"
)
;
val
isLinux
get
()
=
this
==
Linux
val
isWindows
get
()
=
this
==
Windows
val
isMacOS
get
()
=
this
==
MacOS
}
enum
class
Arch
(
val
id
:
String
)
{
X64
(
"x64"
),
Arm64
(
"arm64"
)
}
val
hostOs
by
lazy
{
val
osName
=
System
.
getProperty
(
"os.name"
)
val
osName
=
System
.
getProperty
(
"os.name"
)
when
{
when
{
osName
==
"Mac OS X"
->
OS
.
MacOS
osName
==
"Mac OS X"
->
OS
.
MacOS
...
@@ -31,7 +10,7 @@ val hostOs by lazy {
...
@@ -31,7 +10,7 @@ val hostOs by lazy {
}
}
}
}
val
host
Arch
by
lazy
{
actual
val
hostArch
:
Arch
by
lazy
{
val
osArch
=
System
.
getProperty
(
"os.arch"
)
val
osArch
=
System
.
getProperty
(
"os.arch"
)
when
(
osArch
)
{
when
(
osArch
)
{
"x86_64"
,
"amd64"
->
Arch
.
X64
"x86_64"
,
"amd64"
->
Arch
.
X64
...
@@ -40,7 +19,7 @@ val hostArch by lazy {
...
@@ -40,7 +19,7 @@ val hostArch by lazy {
}
}
}
}
val
hostId
by
lazy
{
actual
val
hostId
by
lazy
{
"${hostOs.id}-${hostArch.id}"
"${hostOs.id}-${hostArch.id}"
}
}
...
@@ -55,3 +34,6 @@ internal val javaVendor by lazy {
...
@@ -55,3 +34,6 @@ internal val javaVendor by lazy {
internal
val
javaLocation
by
lazy
{
internal
val
javaLocation
by
lazy
{
"${System.getProperty("
java
.
home
")}"
"${System.getProperty("
java
.
home
")}"
}
}
actual
val
kotlinBackend
:
KotlinBackend
get
()
=
KotlinBackend
.
JVM
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
View file @
d0a425f4
...
@@ -85,6 +85,9 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -85,6 +85,9 @@ internal val platformOperations: PlatformOperations by lazy {
}
}
}
}
}
}
OS
.
JS
->
{
TODO
(
"Commonize me"
)
}
}
}
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/RenderFactory.kt
View file @
d0a425f4
...
@@ -43,6 +43,9 @@ internal interface RenderFactory {
...
@@ -43,6 +43,9 @@ internal interface RenderFactory {
GraphicsApi
.
DIRECT_SOFTWARE
->
LinuxSoftwareRedrawer
(
layer
,
properties
)
GraphicsApi
.
DIRECT_SOFTWARE
->
LinuxSoftwareRedrawer
(
layer
,
properties
)
else
->
LinuxOpenGLRedrawer
(
layer
,
properties
)
else
->
LinuxOpenGLRedrawer
(
layer
,
properties
)
}
}
OS
.
JS
->
{
TODO
(
"Commonize me"
)
}
}
}
}
}
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
View file @
d0a425f4
...
@@ -56,6 +56,7 @@ internal object SkikoProperties {
...
@@ -56,6 +56,7 @@ internal object SkikoProperties {
OS
.
MacOS
->
return
GraphicsApi
.
METAL
OS
.
MacOS
->
return
GraphicsApi
.
METAL
OS
.
Linux
->
return
GraphicsApi
.
OPENGL
OS
.
Linux
->
return
GraphicsApi
.
OPENGL
OS
.
Windows
->
return
GraphicsApi
.
DIRECT3D
OS
.
Windows
->
return
GraphicsApi
.
DIRECT3D
OS
.
JS
->
TODO
(
"commonize me"
)
}
}
}
}
...
@@ -67,6 +68,7 @@ internal object SkikoProperties {
...
@@ -67,6 +68,7 @@ internal object SkikoProperties {
OS
.
Linux
->
renderApiList
=
mutableListOf
(
GraphicsApi
.
OPENGL
,
GraphicsApi
.
DIRECT_SOFTWARE
,
GraphicsApi
.
SOFTWARE
)
OS
.
Linux
->
renderApiList
=
mutableListOf
(
GraphicsApi
.
OPENGL
,
GraphicsApi
.
DIRECT_SOFTWARE
,
GraphicsApi
.
SOFTWARE
)
OS
.
MacOS
->
renderApiList
=
mutableListOf
(
GraphicsApi
.
METAL
,
GraphicsApi
.
SOFTWARE
)
OS
.
MacOS
->
renderApiList
=
mutableListOf
(
GraphicsApi
.
METAL
,
GraphicsApi
.
SOFTWARE
)
OS
.
Windows
->
renderApiList
=
mutableListOf
(
GraphicsApi
.
DIRECT3D
,
GraphicsApi
.
OPENGL
,
GraphicsApi
.
DIRECT_SOFTWARE
,
GraphicsApi
.
SOFTWARE
)
OS
.
Windows
->
renderApiList
=
mutableListOf
(
GraphicsApi
.
DIRECT3D
,
GraphicsApi
.
OPENGL
,
GraphicsApi
.
DIRECT_SOFTWARE
,
GraphicsApi
.
SOFTWARE
)
OS
.
JS
->
TODO
(
"commonize me"
)
}
}
renderApiList
.
remove
(
head
)
renderApiList
.
remove
(
head
)
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/AbstractDirectSoftwareRedrawer.kt
View file @
d0a425f4
...
@@ -5,7 +5,6 @@ import kotlinx.coroutines.*
...
@@ -5,7 +5,6 @@ import kotlinx.coroutines.*
import
kotlinx.coroutines.swing.Swing
import
kotlinx.coroutines.swing.Swing
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.FrameLimiter
import
org.jetbrains.skiko.FrameLimiter
import
org.jetbrains.skiko.hostOs
import
org.jetbrains.skiko.SkiaLayer
import
org.jetbrains.skiko.SkiaLayer
import
org.jetbrains.skiko.SkiaLayerProperties
import
org.jetbrains.skiko.SkiaLayerProperties
...
...
skiko/src/macosMain/kotlin/org/jetbrains/skiko/native/PlatformOperations.macos.kt
0 → 100644
View file @
d0a425f4
package
org.jetbrains.skiko.native
import
org.jetbrains.skiko.GraphicsApi
import
org.jetbrains.skiko.native.redrawer.MacOsOpenGLRedrawer
internal
actual
fun
makePlatformOperations
():
PlatformOperations
{
return
object
:
PlatformOperations
{
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
properties
:
SkiaLayerProperties
)
=
when
(
SkikoProperties
.
renderApi
)
{
GraphicsApi
.
OPENGL
->
MacOsOpenGLRedrawer
(
layer
,
properties
)
else
->
error
(
"No other renderings for native yet"
)
}
}
}
\ No newline at end of file
skiko/src/macosMain/kotlin/org/jetbrains/skiko/redrawer/MacOsOpenGLRedrawer.kt
View file @
d0a425f4
...
@@ -3,6 +3,7 @@ package org.jetbrains.skiko.native.redrawer
...
@@ -3,6 +3,7 @@ package org.jetbrains.skiko.native.redrawer
import
kotlinx.cinterop.CPointer
import
kotlinx.cinterop.CPointer
import
kotlinx.cinterop.useContents
import
kotlinx.cinterop.useContents
import
org.jetbrains.skiko.native.*
import
org.jetbrains.skiko.native.*
import
org.jetbrains.skiko.redrawer.Redrawer
import
platform.CoreFoundation.CFTimeInterval
import
platform.CoreFoundation.CFTimeInterval
import
platform.CoreGraphics.CGRectMake
import
platform.CoreGraphics.CGRectMake
import
platform.CoreVideo.CVTimeStamp
import
platform.CoreVideo.CVTimeStamp
...
...
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/GraphicsApi.kt
deleted
100644 → 0
View file @
af035822
// TODO: Commonize! This is a complete copy of jvm counterpart.
package
org.jetbrains.skiko.native
enum
class
GraphicsApi
{
UNKNOWN
,
SOFTWARE
,
OPENGL
,
DIRECT3D
,
VULKAN
,
METAL
}
\ No newline at end of file
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/OsArch.native.kt
0 → 100644
View file @
d0a425f4
package
org.jetbrains.skiko
actual
val
hostOs
:
OS
by
lazy
{
when
(
Platform
.
osFamily
)
{
OsFamily
.
MACOSX
->
OS
.
MacOS
OsFamily
.
LINUX
->
OS
.
Linux
OsFamily
.
WINDOWS
->
OS
.
Windows
else
->
throw
Error
(
"Unsupported OS ${Platform.osFamily}"
)
}
}
actual
val
hostArch
:
Arch
by
lazy
{
when
(
Platform
.
cpuArchitecture
)
{
CpuArchitecture
.
X64
->
Arch
.
X64
CpuArchitecture
.
ARM64
->
Arch
.
Arm64
else
->
throw
Error
(
"Unsupported arch ${Platform.cpuArchitecture}"
)
}
}
actual
val
hostId
by
lazy
{
"${hostOs.id}-${hostArch.id}"
}
actual
val
kotlinBackend
:
KotlinBackend
get
()
=
KotlinBackend
.
Native
\ No newline at end of file
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
→
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/
native/
HardwareLayer.kt
View file @
d0a425f4
File moved
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
→
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/
native/
PlatformOperations.kt
View file @
d0a425f4
package
org.jetbrains.skiko.native
package
org.jetbrains.skiko.native
import
org.jetbrains.skiko.native.*
import
org.jetbrains.skiko.redrawer.Redrawer
import
org.jetbrains.skiko.native.SkikoProperties.renderApi
import
org.jetbrains.skiko.native.redrawer.*
internal
interface
PlatformOperations
{
internal
interface
PlatformOperations
{
fun
createRedrawer
(
layer
:
HardwareLayer
,
properties
:
SkiaLayerProperties
):
Redrawer
fun
createRedrawer
(
layer
:
HardwareLayer
,
properties
:
SkiaLayerProperties
):
Redrawer
}
}
// TODO: commonize more.
internal
val
platformOperations
:
PlatformOperations
by
lazy
{
internal
val
platformOperations
:
PlatformOperations
by
lazy
{
object
:
PlatformOperations
{
makePlatformOperations
()
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
properties
:
SkiaLayerProperties
)
=
when
(
renderApi
)
{
GraphicsApi
.
OPENGL
->
MacOsOpenGLRedrawer
(
layer
,
properties
)
else
->
error
(
"No software rendering for native yet"
)
}
}
}
}
internal
expect
fun
makePlatformOperations
():
PlatformOperations
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
→
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/
native/
SkiaLayer.kt
View file @
d0a425f4
package
org.jetbrains.skiko.native
package
org.jetbrains.skiko.native
import
kotlinx.cinterop.pointed
import
kotlinx.cinterop.useContents
import
kotlinx.cinterop.useContents
import
org.jetbrains.skiko.native.context.*
import
org.jetbrains.skiko.native.context.*
import
org.jetbrains.skiko.native.redrawer.*
import
org.jetbrains.skia.*
import
org.jetbrains.skia.*
import
org.jetbrains.skiko.redrawer.Redrawer
interface
SkiaRenderer
{
interface
SkiaRenderer
{
fun
onRender
(
canvas
:
Canvas
,
width
:
Int
,
height
:
Int
,
nanoTime
:
Long
)
fun
onRender
(
canvas
:
Canvas
,
width
:
Int
,
height
:
Int
,
nanoTime
:
Long
)
...
@@ -54,10 +53,10 @@ open class SkiaLayer(
...
@@ -54,10 +53,10 @@ open class SkiaLayer(
val
pictureHeight
=
(
height
*
contentScale
).
coerceAtLeast
(
0.0
)
val
pictureHeight
=
(
height
*
contentScale
).
coerceAtLeast
(
0.0
)
val
bounds
=
Rect
.
makeWH
(
pictureWidth
.
toFloat
(),
pictureHeight
.
toFloat
())
val
bounds
=
Rect
.
makeWH
(
pictureWidth
.
toFloat
(),
pictureHeight
.
toFloat
())
val
canvas
=
pictureRecorder
.
beginRecording
(
bounds
)
!!
val
canvas
=
pictureRecorder
.
beginRecording
(
bounds
)
renderer
?.
onRender
(
canvas
,
pictureWidth
.
toInt
(),
pictureHeight
.
toInt
(),
nanoTime
)
renderer
?.
onRender
(
canvas
,
pictureWidth
.
toInt
(),
pictureHeight
.
toInt
(),
nanoTime
)
val
picture
=
pictureRecorder
.
finishRecordingAsPicture
()
!!
val
picture
=
pictureRecorder
.
finishRecordingAsPicture
()
this
.
picture
=
PictureHolder
(
picture
,
pictureWidth
.
toInt
(),
pictureHeight
.
toInt
())
this
.
picture
=
PictureHolder
(
picture
,
pictureWidth
.
toInt
(),
pictureHeight
.
toInt
())
}
}
...
...
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/SkiaLayerProperties.kt
→
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/
native/
SkiaLayerProperties.kt
View file @
d0a425f4
File moved
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/SkiaWindow.kt
→
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/
native/
SkiaWindow.kt
View file @
d0a425f4
File moved
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/SkikoProperties.kt
→
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/
native/
SkikoProperties.kt
View file @
d0a425f4
package
org.jetbrains.skiko.native
package
org.jetbrains.skiko.native
import
org.jetbrains.skiko.GraphicsApi
// TODO: jvm version uses java properties here.
// TODO: jvm version uses java properties here.
// there is no properties support available for native.
// there is no properties support available for native.
internal
object
SkikoProperties
{
internal
object
SkikoProperties
{
...
...
skiko/src/nativeMain/kotlin/org/jetbrains/skiko/redrawer/Redrawer.kt
deleted
100644 → 0
View file @
af035822
package
org.jetbrains.skiko.native.redrawer
// TODO: this is exact copy of jvm counterpart. Commonize!
interface
Redrawer
{
fun
dispose
()
fun
needRedraw
()
fun
redrawImmediately
()
fun
syncSize
()
=
Unit
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment