Unverified Commit fd05df7c authored by Alexander Maryanovsky's avatar Alexander Maryanovsky Committed by GitHub

Revert attempt to draw the first frame before the skia layer is visible, from reshape (#1100)

parent 025b1093
...@@ -103,6 +103,19 @@ actual open class SkiaLayer internal constructor( ...@@ -103,6 +103,19 @@ actual open class SkiaLayer internal constructor(
isOpaque = false isOpaque = false
layout = null layout = null
backedLayer = object : HardwareLayer(externalAccessibleFactory) { backedLayer = object : HardwareLayer(externalAccessibleFactory) {
override fun paint(g: Graphics) {
Logger.debug { "Paint called on HardwareLayer $this" }
checkContentScale()
// 1. JPanel.paint is not always called (in rare cases).
// For example if we call 'jframe.isResizable = false` on Ubuntu
//
// 2. HardwareLayer.paint is also not always called.
// For example, on macOs when we resize window or change DPI
//
// 3. to avoid double paint in one single frame, use needRedraw instead of redrawImmediately
redrawer?.needRedraw(throttledToVsync = false)
}
@Suppress("OVERRIDE_DEPRECATION") @Suppress("OVERRIDE_DEPRECATION")
override fun reshape(x: Int, y: Int, width: Int, height: Int) { override fun reshape(x: Int, y: Int, width: Int, height: Int) {
...@@ -111,22 +124,7 @@ actual open class SkiaLayer internal constructor( ...@@ -111,22 +124,7 @@ actual open class SkiaLayer internal constructor(
super.reshape(x, y, width, height) super.reshape(x, y, width, height)
redrawer?.syncBounds() redrawer?.syncBounds()
// There's no reason for the render delegate to directly cause resizing SkiaLayer, but protect redrawer?.needRedraw(throttledToVsync = false)
// against it anyway.
if (!isRendering) {
// When the layer isn't yet showing, paint will not be called,
// but in order to avoid the background flashing when the layer
// does show, we already draw to the native surface.
redrawer?.redrawImmediately(updateNeeded = true)
} else {
redrawer?.needRedraw(throttledToVsync = false)
}
}
override fun paint(g: Graphics) {
Logger.debug { "paint called on $this" }
val updateNeeded = checkContentScale()
redrawer?.redrawImmediately(updateNeeded = updateNeeded)
} }
override fun getInputMethodRequests(): InputMethodRequests? { override fun getInputMethodRequests(): InputMethodRequests? {
...@@ -416,6 +414,12 @@ actual open class SkiaLayer internal constructor( ...@@ -416,6 +414,12 @@ actual open class SkiaLayer internal constructor(
backedLayer.validate() backedLayer.validate()
} }
override fun paint(g: Graphics) {
Logger.debug { "paint called on SkiaLayer $this" }
val updateNeeded = checkContentScale()
redrawer?.redrawImmediately(updateNeeded = updateNeeded)
}
// Workaround for JBR-5274 and JBR-5305 // Workaround for JBR-5274 and JBR-5305
fun checkContentScale(): Boolean { fun checkContentScale(): Boolean {
val currentGraphicsContextScaleTransform = graphicsConfiguration.defaultTransform val currentGraphicsContextScaleTransform = graphicsConfiguration.defaultTransform
......
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