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 | |
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
-rw-r--r-- | make/gl-common.cfg | 45 | ||||
-rwxr-xr-x | make/gl-desktop.cfg | 45 | ||||
-rw-r--r-- | make/gl-impl-CustomJavaCode-common.java | 1 | ||||
-rw-r--r-- | make/gl-impl-CustomJavaCode-gl2.java | 88 | ||||
-rwxr-xr-x | make/gl-impl-CustomJavaCode-gles1.java | 96 | ||||
-rwxr-xr-x | make/gl-impl-CustomJavaCode-gles2.java | 75 | ||||
-rw-r--r-- | make/make.jogl.all.linux-x86.sh | 2 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Window.java | 16 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/windows/WindowsWindow.java | 10 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/x11/X11Window.java | 14 | ||||
-rwxr-xr-x | src/classes/com/sun/opengl/impl/GLBufferStateTracker.java | 20 | ||||
-rw-r--r-- | src/classes/com/sun/opengl/impl/GLContextImpl.java | 8 | ||||
-rw-r--r-- | src/classes/com/sun/opengl/impl/GLContextShareSet.java | 54 | ||||
-rw-r--r-- | src/classes/com/sun/opengl/impl/GLDrawableHelper.java | 127 | ||||
-rwxr-xr-x | src/native/newt/X11Window.c | 129 |
15 files changed, 366 insertions, 364 deletions
diff --git a/make/gl-common.cfg b/make/gl-common.cfg index 6b91c2404..6a190d688 100644 --- a/make/gl-common.cfg +++ b/make/gl-common.cfg @@ -295,6 +295,51 @@ BufferObjectKind Element glDrawElements BufferObjectKind Element glDrawRangeElements BufferObjectKind Element glDrawRangeElementsEXT +# There are no PBOs in the embedded OpenGL variants right now +BufferObjectKind UnpackPixel glBitmap +BufferObjectKind UnpackPixel glColorTable +BufferObjectKind UnpackPixel glColorSubTable +BufferObjectKind UnpackPixel glCompressedTexImage1D +BufferObjectKind UnpackPixel glCompressedTexImage1DARB +BufferObjectKind UnpackPixel glCompressedTexImage2D +BufferObjectKind UnpackPixel glCompressedTexImage2DARB +BufferObjectKind UnpackPixel glCompressedTexImage3D +BufferObjectKind UnpackPixel glCompressedTexImage3DARB +BufferObjectKind UnpackPixel glCompressedTexSubImage1D +BufferObjectKind UnpackPixel glCompressedTexSubImage1DARB +BufferObjectKind UnpackPixel glCompressedTexSubImage2D +BufferObjectKind UnpackPixel glCompressedTexSubImage2DARB +BufferObjectKind UnpackPixel glCompressedTexSubImage3D +BufferObjectKind UnpackPixel glCompressedTexSubImage3DARB +BufferObjectKind UnpackPixel glConvolutionFilter1D +BufferObjectKind UnpackPixel glConvolutionFilter2D +BufferObjectKind UnpackPixel glDrawPixels +BufferObjectKind UnpackPixel glPixelMapfv +BufferObjectKind UnpackPixel glPixelMapuiv +BufferObjectKind UnpackPixel glPixelMapusv +BufferObjectKind UnpackPixel glPolygonStipple +BufferObjectKind UnpackPixel glSeparableFilter2D +BufferObjectKind UnpackPixel glTexImage1D +BufferObjectKind UnpackPixel glTexImage2D +BufferObjectKind UnpackPixel glTexImage3D +BufferObjectKind UnpackPixel glTexSubImage1D +BufferObjectKind UnpackPixel glTexSubImage2D +BufferObjectKind UnpackPixel glTexSubImage3D + +BufferObjectKind PackPixel glGetColorTable +BufferObjectKind PackPixel glGetCompressedTexImage +BufferObjectKind PackPixel glGetCompressedTexImageARB +BufferObjectKind PackPixel glGetConvolutionFilter +BufferObjectKind PackPixel glGetHistogram +BufferObjectKind PackPixel glGetMinmax +BufferObjectKind PackPixel glGetPixelMapfv +BufferObjectKind PackPixel glGetPixelMapuiv +BufferObjectKind PackPixel glGetPixelMapusv +BufferObjectKind PackPixel glGetPolygonStipple +BufferObjectKind PackPixel glGetSeparableFilter +BufferObjectKind PackPixel glGetTexImage +BufferObjectKind PackPixel glReadPixels + # Range check directives for various routines # FIXME: some of these are really the bare minimum and won't catch # many classes of errors. Should extend the DebugGL to perform much diff --git a/make/gl-desktop.cfg b/make/gl-desktop.cfg index 4281ddd80..30213c2f6 100755 --- a/make/gl-desktop.cfg +++ b/make/gl-desktop.cfg @@ -6,51 +6,6 @@ GLHeader GL/gl.h GLHeader GL/glext.h -# There are no PBOs in the embedded OpenGL variants right now -BufferObjectKind UnpackPixel glBitmap -BufferObjectKind UnpackPixel glColorTable -BufferObjectKind UnpackPixel glColorSubTable -BufferObjectKind UnpackPixel glCompressedTexImage1D -BufferObjectKind UnpackPixel glCompressedTexImage1DARB -BufferObjectKind UnpackPixel glCompressedTexImage2D -BufferObjectKind UnpackPixel glCompressedTexImage2DARB -BufferObjectKind UnpackPixel glCompressedTexImage3D -BufferObjectKind UnpackPixel glCompressedTexImage3DARB -BufferObjectKind UnpackPixel glCompressedTexSubImage1D -BufferObjectKind UnpackPixel glCompressedTexSubImage1DARB -BufferObjectKind UnpackPixel glCompressedTexSubImage2D -BufferObjectKind UnpackPixel glCompressedTexSubImage2DARB -BufferObjectKind UnpackPixel glCompressedTexSubImage3D -BufferObjectKind UnpackPixel glCompressedTexSubImage3DARB -BufferObjectKind UnpackPixel glConvolutionFilter1D -BufferObjectKind UnpackPixel glConvolutionFilter2D -BufferObjectKind UnpackPixel glDrawPixels -BufferObjectKind UnpackPixel glPixelMapfv -BufferObjectKind UnpackPixel glPixelMapuiv -BufferObjectKind UnpackPixel glPixelMapusv -BufferObjectKind UnpackPixel glPolygonStipple -BufferObjectKind UnpackPixel glSeparableFilter2D -BufferObjectKind UnpackPixel glTexImage1D -BufferObjectKind UnpackPixel glTexImage2D -BufferObjectKind UnpackPixel glTexImage3D -BufferObjectKind UnpackPixel glTexSubImage1D -BufferObjectKind UnpackPixel glTexSubImage2D -BufferObjectKind UnpackPixel glTexSubImage3D - -BufferObjectKind PackPixel glGetColorTable -BufferObjectKind PackPixel glGetCompressedTexImage -BufferObjectKind PackPixel glGetCompressedTexImageARB -BufferObjectKind PackPixel glGetConvolutionFilter -BufferObjectKind PackPixel glGetHistogram -BufferObjectKind PackPixel glGetMinmax -BufferObjectKind PackPixel glGetPixelMapfv -BufferObjectKind PackPixel glGetPixelMapuiv -BufferObjectKind PackPixel glGetPixelMapusv -BufferObjectKind PackPixel glGetPolygonStipple -BufferObjectKind PackPixel glGetSeparableFilter -BufferObjectKind PackPixel glGetTexImage -BufferObjectKind PackPixel glReadPixels - #Include gl-desktop-tracker.cfg diff --git a/make/gl-impl-CustomJavaCode-common.java b/make/gl-impl-CustomJavaCode-common.java index 23daabf1d..fb8a3ba0b 100644 --- a/make/gl-impl-CustomJavaCode-common.java +++ b/make/gl-impl-CustomJavaCode-common.java @@ -94,3 +94,4 @@ return buf.toString(); } + diff --git a/make/gl-impl-CustomJavaCode-gl2.java b/make/gl-impl-CustomJavaCode-gl2.java index f002d6082..cf163ca0d 100644 --- a/make/gl-impl-CustomJavaCode-gl2.java +++ b/make/gl-impl-CustomJavaCode-gl2.java @@ -17,7 +17,7 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL2Impl(GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getOrCreateBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); } public boolean isFunctionAvailable(String glFunctionName) { @@ -154,14 +154,15 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d) { return (elements * esize * w * h * d); } +private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); +private GLBufferSizeTracker bufferSizeTracker; + private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; private boolean haveEXTPixelBufferObject; private boolean haveGL15; private boolean haveGL21; private boolean haveARBVertexBufferObject; -private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); -private GLBufferSizeTracker bufferSizeTracker; private void initBufferObjectExtensionChecks() { if (bufferObjectExtensionsInitialized) @@ -201,6 +202,46 @@ private void checkBufferObject(boolean extension1, } } +private void checkArrayVBODisabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, + false, + false, + GL.GL_ARRAY_BUFFER, + "array vertex_buffer_object"); +} + +private void checkArrayVBOEnabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, + false, + true, + GL.GL_ARRAY_BUFFER, + "array vertex_buffer_object"); +} + +private void checkElementVBODisabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, + false, + false, + GL.GL_ELEMENT_ARRAY_BUFFER, + "element vertex_buffer_object"); +} + +private void checkElementVBOEnabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveGL15, + haveARBVertexBufferObject, + false, + true, + GL.GL_ELEMENT_ARRAY_BUFFER, + "element vertex_buffer_object"); +} + private void checkUnpackPBODisabled() { initBufferObjectExtensionChecks(); checkBufferObject(haveARBPixelBufferObject, @@ -241,47 +282,6 @@ private void checkPackPBOEnabled() { "pack pixel_buffer_object"); } - -private void checkArrayVBODisabled() { - initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - false, - GL2.GL_ARRAY_BUFFER, - "array vertex_buffer_object"); -} - -private void checkArrayVBOEnabled() { - initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - true, - GL2.GL_ARRAY_BUFFER, - "array vertex_buffer_object"); -} - -private void checkElementVBODisabled() { - initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - false, - GL2.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object"); -} - -private void checkElementVBOEnabled() { - initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - true, - GL2.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object"); -} - // Attempt to return the same ByteBuffer object from glMapBuffer if // the vertex buffer object's base address and size haven't changed private static class ARBVBOKey { diff --git a/make/gl-impl-CustomJavaCode-gles1.java b/make/gl-impl-CustomJavaCode-gles1.java index e47dc80e4..7ec61c634 100755 --- a/make/gl-impl-CustomJavaCode-gles1.java +++ b/make/gl-impl-CustomJavaCode-gles1.java @@ -1,10 +1,6 @@ -// Tracks glBegin/glEnd calls to determine whether it is legal to -// query Vertex Buffer Object state -private boolean inBeginEndPair; - public GLES1Impl(GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getOrCreateBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); } public boolean isFunctionAvailable(String glFunctionName) { @@ -103,44 +99,25 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d) { return (elements * esize * w * h * d); } -private boolean bufferObjectExtensionsInitialized = false; -private boolean haveARBPixelBufferObject; -private boolean haveEXTPixelBufferObject; -private boolean haveGL15; -private boolean haveGL21; -private boolean haveARBVertexBufferObject; private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private boolean bufferObjectExtensionsInitialized = false; +private boolean haveOESFramebufferObject; +private boolean haveOESPixelBufferObject; + private void initBufferObjectExtensionChecks() { if (bufferObjectExtensionsInitialized) return; bufferObjectExtensionsInitialized = true; - haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object"); - haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object"); - haveGL15 = isExtensionAvailable("GL_VERSION_1_5"); - haveGL21 = isExtensionAvailable("GL_VERSION_2_1"); - haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object"); + haveOESFramebufferObject = isExtensionAvailable("GL_OES_framebuffer_object"); + haveOESPixelBufferObject = false; // FIXME: can't find it in ES 1.1 or ES 2.0 spec } -// -// FIXME: all of these error checking routines had to be disabled -// because our version and extension querying mechanisms aren't -// working on the device yet -// - - -private void checkBufferObject(boolean extension1, - boolean extension2, - boolean extension3, +private void checkBufferObject(boolean avail, boolean enabled, int state, String kind) { - /* - if (inBeginEndPair) { - throw new GLException("May not call this between glBegin and glEnd"); - } - boolean avail = (extension1 || extension2 || extension3); if (!avail) { if (!enabled) return; @@ -156,55 +133,70 @@ private void checkBufferObject(boolean extension1, throw new GLException(kind + " must be disabled to call this method"); } } - */ } private void checkArrayVBODisabled() { - /* initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, false, GL.GL_ARRAY_BUFFER, "array vertex_buffer_object"); - */ } private void checkArrayVBOEnabled() { - /* initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, true, GL.GL_ARRAY_BUFFER, "array vertex_buffer_object"); - */ } private void checkElementVBODisabled() { - /* initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, false, GL.GL_ELEMENT_ARRAY_BUFFER, "element vertex_buffer_object"); - */ } private void checkElementVBOEnabled() { - /* initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, true, GL.GL_ELEMENT_ARRAY_BUFFER, "element vertex_buffer_object"); - */ +} + +private void checkUnpackPBODisabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + false, + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object"); +} + +private void checkUnpackPBOEnabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + true, + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object"); +} + +private void checkPackPBODisabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + false, + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object"); +} + +private void checkPackPBOEnabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + true, + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object"); } // Attempt to return the same ByteBuffer object from glMapBufferARB if diff --git a/make/gl-impl-CustomJavaCode-gles2.java b/make/gl-impl-CustomJavaCode-gles2.java index c267fc4bf..e3f63f879 100755 --- a/make/gl-impl-CustomJavaCode-gles2.java +++ b/make/gl-impl-CustomJavaCode-gles2.java @@ -4,7 +4,7 @@ private boolean inBeginEndPair; public GLES2Impl(GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getOrCreateBufferSizeTracker(); + this.bufferSizeTracker = context.getBufferSizeTracker(); } public boolean isFunctionAvailable(String glFunctionName) { @@ -109,36 +109,25 @@ private int imageSizeInBytes(int format, int type, int w, int h, int d) { return (elements * esize * w * h * d); } -private boolean bufferObjectExtensionsInitialized = false; -private boolean haveARBPixelBufferObject; -private boolean haveEXTPixelBufferObject; -private boolean haveGL15; -private boolean haveGL21; -private boolean haveARBVertexBufferObject; private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); private GLBufferSizeTracker bufferSizeTracker; +private boolean bufferObjectExtensionsInitialized = false; +private boolean haveOESFramebufferObject; +private boolean haveOESPixelBufferObject; + private void initBufferObjectExtensionChecks() { if (bufferObjectExtensionsInitialized) return; bufferObjectExtensionsInitialized = true; - haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object"); - haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object"); - haveGL15 = isExtensionAvailable("GL_VERSION_1_5"); - haveGL21 = isExtensionAvailable("GL_VERSION_2_1"); - haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object"); + haveOESFramebufferObject = isExtensionAvailable("GL_OES_framebuffer_object"); + haveOESPixelBufferObject = false; // FIXME: can't find it in ES 1.1 or ES 2.0 spec } -private void checkBufferObject(boolean extension1, - boolean extension2, - boolean extension3, +private void checkBufferObject(boolean avail, boolean enabled, int state, String kind) { - if (inBeginEndPair) { - throw new GLException("May not call this between glBegin and glEnd"); - } - boolean avail = (extension1 || extension2 || extension3); if (!avail) { if (!enabled) return; @@ -158,9 +147,7 @@ private void checkBufferObject(boolean extension1, private void checkArrayVBODisabled() { initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, false, GL.GL_ARRAY_BUFFER, "array vertex_buffer_object"); @@ -168,9 +155,7 @@ private void checkArrayVBODisabled() { private void checkArrayVBOEnabled() { initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, true, GL.GL_ARRAY_BUFFER, "array vertex_buffer_object"); @@ -178,9 +163,7 @@ private void checkArrayVBOEnabled() { private void checkElementVBODisabled() { initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, false, GL.GL_ELEMENT_ARRAY_BUFFER, "element vertex_buffer_object"); @@ -188,14 +171,44 @@ private void checkElementVBODisabled() { private void checkElementVBOEnabled() { initBufferObjectExtensionChecks(); - checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, + checkBufferObject(true, true, GL.GL_ELEMENT_ARRAY_BUFFER, "element vertex_buffer_object"); } +private void checkUnpackPBODisabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + false, + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object"); +} + +private void checkUnpackPBOEnabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + true, + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object"); +} + +private void checkPackPBODisabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + false, + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object"); +} + +private void checkPackPBOEnabled() { + initBufferObjectExtensionChecks(); + checkBufferObject(haveOESPixelBufferObject, + true, + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object"); +} + // Attempt to return the same ByteBuffer object from glMapBufferARB if // the vertex buffer object's base address and size haven't changed private static class ARBVBOKey { diff --git a/make/make.jogl.all.linux-x86.sh b/make/make.jogl.all.linux-x86.sh index f538018be..556224d4c 100644 --- a/make/make.jogl.all.linux-x86.sh +++ b/make/make.jogl.all.linux-x86.sh @@ -2,7 +2,7 @@ . ../../setenv-build-jogl.sh -ant -v \ +ant \ -Dgluegen.cpptasks.detected.os=true \ -DisUnix=true \ -DisLinux=true \ 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(); } } } diff --git a/src/native/newt/X11Window.c b/src/native/newt/X11Window.c index 972bb72a7..6853c8434 100755 --- a/src/native/newt/X11Window.c +++ b/src/native/newt/X11Window.c @@ -48,32 +48,35 @@ // #define VERBOSE_ON 1 #ifdef VERBOSE_ON + #define DBG_PRINT(args...) fprintf(stderr, args) -static void _dumpVisualInfo(const char * msg, XVisualInfo *pVisualQuery) { - if(pVisualQuery!=NULL) { - fprintf(stderr, "%s: screen %d, visual: %p, visual-id: 0x%X, depth: %d, class %d, cmap sz: %d, bpp: 3x%d, rgb 0x%X 0x%X 0x%X\n", - msg, - pVisualQuery->screen, - pVisualQuery->visual, - (int)pVisualQuery->visualid, - pVisualQuery->depth, - pVisualQuery->class, - pVisualQuery->colormap_size, - pVisualQuery->bits_per_rgb, - (int)pVisualQuery->red_mask, - (int)pVisualQuery->green_mask, - (int)pVisualQuery->blue_mask - ); - } else { - fprintf(stderr, "%s: NULL XVisualInfo\n", msg); - } -} + #define DUMP_VISUAL_INFO(a,b) _dumpVisualInfo((a),(b)) -#define DUMP_VISUAL_INFO(a,b) _dumpVisualInfo((a),(b)) + static void _dumpVisualInfo(const char * msg, XVisualInfo *pVisualQuery) { + if(pVisualQuery!=NULL) { + fprintf(stderr, "%s: screen %d, visual: %p, visual-id: 0x%X, depth: %d, class %d, cmap sz: %d, bpp: 3x%d, rgb 0x%X 0x%X 0x%X\n", + msg, + pVisualQuery->screen, + pVisualQuery->visual, + (int)pVisualQuery->visualid, + pVisualQuery->depth, + pVisualQuery->class, + pVisualQuery->colormap_size, + pVisualQuery->bits_per_rgb, + (int)pVisualQuery->red_mask, + (int)pVisualQuery->green_mask, + (int)pVisualQuery->blue_mask + ); + } else { + fprintf(stderr, "%s: NULL XVisualInfo\n", msg); + } + } #else -#define DUMP_VISUAL_INFO(a,b) + #define DBG_PRINT(args...) + + #define DUMP_VISUAL_INFO(a,b) #endif @@ -220,9 +223,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow XFree(pVisualQuery); pVisualQuery=NULL; } -#ifdef VERBOSE_ON - fprintf(stderr, "trying given (screen %d, visualID: %d) found: %p\n", scrn_idx, (int)visualID, visual); -#endif + DBG_PRINT( "trying given (screen %d, visualID: %d) found: %p\n", scrn_idx, (int)visualID, visual); } if (visual==NULL) { @@ -246,9 +247,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow visual = NULL; visualID = 0; } -#ifdef VERBOSE_ON - fprintf(stderr, "default visual (screen %d, visualID: %d) found: %p\n", scrn_idx, (int)visualID, visual); -#endif + DBG_PRINT( "default visual (screen %d, visualID: %d) found: %p\n", scrn_idx, (int)visualID, visual); } } if (visual==NULL) @@ -264,9 +263,10 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow windowParent = XRootWindowOfScreen(scrn); - attrMask = (CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect); + attrMask = (CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect) ; + memset(&xswa, 0, sizeof(xswa)); - xswa.override_redirect = True; + xswa.override_redirect = False; // decorated xswa.border_pixel = 0; xswa.background_pixel = 0; xswa.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask; @@ -303,10 +303,13 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_CloseWindow Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; - XUngrabPointer(dpy, CurrentTime); - XUngrabKeyboard(dpy, CurrentTime); + /** + XUngrabPointer(dpy, CurrentTime); + XUngrabKeyboard(dpy, CurrentTime); + */ XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); + XSync(dpy, True); XDestroyWindow(dpy, w); } @@ -322,15 +325,17 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setVisible0 Window w = (Window)window; if(visible==JNI_TRUE) { XMapRaised(dpy, w); + XSync(dpy, False); - XSetInputFocus(dpy, w, RevertToNone, CurrentTime); + XSetInputFocus(dpy, w, RevertToParent, CurrentTime); - XSync(dpy, False); } else { - XUngrabPointer(dpy, CurrentTime); - XUngrabKeyboard(dpy, CurrentTime); - XSelectInput(dpy, w, 0); + /** + XUngrabPointer(dpy, CurrentTime); + XUngrabKeyboard(dpy, CurrentTime); + */ XUnmapWindow(dpy, w); + XSync(dpy, False); } } @@ -474,6 +479,12 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_DispatchMessages if(evt.xvisibility.window==w) { } break; + case Expose: + if(evt.xvisibility.window==w) { + DBG_PRINT( "event . sizeChangedID call\n"); + (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) evt.xexpose.width, (jint) evt.xexpose.height); + } + break; } } } @@ -481,14 +492,46 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_DispatchMessages /* * Class: com_sun_javafx_newt_x11_X11Window * Method: setSize0 - * Signature: (JJII)V + * Signature: (JJIIIZ)V */ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0 - (JNIEnv *env, jobject obj, jlong display, jlong window, jint width, jint height) + (JNIEnv *env, jobject obj, jlong display, jlong window, jint width, jint height, jint decorationToggle, jboolean isVisible) { Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; - XResizeWindow(dpy, w, (unsigned)width, (unsigned)height); + + if(0!=decorationToggle) { + XSetWindowAttributes xswa; + unsigned long attrMask=CWOverrideRedirect; + + if(isVisible==JNI_TRUE) { + DBG_PRINT( "setSize0 . unmap\n"); + XUnmapWindow(dpy, w); + XSync(dpy, False); + } + + if(decorationToggle<0) { + /* undecorated */ + xswa.override_redirect = True; + } else { + /* decorated */ + xswa.override_redirect = False; + } + XChangeWindowAttributes(dpy, w, attrMask, &xswa); + + if(isVisible==JNI_TRUE) { + DBG_PRINT( "setSize0 . map\n"); + XMapRaised(dpy, w); + XSync(dpy, False); + } + } + DBG_PRINT( "setSize0 . XConfigureWindow\n"); + XWindowChanges xwc; + xwc.width=width; + xwc.height=height; + XConfigureWindow(dpy, w, CWWidth|CWHeight, &xwc); + + DBG_PRINT( "setSize0 . sizeChangedID call\n"); (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height); } @@ -502,7 +545,13 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setPosition0 { Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; - XMoveWindow(dpy, w, (unsigned)x, (unsigned)y); + + DBG_PRINT( "setPos0 . XConfigureWindow\n"); + XWindowChanges xwc; + xwc.x=x; + xwc.y=y; + XConfigureWindow(dpy, w, CWX|CWY, &xwc); + // (*env)->CallVoidMethod(env, obj, positionChangedID, (jint) width, (jint) height); } |