Unverified Commit b37b2c49 authored by Roman Sedaikin's avatar Roman Sedaikin Committed by GitHub

Merge pull request #92 from JetBrains/fix-white-lines-glitch

Fix white lines glitch
parents 2b43feb1 4fe90d8f
...@@ -6,4 +6,5 @@ local.properties ...@@ -6,4 +6,5 @@ local.properties
run.sh run.sh
.idea .idea
deploy.sh deploy.sh
deploy.bat
skiko/src/jvmMain/java skiko/src/jvmMain/java
...@@ -116,8 +116,14 @@ open class SkiaLayer( ...@@ -116,8 +116,14 @@ open class SkiaLayer(
} }
override fun setBounds(x: Int, y: Int, width: Int, height: Int) { override fun setBounds(x: Int, y: Int, width: Int, height: Int) {
super.setBounds(x, y, width, height) var roundedWidth = width
backedLayer.setSize(width, height) var roundedHeight = height
if (isInited) {
roundedWidth = roundSize(width)
roundedHeight = roundSize(height)
}
super.setBounds(x, y, roundedWidth, roundedHeight)
backedLayer.setSize(roundedWidth, roundedHeight)
} }
override fun paint(g: Graphics) { override fun paint(g: Graphics) {
...@@ -277,4 +283,16 @@ open class SkiaLayer( ...@@ -277,4 +283,16 @@ open class SkiaLayer(
redrawer = platformOperations.createRedrawer(this, renderApi, properties) redrawer = platformOperations.createRedrawer(this, renderApi, properties)
redrawer!!.redrawImmediately() redrawer!!.redrawImmediately()
} }
private fun roundSize(value: Int): Int {
var rounded = value * contentScale
val diff = rounded - rounded.toInt()
// We check values close to 0.5 and edit the size to avoid white lines glitch
if (diff > 0.4f && diff < 0.6f) {
rounded = value + 1f
} else {
rounded = value.toFloat()
}
return rounded.toInt()
}
} }
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