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
4aab7c3a
Commit
4aab7c3a
authored
Aug 06, 2020
by
Nikolay Igotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor tweaks to native code.
parent
c83d06cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
26 deletions
+58
-26
build.gradle.kts
skiko/build.gradle.kts
+4
-3
jawt.cc
skiko/src/jvmMain/cpp/common/jawt.cc
+51
-20
SkiaWindow.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaWindow.kt
+2
-2
drawlayer.m
skiko/src/jvmMain/objectiveC/macos/drawlayer.m
+1
-1
No files found.
skiko/build.gradle.kts
View file @
4aab7c3a
...
@@ -77,6 +77,10 @@ kotlin {
...
@@ -77,6 +77,10 @@ kotlin {
}
}
}
}
tasks
.
withType
(
JavaCompile
::
class
.
java
).
configureEach
{
this
.
getOptions
().
compilerArgs
.
addAll
(
listOf
(
"-source"
,
"11"
,
"-target"
,
"11"
))
}
// See https://docs.gradle.org/current/userguide/cpp_library_plugin.html.
// See https://docs.gradle.org/current/userguide/cpp_library_plugin.html.
tasks
.
withType
(
CppCompile
::
class
.
java
).
configureEach
{
tasks
.
withType
(
CppCompile
::
class
.
java
).
configureEach
{
// Prefer 'java.home' system property to simplify overriding from Intellij.
// Prefer 'java.home' system property to simplify overriding from Intellij.
...
@@ -172,7 +176,6 @@ project.tasks.register<Exec>("objcCompile") {
...
@@ -172,7 +176,6 @@ project.tasks.register<Exec>("objcCompile") {
outputs
.
files
(
"$outDir/$objcSrc.o"
)
outputs
.
files
(
"$outDir/$objcSrc.o"
)
}
}
tasks
.
withType
(
LinkSharedLibrary
::
class
.
java
).
configureEach
{
tasks
.
withType
(
LinkSharedLibrary
::
class
.
java
).
configureEach
{
when
(
target
)
{
when
(
target
)
{
"macos"
->
{
"macos"
->
{
...
@@ -254,8 +257,6 @@ project.tasks.register<JavaExec>("run") {
...
@@ -254,8 +257,6 @@ project.tasks.register<JavaExec>("run") {
classpath
=
files
(
skikoJvmRuntimeJar
.
map
{
it
.
archiveFile
})
classpath
=
files
(
skikoJvmRuntimeJar
.
map
{
it
.
archiveFile
})
}
}
// disable unexpected native publications (default C++ publications are failing)
// disable unexpected native publications (default C++ publications are failing)
tasks
.
withType
<
AbstractPublishToMaven
>().
configureEach
{
tasks
.
withType
<
AbstractPublishToMaven
>().
configureEach
{
doFirst
{
doFirst
{
...
...
skiko/src/jvmMain/cpp/common/jawt.cc
View file @
4aab7c3a
...
@@ -10,15 +10,43 @@
...
@@ -10,15 +10,43 @@
typedef
jboolean
(
*
JAWT_GetAWT_t
)(
JNIEnv
*
,
JAWT
*
);
typedef
jboolean
(
*
JAWT_GetAWT_t
)(
JNIEnv
*
,
JAWT
*
);
#if 0
bool check(JNIEnv* env, const char* msg) {
if (env->ExceptionCheck()) {
jthrowable exception = env->ExceptionOccurred();
jclass throwableClass = env->FindClass("java/lang/Throwable");
jmethodID toStringMethod = env->GetMethodID(
throwableClass, "toString", "()Ljava/lang/String;");
jstring messageObject = (jstring) env->CallObjectMethod(exception, toStringMethod);
const char* messageString = env->GetStringUTFChars(messageObject, 0);
fprintf(stderr, "Java exception: %s\n", messageString);
env->ReleaseStringUTFChars(messageObject, messageString);
jmethodID printStackTraceMethod = env->GetMethodID(throwableClass, "printStackTrace", "()V");
env->CallVoidMethod(exception, printStackTraceMethod);
env->ExceptionClear();
}
}
#endif
void
findJdkHome
(
JNIEnv
*
env
,
char
*
path
,
int
pathLength
)
{
jclass
systemClass
=
env
->
FindClass
(
"java/lang/System"
);
jmethodID
getPropertyMethod
=
env
->
GetStaticMethodID
(
systemClass
,
"getProperty"
,
"(Ljava/lang/String;)Ljava/lang/String;"
);
jstring
javaHomeString
=
env
->
NewStringUTF
(
"java.home"
);
jstring
propertyString
=
(
jstring
)
env
->
CallStaticObjectMethod
(
systemClass
,
getPropertyMethod
,
javaHomeString
);
const
char
*
propertyChars
=
env
->
GetStringUTFChars
(
propertyString
,
0
);
snprintf
(
path
,
pathLength
,
"%s"
,
propertyChars
);
env
->
ReleaseStringUTFChars
(
propertyString
,
propertyChars
);
}
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
)
{
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
)
{
static
JAWT_GetAWT_t
func
=
nullptr
;
static
JAWT_GetAWT_t
func
=
nullptr
;
if
(
!
func
)
{
char
*
jdkHome
=
getenv
(
"JAVA_HOME"
);
if
(
!
jdkHome
)
{
fprintf
(
stderr
,
"No JAVA_HOME defined!"
);
abort
();
}
#if SK_BUILD_FOR_WIN
#if SK_BUILD_FOR_WIN
if
(
!
func
)
{
char
jdkHome
[
FILENAME_MAX
];
findJdkHome
(
env
,
jdkHome
,
sizeof
(
jdkHome
));
char
path
[
FILENAME_MAX
];
char
path
[
FILENAME_MAX
];
snprintf
(
path
,
sizeof
(
path
),
"%s
\\
bin
\\
jawt.dll"
,
jdkHome
);
snprintf
(
path
,
sizeof
(
path
),
"%s
\\
bin
\\
jawt.dll"
,
jdkHome
);
HMODULE
lib
=
LoadLibrary
(
path
);
HMODULE
lib
=
LoadLibrary
(
path
);
...
@@ -32,25 +60,28 @@ extern "C" jboolean Skiko_GetAWT(JNIEnv *env, JAWT *awt) {
...
@@ -32,25 +60,28 @@ extern "C" jboolean Skiko_GetAWT(JNIEnv *env, JAWT *awt) {
abort
();
abort
();
}
}
#else
#else
char
path
[
FILENAME_MAX
];
if
(
!
func
)
{
snprintf
(
path
,
sizeof
(
path
),
"%s/lib/libjawt%s"
,
jdkHome
,
char
jdkHome
[
FILENAME_MAX
];
findJdkHome
(
env
,
jdkHome
,
sizeof
(
jdkHome
));
char
path
[
FILENAME_MAX
];
snprintf
(
path
,
sizeof
(
path
),
"%s/lib/libjawt%s"
,
jdkHome
,
#if SK_BUILD_FOR_MAC
#if SK_BUILD_FOR_MAC
".dylib"
".dylib"
#else
#else
".so"
".so"
#endif
#endif
);
);
void
*
lib
=
dlopen
(
path
,
RTLD_LAZY
|
RTLD_GLOBAL
);
void
*
lib
=
dlopen
(
path
,
RTLD_LAZY
|
RTLD_GLOBAL
);
if
(
!
lib
)
{
if
(
!
lib
)
{
fprintf
(
stderr
,
"Cannot open %s: %s
\n
"
,
path
,
dlerror
());
fprintf
(
stderr
,
"Cannot open %s: %s
\n
"
,
path
,
dlerror
());
abort
();
abort
();
}
}
func
=
reinterpret_cast
<
JAWT_GetAWT_t
>
(
dlsym
(
lib
,
"JAWT_GetAWT"
));
func
=
reinterpret_cast
<
JAWT_GetAWT_t
>
(
dlsym
(
lib
,
"JAWT_GetAWT"
));
if
(
!
func
)
{
if
(
!
func
)
{
fprintf
(
stderr
,
"Cannot find JAWT_GetAWT in %s
\n
"
,
path
);
fprintf
(
stderr
,
"Cannot find JAWT_GetAWT in %s
\n
"
,
path
);
abort
();
abort
();
}
}
#endif
}
}
#endif
return
func
(
env
,
awt
);
return
func
(
env
,
awt
);
}
}
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaWindow.kt
View file @
4aab7c3a
...
@@ -117,6 +117,6 @@ open class SkiaWindow : JFrame() {
...
@@ -117,6 +117,6 @@ open class SkiaWindow : JFrame() {
}
}
fun
display
()
{
fun
display
()
{
layer
.
display
()
layer
.
redrawLayer
()
}
}
}
}
skiko/src/jvmMain/objectiveC/macos/drawlayer.m
View file @
4aab7c3a
...
@@ -163,7 +163,7 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_updateLayer(JNIEnv
...
@@ -163,7 +163,7 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_updateLayer(JNIEnv
jint
lock
=
0
;
jint
lock
=
0
;
NSObject
<
JAWT_SurfaceLayers
>*
dsi_mac
=
NULL
;
NSObject
<
JAWT_SurfaceLayers
>*
dsi_mac
=
NULL
;
awt
.
version
=
JAWT_VERSION_9
;
awt
.
version
=
JAWT_VERSION_9
/* | JAWT_MACOSX_USE_CALAYER */
;
result
=
Skiko_GetAWT
(
env
,
&
awt
);
result
=
Skiko_GetAWT
(
env
,
&
awt
);
assert
(
result
!=
JNI_FALSE
);
assert
(
result
!=
JNI_FALSE
);
...
...
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