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
5ed970f0
Unverified
Commit
5ed970f0
authored
Jun 12, 2024
by
Elijah Semyonov
Committed by
GitHub
Jun 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose SkiaLayerProperties (#938)
parent
3f41f665
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
8 deletions
+82
-8
SkiaLayer.awt.kt
...o/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
+13
-0
MetalRedrawer.kt
...Main/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
+10
-2
MetalRedrawer.mm
skiko/src/awtMain/objectiveC/macos/MetalRedrawer.mm
+1
-1
BreakIteratorTests.kt
...ommonTest/kotlin/org/jetbrains/skia/BreakIteratorTests.kt
+2
-2
FontTests.kt
skiko/src/commonTest/kotlin/org/jetbrains/skia/FontTests.kt
+4
-1
SkiaLayerProperties.kt
...jvmMain/kotlin/org/jetbrains/skiko/SkiaLayerProperties.kt
+52
-2
No files found.
skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
View file @
5ed970f0
...
@@ -71,6 +71,19 @@ actual open class SkiaLayer internal constructor(
...
@@ -71,6 +71,19 @@ actual open class SkiaLayer internal constructor(
pixelGeometry
pixelGeometry
)
)
constructor
(
externalAccessibleFactory
:
((
Component
)
->
Accessible
)?
=
null
,
properties
:
SkiaLayerProperties
,
analytics
:
SkiaLayerAnalytics
=
SkiaLayerAnalytics
.
Empty
,
pixelGeometry
:
PixelGeometry
=
PixelGeometry
.
UNKNOWN
,
)
:
this
(
externalAccessibleFactory
,
properties
,
RenderFactory
.
Default
,
analytics
,
pixelGeometry
)
val
canvas
:
java
.
awt
.
Canvas
val
canvas
:
java
.
awt
.
Canvas
get
()
=
backedLayer
get
()
=
backedLayer
...
...
skiko/src/awtMain/kotlin/org/jetbrains/skiko/redrawer/MetalRedrawer.kt
View file @
5ed970f0
...
@@ -72,7 +72,7 @@ internal class MetalRedrawer(
...
@@ -72,7 +72,7 @@ internal class MetalRedrawer(
}
}
_device
=
initDevice
_device
=
initDevice
contextHandler
=
MetalContextHandler
(
layer
,
initDevice
,
adapter
)
contextHandler
=
MetalContextHandler
(
layer
,
initDevice
,
adapter
)
set
V
SyncEnabled
(
initDevice
.
ptr
,
properties
.
isVsyncEnabled
)
set
Display
SyncEnabled
(
initDevice
.
ptr
,
properties
.
isVsyncEnabled
)
}
}
override
val
renderInfo
:
String
get
()
=
contextHandler
.
rendererInfo
()
override
val
renderInfo
:
String
get
()
=
contextHandler
.
rendererInfo
()
...
@@ -190,5 +190,13 @@ internal class MetalRedrawer(
...
@@ -190,5 +190,13 @@ internal class MetalRedrawer(
private
external
fun
resizeLayers
(
device
:
Long
,
x
:
Int
,
y
:
Int
,
width
:
Int
,
height
:
Int
)
private
external
fun
resizeLayers
(
device
:
Long
,
x
:
Int
,
y
:
Int
,
width
:
Int
,
height
:
Int
)
private
external
fun
setLayerVisible
(
device
:
Long
,
isVisible
:
Boolean
)
private
external
fun
setLayerVisible
(
device
:
Long
,
isVisible
:
Boolean
)
private
external
fun
setContentScale
(
device
:
Long
,
contentScale
:
Float
)
private
external
fun
setContentScale
(
device
:
Long
,
contentScale
:
Float
)
private
external
fun
setVSyncEnabled
(
device
:
Long
,
enabled
:
Boolean
)
/**
* Set this value to true to synchronize the presentation of the layer’s contents with the display’s refresh,
* also known as vsync or vertical sync. If false, the layer presents new content more quickly,
* but possibly with brief visual artifacts (screen tearing).
*
* @note see https://developer.apple.com/documentation/quartzcore/cametallayer/2887087-displaysyncenabled
*/
private
external
fun
setDisplaySyncEnabled
(
device
:
Long
,
enabled
:
Boolean
)
}
}
skiko/src/awtMain/objectiveC/macos/MetalRedrawer.mm
View file @
5ed970f0
...
@@ -231,7 +231,7 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_setConten
...
@@ -231,7 +231,7 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_setConten
}
}
}
}
JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_set
V
SyncEnabled(JNIEnv *env, jobject obj, jlong devicePtr, jboolean enabled)
JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_set
Display
SyncEnabled(JNIEnv *env, jobject obj, jlong devicePtr, jboolean enabled)
{
{
@autoreleasepool {
@autoreleasepool {
MetalDevice *device = (__bridge MetalDevice *) (void *) devicePtr;
MetalDevice *device = (__bridge MetalDevice *) (void *) devicePtr;
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skia/BreakIteratorTests.kt
View file @
5ed970f0
...
@@ -37,9 +37,9 @@ class BreakIteratorTests {
...
@@ -37,9 +37,9 @@ class BreakIteratorTests {
@SkipJsTarget
@SkipJsTarget
@SkipWasmTarget
@SkipWasmTarget
fun
breakIteratorCloneTest
()
{
fun
breakIteratorCloneTest
()
{
// Wasm
and i
OS builds of Skia do not include required data to implement those iterators,
// Wasm
, iOS, and tv
OS builds of Skia do not include required data to implement those iterators,
// see `third_party/externals/icu/flutter/README.md`.
// see `third_party/externals/icu/flutter/README.md`.
if
(
hostOs
==
OS
.
Ios
)
if
(
hostOs
==
OS
.
Ios
||
hostOs
==
OS
.
Tvos
)
return
return
if
(
isDebugModeOnJvm
)
if
(
isDebugModeOnJvm
)
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skia/FontTests.kt
View file @
5ed970f0
...
@@ -15,6 +15,7 @@ private fun isMac() = (hostOs == OS.MacOS)
...
@@ -15,6 +15,7 @@ private fun isMac() = (hostOs == OS.MacOS)
private
fun
isIos
()
=
(
hostOs
==
OS
.
Ios
)
private
fun
isIos
()
=
(
hostOs
==
OS
.
Ios
)
private
fun
isLinux
()
=
(
hostOs
==
OS
.
Linux
)
private
fun
isLinux
()
=
(
hostOs
==
OS
.
Linux
)
private
fun
isWindows
()
=
(
hostOs
==
OS
.
Windows
)
private
fun
isWindows
()
=
(
hostOs
==
OS
.
Windows
)
private
fun
isTvos
()
=
(
hostOs
==
OS
.
Tvos
)
private
fun
isJs
()
=
(
kotlinBackend
==
KotlinBackend
.
JS
)
private
fun
isJs
()
=
(
kotlinBackend
==
KotlinBackend
.
JS
)
private
val
COARSE_EPSILON
=
2.4f
private
val
COARSE_EPSILON
=
2.4f
private
const
val
jbMonoPath
=
"./fonts/JetBrainsMono-Regular.ttf"
private
const
val
jbMonoPath
=
"./fonts/JetBrainsMono-Regular.ttf"
...
@@ -91,6 +92,8 @@ class FontTests {
...
@@ -91,6 +92,8 @@ class FontTests {
assertEquals
(
if
(
isLinux
()
||
isJs
())
26
else
24
,
firstGlyphPath
.
pointsCount
)
assertEquals
(
if
(
isLinux
()
||
isJs
())
26
else
24
,
firstGlyphPath
.
pointsCount
)
//FontMetrics(_top=-11.64, _ascent=-11.64, _descent=3.24, _bottom=3.24, _leading=0.0, _avgCharWidth=29.46, _maxCharWidth=29.46, _xMin=-20.88, _xMax=8.58, _xHeight=6.6, _capHeight=8.64, _underlineThickness=0.54, _underlinePosition=1.44, _strikeoutThickness=0.54, _strikeoutPosition=-3.9), eps=0.01
//FontMetrics(_top=-11.64, _ascent=-11.64, _descent=3.2400002, _bottom=3.2400002, _leading=0.0, _avgCharWidth=7.2, _maxCharWidth=29.460001, _xMin=-20.880001, _xMax=8.58, _xHeight=6.6000004, _capHeight=8.64, _underlineThickness=0.54, _underlinePosition=1.4399999, _strikeoutThickness=0.54, _strikeoutPosition=-3.8999999)
assertCloseEnough
(
FontMetrics
(
assertCloseEnough
(
FontMetrics
(
top
=
-
11.64f
,
top
=
-
11.64f
,
ascent
=
-
11.64f
,
ascent
=
-
11.64f
,
...
@@ -99,7 +102,7 @@ class FontTests {
...
@@ -99,7 +102,7 @@ class FontTests {
leading
=
0f
,
leading
=
0f
,
avgCharWidth
=
when
{
avgCharWidth
=
when
{
isJs
()
->
7.2f
isJs
()
->
7.2f
isIos
()
||
isMac
()
->
29.460001f
isIos
()
||
isMac
()
||
isTvos
()
->
29.460001f
isWindows
()
->
0f
isWindows
()
->
0f
else
->
7.2f
else
->
7.2f
},
},
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayerProperties.kt
View file @
5ed970f0
package
org.jetbrains.skiko
package
org.jetbrains.skiko
internal
data class
SkiaLayerProperties
(
/**
* SkiaLayerProperties is a class that represents the rendering configuration for a SkiaLayer.
*
* @property isVsyncEnabled Specifies whether vertical synchronization (VSync) is enabled.
* Default value is [SkikoProperties.vsyncEnabled]. Setting this to true is a hint toward underlying implementation
* to synchronize the rendering with the display presentation. It guarantees that the frame is presented without
* visual artifacts like tearing in exchange for a possible latency increase.
* @property isVsyncFramelimitFallbackEnabled Specifies whether framelimit fallback is enabled (software renderer).
* Default value is [SkikoProperties.vsyncFramelimitFallbackEnabled].
* @property renderApi Specifies the graphics API used for rendering.
* Default value is [SkikoProperties.renderApi].
* @property adapterPriority Specifies the GPU that will be selected for rendering.
* Default value is [SkikoProperties.gpuPriority].
*/
class
SkiaLayerProperties
(
val
isVsyncEnabled
:
Boolean
=
SkikoProperties
.
vsyncEnabled
,
val
isVsyncEnabled
:
Boolean
=
SkikoProperties
.
vsyncEnabled
,
val
isVsyncFramelimitFallbackEnabled
:
Boolean
=
SkikoProperties
.
vsyncFramelimitFallbackEnabled
,
val
isVsyncFramelimitFallbackEnabled
:
Boolean
=
SkikoProperties
.
vsyncFramelimitFallbackEnabled
,
val
renderApi
:
GraphicsApi
=
SkikoProperties
.
renderApi
,
val
renderApi
:
GraphicsApi
=
SkikoProperties
.
renderApi
,
val
adapterPriority
:
GpuPriority
=
SkikoProperties
.
gpuPriority
,
val
adapterPriority
:
GpuPriority
=
SkikoProperties
.
gpuPriority
,
)
)
{
override
fun
equals
(
other
:
Any
?):
Boolean
{
if
(
this
===
other
)
return
true
val
rhs
=
other
as
?
SkiaLayerProperties
?:
return
false
if
(
isVsyncEnabled
!=
rhs
.
isVsyncEnabled
)
return
false
if
(
isVsyncFramelimitFallbackEnabled
!=
rhs
.
isVsyncFramelimitFallbackEnabled
)
return
false
if
(
renderApi
!=
rhs
.
renderApi
)
return
false
if
(
adapterPriority
!=
rhs
.
adapterPriority
)
return
false
return
true
}
fun
copy
(
isVsyncEnabled
:
Boolean
=
this
.
isVsyncEnabled
,
isVsyncFramelimitFallbackEnabled
:
Boolean
=
this
.
isVsyncFramelimitFallbackEnabled
,
renderApi
:
GraphicsApi
=
this
.
renderApi
,
adapterPriority
:
GpuPriority
=
this
.
adapterPriority
,
):
SkiaLayerProperties
{
return
SkiaLayerProperties
(
isVsyncEnabled
=
isVsyncEnabled
,
isVsyncFramelimitFallbackEnabled
=
isVsyncFramelimitFallbackEnabled
,
renderApi
=
renderApi
,
adapterPriority
=
adapterPriority
,
)
}
override
fun
hashCode
():
Int
{
var
result
=
isVsyncEnabled
.
hashCode
()
result
=
31
*
result
+
isVsyncFramelimitFallbackEnabled
.
hashCode
()
result
=
31
*
result
+
renderApi
.
hashCode
()
result
=
31
*
result
+
adapterPriority
.
hashCode
()
return
result
}
}
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