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
285c4f20
Unverified
Commit
285c4f20
authored
Feb 18, 2021
by
Roman Sedaikin
Committed by
GitHub
Feb 18, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into directx
parents
4851cff2
f2b5c392
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
122 additions
and
32 deletions
+122
-32
SkiaWindowTest.kt
...ple/src/test/kotlin/org/jetbrains/skiko/SkiaWindowTest.kt
+39
-0
build.gradle.kts
skiko/build.gradle.kts
+2
-1
PlatformOperations.kt
.../jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
+7
-7
SkiaLayer.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
+4
-2
SkiaLayerProperties.kt
...jvmMain/kotlin/org/jetbrains/skiko/SkiaLayerProperties.kt
+5
-0
SkiaWindow.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaWindow.kt
+4
-2
LinuxOpenGLRedrawer.kt
...otlin/org/jetbrains/skiko/redrawer/LinuxOpenGLRedrawer.kt
+6
-3
MacOsOpenGLRedrawer.kt
...otlin/org/jetbrains/skiko/redrawer/MacOsOpenGLRedrawer.kt
+50
-14
WindowsOpenGLRedrawer.kt
...lin/org/jetbrains/skiko/redrawer/WindowsOpenGLRedrawer.kt
+5
-3
No files found.
samples/SkijaInjectSample/src/test/kotlin/org/jetbrains/skiko/SkiaWindowTest.kt
View file @
285c4f20
package
org.jetbrains.skiko
package
org.jetbrains.skiko
import
kotlinx.coroutines.CompletableDeferred
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.delay
...
@@ -204,6 +205,44 @@ class SkiaWindowTest {
...
@@ -204,6 +205,44 @@ class SkiaWindowTest {
delay
(
5000
)
delay
(
5000
)
}
}
@Test
(
timeout
=
20000
)
fun
`
render
continuously
empty
content
without
vsync
`
()
=
swingTest
{
assumeTrue
(
hostOs
!=
OS
.
MacOS
)
// TODO remove when we will support drawing without vsync on macOs
val
targetDrawCount
=
500
var
drawCount
=
0
val
onDrawCompleted
=
CompletableDeferred
<
Unit
>()
val
window
=
SkiaWindow
(
properties
=
SkiaLayerProperties
(
isVsyncEnabled
=
false
)
)
try
{
window
.
setLocation
(
200
,
200
)
window
.
setSize
(
400
,
200
)
window
.
defaultCloseOperation
=
WindowConstants
.
DISPOSE_ON_CLOSE
window
.
layer
.
renderer
=
object
:
SkiaRenderer
{
override
fun
onRender
(
canvas
:
Canvas
,
width
:
Int
,
height
:
Int
,
nanoTime
:
Long
)
{
drawCount
++
if
(
drawCount
<
targetDrawCount
)
{
window
.
layer
.
needRedraw
()
}
else
{
onDrawCompleted
.
complete
(
Unit
)
}
}
}
window
.
isUndecorated
=
true
window
.
isVisible
=
true
onDrawCompleted
.
await
()
}
finally
{
window
.
close
()
}
}
@Test
@Test
fun
`
render
text
(
Windows
)
`
()
{
fun
`
render
text
(
Windows
)
`
()
{
testRenderText
(
OS
.
Windows
)
testRenderText
(
OS
.
Windows
)
...
...
skiko/build.gradle.kts
View file @
285c4f20
...
@@ -370,7 +370,8 @@ tasks.withType(LinkSharedLibrary::class.java).configureEach {
...
@@ -370,7 +370,8 @@ tasks.withType(LinkSharedLibrary::class.java).configureEach {
"-lGL"
,
"-lGL"
,
"-lfontconfig"
,
"-lfontconfig"
,
// Hack to fix problem with linker not always finding certain declarations.
// Hack to fix problem with linker not always finding certain declarations.
skiaDir
.
get
().
absolutePath
+
"/out/${buildType.id}-${targetArch.id}/libsksg.a"
skiaDir
.
get
().
absolutePath
+
"/out/${buildType.id}-${targetArch.id}/libsksg.a"
,
skiaDir
.
get
().
absolutePath
+
"/out/${buildType.id}-${targetArch.id}/libskia.a"
)
)
)
)
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
View file @
285c4f20
...
@@ -14,7 +14,7 @@ internal interface PlatformOperations {
...
@@ -14,7 +14,7 @@ internal interface PlatformOperations {
fun
isFullscreen
(
component
:
Component
):
Boolean
fun
isFullscreen
(
component
:
Component
):
Boolean
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
fun
getDpiScale
(
component
:
Component
):
Float
fun
getDpiScale
(
component
:
Component
):
Float
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
):
Redrawer
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
,
properties
:
SkiaLayerProperties
):
Redrawer
}
}
internal
val
platformOperations
:
PlatformOperations
by
lazy
{
internal
val
platformOperations
:
PlatformOperations
by
lazy
{
...
@@ -32,9 +32,9 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -32,9 +32,9 @@ internal val platformOperations: PlatformOperations by lazy {
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
}
}
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
)
=
when
(
renderApi
)
{
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
,
properties
:
SkiaLayerProperties
)
=
when
(
renderApi
)
{
GraphicsApi
.
SOFTWARE
->
SoftwareRedrawer
(
layer
)
GraphicsApi
.
SOFTWARE
->
SoftwareRedrawer
(
layer
)
else
->
MacOsOpenGLRedrawer
(
layer
)
else
->
MacOsOpenGLRedrawer
(
layer
,
properties
)
}
}
}
}
OS
.
Windows
->
{
OS
.
Windows
->
{
...
@@ -55,10 +55,10 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -55,10 +55,10 @@ internal val platformOperations: PlatformOperations by lazy {
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
}
}
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
)
=
when
(
renderApi
)
{
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
,
properties
:
SkiaLayerProperties
)
=
when
(
renderApi
)
{
GraphicsApi
.
SOFTWARE
->
SoftwareRedrawer
(
layer
)
GraphicsApi
.
SOFTWARE
->
SoftwareRedrawer
(
layer
)
GraphicsApi
.
DIRECT3D
->
Direct3DRedrawer
(
layer
)
GraphicsApi
.
DIRECT3D
->
Direct3DRedrawer
(
layer
)
else
->
WindowsOpenGLRedrawer
(
layer
)
else
->
WindowsOpenGLRedrawer
(
layer
,
properties
)
}
}
}
}
}
}
...
@@ -92,9 +92,9 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -92,9 +92,9 @@ internal val platformOperations: PlatformOperations by lazy {
// return component.useDrawingSurfacePlatformInfo(::linuxGetDpiScaleNative)
// return component.useDrawingSurfacePlatformInfo(::linuxGetDpiScaleNative)
}
}
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
)
=
when
(
renderApi
)
{
override
fun
createRedrawer
(
layer
:
HardwareLayer
,
renderApi
:
GraphicsApi
,
properties
:
SkiaLayerProperties
)
=
when
(
renderApi
)
{
GraphicsApi
.
SOFTWARE
->
SoftwareRedrawer
(
layer
)
GraphicsApi
.
SOFTWARE
->
SoftwareRedrawer
(
layer
)
else
->
LinuxOpenGLRedrawer
(
layer
)
else
->
LinuxOpenGLRedrawer
(
layer
,
properties
)
}
}
}
}
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
View file @
285c4f20
...
@@ -21,7 +21,9 @@ interface SkiaRenderer {
...
@@ -21,7 +21,9 @@ interface SkiaRenderer {
private
class
PictureHolder
(
val
instance
:
Picture
,
val
width
:
Int
,
val
height
:
Int
)
private
class
PictureHolder
(
val
instance
:
Picture
,
val
width
:
Int
,
val
height
:
Int
)
open
class
SkiaLayer
:
HardwareLayer
()
{
open
class
SkiaLayer
(
private
val
properties
:
SkiaLayerProperties
=
SkiaLayerProperties
()
)
:
HardwareLayer
()
{
var
renderer
:
SkiaRenderer
?
=
null
var
renderer
:
SkiaRenderer
?
=
null
val
clipComponents
=
mutableListOf
<
ClipRectangle
>()
val
clipComponents
=
mutableListOf
<
ClipRectangle
>()
...
@@ -41,7 +43,7 @@ open class SkiaLayer : HardwareLayer() {
...
@@ -41,7 +43,7 @@ open class SkiaLayer : HardwareLayer() {
super
.
init
()
super
.
init
()
val
initialRenderApi
=
fallbackRenderApiQueue
.
removeAt
(
0
)
val
initialRenderApi
=
fallbackRenderApiQueue
.
removeAt
(
0
)
contextHandler
=
createContextHandler
(
this
,
initialRenderApi
)
contextHandler
=
createContextHandler
(
this
,
initialRenderApi
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
initialRenderApi
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
initialRenderApi
,
properties
)
redrawer
?.
syncSize
()
redrawer
?.
syncSize
()
redrawer
?.
redrawImmediately
()
redrawer
?.
redrawImmediately
()
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayerProperties.kt
0 → 100644
View file @
285c4f20
package
org.jetbrains.skiko
class
SkiaLayerProperties
(
val
isVsyncEnabled
:
Boolean
=
SkikoProperties
.
vsyncEnabled
)
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaWindow.kt
View file @
285c4f20
...
@@ -2,8 +2,10 @@ package org.jetbrains.skiko
...
@@ -2,8 +2,10 @@ package org.jetbrains.skiko
import
javax.swing.JFrame
import
javax.swing.JFrame
open
class
SkiaWindow
:
JFrame
()
{
open
class
SkiaWindow
(
val
layer
=
SkiaLayer
()
properties
:
SkiaLayerProperties
=
SkiaLayerProperties
()
)
:
JFrame
()
{
val
layer
=
SkiaLayer
(
properties
)
init
{
init
{
contentPane
.
add
(
layer
)
contentPane
.
add
(
layer
)
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/LinuxOpenGLRedrawer.kt
View file @
285c4f20
...
@@ -7,11 +7,12 @@ import org.jetbrains.skiko.DrawingSurface
...
@@ -7,11 +7,12 @@ import org.jetbrains.skiko.DrawingSurface
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.HardwareLayer
import
org.jetbrains.skiko.HardwareLayer
import
org.jetbrains.skiko.OpenGLApi
import
org.jetbrains.skiko.OpenGLApi
import
org.jetbrains.skiko.Ski
ko
Properties
import
org.jetbrains.skiko.Ski
aLayer
Properties
import
org.jetbrains.skiko.getDrawingSurface
import
org.jetbrains.skiko.getDrawingSurface
internal
class
LinuxOpenGLRedrawer
(
internal
class
LinuxOpenGLRedrawer
(
private
val
layer
:
HardwareLayer
private
val
layer
:
HardwareLayer
,
private
val
properties
:
SkiaLayerProperties
)
:
Redrawer
{
)
:
Redrawer
{
private
val
context
=
layer
.
lockDrawingSurface
{
private
val
context
=
layer
.
lockDrawingSurface
{
it
.
createContext
()
it
.
createContext
()
...
@@ -70,6 +71,8 @@ internal class LinuxOpenGLRedrawer(
...
@@ -70,6 +71,8 @@ internal class LinuxOpenGLRedrawer(
}
}
}
}
val
isVsyncEnabled
=
toRedrawAlive
.
all
{
it
.
properties
.
isVsyncEnabled
}
val
drawingSurfaces
=
toRedrawAlive
.
map
{
lockDrawingSurface
(
it
.
layer
)
}.
toList
()
val
drawingSurfaces
=
toRedrawAlive
.
map
{
lockDrawingSurface
(
it
.
layer
)
}.
toList
()
try
{
try
{
toRedrawAlive
.
forEachIndexed
{
index
,
redrawer
->
toRedrawAlive
.
forEachIndexed
{
index
,
redrawer
->
...
@@ -79,7 +82,7 @@ internal class LinuxOpenGLRedrawer(
...
@@ -79,7 +82,7 @@ internal class LinuxOpenGLRedrawer(
toRedrawAlive
.
forEachIndexed
{
index
,
_
->
toRedrawAlive
.
forEachIndexed
{
index
,
_
->
// it is ok to set swap interval every frame, there is no performance overhead
// it is ok to set swap interval every frame, there is no performance overhead
drawingSurfaces
[
index
].
setSwapInterval
(
if
(
SkikoProperties
.
v
syncEnabled
)
1
else
0
)
drawingSurfaces
[
index
].
setSwapInterval
(
if
(
isV
syncEnabled
)
1
else
0
)
drawingSurfaces
[
index
].
swapBuffers
()
drawingSurfaces
[
index
].
swapBuffers
()
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/MacOsOpenGLRedrawer.kt
View file @
285c4f20
package
org.jetbrains.skiko.redrawer
package
org.jetbrains.skiko.redrawer
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.swing.Swing
import
kotlinx.coroutines.swing.Swing
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.HardwareLayer
import
org.jetbrains.skiko.HardwareLayer
import
org.jetbrains.skiko.OpenGLApi
import
org.jetbrains.skiko.OpenGLApi
import
org.jetbrains.skiko.SkikoProperties
import
org.jetbrains.skiko.SkiaLayerProperties
import
org.jetbrains.skiko.useDrawingSurfacePlatformInfo
import
org.jetbrains.skiko.Task
import
org.jetbrains.skiko.Task
import
org.jetbrains.skiko.useDrawingSurfacePlatformInfo
import
javax.swing.SwingUtilities.convertPoint
import
javax.swing.SwingUtilities.convertPoint
import
javax.swing.SwingUtilities.getRootPane
import
javax.swing.SwingUtilities.getRootPane
import
kotlin.system.measureNanoTime
// Current implementation is fragile (it works in all tested cases, but we can't test everything)
//
// We should investigate can we implement our own CAOpenGLLayer, without its restrictions.
// (see, for example https://github.com/gnustep/libs-gui/blob/master/Source/NSOpenGLView.m)
//
// P.S. MacOsOpenGLRedrawer will not be used by default in the future, because we will support Metal.
internal
class
MacOsOpenGLRedrawer
(
internal
class
MacOsOpenGLRedrawer
(
private
val
layer
:
HardwareLayer
private
val
layer
:
HardwareLayer
,
private
val
properties
:
SkiaLayerProperties
)
:
Redrawer
{
)
:
Redrawer
{
private
val
containerLayerPtr
=
layer
.
useDrawingSurfacePlatformInfo
(
::
initContainer
)
private
val
containerLayerPtr
=
layer
.
useDrawingSurfacePlatformInfo
(
::
initContainer
)
private
val
drawLock
=
Any
()
private
val
drawLock
=
Any
()
...
@@ -24,6 +34,8 @@ internal class MacOsOpenGLRedrawer(
...
@@ -24,6 +34,8 @@ internal class MacOsOpenGLRedrawer(
layer
.
draw
()
layer
.
draw
()
}
}
}
}
suspend
fun
display
()
=
display
(
::
setNeedsDisplay
)
}
}
// use a separate layer for vsync, because with single layer we cannot asynchronously update layer
// use a separate layer for vsync, because with single layer we cannot asynchronously update layer
...
@@ -52,7 +64,7 @@ internal class MacOsOpenGLRedrawer(
...
@@ -52,7 +64,7 @@ internal class MacOsOpenGLRedrawer(
return
canDraw
return
canDraw
}
}
override
fun
setNeeds
Display
()
{
private
fun
requestAsync
Display
()
{
// Use asynchronous mode instead of just setNeedsDisplay,
// Use asynchronous mode instead of just setNeedsDisplay,
// so Core Animation will wait for the next frame in vsync signal
// so Core Animation will wait for the next frame in vsync signal
//
//
...
@@ -63,13 +75,13 @@ internal class MacOsOpenGLRedrawer(
...
@@ -63,13 +75,13 @@ internal class MacOsOpenGLRedrawer(
// https://chromium.googlesource.com/chromium/chromium/+/0489078bf98350b00876070cf2fdce230905f47e/content/browser/renderer_host/compositing_iosurface_layer_mac.mm#57
// https://chromium.googlesource.com/chromium/chromium/+/0489078bf98350b00876070cf2fdce230905f47e/content/browser/renderer_host/compositing_iosurface_layer_mac.mm#57
if
(!
isAsynchronous
)
{
if
(!
isAsynchronous
)
{
isAsynchronous
=
true
isAsynchronous
=
true
s
uper
.
s
etNeedsDisplay
()
setNeedsDisplay
()
}
}
}
}
suspend
fun
sync
()
{
suspend
fun
sync
()
{
canDraw
=
true
canDraw
=
true
display
()
display
(
::
requestAsyncDisplay
)
canDraw
=
false
canDraw
=
false
}
}
}
}
...
@@ -78,13 +90,11 @@ internal class MacOsOpenGLRedrawer(
...
@@ -78,13 +90,11 @@ internal class MacOsOpenGLRedrawer(
synchronized
(
drawLock
)
{
synchronized
(
drawLock
)
{
layer
.
update
(
System
.
nanoTime
())
layer
.
update
(
System
.
nanoTime
())
}
}
if
(
SkikoProperties
.
v
syncEnabled
)
{
if
(
properties
.
isV
syncEnabled
)
{
drawLayer
.
setNeedsDisplay
()
drawLayer
.
setNeedsDisplay
()
vsyncLayer
.
sync
()
vsyncLayer
.
sync
()
}
else
{
}
else
{
// If vsync is disabled we should await the drawing to end.
error
(
"Drawing without vsync isn't supported on macOs with OpenGL"
)
// Otherwise we will call 'update' multiple times.
drawLayer
.
display
()
}
}
}
}
...
@@ -113,7 +123,16 @@ internal class MacOsOpenGLRedrawer(
...
@@ -113,7 +123,16 @@ internal class MacOsOpenGLRedrawer(
override
fun
redrawImmediately
()
{
override
fun
redrawImmediately
()
{
layer
.
update
(
System
.
nanoTime
())
layer
.
update
(
System
.
nanoTime
())
drawLayer
.
setNeedsDisplay
()
// macOs will call 'draw' itself because of 'setNeedsDisplayOnBoundsChange=true'.
// But we schedule new frame after vsync anyway.
// Because 'redrawImmediately' can be called after 'draw',
// and we need at least one 'draw' after 'redrawImmediately'.
//
// We don't use setNeedsDisplay, because frequent calls of it are unreliable.
// 'setNeedsDisplayOnBoundsChange=true' with combination of 'scheduleFrame' is enough
// to not see the white bars on resize.
frameDispatcher
.
scheduleFrame
()
}
}
}
}
...
@@ -134,15 +153,32 @@ private abstract class AWTGLLayer(private val containerPtr: Long, setNeedsDispla
...
@@ -134,15 +153,32 @@ private abstract class AWTGLLayer(private val containerPtr: Long, setNeedsDispla
get
()
=
isAsynchronous
(
ptr
)
get
()
=
isAsynchronous
(
ptr
)
set
(
value
)
=
setAsynchronous
(
ptr
,
value
)
set
(
value
)
=
setAsynchronous
(
ptr
,
value
)
open
fun
setNeedsDisplay
()
=
setNeedsDisplayOnMainThread
(
ptr
)
/**
* Schedule next [draw] as soon as possible (not waiting for vsync)
*
* WARNING!!!
*
* CAOpenGLLayer will not call [draw] if we call [setNeedsDisplay] too often.
*
* Experimentally we found out that after 15 draw's between two vsync's (900 FPS on 60 Hz display) will cause
* setNeedsDisplay to not schedule the next draw at all.
*
* Only after the next vsync, [setNeedsDisplay] will be working again.
*/
fun
setNeedsDisplay
()
{
setNeedsDisplayOnMainThread
(
ptr
)
}
suspend
fun
display
()
=
display
.
runAndAwait
{
protected
suspend
fun
display
(
setNeedsDisplay
()
startDisplay
:
()
->
Unit
)
=
display
.
runAndAwait
{
startDisplay
()
}
}
// Called in AppKit Thread
// Called in AppKit Thread
protected
open
fun
canDraw
()
=
true
protected
open
fun
canDraw
()
=
true
// Called in AppKit Thread
@Suppress
(
"unused"
)
// called from native code
@Suppress
(
"unused"
)
// called from native code
private
fun
performDraw
()
{
private
fun
performDraw
()
{
try
{
try
{
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/redrawer/WindowsOpenGLRedrawer.kt
View file @
285c4f20
...
@@ -7,11 +7,12 @@ import kotlinx.coroutines.withContext
...
@@ -7,11 +7,12 @@ import kotlinx.coroutines.withContext
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.FrameDispatcher
import
org.jetbrains.skiko.HardwareLayer
import
org.jetbrains.skiko.HardwareLayer
import
org.jetbrains.skiko.OpenGLApi
import
org.jetbrains.skiko.OpenGLApi
import
org.jetbrains.skiko.Ski
ko
Properties
import
org.jetbrains.skiko.Ski
aLayer
Properties
import
org.jetbrains.skiko.useDrawingSurfacePlatformInfo
import
org.jetbrains.skiko.useDrawingSurfacePlatformInfo
internal
class
WindowsOpenGLRedrawer
(
internal
class
WindowsOpenGLRedrawer
(
private
val
layer
:
HardwareLayer
private
val
layer
:
HardwareLayer
,
private
val
properties
:
SkiaLayerProperties
)
:
Redrawer
{
)
:
Redrawer
{
private
val
device
=
layer
.
useDrawingSurfacePlatformInfo
(
::
getDevice
)
private
val
device
=
layer
.
useDrawingSurfacePlatformInfo
(
::
getDevice
)
private
val
context
=
createContext
(
device
)
private
val
context
=
createContext
(
device
)
...
@@ -92,7 +93,8 @@ internal class WindowsOpenGLRedrawer(
...
@@ -92,7 +93,8 @@ internal class WindowsOpenGLRedrawer(
OpenGLApi
.
instance
.
glFinish
()
OpenGLApi
.
instance
.
glFinish
()
}
}
if
(
SkikoProperties
.
vsyncEnabled
)
{
val
isVsyncEnabled
=
toRedrawAlive
.
all
{
it
.
properties
.
isVsyncEnabled
}
if
(
isVsyncEnabled
)
{
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
dwmFlush
()
// wait for vsync
dwmFlush
()
// wait for vsync
}
}
...
...
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