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
4e00455a
Commit
4e00455a
authored
Dec 15, 2020
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Getting dpi scale by Display in Linux.
parent
b0dc2e01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
22 deletions
+36
-22
drawlayer.cc
skiko/src/jvmMain/cpp/linux/drawlayer.cc
+32
-12
PlatformOperations.kt
.../jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
+2
-2
SkiaLayer.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
+2
-8
No files found.
skiko/src/jvmMain/cpp/linux/drawlayer.cc
View file @
4e00455a
...
@@ -255,23 +255,43 @@ extern "C"
...
@@ -255,23 +255,43 @@ extern "C"
return
1
;
return
1
;
}
}
double
getDpiScale
(
)
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
,
jobject
component
)
{
{
Display
*
display
=
XOpenDisplay
(
nullptr
);
JAWT
awt
;
if
(
display
!=
nullptr
)
JAWT_DrawingSurface
*
ds
=
NULL
;
JAWT_DrawingSurfaceInfo
*
dsi
=
NULL
;
jboolean
result
=
JNI_FALSE
;
jint
lock
=
0
;
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
;
awt
.
version
=
(
jint
)
JAWT_VERSION_9
;
result
=
Skiko_GetAWT
(
env
,
&
awt
);
if
(
result
==
JNI_FALSE
)
{
{
double
result
=
getDpiScaleByDisplay
(
display
);
fprintf
(
stderr
,
"JAWT_GetAWT failed! Result is JNI_FALSE
\n
"
);
XCloseDisplay
(
display
);
return
-
1
;
return
result
;
}
}
else
if
(
jvm
==
NULL
)
{
{
return
1
;
env
->
GetJavaVM
(
&
jvm
)
;
}
}
}
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
)
ds
=
awt
.
GetDrawingSurface
(
env
,
component
);
{
lock
=
ds
->
Lock
(
ds
);
return
(
float
)
getDpiScale
();
dsi
=
ds
->
GetDrawingSurfaceInfo
(
ds
);
dsi_x11
=
(
JAWT_X11DrawingSurfaceInfo
*
)
dsi
->
platformInfo
;
Display
*
display
=
dsi_x11
->
display
;
float
dpi
=
(
float
)
getDpiScaleByDisplay
(
display
);
ds
->
FreeDrawingSurfaceInfo
(
dsi
);
ds
->
Unlock
(
ds
);
awt
.
FreeDrawingSurface
(
ds
);
return
dpi
;
}
}
}
// extern "C"
}
// extern "C"
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
View file @
4e00455a
...
@@ -59,7 +59,7 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -59,7 +59,7 @@ internal val platformOperations: PlatformOperations by lazy {
}
}
override
fun
getDpiScale
(
component
:
Component
):
Float
{
override
fun
getDpiScale
(
component
:
Component
):
Float
{
return
linuxGetDpiScaleNative
()
return
linuxGetDpiScaleNative
(
component
)
}
}
}
}
}
}
...
@@ -71,4 +71,4 @@ external private fun osxIsFullscreenNative(component: Component): Boolean
...
@@ -71,4 +71,4 @@ external private fun osxIsFullscreenNative(component: Component): Boolean
external
private
fun
osxSetFullscreenNative
(
component
:
Component
,
value
:
Boolean
)
external
private
fun
osxSetFullscreenNative
(
component
:
Component
,
value
:
Boolean
)
// Linux
// Linux
external
private
fun
linuxGetDpiScaleNative
():
Float
external
private
fun
linuxGetDpiScaleNative
(
component
:
Component
):
Float
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
View file @
4e00455a
...
@@ -13,13 +13,7 @@ import org.jetbrains.skija.SurfaceOrigin
...
@@ -13,13 +13,7 @@ import org.jetbrains.skija.SurfaceOrigin
import
org.jetbrains.skija.ClipMode
import
org.jetbrains.skija.ClipMode
private
class
SkijaState
{
private
class
SkijaState
{
val
canvasBleach
:
()
->
Unit
val
bleachConstant
=
if
(
hostOs
==
OS
.
MacOS
)
0
else
-
1
init
{
when
(
hostOs
)
{
OS
.
MacOS
->
canvasBleach
=
{
canvas
?.
clear
(
0
)
}
else
->
canvasBleach
=
{
canvas
?.
clear
(-
1
)
}
}
}
var
context
:
DirectContext
?
=
null
var
context
:
DirectContext
?
=
null
var
renderTarget
:
BackendRenderTarget
?
=
null
var
renderTarget
:
BackendRenderTarget
?
=
null
var
surface
:
Surface
?
=
null
var
surface
:
Surface
?
=
null
...
@@ -71,7 +65,7 @@ open class SkiaLayer() : HardwareLayer() {
...
@@ -71,7 +65,7 @@ open class SkiaLayer() : HardwareLayer() {
}
}
initSkija
()
initSkija
()
skijaState
.
apply
{
skijaState
.
apply
{
canvas
Bleach
.
invoke
(
)
canvas
!!
.
clear
(
bleachConstant
)
// cliping
// cliping
for
(
component
in
clipComponets
)
{
for
(
component
in
clipComponets
)
{
...
...
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