From 774138544e1eec3330309ad682fa05154a07ab8d Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Thu, 14 Oct 2010 21:26:43 +0200
Subject: JOGL: Reenable Applet/Webstart/RCP support for JOGL + AWT + X11

Changed GLProfile/NativeWindowFactory/.. initialization methodology:

    GLProfile:
        public static synchronized void initSingleton(final boolean firstUIActionOnProcess);

    NativeWindowFactory:
        public static synchronized void initSingleton(final boolean firstUIActionOnProcess);

+++

Introducing NativeWindow ToolkitLock, implementations are
    NullToolkitLock
    JAWTToolkitLock
    X11JAWTToolkitLock
    X11ToolkitLock

AbstractGraphicsDevice provides generic global toolkit locking methods,
implemented by the ToolkitLock interface.

ToolkitLock's are aggregated in NativeWindow's DefaultGraphicsDevice
to implement it's superclass lock()/unlock() methods.

This enables a device specific locking strategy, ie on X11/AWT utilizing
JAWT && X11 locking, and maybe none for others (NEWT).

No locking is required for X11 / AWT, in case the above mentioned
initialization happened as a 'firstUIActionOnProcess'.

The ToolkitLock factory is currently a hardcoded part of NativeWindowFactory.
We may have to allow 3rd party NativeWindow implementations
to register custom ones.

+++

com.jogamp.opengl.impl.GLDrawableImpl cleanup:
  Dealing with all locking code, providing all public methods. Exceptions are commented.
  Specializations x11/windows/.. only contains platform code.
  Pulled down access qualifiers if possible public -> protected.

com.jogamp.nativewindow.impl.x11.X11Util
  Wrapping all X11Lib method with the new locking code.

com.jogamp.nativewindow.impl.jawt.JAWTUtil
  Utilize global SunToolkit.awtLock() is available,
  the fallback to global JAWT.lock().
  The latter just invokes the first.

javax.media.nativewindow.awt.AWTGraphicsDevice
    setHandle(long handle) -> setSubType(String type, long handle)
    which also resets the ToolkitLock respecting the new type.
    This ensures correct locking after the sub type has been determined,
    ie AWT using an X11 peer.

+++

Misc Changes done on the way ..

GLCanvas:
    Fixed inversed this.drawableHelper.isExternalAnimatorAnimating() condition,
    which disabled normal repaint.

GLJPanel:
    Removed drawableHelper.isExternalAnimatorAnimating() condition,
    which disabled painting, since the animation thread just updates the source image.

NEWT WindowImpl:
    When reparenting back to parent and 'refit' child if it's size exceeds it's parent.
    More 'Fix: Memory consumption' commit 6ced17f0325d5719e992b246ffd156e5b39694b4.

NEWTEvent:
    Removed code to evaluate the 'system event' attribute, need to find a better approach.
---
 .../classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java | 10 +++++-----
 .../opengl/impl/egl/EGLGraphicsConfigurationFactory.java       |  7 +++----
 2 files changed, 8 insertions(+), 9 deletions(-)

(limited to 'src/jogl/classes/com/jogamp/opengl/impl/egl')

diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
index b1084dd8f..83e85b922 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -115,14 +115,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
     protected final GLDrawableImpl getSharedDrawable() { return null; }
     protected final GLContextImpl getSharedContext() { return null; }
 
-    public GLDrawableImpl createOnscreenDrawable(NativeSurface target) {
+    protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
         if (target == null) {
           throw new IllegalArgumentException("Null target");
         }
         return new EGLOnscreenDrawable(this, target);
     }
 
-    protected GLDrawableImpl createOffscreenDrawable(NativeSurface target) {
+    protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
         throw new GLException("Not yet implemented");
     }
 
@@ -134,13 +134,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         return new EGLPbufferDrawable(this, target);
     }
 
-    protected NativeSurface createOffscreenSurface(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+    protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
         ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capabilities, chooser));
         ns.setSize(width, height);
         return ns;
     }
 
-    public GLContext createExternalGLContext() {
+    protected GLContext createExternalGLContextImpl() {
         AbstractGraphicsScreen absScreen = DefaultGraphicsScreen.createScreenDevice(0);
         return new EGLExternalContext(absScreen);
     }
@@ -149,7 +149,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         return false;
     }
 
-    public GLDrawable createExternalGLDrawable() {
+    protected GLDrawable createExternalGLDrawableImpl() {
         throw new GLException("Not yet implemented");
     }
 
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index 33e301ee9..88e8a9ed1 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -53,9 +53,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
         GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, this);
     }
 
-    public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
-                                                                     CapabilitiesChooser chooser,
-                                                                     AbstractGraphicsScreen absScreen) {
+    protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl (
+            Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
         if (absScreen == null) {
             throw new IllegalArgumentException("This NativeWindowFactory accepts only AbstractGraphicsDevice objects");
         }
@@ -75,7 +74,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
                                                  absScreen);
     }
 
-    public static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
+    private static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
                                                                              GLCapabilitiesChooser chooser,
                                                                              AbstractGraphicsScreen absScreen) {
         if (capabilities == null) {
-- 
cgit v1.2.3