diff options
author | Sven Gothel <[email protected]> | 2019-09-04 04:20:22 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-09-04 04:20:22 +0200 |
commit | c5431f46b7bf64f109315ec78461859dd88f202a (patch) | |
tree | d5952708d0d1460bb299a04e95a126f919f7e5ba /src/jogl/classes/com/jogamp | |
parent | d1f4bcc64222d53eb7241184210730aa28ae1f6d (diff) |
Bug 1363: Java 11: JAWTUtil: Use sun.awt.SunToolkit.awtLock/Unlock and disableBackgroundErase (impl. semantics)
Commit 13c6bbbde5ea476d60e0a2f04a5172d3302d0edd simply removed the
AWT commonly used SunToolkit lock/unlock methods, which was incorrect.
It lead to certain resources access collisions as access has to be synchronized
using the same reentry lock across AWT and NativeWindow/JOGL.
We utilize the new com.jogamp.common.util.UnsafeUtil of GlueGen commit 07c1885e9a3d1f3a3853414648c06fb3864bc69f
to disable the IllegalAccessLogger while fetching the methods/fields and making them accessible.
JAWUtil also hosts access to SunToolkit's disableBackgroundAccess(Component)
aligning the code for GLCanvas, NewtCanvasAWT and AWTCanvas.
Diffstat (limited to 'src/jogl/classes/com/jogamp')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java | 63 |
1 files changed, 5 insertions, 58 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java index 5e0074ff8..5e440092b 100644 --- a/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/awt/GLCanvas.java @@ -41,9 +41,6 @@ package com.jogamp.opengl.awt; import java.beans.Beans; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.awt.Canvas; import java.awt.Color; import java.awt.FontMetrics; @@ -104,6 +101,7 @@ import com.jogamp.opengl.util.GLDrawableUtil; import com.jogamp.opengl.util.TileRenderer; import jogamp.nativewindow.SurfaceScaleUtils; +import jogamp.nativewindow.jawt.JAWTUtil; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; @@ -158,11 +156,11 @@ import jogamp.opengl.awt.AWTTilePainter; * </ul> * * <h5><a name="contextSharing">OpenGL Context Sharing</a></h5> - * + * * To share a {@link GLContext} see the following note in the documentation overview: * <a href="../../../../overview-summary.html#SHARING">context sharing</a> * as well as {@link GLSharedContextSetter}. - * + * */ @SuppressWarnings("serial") @@ -593,7 +591,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing */ // before native peer is valid: X11 - disableBackgroundErase(); + JAWTUtil.disableBackgroundErase(this); final GraphicsDevice awtDevice; if(null==awtDeviceReq) { @@ -618,7 +616,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing super.addNotify(); // after native peer is valid: Windows - disableBackgroundErase(); + JAWTUtil.disableBackgroundErase(this); createJAWTDrawableAndContext(); @@ -1478,57 +1476,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } }; - // Disables the AWT's erasing of this Canvas's background on Windows - // in Java SE 6. This internal API is not available in previous - // releases, but the system property - // -Dsun.awt.noerasebackground=true can be specified to get similar - // results globally in previous releases. - private static boolean disableBackgroundEraseInitialized; - private static Method disableBackgroundEraseMethod; - private void disableBackgroundErase() { - if (!disableBackgroundEraseInitialized) { - try { - AccessController.doPrivileged(new PrivilegedAction<Object>() { - @Override - public Object run() { - try { - Class<?> clazz = getToolkit().getClass(); - while (clazz != null && disableBackgroundEraseMethod == null) { - try { - disableBackgroundEraseMethod = - clazz.getDeclaredMethod("disableBackgroundErase", - new Class[] { Canvas.class }); - disableBackgroundEraseMethod.setAccessible(true); - } catch (final Exception e) { - clazz = clazz.getSuperclass(); - } - } - } catch (final Exception e) { - } - return null; - } - }); - } catch (final Exception e) { - } - disableBackgroundEraseInitialized = true; - if(DEBUG) { - System.err.println(getThreadName()+": GLCanvas: TK disableBackgroundErase method found: "+ - (null!=disableBackgroundEraseMethod)); - } - } - if (disableBackgroundEraseMethod != null) { - Throwable t=null; - try { - disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this }); - } catch (final Exception e) { - t = e; - } - if(DEBUG) { - System.err.println(getThreadName()+": GLCanvas: TK disableBackgroundErase error: "+t); - } - } - } - /** * Issues the GraphicsConfigurationFactory's choosing facility within EDT, * since resources created (X11: Display), must be destroyed in the same thread, where they have been created. |