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
b55efc68
Unverified
Commit
b55efc68
authored
Jun 23, 2021
by
Roman Sedaikin
Committed by
GitHub
Jun 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linux dpi (#128)
* Fix dpi scaling issue on Linux.
parent
fb3de434
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
26 deletions
+36
-26
build.gradle.kts
samples/SkijaInjectSample/build.gradle.kts
+1
-0
drawlayer.cc
skiko/src/jvmMain/cpp/linux/drawlayer.cc
+22
-5
Library.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
+1
-5
PlatformOperations.kt
.../jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
+0
-12
Setup.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Setup.kt
+12
-4
No files found.
samples/SkijaInjectSample/build.gradle.kts
View file @
b55efc68
...
@@ -52,6 +52,7 @@ val additionalArguments = mutableMapOf<String, String>()
...
@@ -52,6 +52,7 @@ val additionalArguments = mutableMapOf<String, String>()
val
casualRun
=
tasks
.
named
<
JavaExec
>(
"run"
)
{
val
casualRun
=
tasks
.
named
<
JavaExec
>(
"run"
)
{
systemProperty
(
"skiko.fps.enabled"
,
"true"
)
systemProperty
(
"skiko.fps.enabled"
,
"true"
)
systemProperty
(
"skiko.linux.autodpi"
,
"true"
)
systemProperty
(
"skiko.hardwareInfo.enabled"
,
"true"
)
systemProperty
(
"skiko.hardwareInfo.enabled"
,
"true"
)
jvmArgs
?.
add
(
"-ea"
)
jvmArgs
?.
add
(
"-ea"
)
// Use systemProperty("skiko.library.path", "/tmp") to test loader.
// Use systemProperty("skiko.library.path", "/tmp") to test loader.
...
...
skiko/src/jvmMain/cpp/linux/drawlayer.cc
View file @
b55efc68
...
@@ -55,6 +55,17 @@ extern "C"
...
@@ -55,6 +55,17 @@ extern "C"
return
1
;
return
1
;
}
}
double
getDpiScale
()
{
Display
*
display
=
XOpenDisplay
(
nullptr
);
if
(
display
!=
nullptr
)
{
double
result
=
getDpiScaleByDisplay
(
display
);
XCloseDisplay
(
display
);
return
result
;
}
else
{
return
1
;
}
}
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
,
jlong
platformInfoPtr
)
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
,
jlong
platformInfoPtr
)
{
{
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
fromJavaPointer
<
JAWT_X11DrawingSurfaceInfo
*>
(
platformInfoPtr
);
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
fromJavaPointer
<
JAWT_X11DrawingSurfaceInfo
*>
(
platformInfoPtr
);
...
@@ -67,4 +78,10 @@ extern "C"
...
@@ -67,4 +78,10 @@ extern "C"
return
2
;
return
2
;
}
}
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_SetupKt_linuxGetSystemDpiScale
(
JNIEnv
*
env
,
jobject
layer
)
{
return
(
float
)
getDpiScale
();
}
}
// extern "C"
}
// extern "C"
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Library.kt
View file @
b55efc68
...
@@ -79,11 +79,7 @@ object Library {
...
@@ -79,11 +79,7 @@ object Library {
}
}
// TODO move properties to SkikoProperties
// TODO move properties to SkikoProperties
Setup
.
init
(
Setup
.
init
()
System
.
getProperty
(
"skiko.rendering.noerasebackground"
)
!=
"false"
,
System
.
getProperty
(
"skiko.rendering.laf.global"
)
==
"true"
,
System
.
getProperty
(
"skiko.rendering.useScreenMenuBar"
)
!=
"false"
)
try
{
try
{
// Init code executed after library was loaded.
// Init code executed after library was loaded.
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
View file @
b55efc68
...
@@ -110,18 +110,6 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -110,18 +110,6 @@ internal val platformOperations: PlatformOperations by lazy {
override
fun
getDpiScale
(
component
:
Component
):
Float
{
override
fun
getDpiScale
(
component
:
Component
):
Float
{
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
// TODO doesn't work well because java doesn't scale windows (content has offset with 200% scale)
//
// Two solutions:
// 1. dynamically change sun.java2d.uiScale (it is global property,
// so we have to be careful) and update all windows
//
// 2. apply contentScale manually to all windows
// (it is not good, because on different platform windows will have different size.
// Maybe we will apply contentScale manually on all platforms?)
// see also comment for HardwareLayer.checkContentScale
// return component.useDrawingSurfacePlatformInfo(::linuxGetDpiScaleNative)
}
}
override
fun
createRedrawer
(
override
fun
createRedrawer
(
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Setup.kt
View file @
b55efc68
...
@@ -4,10 +4,16 @@ import javax.swing.UIManager
...
@@ -4,10 +4,16 @@ import javax.swing.UIManager
object
Setup
{
object
Setup
{
fun
init
(
fun
init
(
noEraseBackground
:
Boolean
=
true
,
noEraseBackground
:
Boolean
=
System
.
getProperty
(
"skiko.rendering.noerasebackground"
)
!=
"false"
,
globalLAF
:
Boolean
=
false
,
globalLAF
:
Boolean
=
System
.
getProperty
(
"skiko.rendering.laf.global"
)
==
"true"
,
useScreenMenuBar
:
Boolean
=
true
useScreenMenuBar
:
Boolean
=
System
.
getProperty
(
"skiko.rendering.useScreenMenuBar"
)
!=
"false"
,
autoLinuxDpi
:
Boolean
=
System
.
getProperty
(
"skiko.linux.autodpi"
)
==
"true"
)
{
)
{
if
(
hostOs
==
OS
.
Linux
&&
autoLinuxDpi
)
{
val
scale
=
linuxGetSystemDpiScale
()
System
.
setProperty
(
"sun.java2d.uiScale.enabled"
,
"true"
)
System
.
setProperty
(
"sun.java2d.uiScale"
,
"$scale"
)
}
if
(
noEraseBackground
)
{
if
(
noEraseBackground
)
{
// we have to set this property to avoid render flickering.
// we have to set this property to avoid render flickering.
System
.
setProperty
(
"sun.awt.noerasebackground"
,
"true"
)
System
.
setProperty
(
"sun.awt.noerasebackground"
,
"true"
)
...
@@ -25,3 +31,5 @@ object Setup {
...
@@ -25,3 +31,5 @@ object Setup {
}
}
}
}
}
}
private
external
fun
linuxGetSystemDpiScale
():
Float
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