Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

WIP: synchronize sceneState on scale-factor change #99

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -155,6 +168,8 @@ public void setPixelScaleFactors(float scalex, float scaley) {
renderScaleX = scalex;
renderScaleY = scaley;
entireSceneNeedsRepaint();
updateSceneState.set(true);
Toolkit.getToolkit().firePulse();
}

public float getRenderScaleX() {
Expand Down