aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-03-05 19:20:19 +0100
committerSven Gothel <[email protected]>2020-03-05 20:08:02 +0100
commit972cd560eed70f1d97ef9ba1bd7a450710d4ba20 (patch)
tree05f2a27c30b3e6816b442f2d3ac87782a7a6eda7
parentd1a4d790c89934616fa1883312b4064bda9fa420 (diff)
Bug 1398: Expose NativeSurface implementation's RecursiveLock if utilized
This prepares proper release of the acquired NativeSurface lock to cure the missing CGLContext lock, see followup commit.
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java19
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java4
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java4
6 files changed, 43 insertions, 0 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
index ce0699c56..5433ea6c0 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
@@ -28,6 +28,8 @@
package com.jogamp.nativewindow;
+import com.jogamp.common.util.locks.RecursiveLock;
+
/**
* Provides low-level information required for
* hardware-accelerated rendering using a surface in a platform-independent manner.
@@ -55,6 +57,23 @@ public interface NativeSurface extends SurfaceUpdatedListener {
/** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged, {@value}. */
public static final int LOCK_SUCCESS = 3;
+
+ /**
+ * Returns the implementation's {@link RecursiveLock} synchronizing multithreaded access
+ * if used. Otherwise {@code null} is being returned.
+ * <p>
+ * {@link NativeSurface}'s {@link RecursiveLock} is only exposed to resolve special
+ * situations within the implementation and its usage is not advised if not absolutely necessary.
+ * </p>
+ * <p>
+ * Note that certain {@link NativeSurface} implementations only use the {@link RecursiveLock}
+ * as an upfront re-entrance lock vehicle, but actually acquire and release
+ * the underlying windowing toolkit's lock facility on the first or last re-entrance lock,
+ * respectively.
+ * </p>
+ */
+ public RecursiveLock getLock();
+
/**
* Lock the surface of this native window.
* <p>
diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java
index 9f650f760..98fb6aa3b 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java
@@ -191,6 +191,11 @@ public abstract class ProxySurfaceImpl implements ProxySurface {
}
@Override
+ public RecursiveLock getLock() {
+ return surfaceLock;
+ }
+
+ @Override
public int lockSurface() throws NativeWindowException, RuntimeException {
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
diff --git a/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java b/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java
index 73f181dcf..ae46e2922 100644
--- a/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java
+++ b/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java
@@ -29,6 +29,7 @@
package com.jogamp.newt.javafx;
import com.jogamp.common.util.PropertyAccess;
+import com.jogamp.common.util.locks.RecursiveLock;
import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
import com.jogamp.nativewindow.AbstractGraphicsScreen;
import com.jogamp.nativewindow.Capabilities;
@@ -96,6 +97,7 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC
private volatile boolean postSetPos = false; // pending pos
private final EventHandler<javafx.stage.WindowEvent> windowClosingListener = new EventHandler<javafx.stage.WindowEvent>() {
+ @Override
public final void handle(final javafx.stage.WindowEvent e) {
if( DEBUG ) {
System.err.println("NewtCanvasJFX.Event.DISPOSE, "+e+", closeOp "+closingMode);
@@ -108,6 +110,7 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC
}
} };
private final EventHandler<javafx.stage.WindowEvent> windowShownListener = new EventHandler<javafx.stage.WindowEvent>() {
+ @Override
public final void handle(final javafx.stage.WindowEvent e) {
if( DEBUG ) {
System.err.println("NewtCanvasJFX.Event.SHOWN, "+e);
@@ -530,6 +533,9 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC
}
@Override
+ public RecursiveLock getLock() { return null; }
+
+ @Override
public int lockSurface() throws NativeWindowException, RuntimeException {
return NativeSurface.LOCK_SUCCESS;
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 1da287102..f6c7ad955 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -971,6 +971,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
//
@Override
+ public RecursiveLock getLock() {
+ return window.getLock();
+ }
+
+ @Override
public final int lockSurface() throws NativeWindowException, RuntimeException {
return window.lockSurface();
}
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index ae740bfaa..dc16f09a9 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -28,6 +28,7 @@
package com.jogamp.newt.swt;
+import com.jogamp.common.util.locks.RecursiveLock;
import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
import com.jogamp.nativewindow.AbstractGraphicsDevice;
import com.jogamp.nativewindow.AbstractGraphicsScreen;
@@ -627,6 +628,9 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
}
@Override
+ public RecursiveLock getLock() { return null; }
+
+ @Override
public int lockSurface() throws NativeWindowException, RuntimeException {
return NativeSurface.LOCK_SUCCESS;
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 8ef137b34..3fa648686 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -543,6 +543,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
void clearButton() {
lastButtonPressTime = 0;
}
+ @Override
public String toString() { return "PState0[inside "+insideSurface+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+", dragging "+dragging+"]"; }
}
private final PointerState0 pState0 = new PointerState0();
@@ -577,6 +578,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
return null;
}
+ @Override
public final String toString() { return "PState1[inside "+insideSurface+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+
", pressed [button "+buttonPressed+", mask "+buttonPressedMask+", dragging "+dragging+", clickCount "+lastButtonClickCount+"]"; }
}
@@ -1115,6 +1117,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return windowLock.getOwner();
}
+ @Override
public final RecursiveLock getLock() {
return windowLock;
}
@@ -2487,6 +2490,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if( this.pointerIcon != piImpl ) {
if( isNativeValid() ) {
runOnEDTIfAvail(true, new Runnable() {
+ @Override
public void run() {
setPointerIconIntern(piImpl);
} } );