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
4158afd8
Commit
4158afd8
authored
Aug 18, 2020
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Plain Diff
Moved noerasebackground property to Library.load
parents
7bcf714c
5e28f92a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
5 deletions
+99
-5
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
loader.diff
third_party/loader.diff
+63
-0
No files found.
samples/SkijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
View file @
4158afd8
...
@@ -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 @
4158afd8
...
@@ -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 @
4158afd8
...
@@ -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
...
...
third_party/loader.diff
0 → 100644
View file @
4158afd8
diff --git a/include/private/SkPathRef.h b/include/private/SkPathRef.h
index f9533d7261..9c178fb69f 100644
--- a/include/private/SkPathRef.h
+++ b/include/private/SkPathRef.h
@@ -8,6 +8,8 @@
#ifndef SkPathRef_DEFINED
#define SkPathRef_DEFINED
+#include <tuple>
+
#include "include/core/SkMatrix.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
diff --git a/third_party/icu/SkLoadICU.cpp b/third_party/icu/SkLoadICU.cpp
index ac7ba0c15d..b41af4e85a 100644
--- a/third_party/icu/SkLoadICU.cpp
+++ b/third_party/icu/SkLoadICU.cpp
@@ -68,6 +68,16 @@ static bool init_icu(void* addr) {
return true;
}
+static std::string library_directory() {
+ HMODULE hModule = NULL;
+ GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ reinterpret_cast<LPCSTR>(&library_directory), &hModule);
+ char path[MAX_PATH];
+ GetModuleFileNameA(hModule, path, MAX_PATH);
+ const char* end = strrchr(path, '\\');
+ return end ? std::string(path, end - path) : std::string();
+}
+
static std::string executable_directory() {
HMODULE hModule = GetModuleHandleA(NULL);
char path[MAX_PATH];
@@ -76,17 +86,21 @@ static std::string executable_directory() {
return end ? std::string(path, end - path) : std::string();
}
+static bool load_from(const std::string& dir) {
+ auto sPath = dir + "\\icudtl.dat";
+ if (void* addr = win_mmap(sPath.c_str())) {
+ if (init_icu(addr)) {
+ return true;
+ }
+ }
+ return false;
+}
+
bool SkLoadICU() {
static bool good = false;
static std::once_flag flag;
std::call_once(flag, []() {
- std::string sPath = executable_directory();
- sPath += "\\icudtl.dat";
- if (void* addr = win_mmap(sPath.c_str())) {
- if (init_icu(addr)) {
- good = true;
- }
- }
+ good = load_from(executable_directory()) || load_from(library_directory());
});
return good;
}
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