From 3e141416ea6c85c14dc622dae57f071d5fd0ff4f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Mar 2020 19:20:19 +0100 Subject: 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. --- .../com/jogamp/nativewindow/NativeSurface.java | 19 +++++++++++++++++++ .../classes/jogamp/nativewindow/ProxySurfaceImpl.java | 5 +++++ 2 files changed, 24 insertions(+) (limited to 'src/nativewindow') 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. + *

+ * {@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. + *

+ *

+ * 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. + *

+ */ + public RecursiveLock getLock(); + /** * Lock the surface of this native window. *

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 @@ -190,6 +190,11 @@ public abstract class ProxySurfaceImpl implements ProxySurface { surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); } + @Override + public RecursiveLock getLock() { + return surfaceLock; + } + @Override public int lockSurface() throws NativeWindowException, RuntimeException { surfaceLock.lock(); -- cgit v1.2.3