diff options
author | Sven Gothel <[email protected]> | 2008-07-11 10:57:14 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2008-07-11 10:57:14 +0000 |
commit | b02975d74ba8410dffaccc18f2279c1e165972df (patch) | |
tree | 27ce9e90da732cb428d34199dd49244f6c172b7a /src/classes | |
parent | b92e5acb2b4db1bf6873bea74bda64d63afd6fee (diff) |
Fixed:
- NEWT:
- X11: Fullscreen toggle: (un)decorated window and resize event
- CloseNative: Use copied display/window handle to close after invalidate
- Cleanup/validations
- GLDrawableHelper: Removed 'optimization' path - no sense and too complicated
- GL, GLContextImpl, GLContextShareSet:
- Activated: registerForBufferObjectSharing
- Working BufferSizeTracker
- GLBufferStateTracker: Activated: PBO state for GL2
- GL2/GLES1/GLES2: Activated VBO/PBO validation code
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1720 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes')
7 files changed, 98 insertions, 151 deletions
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index a5bdf0806..35d358b53 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -146,7 +146,9 @@ public abstract class Window implements NativeWindow ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+isVisible()+ ", wrappedWindow "+getWrappedWindow()+ - ", terminalObject "+isTerminalObject()+"]"; + ", terminalObject "+isTerminalObject()+ + ", screen handle/index "+getScreenHandle()+"/"+getScreenIndex() + + ", display handle "+getDisplayHandle()+ "]"; } protected Screen screen; @@ -186,6 +188,10 @@ public abstract class Window implements NativeWindow } public void invalidate() { + invalidate(false); + } + + public void invalidate(boolean internal) { unlockSurface(); screen = null; visualID = 0; @@ -207,15 +213,19 @@ public abstract class Window implements NativeWindow } public long getDisplayHandle() { + if(null==screen || + null==screen.getDisplay()) { + return 0; + } return screen.getDisplay().getHandle(); } public long getScreenHandle() { - return screen.getHandle(); + return (null!=screen)?screen.getHandle():0; } public int getScreenIndex() { - return screen.getIndex(); + return (null!=screen)?screen.getIndex():0; } public long getWindowHandle() { diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java index 9e0df6c71..626f98199 100755 --- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java @@ -39,6 +39,7 @@ import com.sun.opengl.impl.*; public class WindowsWindow extends Window { private long hdc; + private long windowHandleClose; private static final String WINDOW_CLASS_NAME = "NewtWindow"; static { @@ -69,14 +70,19 @@ public class WindowsWindow extends Window { if (windowHandle == 0) { throw new RuntimeException("Error creating window"); } + windowHandleClose = windowHandle; } protected void closeNative() { if (hdc != 0) { - ReleaseDC(windowHandle, hdc); + if(windowHandleClose != 0) { + ReleaseDC(windowHandleClose, hdc); + } hdc = 0; } - DestroyWindow(windowHandle); + if(windowHandleClose != 0) { + DestroyWindow(windowHandleClose); + } } public void setVisible(boolean visible) { diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java index 05d9abcb9..395fad8c4 100755 --- a/src/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java @@ -62,10 +62,14 @@ public class X11Window extends Window { if (w == 0 || w!=windowHandle) { throw new RuntimeException("Error creating window: "+w); } + windowHandleClose = windowHandle; + displayHandleClose = getDisplayHandle(); } protected void closeNative() { - CloseWindow(getDisplayHandle(), windowHandle); + if(0!=displayHandleClose && 0!=windowHandleClose) { + CloseWindow(displayHandleClose, windowHandleClose); + } } public void setVisible(boolean visible) { @@ -77,7 +81,7 @@ public class X11Window extends Window { } public void setSize(int width, int height) { - setSize0(getDisplayHandle(), windowHandle, width, height); + setSize0(getDisplayHandle(), windowHandle, width, height, 0, visible); } public void setPosition(int x, int y) { @@ -99,7 +103,7 @@ public class X11Window extends Window { h = nfs_height; } setPosition0(getDisplayHandle(), windowHandle, x, y); - setSize0(getDisplayHandle(), windowHandle, w, h); + setSize0(getDisplayHandle(), windowHandle, w, h, fullscreen?-1:1, visible); } return true; } @@ -126,7 +130,7 @@ public class X11Window extends Window { private native void CloseWindow(long display, long windowHandle); private native void setVisible0(long display, long windowHandle, boolean visible); private native void DispatchMessages(long display, long windowHandle, int eventMask); - private native void setSize0(long display, long windowHandle, int width, int height); + private native void setSize0(long display, long windowHandle, int width, int height, int decorationToggle, boolean isVisible); private native void setPosition0(long display, long windowHandle, int x, int y); private native int getDisplayWidth0(long display, int scrn_idx); private native int getDisplayHeight0(long display, int scrn_idx); @@ -162,4 +166,6 @@ public class X11Window extends Window { private void windowDestroyed() { } + private long windowHandleClose; + private long displayHandleClose; } diff --git a/src/classes/com/sun/opengl/impl/GLBufferStateTracker.java b/src/classes/com/sun/opengl/impl/GLBufferStateTracker.java index 54acd8899..ddc82eba2 100755 --- a/src/classes/com/sun/opengl/impl/GLBufferStateTracker.java +++ b/src/classes/com/sun/opengl/impl/GLBufferStateTracker.java @@ -81,9 +81,8 @@ public class GLBufferStateTracker { private static final Integer arrayBufferEnum = new Integer(GL.GL_ARRAY_BUFFER); private static final Integer elementArrayBufferEnum = new Integer(GL.GL_ELEMENT_ARRAY_BUFFER); - // FIXME: refactor dependencies on desktop OpenGL - // private static final Integer pixelPackBufferEnum = new Integer(GL.GL_PIXEL_PACK_BUFFER); - // private static final Integer pixelUnpackBufferEnum = new Integer(GL.GL_PIXEL_UNPACK_BUFFER); + private static final Integer pixelPackBufferEnum = new Integer(GL2.GL_PIXEL_PACK_BUFFER); + private static final Integer pixelUnpackBufferEnum = new Integer(GL2.GL_PIXEL_UNPACK_BUFFER); private static final Integer zero = new Integer(0); // Maps binding targets to buffer objects. A null value indicates @@ -97,9 +96,8 @@ public class GLBufferStateTracker { // Start with known unbound targets for known keys bindingMap.put(arrayBufferEnum, zero); bindingMap.put(elementArrayBufferEnum, zero); - // FIXME: refactor dependencies on desktop OpenGL - // bindingMap.put(pixelPackBufferEnum, zero); - // bindingMap.put(pixelUnpackBufferEnum, zero); + bindingMap.put(pixelPackBufferEnum, zero); + bindingMap.put(pixelUnpackBufferEnum, zero); } public void setBoundBufferObject(int target, int buffer) { @@ -123,9 +121,8 @@ public class GLBufferStateTracker { switch (target) { case GL.GL_ARRAY_BUFFER: queryTarget = GL.GL_ARRAY_BUFFER_BINDING; break; case GL.GL_ELEMENT_ARRAY_BUFFER: queryTarget = GL.GL_ELEMENT_ARRAY_BUFFER_BINDING; break; - // FIXME: refactor dependencies on desktop OpenGL - // case GL.GL_PIXEL_PACK_BUFFER: queryTarget = GL.GL_PIXEL_PACK_BUFFER_BINDING; break; - // case GL.GL_PIXEL_UNPACK_BUFFER: queryTarget = GL.GL_PIXEL_UNPACK_BUFFER_BINDING; break; + case GL2.GL_PIXEL_PACK_BUFFER: queryTarget = GL2.GL_PIXEL_PACK_BUFFER_BINDING; break; + case GL2.GL_PIXEL_UNPACK_BUFFER: queryTarget = GL2.GL_PIXEL_UNPACK_BUFFER_BINDING; break; default: gotQueryTarget = false; break; } if (gotQueryTarget) { @@ -168,9 +165,8 @@ public class GLBufferStateTracker { case 0: return zero; case GL.GL_ARRAY_BUFFER: return arrayBufferEnum; case GL.GL_ELEMENT_ARRAY_BUFFER: return elementArrayBufferEnum; - // FIXME: refactor dependencies on desktop OpenGL - // case GL.GL_PIXEL_PACK_BUFFER: return pixelPackBufferEnum; - // case GL.GL_PIXEL_UNPACK_BUFFER: return pixelUnpackBufferEnum; + case GL2.GL_PIXEL_PACK_BUFFER: return pixelPackBufferEnum; + case GL2.GL_PIXEL_UNPACK_BUFFER: return pixelUnpackBufferEnum; default: return new Integer(key); } } diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java index 90b52a285..014cc9cf5 100644 --- a/src/classes/com/sun/opengl/impl/GLContextImpl.java +++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java @@ -80,6 +80,7 @@ public abstract class GLContextImpl extends GLContext { if (shareWith != null) { GLContextShareSet.registerSharing(this, shareWith); } + GLContextShareSet.registerForBufferObjectSharing(shareWith, this); // This must occur after the above calls into the // GLContextShareSet, which set up state needed by the GL object setGL(createGL()); @@ -395,13 +396,6 @@ public abstract class GLContextImpl extends GLContext { this.bufferSizeTracker = bufferSizeTracker; } - public GLBufferSizeTracker getOrCreateBufferSizeTracker() { - if(null==bufferSizeTracker) { - bufferSizeTracker=new GLBufferSizeTracker(); - } - return bufferSizeTracker; - } - public GLBufferSizeTracker getBufferSizeTracker() { return bufferSizeTracker; } diff --git a/src/classes/com/sun/opengl/impl/GLContextShareSet.java b/src/classes/com/sun/opengl/impl/GLContextShareSet.java index a3614633d..d02b8c8a6 100644 --- a/src/classes/com/sun/opengl/impl/GLContextShareSet.java +++ b/src/classes/com/sun/opengl/impl/GLContextShareSet.java @@ -150,6 +150,31 @@ public class GLContextShareSet { } } + /** In order to avoid glGet calls for buffer object checks related + to glVertexPointer, etc. calls as well as glMapBuffer calls, we + need to share the same GLBufferSizeTracker object between + contexts sharing textures and display lists. For now we keep + this mechanism orthogonal to the GLObjectTracker to hopefully + keep things easier to understand. (The GLObjectTracker is + currently only needed in a fairly esoteric case, when the + Java2D/JOGL bridge is active, but the GLBufferSizeTracker + mechanism is now always required.) */ + public static void registerForBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) { + // FIXME: downcasts to GLContextImpl undesirable + GLContextImpl older = (GLContextImpl) olderContextOrNull; + GLContextImpl newer = (GLContextImpl) newContext; + GLBufferSizeTracker tracker = null; + if (older != null) { + tracker = older.getBufferSizeTracker(); + assert (tracker != null) + : "registerForBufferObjectSharing was not called properly for the older context, or has a bug in it"; + } + if (tracker == null) { + tracker = new GLBufferSizeTracker(); + } + newer.setBufferSizeTracker(tracker); + } + // FIXME: refactor Java SE dependencies // /** Indicates that the two supplied contexts (which must be able to // share textures and display lists) should be in the same @@ -242,35 +267,10 @@ public class GLContextShareSet { // } // } // } - // - // /** In order to avoid glGet calls for buffer object checks related - // to glVertexPointer, etc. calls as well as glMapBuffer calls, we - // need to share the same GLBufferSizeTracker object between - // contexts sharing textures and display lists. For now we keep - // this mechanism orthogonal to the GLObjectTracker to hopefully - // keep things easier to understand. (The GLObjectTracker is - // currently only needed in a fairly esoteric case, when the - // Java2D/JOGL bridge is active, but the GLBufferSizeTracker - // mechanism is now always required.) */ - // public static void registerForBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) { - // // FIXME: downcasts to GLContextImpl undesirable - // GLContextImpl older = (GLContextImpl) olderContextOrNull; - // GLContextImpl newer = (GLContextImpl) newContext; - // GLBufferSizeTracker tracker = null; - // if (older != null) { - // tracker = older.getBufferSizeTracker(); - // assert (tracker != null) - // : "registerForBufferObjectSharing was not called properly for the older context, or has a bug in it"; - // } - // if (tracker == null) { - // tracker = new GLBufferSizeTracker(); - // } - // newer.setBufferSizeTracker(tracker); - // } - + //---------------------------------------------------------------------- // Internals only below this point - // + private static ShareSet entryFor(GLContext context) { return (ShareSet) shareMap.get(context); diff --git a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java index 2a96e2958..8c9568381 100644 --- a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java +++ b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java @@ -105,111 +105,46 @@ public class GLDrawableHelper { GLContext context, Runnable runnable, Runnable initAction) { - // FIXME: downcast to GLContextImpl undesirable - boolean isOptimizable = ((context instanceof GLContextImpl) && - ((GLContextImpl) context).isOptimizable()); - - if (GLWorkerThread.isStarted() && - GLWorkerThread.isWorkerThread() && - isOptimizable) { - // We're going to allow a context to be left current on the - // GLWorkerThread for optimization purposes - GLContext lastContext = GLContext.getCurrent(); - Runnable lastInitAction = (Runnable) perThreadInitAction.get(); - if (lastContext != null && lastContext != context) { - lastContext.release(); - } else { - lastContext = null; - } - - // FIXME: probably need to handle the case where the user is - // waiting for this context to be released; need to periodically - // release the context? See if anybody is waiting to make it - // current on another thread? (The latter would require the use - // of internal APIs...) - - int res = 0; - try { - res = context.makeCurrent(); - if (res != GLContext.CONTEXT_NOT_CURRENT) { - perThreadInitAction.set(initAction); - if (res == GLContext.CONTEXT_CURRENT_NEW) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); - } - initAction.run(); - } - if (DEBUG && VERBOSE) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable"); - } - runnable.run(); - if (autoSwapBufferMode) { - if (drawable != null) { - drawable.swapBuffers(); - } + // Support for recursive makeCurrent() calls as well as calling + // other drawables' display() methods from within another one's + GLContext lastContext = GLContext.getCurrent(); + Runnable lastInitAction = (Runnable) perThreadInitAction.get(); + if (lastContext != null) { + lastContext.release(); + } + + int res = 0; + try { + res = context.makeCurrent(); + if (res != GLContext.CONTEXT_NOT_CURRENT) { + perThreadInitAction.set(initAction); + if (res == GLContext.CONTEXT_CURRENT_NEW) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); } + initAction.run(); } - } finally { - - // FIXME: take this out as soon as possible - if (NVIDIA_CRASH_WORKAROUND) { - try { - if (res != GLContext.CONTEXT_NOT_CURRENT) { - context.release(); - } - } catch (Exception e) { - } + if (DEBUG && VERBOSE) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable"); } - - if (lastContext != null) { - int res2 = lastContext.makeCurrent(); - if (res2 == GLContext.CONTEXT_CURRENT_NEW) { - lastInitAction.run(); + runnable.run(); + if (autoSwapBufferMode) { + if (drawable != null) { + drawable.swapBuffers(); } } } - } else { - // Support for recursive makeCurrent() calls as well as calling - // other drawables' display() methods from within another one's - GLContext lastContext = GLContext.getCurrent(); - Runnable lastInitAction = (Runnable) perThreadInitAction.get(); - if (lastContext != null) { - lastContext.release(); - } - - int res = 0; + } finally { try { - res = context.makeCurrent(); if (res != GLContext.CONTEXT_NOT_CURRENT) { - perThreadInitAction.set(initAction); - if (res == GLContext.CONTEXT_CURRENT_NEW) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); - } - initAction.run(); - } - if (DEBUG && VERBOSE) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable"); - } - runnable.run(); - if (autoSwapBufferMode) { - if (drawable != null) { - drawable.swapBuffers(); - } - } + context.release(); } - } finally { - try { - if (res != GLContext.CONTEXT_NOT_CURRENT) { - context.release(); - } - } catch (Exception e) { - } - if (lastContext != null) { - int res2 = lastContext.makeCurrent(); - if (res2 == GLContext.CONTEXT_CURRENT_NEW) { - lastInitAction.run(); - } + } catch (Exception e) { + } + if (lastContext != null) { + int res2 = lastContext.makeCurrent(); + if (res2 == GLContext.CONTEXT_CURRENT_NEW) { + lastInitAction.run(); } } } |