Unverified Commit 70f772af authored by Roman Sedaikin's avatar Roman Sedaikin Committed by GitHub

Fixed case when user get low refresh rate with VRR capable display. (#475)

To disable VRR support, we create a transparent JPanel with size (1, 1) and add it on top of the SkiaLayer. This causes mixed rendering technologies (java2d and OpenGL/DirectX) to work simultaneously in the same window and VRR cannot be enabled.
see:
https://github.com/JetBrains/compose-jb/issues/1648
https://youtrack.jetbrains.com/issue/TBX-6507#focus=Comments-27-5482439.0-0
parent 233c5013
......@@ -65,6 +65,8 @@ actual open class SkiaLayer internal constructor(
val canvas: java.awt.Canvas
get() = backedLayer
private var vrrDisplayLocker: JPanel? = null
init {
isOpaque = false
layout = null
......@@ -247,6 +249,14 @@ actual open class SkiaLayer internal constructor(
renderApi = fallbackRenderApiQueue.removeAt(0)
redrawer?.dispose()
redrawer = renderFactory.createRedrawer(this, renderApi, properties)
vrrDisplayLocker?.let { remove(it) }
if (hostOs == OS.Windows && (renderApi == GraphicsApi.DIRECT3D || renderApi == GraphicsApi.OPENGL)) {
vrrDisplayLocker = JPanel().apply {
background = Color(0, 0, 0, 0)
setBounds(0, 0, 1, 1)
}
add(vrrDisplayLocker, Integer.valueOf(0))
}
redrawer?.syncSize()
} catch (e: RenderException) {
println(e.message)
......@@ -307,6 +317,7 @@ actual open class SkiaLayer internal constructor(
}
super.setBounds(x, y, roundedWidth, roundedHeight)
backedLayer.setSize(roundedWidth, roundedHeight)
vrrDisplayLocker?.setBounds(0, 0, 1, 1)
redrawer?.syncSize()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment