Unverified Commit 42fd44dc authored by Pavel's avatar Pavel Committed by GitHub

update info about dpi event if we came from `frameDispatcher` (#620)

* update info about dpi-scale also on hardware layer paint

* `checkContentScale` on both of paints and on `update`

do not try to sync size if scale don't changed because it acquires draw lock

* remove misleading comment
parent 6c1f03c1
......@@ -83,6 +83,7 @@ actual open class SkiaLayer internal constructor(
// 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
this@SkiaLayer.checkContentScale()
redrawer?.needRedraw()
}
......@@ -351,11 +352,7 @@ actual open class SkiaLayer internal constructor(
override fun paint(g: java.awt.Graphics) {
super.paint(g)
if (backedLayer.checkContentScale()) {
notifyChange(PropertyKind.ContentScale)
}
redrawer?.syncSize() // setBounds not always called (for example when we change density on Linux
checkContentScale()
// `paint` can be called when we already inside `draw` method.
//
// For example if we call some AWT function inside renderer.onRender,
......@@ -369,6 +366,17 @@ actual open class SkiaLayer internal constructor(
}
}
/*
In AWT there is no a change DPI event; so we should call this function when we expect that DPI maybe changed
We hope that call it on AWT/SWING `paint` and our update is enough
*/
private fun checkContentScale() {
if (backedLayer.checkContentScale()) {
notifyChange(PropertyKind.ContentScale)
redrawer?.syncSize()
}
}
// We need to delegate all event listeners to the Canvas (so and focus/input)
// Canvas is heavyweight AWT component, JPanel is lightweight Swing component
// Event handling doesn't properly work when we mix heavyweight and lightweight components.
......@@ -494,6 +502,8 @@ actual open class SkiaLayer internal constructor(
check(isEventDispatchThread()) { "Method should be called from AWT event dispatch thread" }
check(!isDisposed) { "SkiaLayer is disposed" }
checkContentScale()
FrameWatcher.nextFrame()
fpsCounter?.tick()
......
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