Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
igordmn committed Sep 16, 2024
1 parent ee5bcba commit e97db0b
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions skiko/src/awtMain/kotlin/org/jetbrains/skiko/SkiaLayer.awt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -591,22 +591,21 @@ actual open class SkiaLayer internal constructor(
}

private fun adjustBackedLayerSize() {
backedLayer.setBounds(0, 0, adjustSizeToContentScale(width), adjustSizeToContentScale(height))
backedLayer.validate()
val isAttached = graphicsConfiguration != null
if (isAttached) {
backedLayer.setBounds(0, 0, adjustSizeToContentScale(width), adjustSizeToContentScale(height))
backedLayer.validate()
}
}

private fun adjustSizeToContentScale(value: Int): Int {
return if (isInited) {
val scaled = value * contentScale
val diff = scaled - scaled.toInt()
// We check values close to 0.5 and edit the size to avoid white lines glitch
if (diff > 0.4f && diff < 0.6f) {
(value + 1f).toInt()
} else {
value.toFloat().toInt()
}
val scaled = value * contentScale
val diff = scaled - scaled.toInt()
// We check values close to 0.5 and edit the size to avoid white lines glitch
return if (diff > 0.4f && diff < 0.6f) {
(value + 1f).toInt()
} else {
value
value.toFloat().toInt()
}
}

Expand Down

0 comments on commit e97db0b

Please sign in to comment.