From 6e599a2696f878786783e0fea17534e67655a5c9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 May 2010 06:15:17 +0200 Subject: Changed NEWT NativeWindow creation contract - AWT/NEWT Parenting - Misc Fixes +++++ Changed NEWT NativeWindow creation contract Original contract: (1) A native window was created as soon as possible, ie when NEWTFactory.createWindow(..) was called - if possible. (2) A valid native window has to be created at least after setVisible(true) has been called. Problems: Not all implementation are able to create the native window that early, but at setVisible(true) only (e.g: KD and EGL). Due to window parenting especially the new AWT/NEWT parenting, the native window can only be created in case the parent native window is valid. New contract: (1) A native window is created at setVisible(true), if it's a top level window or the native parent window is valid. (2) A valid native window may not be created after setVisible(true) has been called. Subsequent setVisible(true) calls shall be made in case the creation has not been done yet. This is demonstrated in GLWindow.display() for example. The new contract implements a lazy native window creation. +++++ AWT/NEWT Parenting - HierarchyListener and ComponentListener ensure that the NEWT child window will be setVisible according to the AWT parent window. - Lazy native window creation relaxes requirements to the parent window's state. - Attachment of the child window and setVisible() may be called after NEWT child window creation. - GLWindow supports NEWT child window creation directly The test case TestParenting01AWT.java reflect this new contract and demonstrates more simplified and more flexible use cases. +++++ NEWT Fixes: - All NEWT implementation's native code method names end with 0. - GLWindow: don't issue the actual 'init'/'display' call to GLEventListeners in case the window is not visible. - NEWT setSize/setPosition: if native-window call native-window action and let the attributes being set by the feedback call, which issues more action, ie RESIZE. else set the attributes directly, no feedback call/action is necessary. +++++ X11 Fixes: - X11GLContext MakeContextCurrent: Use MakeCurrent in case write and read drawable are equal, otherwise SEGV happens on ATI with heavy multithreading involved! Even XLockDisplay and XSync didn't help here .. - X11GLXDrawableFactory shared resource: Removed the resource holder thread to simplify code, hence proper release is no more desired and it could become a cause for deadlock. - Moved XInitThreads() from NEWT X11Window -> NativeWindow X11Util, since NativeWindow is loaded first (essential for XInitThreads()) and it is the more basic lib. - Made call to XInitThreads() conditional, ie it's spared if AWT could be used - which causes SEGV .. (AWT bug). See X11Util.java +++++ JOGL Fixes: - GLProfile.isAWTAvailable() -> NativeWindowFactory.isAWTAvailable() - GLProfile.isAWTJOGLAvailable() -> GLProfile.isAWTAvailable() --- src/jogl/classes/javax/media/opengl/GLProfile.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/jogl/classes/javax') diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 6b49b24df..d746101ca 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -45,6 +45,7 @@ import java.util.HashMap; import java.util.Iterator; import java.security.*; import javax.media.opengl.fixedfunc.GLPointerFunc; +import javax.media.nativewindow.NativeWindowFactory; /** * Specifies the the OpenGL profile. @@ -830,7 +831,6 @@ public class GLProfile implements Cloneable { private static final String GL2ES12 = "GL2ES12"; private static /*final*/ boolean isAWTAvailable; - private static /*final*/ boolean isAWTJOGLAvailable; private static /*final*/ boolean hasGL234Impl; private static /*final*/ boolean hasGL4bcImpl; @@ -862,12 +862,8 @@ public class GLProfile implements Cloneable { AccessControlContext acc = AccessController.getContext(); - isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) && - ReflectionUtil.isClassAvailable("java.awt.Component") ; - - isAWTJOGLAvailable = isAWTAvailable && - ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow - ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL + isAWTAvailable = NativeWindowFactory.isAWTAvailable() && + ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL boolean hasDesktopGL = false; boolean hasDesktopGLES12 = false; @@ -1040,7 +1036,6 @@ public class GLProfile implements Cloneable { if (DEBUG) { System.err.println("GLProfile.static isAWTAvailable "+isAWTAvailable); - System.err.println("GLProfile.static isAWTJOGLAvailable "+isAWTJOGLAvailable); System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory); System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL); System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12); @@ -1156,8 +1151,9 @@ public class GLProfile implements Cloneable { return null; } + /** @return {@link javax.media.nativewindow.NativeWindowFactory#isAWTAvailable()} and + JOGL's AWT part */ public static boolean isAWTAvailable() { return isAWTAvailable; } - public static boolean isAWTJOGLAvailable() { return isAWTJOGLAvailable; } public static String getGLTypeName(int type) { switch (type) { -- cgit v1.2.3