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
edc9b1c1
Commit
edc9b1c1
authored
Aug 17, 2020
by
Nikolay Igotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ICU loader.
parent
9b66885d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
5 deletions
+51
-5
loader.diff
loader.diff
+15
-0
App.kt
...kijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
+15
-0
build.gradle.kts
skiko/build.gradle.kts
+7
-2
Library.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
+14
-3
No files found.
loader.diff
0 → 100644
View file @
edc9b1c1
diff --git a/third_party/icu/SkLoadICU.cpp b/third_party/icu/SkLoadICU.cpp
index ac7ba0c15d..2b445e286e 100644
--- a/third_party/icu/SkLoadICU.cpp
+++ b/third_party/icu/SkLoadICU.cpp
@@ -69,7 +69,9 @@ static bool init_icu(void* addr) {
}
static std::string executable_directory() {
- HMODULE hModule = GetModuleHandleA(NULL);
+ HMODULE hModule = NULL;
+ GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ reinterpret_cast<LPCSTR>(&executable_directory), &hModule);
char path[MAX_PATH];
GetModuleFileNameA(hModule, path, MAX_PATH);
const char* end = strrchr(path, '\\');
samples/SkijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
View file @
edc9b1c1
...
@@ -10,6 +10,10 @@ import org.jetbrains.skiko.SkiaRenderer
...
@@ -10,6 +10,10 @@ import org.jetbrains.skiko.SkiaRenderer
import
java.awt.event.MouseMotionAdapter
import
java.awt.event.MouseMotionAdapter
import
kotlin.math.cos
import
kotlin.math.cos
import
kotlin.math.sin
import
kotlin.math.sin
import
org.jetbrains.skija.paragraph.FontCollection
import
org.jetbrains.skija.paragraph.ParagraphBuilder
import
org.jetbrains.skija.paragraph.ParagraphStyle
import
org.jetbrains.skija.paragraph.TextStyle
fun
main
(
args
:
Array
<
String
>)
{
fun
main
(
args
:
Array
<
String
>)
{
createWindow
(
"First window"
);
createWindow
(
"First window"
);
...
@@ -117,4 +121,15 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, xpos: Int, ypos: I
...
@@ -117,4 +121,15 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, xpos: Int, ypos: I
}
}
val
text
=
"${state.text} ${state.frame++}!"
val
text
=
"${state.text} ${state.frame++}!"
canvas
.
drawString
(
text
,
xpos
.
toFloat
(),
ypos
.
toFloat
(),
renderer
.
font
,
renderer
.
paint
)
canvas
.
drawString
(
text
,
xpos
.
toFloat
(),
ypos
.
toFloat
(),
renderer
.
font
,
renderer
.
paint
)
val
fontCollection
=
FontCollection
()
.
setDefaultFontManager
(
FontMgr
.
getDefault
())
val
style
=
ParagraphStyle
()
val
paragraph
=
ParagraphBuilder
(
style
,
fontCollection
)
.
pushStyle
(
TextStyle
().
setColor
(
0
xFF000000
.
toInt
()))
.
addText
(
"Text"
)
.
popStyle
()
.
build
()
paragraph
.
layout
(
Float
.
POSITIVE_INFINITY
)
paragraph
.
paint
(
canvas
,
0f
,
0f
)
}
}
skiko/build.gradle.kts
View file @
edc9b1c1
...
@@ -13,7 +13,7 @@ version = when {
...
@@ -13,7 +13,7 @@ version = when {
else
->
project
.
property
(
"deploy.version"
)
as
String
else
->
project
.
property
(
"deploy.version"
)
as
String
}
}
val
skiaDir
=
System
.
getenv
(
"SKIA_DIR"
)
?:
"/Users/igotti/compose/skija/third_party/skia
"
val
skiaDir
=
System
.
getenv
(
"SKIA_DIR"
)
?:
System
.
getProperty
(
"skia.dir"
)
?:
"PLEASE_SET_SKIA_DIR
"
val
hostOs
=
System
.
getProperty
(
"os.name"
)
val
hostOs
=
System
.
getProperty
(
"os.name"
)
val
target
=
when
{
val
target
=
when
{
hostOs
==
"Mac OS X"
->
"macos"
hostOs
==
"Mac OS X"
->
"macos"
...
@@ -249,7 +249,12 @@ val skikoJvmJar: Provider<Jar> by tasks.registering(Jar::class) {
...
@@ -249,7 +249,12 @@ val skikoJvmJar: Provider<Jar> by tasks.registering(Jar::class) {
val
skikoJvmRuntimeJar
by
project
.
tasks
.
registering
(
Jar
::
class
)
{
val
skikoJvmRuntimeJar
by
project
.
tasks
.
registering
(
Jar
::
class
)
{
archiveBaseName
.
set
(
"skiko-$target"
)
archiveBaseName
.
set
(
"skiko-$target"
)
from
(
skikoJvmJar
.
map
{
zipTree
(
it
.
archiveFile
)
})
from
(
skikoJvmJar
.
map
{
zipTree
(
it
.
archiveFile
)
})
from
(
project
.
tasks
.
named
(
"linkRelease${target.capitalize()}"
).
map
{
it
.
outputs
.
files
.
filter
{
it
.
isFile
}})
from
(
project
.
tasks
.
named
(
"linkRelease${target.capitalize()}"
).
map
{
it
.
outputs
.
files
.
filter
{
it
.
isFile
}
})
if
(
target
==
"windows"
)
{
from
(
files
(
"$skiaDir/out/Release-x64/icudtl.dat"
))
}
}
}
project
.
tasks
.
register
<
JavaExec
>(
"run"
)
{
project
.
tasks
.
register
<
JavaExec
>(
"run"
)
{
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
View file @
edc9b1c1
...
@@ -3,7 +3,6 @@ package org.jetbrains.skiko
...
@@ -3,7 +3,6 @@ package org.jetbrains.skiko
import
java.io.File
import
java.io.File
import
java.nio.file.Files
import
java.nio.file.Files
import
java.nio.file.StandardCopyOption
import
java.nio.file.StandardCopyOption
import
java.util.*
// based on https://github.com/JetBrains/skija/blob/bc6e0531021e4ff839c07196e0336d6456ed7520/src/main/java/org/jetbrains/skija/Library.java
// based on https://github.com/JetBrains/skija/blob/bc6e0531021e4ff839c07196e0336d6456ed7520/src/main/java/org/jetbrains/skija/Library.java
object
Library
{
object
Library
{
...
@@ -16,18 +15,30 @@ object Library {
...
@@ -16,18 +15,30 @@ object Library {
val
libFileName
=
System
.
mapLibraryName
(
name
)
val
libFileName
=
System
.
mapLibraryName
(
name
)
val
url
=
Library
::
class
.
java
.
getResource
(
resourcePath
+
libFileName
)
val
url
=
Library
::
class
.
java
.
getResource
(
resourcePath
+
libFileName
)
val
tempRoot
=
File
(
System
.
getProperty
(
"java.io.tmpdir"
))
val
tempDir
=
tempRoot
.
resolve
(
"skiko_"
+
System
.
nanoTime
()).
apply
{
mkdirs
()
}
val
libFile
=
when
{
val
libFile
=
when
{
url
==
null
->
error
(
"Library $libFileName is not found in $resourcePath"
)
url
==
null
->
error
(
"Library $libFileName is not found in $resourcePath"
)
url
.
protocol
==
"file"
->
File
(
url
.
toURI
())
url
.
protocol
==
"file"
->
File
(
url
.
toURI
())
else
->
url
.
openStream
().
use
{
input
->
else
->
url
.
openStream
().
use
{
input
->
val
tempRoot
=
File
(
System
.
getProperty
(
"java.io.tmpdir"
))
val
tempDir
=
tempRoot
.
resolve
(
"skiko_"
+
System
.
nanoTime
()).
apply
{
mkdirs
()
}
File
(
tempDir
,
libFileName
).
also
{
File
(
tempDir
,
libFileName
).
also
{
it
.
deleteOnExit
()
it
.
deleteOnExit
()
Files
.
copy
(
input
,
it
.
toPath
(),
StandardCopyOption
.
REPLACE_EXISTING
)
Files
.
copy
(
input
,
it
.
toPath
(),
StandardCopyOption
.
REPLACE_EXISTING
)
}
}
}
}
}
}
val
loadIcu
=
System
.
getProperty
(
"os.name"
).
toLowerCase
().
startsWith
(
"win"
)
val
icuData
=
"icudtl.dat"
if
(
loadIcu
)
{
val
icuUrl
=
Library
::
class
.
java
.
getResource
(
resourcePath
+
icuData
)
icuUrl
.
openStream
().
use
{
input
->
File
(
tempDir
,
icuData
).
also
{
it
.
deleteOnExit
()
Files
.
copy
(
input
,
it
.
toPath
(),
StandardCopyOption
.
REPLACE_EXISTING
)
}
}
}
System
.
load
(
libFile
.
absolutePath
)
System
.
load
(
libFile
.
absolutePath
)
loaded
=
true
loaded
=
true
}
}
...
...
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