diff options
author | Michael Bien <[email protected]> | 2009-07-24 17:22:11 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2009-07-24 17:22:11 +0200 |
commit | 2a8e9876ca4567de3b08813c280d006f9b2c32e6 (patch) | |
tree | a44911062f30e557255162772c9b5fa64d1ad59a /src/nativewindow | |
parent | 801df10c0ee6ac6da81f1eb770dbc8a7ff7c5e38 (diff) | |
parent | 0906140a18690a9dced8dec12dfdd8cf4c95a4df (diff) |
Merge branch 'master' of ssh://[email protected]/jogl~jogl-git
Diffstat (limited to 'src/nativewindow')
6 files changed, 74 insertions, 18 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java index 46128b227..c7d2acec0 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java @@ -44,7 +44,6 @@ public class NullWindow implements NativeWindow { protected long surfaceHandle, displayHandle; protected AbstractGraphicsConfiguration config; - public NullWindow(AbstractGraphicsConfiguration cfg) { invalidate(); config = cfg; @@ -128,4 +127,12 @@ public class NullWindow implements NativeWindow { public int getHeight() { return height; } + + public String toString() { + return "NullWindow[config "+config+ + ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ + ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ + ", size "+getWidth()+"x"+getHeight()+"]"; + } + } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java index af93b8c31..aac01e990 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java @@ -41,19 +41,39 @@ import com.sun.nativewindow.impl.*; import javax.media.nativewindow.*; import java.awt.GraphicsEnvironment; +import java.lang.reflect.*; public class JAWTUtil { + // See whether we're running in headless mode + private static final boolean headlessMode; + + // Java2D magic .. + private static final Class j2dClazz; + private static final Method isQueueFlusherThread; + private static final boolean j2dExist; + static { JAWTNativeLibLoader.loadAWTImpl(); JAWTNativeLibLoader.loadNativeWindow("awt"); lockedStack = null; headlessMode = GraphicsEnvironment.isHeadless(); - } - // See whether we're running in headless mode - private static final boolean headlessMode; + boolean ok=false; + Class jC=null; + Method m=null; + if(!headlessMode) { + try { + jC = Class.forName("com.sun.opengl.impl.awt.Java2D"); + m = jC.getMethod("isQueueFlusherThread", null); + ok = true; + } catch (Exception e) {} + } + j2dClazz = jC; + isQueueFlusherThread = m; + j2dExist = ok; + } private static Exception lockedStack; @@ -61,11 +81,27 @@ public class JAWTUtil { // ie loading the native libraries .. public static void init() { } + public static final boolean hasJava2D() { + return j2dExist; + } + + public static final boolean isJava2DQueueFlusherThread() { + boolean b = false; + if(j2dExist) { + try { + b = ((Boolean)isQueueFlusherThread.invoke(null, null)).booleanValue(); + } catch (Exception e) {} + } + return b; + } + public static boolean isHeadlessMode() { return headlessMode; } public static synchronized void lockToolkit() throws NativeWindowException { + if (isJava2DQueueFlusherThread()) return; + if (null!=lockedStack) { lockedStack.printStackTrace(); throw new NativeWindowException("JAWT Toolkit already locked - "+Thread.currentThread().getName()); @@ -83,6 +119,8 @@ public class JAWTUtil { } public static synchronized void unlockToolkit() { + if (isJava2DQueueFlusherThread()) return; + if (null!=lockedStack) { lockedStack = null; if (headlessMode) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java index 6c4c93003..9df57b6d2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java +++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java @@ -57,6 +57,9 @@ public class Capabilities implements Cloneable { private int transparentValueBlue = -1; private int transparentValueAlpha = -1; + // Switch for on- or offscreen + private boolean onscreen = true; + /** Creates a Capabilities object. All attributes are in a default state. */ @@ -79,7 +82,8 @@ public class Capabilities implements Cloneable { other.getGreenBits()==greenBits && other.getBlueBits()==blueBits && other.getAlphaBits()==alphaBits && - other.isBackgroundOpaque()==backgroundOpaque; + other.isBackgroundOpaque()==backgroundOpaque && + other.isOnscreen()==onscreen; if(!backgroundOpaque) { res = res && other.getTransparentRedValue()==transparentValueRed && other.getTransparentGreenValue()==transparentValueGreen && @@ -184,6 +188,20 @@ public class Capabilities implements Cloneable { return backgroundOpaque; } + /** Sets whether the drawable surface supports onscreen. + Defaults to true. + */ + public void setOnscreen(boolean onscreen) { + this.onscreen=onscreen; + } + + /** Indicates whether the drawable surface is onscreen. + Defaults to true. + */ + public boolean isOnscreen() { + return onscreen; + } + /** Gets the transparent red value for the frame buffer configuration. * This value is undefined if {@link #isBackgroundOpaque()} equals true. * @see #setTransparentRedValue @@ -242,7 +260,8 @@ public class Capabilities implements Cloneable { public String toString() { StringBuffer msg = new StringBuffer(); msg.append("Capabilities["); - msg.append("Red: " + redBits + + msg.append("Onscreen: "+ onscreen + + ", Red: " + redBits + ", Green: " + greenBits + ", Blue: " + blueBits + ", Alpha: " + alphaBits + diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index eb0c25aed..cbd485649 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -129,7 +129,8 @@ public abstract class NativeWindowFactory { } boolean toolkitLockForced = Debug.getBooleanProperty("nativewindow.locking", true, acc); - boolean awtToolkitLockDisabled = Debug.getBooleanProperty("java.awt.headless", false, acc); + boolean awtToolkitLockDisabled = Debug.getBooleanProperty("java.awt.headless", false, acc) || + Debug.getBooleanProperty("nativewindow.nolocking", true, acc) ; NativeWindowFactory _factory = null; @@ -166,13 +167,6 @@ public abstract class NativeWindowFactory { // primitives in its OpenGL window system binding) makes // the JOGL library more powerful. // - // (FIXME: from code examination, it looks like there are - // regressions in the support for external GLDrawables in - // JOGL 2 compared to JOGL 1.1.1. Note that the "default" - // X display connection from X11Util is being used during - // construction of the X11ExternalGLXDrawable instead of - // the result of glXGetCurrentDisplay().) - // // The X11AWTNativeWindowFactory provides a locking // mechanism compatible with the AWT. It may be desirable // to replace this window factory when using third-party diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java index 911b8f416..f0ea11011 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java @@ -34,8 +34,6 @@ package javax.media.nativewindow.x11; import javax.media.nativewindow.*; -import com.sun.nativewindow.impl.x11.*; - /** Encapsulates a graphics device on X11 platforms. */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java index 45146d33e..360036563 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java @@ -33,8 +33,8 @@ package javax.media.nativewindow.x11; import javax.media.nativewindow.*; - -import com.sun.nativewindow.impl.x11.*; +import com.sun.nativewindow.impl.x11.X11Util; +import com.sun.nativewindow.impl.x11.X11Lib; /** Encapsulates a screen index on X11 platforms. Objects of this type are passed to {@link |