From e79926da16a00acaf793ddb7236d4d5637933e12 Mon Sep 17 00:00:00 2001 From: Tom Schindl Date: Mon, 11 Jun 2018 19:55:35 +0200 Subject: [PATCH 1/2] synchronize sceneState on scale-factor change --- .../src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java index 4f451fa4e0..c595390b94 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java @@ -155,6 +155,7 @@ public void setPixelScaleFactors(float scalex, float scaley) { renderScaleX = scalex; renderScaleY = scaley; entireSceneNeedsRepaint(); + sceneState.update(); } public float getRenderScaleX() { From 14def76bed8a5a05898da6b191379eff6037abda Mon Sep 17 00:00:00 2001 From: Tom Schindl Date: Fri, 15 Jun 2018 14:53:22 +0200 Subject: [PATCH 2/2] update the scene-state in on the next pulse and fire a new pulse --- .../sun/javafx/tk/quantum/EmbeddedScene.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java index c595390b94..91f0485035 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java @@ -33,11 +33,12 @@ import javafx.scene.input.InputMethodRequests; import javafx.scene.input.InputMethodTextRun; import javafx.scene.input.MouseEvent; -import javafx.scene.input.ScrollEvent; import javafx.scene.image.PixelFormat; import java.nio.IntBuffer; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.concurrent.atomic.AtomicBoolean; + import com.sun.javafx.cursor.CursorFrame; import com.sun.javafx.embed.AbstractEvents; import com.sun.javafx.embed.EmbeddedSceneDTInterface; @@ -47,6 +48,7 @@ import com.sun.javafx.scene.traversal.Direction; import com.sun.javafx.sg.prism.NGNode; import com.sun.javafx.tk.TKClipboard; +import com.sun.javafx.tk.TKPulseListener; import com.sun.javafx.tk.Toolkit; import com.sun.prism.paint.Color; import com.sun.prism.paint.Paint; @@ -71,6 +73,8 @@ final class EmbeddedScene extends GlassScene implements EmbeddedSceneInterface { private volatile float texScaleFactorY = 1.0f; private volatile PixelFormat pixelFormat; + private final TKPulseListener pulseListener; + private final AtomicBoolean updateSceneState = new AtomicBoolean(); public EmbeddedScene(HostInterface host, boolean depthBuffer, boolean msaa) { super(depthBuffer, msaa); @@ -96,12 +100,21 @@ public EmbeddedScene(HostInterface host, boolean depthBuffer, boolean msaa) { { pixelFormat = PixelFormat.getIntArgbInstance(); } + + pulseListener = () -> { + if( updateSceneState.getAndSet(false) ) { + updateSceneState(); + } + }; + Toolkit.getToolkit().addStageTkPulseListener(pulseListener); + assert pixelFormat != null; } @Override public void dispose() { assert host != null; + Toolkit.getToolkit().removeStageTkPulseListener(pulseListener); QuantumToolkit.runWithRenderLock(() -> { host.setEmbeddedScene(null); host = null; @@ -155,7 +168,8 @@ public void setPixelScaleFactors(float scalex, float scaley) { renderScaleX = scalex; renderScaleY = scaley; entireSceneNeedsRepaint(); - sceneState.update(); + updateSceneState.set(true); + Toolkit.getToolkit().firePulse(); } public float getRenderScaleX() {