diff options
19 files changed, 202 insertions, 176 deletions
diff --git a/make/build.xml b/make/build.xml index 798a58b10..e696d9af3 100644 --- a/make/build.xml +++ b/make/build.xml @@ -756,9 +756,14 @@ </linker> <patternset id="c.src.files.jogl"> - <include name="${rootrel.src.c.jogl}/*.c"/> + <include name="${rootrel.src.c.jogl}/InternalBufferUtils.c"/> <include name="${rootrel.src.c.jogl}/*.m" if="os.isMacOSX"/> - <include name="${rootrel.generated.c.jogl}/*.c"/> + <include name="${rootrel.generated.c.jogl}/*GL*.c"/> + </patternset> + + <patternset id="c.src.files.jogl_awt"> + <include name="${rootrel.src.c.jogl}/JAWT*.c"/> + <include name="${rootrel.generated.c.jogl}/JAWT*.c"/> </patternset> <patternset id="c.src.files.cg"> @@ -809,7 +814,7 @@ </compiler> <linker extends="${linker.cfg.id}"> - <syslibset dir="${java.lib.dir.platform}" libs="jawt"/> + <syslibset dir="${java.lib.dir.platform}" libs="jawt" if="c.compiler.use-jawt"/> </linker> </cc> </target> @@ -827,57 +832,72 @@ <move file="${obj}/libjogl.dylib" tofile="${obj}/libjogl.jnilib" /> </target> + <target name="c.rename.jogl_awt.lib.macosx" if="os.isMacOSX"> + <!-- FIXME: this is a hack; the cpptask should have an option to change the + suffix or at least understand the override from dylib to jnilib --> + <move file="${obj}/libjogl_awt.dylib" tofile="${obj}/libjogl_awt.jnilib" /> + </target> + <target name="c.rename.jogl_cg.lib.macosx" if="os.isMacOSX"> <!-- FIXME: this is a hack; the cpptask should have an option to change the suffix or at least understand the override from dylib to jnilib --> <move file="${obj}/libjogl_cg.dylib" tofile="${obj}/libjogl_cg.jnilib" /> </target> - <target name="c.build.jogl"> + <target name="c.build.jogl.core"> <antcall target="c.build" inheritRefs="true"> <param name="c.compiler.src.files" value="c.src.files.jogl"/> - <param name="output.lib.name" value="jogl"/> + <param name="output.lib.name" value="jogl"/> </antcall> <antcall target="c.rename.jogl.lib.macosx" inheritRefs="true" /> </target> + <target name="c.build.jogl.awt"> + <antcall target="c.build" inheritRefs="true"> + <param name="c.compiler.src.files" value="c.src.files.jogl_awt"/> + <param name="c.compiler.use-jawt" value="true"/> + <param name="output.lib.name" value="jogl_awt"/> + </antcall> + <antcall target="c.rename.jogl_awt.lib.macosx" inheritRefs="true" /> + </target> + <target name="c.build.cg" if="jogl.cg"> <antcall target="c.build" inheritRefs="true"> - <param name="c.compiler.src.files" value="c.src.files.cg"/> - <param name="c.compiler.use-cglib" value="XXX"/> - <param name="output.lib.name" value="jogl_cg"/> + <param name="c.compiler.src.files" value="c.src.files.cg"/> + <param name="c.compiler.use-cglib" value="true"/> + <param name="output.lib.name" value="jogl_cg"/> </antcall> <antcall target="c.rename.jogl_cg.lib.macosx" inheritRefs="true" /> </target> - <target name="c.compile.jogl.win32.vc6" depends="declare.win32.vc6, c.build.jogl, c.build.cg" > + <target name="c.compile.jogl.win32.vc6" depends="declare.win32.vc6, c.build.jogl.core, c.build.jogl.awt, c.build.cg" > </target> - <target name="c.compile.jogl.win32.vc7" depends="declare.win32.vc7, c.build.jogl, c.build.cg"> + <target name="c.compile.jogl.win32.vc7" depends="declare.win32.vc7, c.build.jogl.core, c.build.jogl.awt, c.build.cg"> <property name="c.compiler.use-msvc7" value="true"/> </target> - <target name="c.compile.jogl.win32.mingw" depends="declare.win32.mingw, c.build.jogl, c.build.cg"> + <target name="c.compile.jogl.win32.mingw" depends="declare.win32.mingw, c.build.jogl.core, c.build.jogl.awt, c.build.cg"> <antcall target="c.rename.jogl.libs.mingw" inheritrefs="true" /> </target> - <target name="c.compile.jogl.linux" depends="declare.linux, c.build.jogl, c.build.cg" > + <target name="c.compile.jogl.linux" depends="declare.linux, c.build.jogl.core, c.build.jogl.awt, c.build.cg" > </target> - <target name="c.compile.jogl.linux.amd64" depends="declare.linux.amd64, c.build.jogl, c.build.cg" > + <target name="c.compile.jogl.linux.amd64" depends="declare.linux.amd64, c.build.jogl.core, c.build.jogl.awt, c.build.cg" > </target> - <target name="c.compile.jogl.linux.ia64" depends="declare.linux.ia64, c.build.jogl, c.build.cg" > + <target name="c.compile.jogl.linux.ia64" depends="declare.linux.ia64, c.build.jogl.core, c.build.jogl.awt, c.build.cg" > </target> - <target name="c.compile.jogl.solaris" depends="declare.solaris, c.build.jogl"> + <target name="c.compile.jogl.solaris" depends="declare.solaris, c.build.jogl.core, c.build.jogl.awt"> </target> - <target name="c.compile.jogl.macosx" depends="declare.macosx, c.build.jogl, c.build.cg"> + <target name="c.compile.jogl.macosx" depends="declare.macosx, c.build.jogl.core, c.build.jogl.awt, c.build.cg"> </target> - <target name="c.compile.jogl.freebsd" depends="declare.freebsd, c.build.jogl, c.build.cg" > + <target name="c.compile.jogl.freebsd" depends="declare.freebsd, c.build.jogl.core, c.build.jogl.awt, c.build.cg" > </target> <!-- ================================================================== --> @@ -983,6 +1003,7 @@ <and> <available file="${jogl.dist.dir}/jogl-win32/jogl.jar" /> <available file="${jogl.dist.dir}/jogl-win32/jogl.dll" /> + <available file="${jogl.dist.dir}/jogl-win32/jogl_awt.dll" /> <available file="${jogl.dist.dir}/jogl-win32/jogl_cg.dll" /> </and> </condition> @@ -1000,6 +1021,7 @@ <and> <available file="${jogl.dist.dir}/jogl-linux/jogl.jar" /> <available file="${jogl.dist.dir}/jogl-linux/libjogl.so" /> + <available file="${jogl.dist.dir}/jogl-linux/libjogl_awt.so" /> <available file="${jogl.dist.dir}/jogl-linux/libjogl_cg.so" /> </and> </condition> @@ -1017,6 +1039,7 @@ <and> <available file="${jogl.dist.dir}/jogl-macosx/jogl.jar" /> <available file="${jogl.dist.dir}/jogl-macosx/libjogl.jnilib" /> + <available file="${jogl.dist.dir}/jogl-macosx/libjogl_awt.jnilib" /> <available file="${jogl.dist.dir}/jogl-macosx/libjogl_cg.jnilib" /> </and> </condition> @@ -1034,6 +1057,7 @@ <and> <available file="${jogl.dist.dir}/jogl-solsparc/jogl.jar" /> <available file="${jogl.dist.dir}/jogl-solsparc/libjogl.so" /> + <available file="${jogl.dist.dir}/jogl-solsparc/libjogl_awt.so" /> </and> </condition> <fail unless="solsparc.complete"> @@ -1050,6 +1074,7 @@ <and> <available file="${jogl.dist.dir}/jogl-solx86/jogl.jar" /> <available file="${jogl.dist.dir}/jogl-solx86/libjogl.so" /> + <available file="${jogl.dist.dir}/jogl-solx86/libjogl_awt.so" /> </and> </condition> <fail unless="solx86.complete"> diff --git a/make/jawt-CustomJavaCode.java b/make/jawt-CustomJavaCode.java new file mode 100755 index 000000000..7e8e83b39 --- /dev/null +++ b/make/jawt-CustomJavaCode.java @@ -0,0 +1,27 @@ +private static volatile JAWT jawt; + +/** Helper routine for all users to call to access the JAWT. */ +public static JAWT getJAWT() { + if (jawt == null) { + synchronized (JAWT.class) { + if (jawt == null) { + NativeLibLoader.loadAWTImpl(); + // Workaround for 4845371. + // Make sure the first reference to the JNI GetDirectBufferAddress is done + // from a privileged context so the VM's internal class lookups will succeed. + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + JAWT j = JAWT.create(); + j.version(JAWTFactory.JAWT_VERSION_1_4); + if (!JAWTFactory.JAWT_GetAWT(j)) { + throw new RuntimeException("Unable to initialize JAWT"); + } + jawt = j; + return null; + } + }); + } + } + } + return jawt; +} diff --git a/make/jawt-macosx.cfg b/make/jawt-macosx.cfg index 10097ec65..a7886a250 100644 --- a/make/jawt-macosx.cfg +++ b/make/jawt-macosx.cfg @@ -15,11 +15,13 @@ Opaque long NSView * IgnoreField JAWT GetComponent IgnoreField JAWT_DrawingSurfaceInfo platformInfo +IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java + CustomCCode #include <inttypes.h> CustomCCode #include <jawt.h> - CustomCCode #include </usr/include/machine/types.h> +import java.security.* Import com.sun.opengl.impl.JAWT_PlatformInfo StructPackage JAWT_MacOSXDrawingSurfaceInfo com.sun.opengl.impl.macosx EmitStruct JAWT_MacOSXDrawingSurfaceInfo diff --git a/make/jawt-win32.cfg b/make/jawt-win32.cfg index c8a81ecfd..7f9d74e7b 100644 --- a/make/jawt-win32.cfg +++ b/make/jawt-win32.cfg @@ -5,24 +5,31 @@ Package com.sun.opengl.impl JavaClass JAWTFactory JavaOutputDir ..\build\gensrc\classes NativeOutputDir ..\build\gensrc\native\jogl + HierarchicalNativeOutput false + Opaque boolean jboolean Opaque long HDC + IgnoreField JAWT GetComponent IgnoreField JAWT_DrawingSurfaceInfo platformInfo IgnoreField JAWT_Win32DrawingSurfaceInfo null IgnoreField JAWT_Win32DrawingSurfaceInfo hpalette -CustomCCode #include <jawt.h> +IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java + +CustomCCode #include <jawt.h> CustomCCode /* This typedef is only needed for VC6 */ CustomCCode #if _MSC_VER <= 1200 CustomCCode typedef int intptr_t; CustomCCode #endif +import java.security.* Import com.sun.opengl.impl.JAWT_PlatformInfo StructPackage JAWT_Win32DrawingSurfaceInfo com.sun.opengl.impl.windows EmitStruct JAWT_Win32DrawingSurfaceInfo Implements JAWT_Win32DrawingSurfaceInfo JAWT_PlatformInfo + CustomJavaCode JAWT_DrawingSurfaceInfo public JAWT_PlatformInfo platformInfo() { CustomJavaCode JAWT_DrawingSurfaceInfo return platformInfo0(getBuffer()); CustomJavaCode JAWT_DrawingSurfaceInfo } diff --git a/make/jawt-x11.cfg b/make/jawt-x11.cfg index d326c2f26..43ccef7ec 100644 --- a/make/jawt-x11.cfg +++ b/make/jawt-x11.cfg @@ -5,15 +5,23 @@ Package com.sun.opengl.impl JavaClass JAWTFactory JavaOutputDir ../build/gensrc/classes NativeOutputDir ../build/gensrc/native/jogl + HierarchicalNativeOutput false + Opaque boolean jboolean Opaque long Drawable Opaque long Display * + IgnoreField JAWT GetComponent IgnoreField JAWT_DrawingSurfaceInfo platformInfo IgnoreField JAWT_X11DrawingSurfaceInfo GetAWTColor + +IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java + CustomCCode #include <inttypes.h> CustomCCode #include <jawt.h> + +import java.security.* Import com.sun.opengl.impl.JAWT_PlatformInfo StructPackage JAWT_X11DrawingSurfaceInfo com.sun.opengl.impl.x11 EmitStruct JAWT_X11DrawingSurfaceInfo diff --git a/src/classes/com/sun/opengl/impl/NativeLibLoader.java b/src/classes/com/sun/opengl/impl/NativeLibLoader.java index 6d4815cd7..1a3d5c277 100644 --- a/src/classes/com/sun/opengl/impl/NativeLibLoader.java +++ b/src/classes/com/sun/opengl/impl/NativeLibLoader.java @@ -44,7 +44,6 @@ import java.security.*; public class NativeLibLoader { private static volatile boolean doLoading = true; - private static volatile boolean doneLoading = false; public static void disableLoading() { doLoading = false; @@ -54,38 +53,55 @@ public class NativeLibLoader { doLoading = true; } - public static synchronized void load() { - if (doLoading && !doneLoading) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - boolean isOSX = System.getProperty("os.name").equals("Mac OS X"); - if (!isOSX) { - try { - // On X11 systems, toolkit must be loaded before - // trying to resolve JAWT in order for libmawt.so to - // be found properly - Toolkit.getDefaultToolkit(); - System.loadLibrary("jawt"); - } catch (UnsatisfiedLinkError e) { - // Accessibility technologies load JAWT themselves; safe to continue - // as long as JAWT is loaded by any loader - if (e.getMessage().indexOf("already loaded") == -1) { - throw e; - } + private static volatile boolean loadedCore = false; + private static volatile boolean loadedAWTImpl = false; + + public static void loadCore() { + if (doLoading && !loadedCore) { + synchronized (NativeLibLoader.class) { + if (!loadedCore) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + System.loadLibrary("jogl"); + return null; } - } - System.loadLibrary("jogl"); + }); + loadedCore = true; + } + } + } + } - // Workaround for 4845371. - // Make sure the first reference to the JNI GetDirectBufferAddress is done - // from a privileged context so the VM's internal class lookups will succeed. - JAWT jawt = JAWT.create(); - JAWTFactory.JAWT_GetAWT(jawt); + public static void loadAWTImpl() { + if (doLoading && !loadedAWTImpl) { + synchronized (NativeLibLoader.class) { + if (!loadedAWTImpl) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + boolean isOSX = System.getProperty("os.name").equals("Mac OS X"); + if (!isOSX) { + // Must pre-load JAWT on all non-Mac platforms to + // ensure references from jogl_awt shared object + // will succeed since JAWT shared object isn't in + // default library path + try { + System.loadLibrary("jawt"); + } catch (UnsatisfiedLinkError e) { + // Accessibility technologies load JAWT themselves; safe to continue + // as long as JAWT is loaded by any loader + if (e.getMessage().indexOf("already loaded") == -1) { + throw e; + } + } + } + System.loadLibrary("jogl_awt"); - return null; - } - }); - doneLoading = true; + return null; + } + }); + loadedAWTImpl = true; + } + } } } } diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java index 62b7f3b93..9b351798c 100644 --- a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java @@ -51,7 +51,7 @@ import com.sun.opengl.impl.*; public class MacOSXGLDrawableFactory extends GLDrawableFactoryImpl { static { - NativeLibLoader.load(); + NativeLibLoader.loadCore(); } public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLDrawable.java index 4d0f16623..c9e993237 100644 --- a/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLDrawable.java @@ -52,7 +52,6 @@ public class MacOSXOnscreenGLDrawable extends MacOSXGLDrawable { public static final int LOCK_SURFACE_CHANGED = 2; public static final int LOCK_SUCCESS = 3; - private static JAWT jawt; protected Component component; private List/*<WeakReference<GLContext>>*/ createdContexts = @@ -134,7 +133,7 @@ public class MacOSXOnscreenGLDrawable extends MacOSXGLDrawable { if (nsView != 0) { throw new GLException("Surface already locked"); } - ds = getJAWT().GetDrawingSurface(component); + ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized return LOCK_SURFACE_NOT_READY; @@ -165,7 +164,7 @@ public class MacOSXOnscreenGLDrawable extends MacOSXGLDrawable { if (dsi == null) { // Widget not yet realized ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; return LOCK_SURFACE_NOT_READY; } @@ -175,7 +174,7 @@ public class MacOSXOnscreenGLDrawable extends MacOSXGLDrawable { // Widget not yet realized ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; return LOCK_SURFACE_NOT_READY; @@ -185,7 +184,7 @@ public class MacOSXOnscreenGLDrawable extends MacOSXGLDrawable { // Widget not yet realized ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; macosxdsi = null; @@ -200,29 +199,10 @@ public class MacOSXOnscreenGLDrawable extends MacOSXGLDrawable { } ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; macosxdsi = null; nsView = 0; } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - private JAWT getJAWT() - { - if (jawt == null) - { - JAWT j = JAWT.create(); - j.version(JAWTFactory.JAWT_VERSION_1_4); - if (!JAWTFactory.JAWT_GetAWT(j)) - { - throw new RuntimeException("Unable to initialize JAWT"); - } - jawt = j; - } - return jawt; - } } diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java index ae48be999..ac56d9469 100644 --- a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java @@ -61,7 +61,7 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl { private long hglu32; static { - NativeLibLoader.load(); + NativeLibLoader.loadCore(); } public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsOnscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/WindowsOnscreenGLDrawable.java index fa3766a80..c475e1d0a 100644 --- a/src/classes/com/sun/opengl/impl/windows/WindowsOnscreenGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/WindowsOnscreenGLDrawable.java @@ -48,7 +48,6 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { public static final int LOCK_SURFACE_NOT_READY = 1; public static final int LOCK_SURFACE_CHANGED = 2; public static final int LOCK_SUCCESS = 3; - private static JAWT jawt; // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; @@ -123,7 +122,7 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { if (hdc != 0) { throw new GLException("Surface already locked"); } - ds = getJAWT().GetDrawingSurface(component); + ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized return LOCK_SURFACE_NOT_READY; @@ -145,7 +144,7 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { if (dsi == null) { // Widget not yet realized ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; return LOCK_SURFACE_NOT_READY; } @@ -155,7 +154,7 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { // Widget not yet realized ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; win32dsi = null; @@ -173,26 +172,10 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { } ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; win32dsi = null; hdc = 0; } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - private JAWT getJAWT() { - if (jawt == null) { - JAWT j = JAWT.create(); - j.version(JAWTFactory.JAWT_VERSION_1_4); - if (!JAWTFactory.JAWT_GetAWT(j)) { - throw new RuntimeException("Unable to initialize JAWT"); - } - jawt = j; - } - return jawt; - } } diff --git a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java index 4d329ba24..411f7c89f 100755 --- a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java +++ b/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java @@ -48,11 +48,11 @@ public class X11ExternalGLContext extends X11GLContext { public X11ExternalGLContext() { super(null, null); - lockAWT(); + lockToolkit(); try { context = GLX.glXGetCurrentContext(); } finally { - unlockAWT(); + unlockToolkit(); } GLContextShareSet.contextCreated(this); resetGLFunctionAvailability(); diff --git a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java index 371930013..96e1d0034 100755 --- a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java @@ -50,7 +50,7 @@ public class X11ExternalGLDrawable extends X11GLDrawable { public X11ExternalGLDrawable() { super(null, null, null); - lockAWT(); + lockToolkit(); try { display = GLX.glXGetCurrentDisplay(); drawable = GLX.glXGetCurrentDrawable(); @@ -72,7 +72,7 @@ public class X11ExternalGLDrawable extends X11GLDrawable { GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0); screen = val[0]; } finally { - unlockAWT(); + unlockToolkit(); } } @@ -113,7 +113,7 @@ public class X11ExternalGLDrawable extends X11GLDrawable { // Note that we have to completely override makeCurrentImpl // because the underlying makeCurrent call differs from the norm - lockAWT(); + lockToolkit(); try { boolean created = false; if (context == 0) { @@ -144,18 +144,18 @@ public class X11ExternalGLDrawable extends X11GLDrawable { } return CONTEXT_CURRENT; } finally { - unlockAWT(); + unlockToolkit(); } } protected void releaseImpl() throws GLException { - lockAWT(); + lockToolkit(); try { if (!GLX.glXMakeContextCurrent(drawable.getDisplay(), 0, 0, 0)) { throw new GLException("Error freeing OpenGL context"); } } finally { - unlockAWT(); + unlockToolkit(); } } diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLContext.java b/src/classes/com/sun/opengl/impl/x11/X11GLContext.java index ed9736f22..f8d35edd4 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11GLContext.java +++ b/src/classes/com/sun/opengl/impl/x11/X11GLContext.java @@ -164,7 +164,7 @@ public abstract class X11GLContext extends GLContextImpl { } protected void destroyImpl() throws GLException { - lockAWT(); + lockToolkit(); if (context != 0) { GLX.glXDestroyContext(mostRecentDisplay, context); if (DEBUG) { @@ -174,7 +174,7 @@ public abstract class X11GLContext extends GLContextImpl { mostRecentDisplay = 0; GLContextShareSet.contextDestroyed(this); } - unlockAWT(); + unlockToolkit(); } public boolean isCreated() { @@ -208,7 +208,7 @@ public abstract class X11GLContext extends GLContextImpl { glXQueryExtensionsStringInitialized = true; } if (glXQueryExtensionsStringAvailable) { - lockAWT(); + lockToolkit(); try { String ret = GLX.glXQueryExtensionsString(drawable.getDisplay(), GLX.DefaultScreen(drawable.getDisplay())); if (DEBUG) { @@ -216,7 +216,7 @@ public abstract class X11GLContext extends GLContextImpl { } return ret; } finally { - unlockAWT(); + unlockToolkit(); } } else { return ""; @@ -291,11 +291,11 @@ public abstract class X11GLContext extends GLContextImpl { // These synchronization primitives prevent the AWT from making // requests from the X server asynchronously to this code. - protected void lockAWT() { - X11GLDrawableFactory.lockAWT(); + protected void lockToolkit() { + X11GLDrawableFactory.lockToolkit(); } - protected void unlockAWT() { - X11GLDrawableFactory.unlockAWT(); + protected void unlockToolkit() { + X11GLDrawableFactory.unlockToolkit(); } } diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java index 343931965..bfa467b10 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java @@ -103,9 +103,9 @@ public abstract class X11GLDrawable extends GLDrawableImpl { XVisualInfo template = XVisualInfo.create(); // FIXME: probably not 64-bit clean template.visualid((int) visualID); - lockAWT(); + lockToolkit(); XVisualInfo[] infos = GLX.XGetVisualInfo(display, GLX.VisualIDMask, template, count, 0); - unlockAWT(); + unlockToolkit(); if (infos == null || infos.length == 0) { throw new GLException("Error while getting XVisualInfo for visual ID " + visualID); } @@ -126,7 +126,7 @@ public abstract class X11GLDrawable extends GLDrawableImpl { template.screen(screen); XVisualInfo[] infos = null; GLCapabilities[] caps = null; - lockAWT(); + lockToolkit(); try { infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count, 0); if (infos == null) { @@ -137,7 +137,7 @@ public abstract class X11GLDrawable extends GLDrawableImpl { caps[i] = X11GLDrawableFactory.xvi2GLCapabilities(display, infos[i]); } } finally { - unlockAWT(); + unlockToolkit(); } int chosen = chooser.chooseCapabilities(capabilities, caps, -1); if (chosen < 0 || chosen >= caps.length) { @@ -162,11 +162,11 @@ public abstract class X11GLDrawable extends GLDrawableImpl { // These synchronization primitives prevent the AWT from making // requests from the X server asynchronously to this code. - protected void lockAWT() { - X11GLDrawableFactory.lockAWT(); + protected void lockToolkit() { + X11GLDrawableFactory.lockToolkit(); } - protected void unlockAWT() { - X11GLDrawableFactory.unlockAWT(); + protected void unlockToolkit() { + X11GLDrawableFactory.unlockToolkit(); } } diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java index 38d63f04d..90f5b9fe5 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java @@ -56,7 +56,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { private static boolean isLinuxAMD64; static { - NativeLibLoader.load(); + NativeLibLoader.loadCore(); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -100,7 +100,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { XVisualInfo[] infos = null; GLCapabilities[] caps = null; int recommendedIndex = -1; - lockAWT(); + lockToolkit(); try { long display = getDisplayConnection(); XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0); @@ -120,7 +120,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { } } } finally { - unlockAWT(); + unlockToolkit(); } int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex); if (chosen < 0 || chosen >= caps.length) { @@ -180,7 +180,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { Runnable r = new Runnable() { public void run() { long display = getDisplayConnection(); - lockAWT(); + lockToolkit(); try { int[] major = new int[1]; int[] minor = new int[1]; @@ -207,7 +207,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { pbufferSupportInitialized = true; } finally { - unlockAWT(); + unlockToolkit(); } } }; @@ -343,48 +343,34 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl { return res; } - // JAWT access - private static JAWT jawt; - public static JAWT getJAWT() { - if (jawt == null) { - JAWT j = JAWT.create(); - j.version(JAWTFactory.JAWT_VERSION_1_4); - if (!JAWTFactory.JAWT_GetAWT(j)) { - throw new RuntimeException("Unable to initialize JAWT"); - } - jawt = j; - } - return jawt; - } - - public static void lockAWT() { + public static void lockToolkit() { if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) { - getJAWT().Lock(); + JAWT.getJAWT().Lock(); } } - public static void unlockAWT() { + public static void unlockToolkit() { if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) { - getJAWT().Unlock(); + JAWT.getJAWT().Unlock(); } } - public void lockAWTForJava2D() { - lockAWT(); + public void lockToolkitForJava2D() { + lockToolkit(); } - public void unlockAWTForJava2D() { - unlockAWT(); + public void unlockToolkitForJava2D() { + unlockToolkit(); } // Display connection for use by visual selection algorithm and by all offscreen surfaces private static long staticDisplay; public static long getDisplayConnection() { if (staticDisplay == 0) { - lockAWT(); + lockToolkit(); try { staticDisplay = GLX.XOpenDisplay(null); } finally { - unlockAWT(); + unlockToolkit(); } if (staticDisplay == 0) { throw new GLException("Unable to open default display, needed for visual selection and offscreen surface handling"); diff --git a/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java index 2d7dedd7f..5370860c6 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java @@ -80,7 +80,7 @@ public class X11OffscreenGLDrawable extends X11GLDrawable { XVisualInfo vis = chooseVisual(false); int bitsPerPixel = vis.depth(); - lockAWT(); + lockToolkit(); try { int screen = GLX.DefaultScreen(display); pixmap = GLX.XCreatePixmap(display, (int) GLX.RootWindow(display, screen), width, height, bitsPerPixel); @@ -100,7 +100,7 @@ public class X11OffscreenGLDrawable extends X11GLDrawable { ", display " + toHexString(display)); } } finally { - unlockAWT(); + unlockToolkit(); } } @@ -113,7 +113,7 @@ public class X11OffscreenGLDrawable extends X11GLDrawable { } // Must destroy pixmap and GLXPixmap - lockAWT(); + lockToolkit(); if (DEBUG) { long cur = GLX.glXGetCurrentContext(); @@ -130,7 +130,7 @@ public class X11OffscreenGLDrawable extends X11GLDrawable { GLX.glXDestroyGLXPixmap(display, drawable); GLX.XFreePixmap(display, pixmap); - unlockAWT(); + unlockToolkit(); drawable = 0; pixmap = 0; display = 0; diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java index 49000fc14..810de42c5 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java @@ -91,7 +91,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { } public void swapBuffers() throws GLException { - lockAWT(); + lockToolkit(); try { boolean didLock = false; @@ -109,7 +109,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { unlockSurface(); } } finally { - unlockAWT(); + unlockToolkit(); } } @@ -120,7 +120,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { if (drawable != 0) { throw new GLException("Surface already locked"); } - ds = getJAWT().GetDrawingSurface(component); + ds = JAWT.getJAWT().GetDrawingSurface(component); if (ds == null) { // Widget not yet realized return LOCK_SURFACE_NOT_READY; @@ -142,7 +142,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { if (dsi == null) { // Widget not yet realized ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; return LOCK_SURFACE_NOT_READY; } @@ -154,7 +154,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { // Widget not yet realized ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; x11dsi = null; @@ -172,7 +172,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { } ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); - getJAWT().FreeDrawingSurface(ds); + JAWT.getJAWT().FreeDrawingSurface(ds); ds = null; dsi = null; x11dsi = null; @@ -180,12 +180,4 @@ public class X11OnscreenGLDrawable extends X11GLDrawable { drawable = 0; visualID = 0; } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - private JAWT getJAWT() { - return X11GLDrawableFactory.getJAWT(); - } } diff --git a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java index 0cb945de7..3b0d51f13 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java +++ b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java @@ -72,7 +72,7 @@ public class X11PbufferGLContext extends X11GLContext { // Note that we have to completely override makeCurrentImpl // because the underlying makeCurrent call differs for pbuffers - lockAWT(); + lockToolkit(); try { boolean created = false; if (context == 0) { @@ -103,18 +103,18 @@ public class X11PbufferGLContext extends X11GLContext { } return CONTEXT_CURRENT; } finally { - unlockAWT(); + unlockToolkit(); } } protected void releaseImpl() throws GLException { - lockAWT(); + lockToolkit(); try { if (!GLX.glXMakeContextCurrent(drawable.getDisplay(), 0, 0, 0)) { throw new GLException("Error freeing OpenGL context"); } } finally { - unlockAWT(); + unlockToolkit(); } } diff --git a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java index 2a1248405..85df39267 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java @@ -78,11 +78,11 @@ public class X11PbufferGLDrawable extends X11GLDrawable { } public void destroy() { - lockAWT(); + lockToolkit(); if (drawable != 0) { GLX.glXDestroyPbuffer(display, drawable); } - unlockAWT(); + unlockToolkit(); display = 0; } @@ -100,7 +100,7 @@ public class X11PbufferGLDrawable extends X11GLDrawable { } public void createPbuffer(long display) { - lockAWT(); + lockToolkit(); try { if (display == 0) { throw new GLException("Null display"); @@ -241,7 +241,7 @@ public class X11PbufferGLDrawable extends X11GLDrawable { System.err.println("Created pbuffer " + width + " x " + height); } } finally { - unlockAWT(); + unlockToolkit(); } } |