From d96486967efcfb6f43226da9fa60cbc3d68ab323 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 28 Jun 2008 14:30:26 +0000 Subject: 3rd round cdcfp - compile clean. Re-adding cdcfp: com/sun/opengl/impl/glu/mipmap/* com/sun/opengl/impl/GLPbufferImpl.java Using 'BufferUtil.nativeOrder(ByteBuffer)' to set up the native byte order. 'BufferUtil.nativeOrder' is now public. GLDrawableFactory: - removed 'hardcoded' awt attribute. Cleanup NEWT's AWT wrapping implementation. - NativeWindowFactory incooperates with the wrapping property. Bugs on X11/NEWT/AWT: - no events - deadlock at shutdown - deadlock if EGLDrawable with AWT get's locked git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1700 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../com/sun/opengl/impl/GLDrawableFactoryImpl.java | 8 +- .../com/sun/opengl/impl/GLDrawableImpl.java | 7 ++ src/classes/com/sun/opengl/impl/GLPbufferImpl.java | 16 +--- src/classes/com/sun/opengl/impl/GLReflection.java | 30 ++++++-- .../com/sun/opengl/impl/NativeWindowHelper.java | 50 ------------- src/classes/com/sun/opengl/impl/NullWindow.java | 4 + src/classes/com/sun/opengl/impl/awt/Java2D.java | 11 +-- .../com/sun/opengl/impl/egl/EGLDrawable.java | 49 ++++++++++--- .../sun/opengl/impl/egl/EGLDrawableFactory.java | 1 + .../opengl/impl/egl/awt/EGLAWTDrawableFactory.java | 55 ++++++++++++++ .../sun/opengl/impl/glu/mipmap/BuildMipmap.java | 85 +++++++++++----------- .../com/sun/opengl/impl/glu/mipmap/Mipmap.java | 5 +- .../sun/opengl/impl/glu/mipmap/ScaleInternal.java | 11 ++- .../sun/opengl/impl/glu/mipmap/Type_Widget.java | 2 +- src/classes/com/sun/opengl/impl/jawt/JAWTUtil.java | 6 +- .../com/sun/opengl/impl/jawt/JAWTWindow.java | 21 +++++- .../sun/opengl/impl/jawt/x11/X11JAWTWindow.java | 4 +- .../opengl/impl/macosx/cgl/MacOSXCGLDrawable.java | 3 - .../impl/macosx/cgl/MacOSXCGLDrawableFactory.java | 2 +- .../impl/macosx/cgl/MacOSXPbufferCGLDrawable.java | 1 + .../impl/windows/wgl/WindowsDummyWGLDrawable.java | 1 + .../windows/wgl/WindowsExternalWGLDrawable.java | 3 - .../windows/wgl/WindowsOffscreenWGLDrawable.java | 1 + .../windows/wgl/WindowsPbufferWGLDrawable.java | 1 + .../windows/wgl/WindowsWGLDrawableFactory.java | 2 +- .../impl/x11/glx/X11ExternalGLXDrawable.java | 3 - .../com/sun/opengl/impl/x11/glx/X11GLXContext.java | 2 +- .../opengl/impl/x11/glx/X11GLXDrawableFactory.java | 12 +-- .../impl/x11/glx/X11OffscreenGLXDrawable.java | 2 +- .../impl/x11/glx/X11OnscreenGLXDrawable.java | 10 +-- .../opengl/impl/x11/glx/X11PbufferGLXDrawable.java | 1 + .../impl/x11/glx/awt/X11AWTGLXDrawableFactory.java | 2 + 32 files changed, 227 insertions(+), 184 deletions(-) delete mode 100644 src/classes/com/sun/opengl/impl/NativeWindowHelper.java create mode 100644 src/classes/com/sun/opengl/impl/egl/awt/EGLAWTDrawableFactory.java (limited to 'src/classes/com/sun/opengl/impl') diff --git a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java index 21fe5b386..6eb405b0d 100644 --- a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java +++ b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java @@ -62,12 +62,12 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements super(); } - public static GLDrawableFactoryImpl getFactoryImpl(boolean awt) { - return (GLDrawableFactoryImpl) getFactory(awt); + public static GLDrawableFactoryImpl getFactoryImpl(Class winClazz) { + return (GLDrawableFactoryImpl) getFactory(winClazz); } - public static GLDrawableFactoryImpl getFactoryImpl(Object target) { - return (GLDrawableFactoryImpl) getFactory(target); + public static GLDrawableFactoryImpl getFactoryImpl() { + return (GLDrawableFactoryImpl) getFactory(); } // Helper function for more lazily loading the GLU library; diff --git a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java index 26f3d6585..3053a91de 100644 --- a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -52,6 +52,7 @@ public abstract class GLDrawableImpl implements GLDrawable { /** For offscreen GLDrawables (pbuffers and "pixmap" drawables), indicates that native resources should be reclaimed. */ public void destroy() throws GLException { + setRealized(false); } public void swapBuffers() throws GLException { @@ -125,6 +126,12 @@ public abstract class GLDrawableImpl implements GLDrawable { return component.isSurfaceLocked(); } + public String toString() { + return "GLDrawable[realized "+getRealized()+ + ", window "+getNativeWindow()+ + ", factory "+getFactory()+"]"; + } + protected GLDrawableFactory factory; protected NativeWindow component; private GLCapabilities chosenCapabilities; diff --git a/src/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/classes/com/sun/opengl/impl/GLPbufferImpl.java index 7a7b2772a..1f48ae8a1 100644 --- a/src/classes/com/sun/opengl/impl/GLPbufferImpl.java +++ b/src/classes/com/sun/opengl/impl/GLPbufferImpl.java @@ -43,8 +43,8 @@ package com.sun.opengl.impl; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.event.*; - */ import java.beans.PropertyChangeListener; + */ import javax.media.opengl.*; @@ -186,20 +186,6 @@ public class GLPbufferImpl implements GLPbuffer { return surfaceLocked; } - private boolean tkLocked = false; - - public void lockToolkit() throws GLException { - tkLocked=true; - } - - public void unlockToolkit() { - tkLocked=false; - } - - public boolean isToolkitLocked() { - return tkLocked; - } - //---------------------------------------------------------------------- // No-ops for ComponentEvents // diff --git a/src/classes/com/sun/opengl/impl/GLReflection.java b/src/classes/com/sun/opengl/impl/GLReflection.java index 94e004f30..6898db82d 100644 --- a/src/classes/com/sun/opengl/impl/GLReflection.java +++ b/src/classes/com/sun/opengl/impl/GLReflection.java @@ -89,7 +89,9 @@ public final class GLReflection { } public static final boolean instanceOf(Object obj, String clazzName) { - Class clazz = obj.getClass(); + return instanceOf(obj.getClass(), clazzName); + } + public static final boolean instanceOf(Class clazz, String clazzName) { do { if(clazz.getName().equals(clazzName)) { return true; @@ -100,15 +102,29 @@ public final class GLReflection { } public static final boolean implementationOf(Object obj, String faceName) { - Class[] clazzes = obj.getClass().getInterfaces(); - for(int i=clazzes.length-1; i>=0; i--) { - Class face = clazzes[i]; - if(face.getName().equals(faceName)) { - return true; + return implementationOf(obj.getClass(), faceName); + } + public static final boolean implementationOf(Class clazz, String faceName) { + do { + Class[] clazzes = clazz.getInterfaces(); + for(int i=clazzes.length-1; i>=0; i--) { + Class face = clazzes[i]; + if(face.getName().equals(faceName)) { + return true; + } } - } + clazz = clazz.getSuperclass(); + } while (clazz!=null); return false; } + public static boolean isAWTComponent(Object target) { + return instanceOf(target, "java.awt.Component"); + } + + public static boolean isAWTComponent(Class clazz) { + return instanceOf(clazz, "java.awt.Component"); + } + } diff --git a/src/classes/com/sun/opengl/impl/NativeWindowHelper.java b/src/classes/com/sun/opengl/impl/NativeWindowHelper.java deleted file mode 100644 index 5432d8cb1..000000000 --- a/src/classes/com/sun/opengl/impl/NativeWindowHelper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package com.sun.opengl.impl; - -import javax.media.opengl.*; - -/** Helper class to assist in the case where for example a Newt window - wraps an AWT window. */ - -public class NativeWindowHelper { - private NativeWindowHelper() {} - - public static NativeWindow unwrap(NativeWindow target) { - if (target.getWrappedWindow() != null) { - target = NativeWindowFactory.getNativeWindow(target.getWrappedWindow()); - } - return target; - } -} diff --git a/src/classes/com/sun/opengl/impl/NullWindow.java b/src/classes/com/sun/opengl/impl/NullWindow.java index ef23083b0..a366a734a 100644 --- a/src/classes/com/sun/opengl/impl/NullWindow.java +++ b/src/classes/com/sun/opengl/impl/NullWindow.java @@ -109,6 +109,10 @@ public class NullWindow implements NativeWindow { return null; } + public final boolean isTerminalObject() { + return true; + } + public void setSize(int width, int height) { this.width=width; this.height=height; diff --git a/src/classes/com/sun/opengl/impl/awt/Java2D.java b/src/classes/com/sun/opengl/impl/awt/Java2D.java index 0595dbed7..0611f799f 100755 --- a/src/classes/com/sun/opengl/impl/awt/Java2D.java +++ b/src/classes/com/sun/opengl/impl/awt/Java2D.java @@ -40,6 +40,7 @@ package com.sun.opengl.impl.awt; import com.sun.opengl.impl.*; +import com.sun.opengl.impl.jawt.*; import java.awt.*; import java.awt.image.*; @@ -288,11 +289,11 @@ public class Java2D { getDefaultScreenDevice(). getDefaultConfiguration()); - GLDrawableFactoryImpl.getFactoryImpl(true).lockToolkit(); + JAWTUtil.lockToolkit(); try { invokeWithOGLContextCurrentMethod.invoke(null, new Object[] {g, r}); } finally { - GLDrawableFactoryImpl.getFactory(true).unlockToolkit(); + JAWTUtil.unlockToolkit(); } } catch (InvocationTargetException e) { throw new GLException(e.getTargetException()); @@ -313,11 +314,11 @@ public class Java2D { checkActive(); try { - GLDrawableFactoryImpl.getFactoryImpl(true).lockToolkit(); + JAWTUtil.lockToolkit(); try { return ((Boolean) invokeWithOGLSharedContextCurrentMethod.invoke(null, new Object[] {g, r})).booleanValue(); } finally { - GLDrawableFactoryImpl.getFactoryImpl(true).unlockToolkit(); + JAWTUtil.unlockToolkit(); } } catch (InvocationTargetException e) { throw new GLException(e.getTargetException()); @@ -558,7 +559,7 @@ public class Java2D { } invokeWithOGLSharedContextCurrent(gc, new Runnable() { public void run() { - j2dFBOShareContext = GLDrawableFactory.getFactory(true).createExternalGLContext(); + j2dFBOShareContext = GLDrawableFactory.getFactory(Component.class).createExternalGLContext(); } }); if (DEBUG) { diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java index b562d7423..034471b00 100755 --- a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java @@ -82,7 +82,11 @@ public class EGLDrawable extends GLDrawableImpl { public void destroy() { setRealized(false); - EGL.eglTerminate(display); + if(EGL.EGL_NO_DISPLAY!=display) { + EGL.eglTerminate(display); + display=EGL.EGL_NO_DISPLAY; + } + super.destroy(); } public _EGLConfig getConfig() { @@ -99,10 +103,18 @@ public class EGLDrawable extends GLDrawableImpl { public void setRealized(boolean realized) { if (realized) { - // Create the window surface - surface = EGL.eglCreateWindowSurface(display, config, component.getWindowHandle(), null); + getFactory().lockToolkit(); + try { + lockSurface(); + + // Create the window surface + surface = EGL.eglCreateWindowSurface(display, config, component.getWindowHandle(), null); + } finally { + unlockSurface(); + getFactory().unlockToolkit(); + } if (surface == EGL.EGL_NO_SURFACE) { - throw new GLException("Creation of window surface (eglCreateWindowSurface) failed"); + throw new GLException("Creation of window surface (eglCreateWindowSurface) failed, component: "+component); } } else if( surface != EGL.EGL_NO_SURFACE ) { // Destroy the window surface @@ -115,6 +127,7 @@ public class EGLDrawable extends GLDrawableImpl { } surface = EGL.EGL_NO_SURFACE; } + super.setRealized(realized); } public void setSize(int width, int height) { @@ -136,16 +149,28 @@ public class EGLDrawable extends GLDrawableImpl { } public void swapBuffers() throws GLException { - EGL.eglSwapBuffers(display, surface); + getFactory().lockToolkit(); + try { + if (component.getSurfaceHandle() == 0) { + if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { + return; + } + } + + EGL.eglSwapBuffers(display, surface); + + } finally { + unlockSurface(); + getFactory().unlockToolkit(); + } } public String toString() { - return "EGLDrawable[ displayHandle " + component.getDisplayHandle() + - ", screenHandle "+ component.getScreenHandle() + - ", windowHandle "+ component.getWindowHandle() + - ", display " + display + - ", config " + config + - ", surface " + surface + - "]"; + return "EGLDrawable[ realized "+getRealized()+ + ", window "+getNativeWindow()+ + ", egl display " + display + + ", egl config " + config + + ", egl surface " + surface + + ", factory "+getFactory()+"]"; } } diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java index a01dd91c7..00f293ffb 100755 --- a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java @@ -115,6 +115,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { public GLDrawable createGLDrawable(NativeWindow target, GLCapabilities capabilities, GLCapabilitiesChooser chooser) { + target = NativeWindowFactory.getNativeWindow(target); return new EGLDrawable(this, target, capabilities, chooser); diff --git a/src/classes/com/sun/opengl/impl/egl/awt/EGLAWTDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/awt/EGLAWTDrawableFactory.java new file mode 100644 index 000000000..e5d1387e8 --- /dev/null +++ b/src/classes/com/sun/opengl/impl/egl/awt/EGLAWTDrawableFactory.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + */ + +package com.sun.opengl.impl.egl.awt; + +import com.sun.opengl.impl.*; +import com.sun.opengl.impl.egl.*; +import com.sun.opengl.impl.jawt.*; + +public class EGLAWTDrawableFactory extends EGLDrawableFactory { + + public void lockToolkit() { + super.lockToolkit(); + // freezes AWT: JAWTUtil.lockToolkit(); + } + + public void unlockToolkit() { + // freezes AWT: JAWTUtil.unlockToolkit(); + super.unlockToolkit(); + } + +} diff --git a/src/classes/com/sun/opengl/impl/glu/mipmap/BuildMipmap.java b/src/classes/com/sun/opengl/impl/glu/mipmap/BuildMipmap.java index 878eeabe7..c30f83d20 100644 --- a/src/classes/com/sun/opengl/impl/glu/mipmap/BuildMipmap.java +++ b/src/classes/com/sun/opengl/impl/glu/mipmap/BuildMipmap.java @@ -47,6 +47,7 @@ package com.sun.opengl.impl.glu.mipmap; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.BufferUtil; import com.sun.opengl.impl.Debug; import java.nio.*; import java.io.*; @@ -73,7 +74,7 @@ public class BuildMipmap { int newImage_width; ShortBuffer otherImage = null; ShortBuffer imageTemp = null; - int memreq; + int memReq; int maxsize; int cmpts; PixelStorageModes psm = new PixelStorageModes(); @@ -88,8 +89,8 @@ public class BuildMipmap { Mipmap.retrieveStoreModes( gl, psm ); try { - newImage = ByteBuffer.allocateDirect( Mipmap.image_size( width, 1, format, - GL2.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() ).asShortBuffer(); + newImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.image_size( width, 1, format, + GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer(); } catch( OutOfMemoryError ome ) { return( GLU.GLU_OUT_OF_MEMORY ); } @@ -114,9 +115,9 @@ public class BuildMipmap { } } else { if( otherImage == null ) { - memreq = Mipmap.image_size( newwidth, 1, format, GL2.GL_UNSIGNED_SHORT ); + memReq = Mipmap.image_size( newwidth, 1, format, GL2.GL_UNSIGNED_SHORT ); try { - otherImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ).asShortBuffer(); + otherImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )).asShortBuffer(); } catch( OutOfMemoryError ome ) { gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() ); @@ -161,7 +162,7 @@ public class BuildMipmap { int newImage_height; ShortBuffer otherImage = null; ShortBuffer tempImage = null; - int memreq; + int memReq; int maxsize; int cmpts; PixelStorageModes psm = new PixelStorageModes(); @@ -177,8 +178,8 @@ public class BuildMipmap { } try { - newImage = ByteBuffer.allocateDirect( Mipmap.image_size( width, height, - format, GL2.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() ).asShortBuffer(); + newImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.image_size( width, height, + format, GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer(); } catch( OutOfMemoryError ome ) { return( GLU.GLU_OUT_OF_MEMORY ); } @@ -203,9 +204,9 @@ public class BuildMipmap { newImage_height, 0, format, GL2.GL_UNSIGNED_SHORT, newImage ); } else { if( otherImage == null ) { - memreq = Mipmap.image_size( newwidth[0], newheight[0], format, GL2.GL_UNSIGNED_SHORT ); + memReq = Mipmap.image_size( newwidth[0], newheight[0], format, GL2.GL_UNSIGNED_SHORT ); try { - otherImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ).asShortBuffer(); + otherImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )).asShortBuffer(); } catch( OutOfMemoryError ome ) { gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() ); @@ -258,9 +259,10 @@ public class BuildMipmap { int newImage_width; int newImage_height; short[] SWAP_IMAGE = null; - int memreq; + int memReq; int maxsize; int cmpts; + int mark=-1; boolean myswap_bytes; int groups_per_line, element_size, group_size; @@ -305,8 +307,8 @@ public class BuildMipmap { rowsize += psm.getUnpackAlignment() - padding; } - data.position( psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size ); - data.mark(); + mark = psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size; + data.position( mark ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); @@ -339,7 +341,7 @@ public class BuildMipmap { if( nextHeight < 1 ) { nextHeight = 1; } - memreq = Mipmap.image_size( nextWidth, nextHeight, format, type ); + memReq = Mipmap.image_size( nextWidth, nextHeight, format, type ); try { switch( type ) { @@ -362,7 +364,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -453,7 +455,7 @@ public class BuildMipmap { myswap_bytes = false; rowsize = newwidth * group_size; - memreq = Mipmap.image_size( newwidth, newheight, format, type ); + memReq = Mipmap.image_size( newwidth, newheight, format, type ); // swap srcImage and dstImage tempImage = srcImage; srcImage = dstImage; @@ -479,7 +481,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -495,7 +497,7 @@ public class BuildMipmap { // level userLevel+1 is in srcImage; level userLevel already saved level = userLevel + 1; } else { // user's image is not nice powerof2 size square - memreq = Mipmap.image_size( newwidth, newheight, format, type ); + memReq = Mipmap.image_size( newwidth, newheight, format, type ); try { switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): @@ -517,7 +519,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -530,7 +532,7 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) ); return( GLU.GLU_OUT_OF_MEMORY ); } - data.reset(); + data.position( mark ); switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): ScaleInternal.scale_internal_ubyte( cmpts, width, height, data, @@ -629,7 +631,7 @@ public class BuildMipmap { nextHeight = 1; } - memreq = Mipmap.image_size( nextWidth, nextHeight, format, type ); + memReq = Mipmap.image_size( nextWidth, nextHeight, format, type ); try { switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): @@ -651,7 +653,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -845,7 +847,7 @@ public class BuildMipmap { int newImage_height; ByteBuffer otherImage; ByteBuffer imageTemp; - int memreq; + int memReq; int maxsize; int cmpts; @@ -878,8 +880,8 @@ public class BuildMipmap { int i, j; try { - newImage = ByteBuffer.allocateDirect( Mipmap.image_size( - width, height, format, GL2.GL_UNSIGNED_BYTE ) ).order( ByteOrder.nativeOrder() ); + newImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.image_size( + width, height, format, GL2.GL_UNSIGNED_BYTE ) )); } catch( OutOfMemoryError err ) { return( GLU.GLU_OUT_OF_MEMORY ); } @@ -920,9 +922,9 @@ public class BuildMipmap { 0, format, GL2.GL_UNSIGNED_BYTE, newImage ); } else { if( otherImage == null ) { - memreq = Mipmap.image_size( newwidth[0], newheight[0], format, GL2.GL_UNSIGNED_BYTE ); + memReq = Mipmap.image_size( newwidth[0], newheight[0], format, GL2.GL_UNSIGNED_BYTE ); try { - otherImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ); + otherImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); } catch( OutOfMemoryError err ) { gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() ); @@ -975,6 +977,7 @@ public class BuildMipmap { int memReq; int maxSize; int cmpts; + int mark=-1; boolean myswapBytes; int groupsPerLine, elementSize, groupSize; @@ -1033,11 +1036,11 @@ public class BuildMipmap { imageSize = rowsPerImage * rowSize; - usersImage = data.duplicate(); - usersImage.position( psm.getUnpackSkipRows() * rowSize + - psm.getUnpackSkipPixels() * groupSize + - psm.getUnpackSkipImages() * imageSize ); - usersImage.mark(); + usersImage = ByteBuffer.wrap(data.array()); + mark = psm.getUnpackSkipRows() * rowSize + + psm.getUnpackSkipPixels() * groupSize + + psm.getUnpackSkipImages() * imageSize; + usersImage.position( mark ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); @@ -1099,7 +1102,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -1285,7 +1288,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -1326,7 +1329,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -1388,7 +1391,7 @@ public class BuildMipmap { case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ): case( GL2.GL_UNSIGNED_INT_10_10_10_2 ): case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ): - dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() ); + dstImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )); break; default: return( GLU.GLU_INVALID_ENUM ); @@ -1410,7 +1413,7 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE ); if( baseLevel <= level && level <= maxLevel ) { - usersImage.reset(); + usersImage.position( mark ); gl.getGL2().glTexImage3D( target, level, internalFormat, width, height, depth, 0, format, type, usersImage ); } @@ -1556,7 +1559,7 @@ public class BuildMipmap { newDepth /= 2; } if( baseLevel <= level && level <= maxLevel ) { - usersImage.reset(); + usersImage.position( mark ); gl.getGL2().glTexImage3D( target, level, internalFormat, width, height, depth, 0, format, type, usersImage ); } @@ -1576,7 +1579,7 @@ public class BuildMipmap { int width, int height) { try { FileOutputStream fos = new FileOutputStream(new File(filename)); - ByteBuffer header = ByteBuffer.allocate(TARGA_HEADER_SIZE); + ByteBuffer header = ByteBuffer.allocateDirect(TARGA_HEADER_SIZE); header.put(0, (byte) 0).put(1, (byte) 0); header.put(2, (byte) 2); // uncompressed type header.put(12, (byte) (width & 0xFF)); // width @@ -1584,8 +1587,8 @@ public class BuildMipmap { header.put(14, (byte) (height & 0xFF)); // height header.put(15, (byte) (height >> 8)); // height header.put(16, (byte) 24); // pixel size - fos.getChannel().write(header); - fos.getChannel().write(data); + fos.write(header.array()); + fos.write(data.array()); data.clear(); fos.close(); } catch (IOException e) { diff --git a/src/classes/com/sun/opengl/impl/glu/mipmap/Mipmap.java b/src/classes/com/sun/opengl/impl/glu/mipmap/Mipmap.java index 6f247940d..b048bf1f5 100644 --- a/src/classes/com/sun/opengl/impl/glu/mipmap/Mipmap.java +++ b/src/classes/com/sun/opengl/impl/glu/mipmap/Mipmap.java @@ -47,6 +47,7 @@ package com.sun.opengl.impl.glu.mipmap; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.BufferUtil; import javax.media.opengl.GLException; import java.nio.*; @@ -573,8 +574,8 @@ public class Mipmap { if( !isLegalFormatForPackedPixelType( format, typeout ) ) { return( GLU.GLU_INVALID_OPERATION ); } - beforeimage = ByteBuffer.allocateDirect( image_size( widthin, heightin, format, GL2.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() ); - afterimage = ByteBuffer.allocateDirect( image_size( widthout, heightout, format, GL2.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() ); + beforeimage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( image_size( widthin, heightin, format, GL2.GL_UNSIGNED_SHORT ) )); + afterimage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( image_size( widthout, heightout, format, GL2.GL_UNSIGNED_SHORT ) )); if( beforeimage == null || afterimage == null ) { return( GLU.GLU_OUT_OF_MEMORY ); } diff --git a/src/classes/com/sun/opengl/impl/glu/mipmap/ScaleInternal.java b/src/classes/com/sun/opengl/impl/glu/mipmap/ScaleInternal.java index f4d94412d..70ddab880 100644 --- a/src/classes/com/sun/opengl/impl/glu/mipmap/ScaleInternal.java +++ b/src/classes/com/sun/opengl/impl/glu/mipmap/ScaleInternal.java @@ -47,6 +47,7 @@ package com.sun.opengl.impl.glu.mipmap; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.BufferUtil; import java.nio.*; /** @@ -2424,12 +2425,10 @@ public class ScaleInternal { } try { - beforeImage = ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn, - heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).order( - ByteOrder.nativeOrder() ).asShortBuffer(); - afterImage = ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn, - heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).order( - ByteOrder.nativeOrder() ).asShortBuffer(); + beforeImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn, + heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer(); + afterImage = BufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn, + heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer(); } catch( OutOfMemoryError err ) { return( GLU.GLU_OUT_OF_MEMORY ); } diff --git a/src/classes/com/sun/opengl/impl/glu/mipmap/Type_Widget.java b/src/classes/com/sun/opengl/impl/glu/mipmap/Type_Widget.java index 7f6ab08c0..d5c6768b3 100644 --- a/src/classes/com/sun/opengl/impl/glu/mipmap/Type_Widget.java +++ b/src/classes/com/sun/opengl/impl/glu/mipmap/Type_Widget.java @@ -56,7 +56,7 @@ public class Type_Widget { /** Creates a new instance of Type_Widget */ public Type_Widget() { - buffer = ByteBuffer.allocate( 4 ); + buffer = ByteBuffer.allocateDirect( 4 ); } public void setUB0( byte b ) { diff --git a/src/classes/com/sun/opengl/impl/jawt/JAWTUtil.java b/src/classes/com/sun/opengl/impl/jawt/JAWTUtil.java index 790d965e9..c542b4703 100644 --- a/src/classes/com/sun/opengl/impl/jawt/JAWTUtil.java +++ b/src/classes/com/sun/opengl/impl/jawt/JAWTUtil.java @@ -64,7 +64,7 @@ public class JAWTUtil { private static boolean lockedToolkit; - public static void lockToolkit() throws GLException { + public static synchronized void lockToolkit() throws GLException { if (lockedToolkit) { throw new GLException("Toolkit already locked"); } @@ -84,13 +84,13 @@ public class JAWTUtil { JAWT.getJAWT().Lock(); } } catch (Exception e) { j2dOk=false; } - } + } if(!j2dOk) { JAWT.getJAWT().Lock(); } } - public static void unlockToolkit() { + public static synchronized void unlockToolkit() { if (lockedToolkit) { if (headlessMode) { // Workaround for running (to some degree) in headless diff --git a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java index effe49b42..905614952 100644 --- a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java +++ b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java @@ -65,12 +65,12 @@ public abstract class JAWTWindow implements NativeWindow { protected int screenIndex; public JAWTWindow(Object comp) { - init(comp); + init((Component)comp); } - protected void init(Object windowObject) throws NativeWindowException { + protected void init(Component windowObject) throws NativeWindowException { invalidate(); - this.component = (Component)windowObject; + this.component = windowObject; initNative(); } @@ -124,7 +124,11 @@ public abstract class JAWTWindow implements NativeWindow { } public Object getWrappedWindow() { - return null; + return component; + } + + public final boolean isTerminalObject() { + return true; } public void setSize(int width, int height) { @@ -166,4 +170,13 @@ public abstract class JAWTWindow implements NativeWindow { return false; // FIXME } + public String toString() { + return "JAWT-Window[windowHandle "+getWindowHandle()+ + ", surfaceHandle "+getSurfaceHandle()+ + ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + ", visible "+isVisible()+ + ", wrappedWindow "+getWrappedWindow()+ + ", terminalObject "+isTerminalObject()+"]"; + } + } diff --git a/src/classes/com/sun/opengl/impl/jawt/x11/X11JAWTWindow.java b/src/classes/com/sun/opengl/impl/jawt/x11/X11JAWTWindow.java index 022010ebd..4e22babee 100644 --- a/src/classes/com/sun/opengl/impl/jawt/x11/X11JAWTWindow.java +++ b/src/classes/com/sun/opengl/impl/jawt/x11/X11JAWTWindow.java @@ -54,7 +54,7 @@ public class X11JAWTWindow extends JAWTWindow { protected void initNative() throws NativeWindowException { } - public int lockSurface() throws NativeWindowException { + public synchronized int lockSurface() throws NativeWindowException { int ret = super.lockSurface(); if(LOCK_SUCCESS != ret) { return ret; @@ -113,7 +113,7 @@ public class X11JAWTWindow extends JAWTWindow { return ret; } - public void unlockSurface() { + public synchronized void unlockSurface() { if(!isSurfaceLocked()) return; ds.FreeDrawingSurfaceInfo(dsi); ds.Unlock(); diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java index ccafc6738..c52b46c7b 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java @@ -87,9 +87,6 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { this.chooser = chooser; } - public void destroy() { - } - public GLCapabilities getChosenGLCapabilities() { int numFormats = 1; GLCapabilities availableCaps[] = new GLCapabilities[numFormats]; diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java index a52348bdd..c905ed48e 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -66,7 +66,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - target = NativeWindowHelper.unwrap(target); + target = NativeWindowFactory.getNativeWindow(target); if (capabilities == null) { capabilities = new GLCapabilities(); } diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index d5291af39..dab06f19a 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -77,6 +77,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } finally { getFactory().unlockToolkit(); } + super.destroy(); } public void setSize(int width, int height) { diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index 85447f00b..bfd23bb0a 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -96,5 +96,6 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { WGL.DestroyWindow(hwnd); hwnd = 0; } + super.destroy(); } } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java index 3a8f75d8e..826acc613 100755 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java @@ -73,7 +73,4 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { public int getHeight() { throw new GLException("Should not call this"); } - - public void destroy() { - } } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index 9f47a03d6..59eff795b 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -134,5 +134,6 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { } finally { getFactory().unlockToolkit(); } + super.destroy(); } } diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 7e55e715c..eabaaa796 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -101,6 +101,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } finally { getFactory().unlockToolkit(); } + super.destroy(); } public void setSize(int newWidth, int newHeight) { diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index fac3d1ff6..78a617f8e 100644 --- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -73,7 +73,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - target = NativeWindowHelper.unwrap(target); + target = NativeWindowFactory.getNativeWindow(target); if (capabilities == null) { capabilities = new GLCapabilities(); } diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java index bbb33bd42..9b1ef65da 100755 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java @@ -109,9 +109,6 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { throw new GLException("Should not call this"); } - public void destroy() { - } - class Context extends X11GLXContext { Context(X11GLXDrawable drawable, GLContext shareWith) { super(drawable, shareWith); diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java index 457240503..5312e29c9 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java @@ -325,7 +325,7 @@ public abstract class X11GLXContext extends GLContextImpl { public boolean isOptimizable() { return (super.isOptimizable() && - !X11GLXDrawableFactory.getX11Factory().isVendorATI()); + !((X11GLXDrawableFactory)getGLDrawable().getFactory()).isVendorATI()); } //---------------------------------------------------------------------- diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java index 075106005..8bf18e670 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -114,7 +114,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - target = NativeWindowHelper.unwrap(target); + target = NativeWindowFactory.getNativeWindow(target); X11OnscreenGLXDrawable drawable = new X11OnscreenGLXDrawable(this, target); long visualID = target.getVisualID(); int screen = target.getScreenIndex(); @@ -424,12 +424,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return caps; } - public void lockToolkit() { - } - - public void unlockToolkit() { - } - // Display connection for use by visual selection algorithm and by all offscreen surfaces private static long staticDisplay=0; private static boolean xineramaEnabled=false; @@ -508,10 +502,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return tmp[tmp_offset]; } - public static X11GLXDrawableFactory getX11Factory() { - return (X11GLXDrawableFactory) getFactory(false); - } - /** Workaround for apparent issue with ATI's proprietary drivers where direct contexts still send GLX tokens for GL calls */ public static boolean isVendorATI() { diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java index 446d6f4e5..74b2191ab 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java @@ -131,11 +131,11 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { drawable = 0; pixmap = 0; display = 0; - nw.invalidate(); setChosenGLCapabilities(null); } finally { getFactory().unlockToolkit(); } + super.destroy(); } public boolean isDoubleBuffered() { diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java index 1741ba72a..107eba9d2 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java @@ -66,23 +66,17 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { public void swapBuffers() throws GLException { getFactory().lockToolkit(); - try { - boolean didLock = false; - + try { if (component.getSurfaceHandle() == 0) { if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { return; } - - didLock = true; } GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); - if (didLock) { - unlockSurface(); - } } finally { + unlockSurface(); getFactory().unlockToolkit(); } } diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java index 3f29095cb..d5cdd6016 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java @@ -89,6 +89,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } finally { getFactory().unlockToolkit(); } + super.destroy(); } public void setSize(int width, int height) { diff --git a/src/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXDrawableFactory.java index a6f545b87..a5ec4c46c 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXDrawableFactory.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXDrawableFactory.java @@ -171,11 +171,13 @@ public class X11AWTGLXDrawableFactory extends X11GLXDrawableFactory { } public void lockToolkit() { + super.lockToolkit(); JAWTUtil.lockToolkit(); } public void unlockToolkit() { JAWTUtil.unlockToolkit(); + super.unlockToolkit(); } } -- cgit v1.2.3