summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-05 05:51:40 +0100
committerSven Gothel <[email protected]>2011-11-05 05:51:40 +0100
commit6d57bd7717834afcd5f1dc3b60d696eda1997fe8 (patch)
treea1ad158532dafb018044bc101301901cc08473ca /src
parentfe4f9f3f83cda05052549cc34fb3f7acb4eabb9c (diff)
Cleanup ; JAWT* version flag setting based whether
Cleanup - use Platform OS_TYPE - .. JAWT* version flag - if JAWTWindow is Applet, attempt offscreenLayer if avail - ..
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableImpl.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java6
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java9
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java40
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java4
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java2
7 files changed, 52 insertions, 23 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index 58c9aaaa6..6b6ce9f9e 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -125,7 +125,10 @@ public abstract class GLDrawableImpl implements GLDrawable {
return surface;
}
+ /** called with locked surface @ setRealized(false) */
protected void destroyHandle() {}
+
+ /** called with locked surface @ setRealized(true) or @ lockSurface(..) when surface changed */
protected void updateHandle() {}
public long getHandle() {
diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
index 318d00637..1f8ba5cc4 100644
--- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
+++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
@@ -146,6 +146,17 @@ public class GLGraphicsConfigurationUtil {
return capsRequested;
}
+ public static GLCapabilitiesImmutable fixSingleBufferGLCapabilities(GLCapabilitiesImmutable capsRequested)
+ {
+ if( capsRequested.getDoubleBuffered() ) {
+ // fix caps ..
+ GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
+ caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+ return caps2;
+ }
+ return capsRequested;
+ }
+
public static GLCapabilitiesImmutable fixOpaqueGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean isOpaque)
{
GLCapabilities caps2 = null;
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
index 8ef642322..8cea2a550 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
@@ -56,14 +56,16 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
@SuppressWarnings("unused")
+ @Override
public long getHandle() {
if(USE_GLXWINDOW && useGLXWindow) {
return glXWindow;
}
- return getNativeSurface().getSurfaceHandle();
+ return super.getHandle();
}
@SuppressWarnings("unused")
+ @Override
protected void destroyHandle() {
if(USE_GLXWINDOW && 0!=glXWindow) {
GLX.glXDestroyWindow(getNativeSurface().getDisplayHandle(), glXWindow);
@@ -72,7 +74,7 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
}
- /** must be locked already */
+ @Override
protected void updateHandle() {
if(USE_GLXWINDOW) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index afcc3cbf0..a88ca678e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -77,14 +77,17 @@ public class JAWTUtil {
boolean ok;
}
- public static void setJAWTVersionFlags(boolean useOffScreenLayerIfAvailable) {
+ public static boolean setJAWTVersionFlags(boolean useOffScreenLayerIfAvailable) {
+ if(JAWT.isJAWTInstantiated()) { return false; } // already instantiated
+
if(useOffScreenLayerIfAvailable &&
Platform.OS_TYPE == Platform.OSType.MACOS &&
Platform.OS_VERSION_NUMBER.compareTo(JAWT.JAWT_MacOSXCALayerMinVersion) >= 0) {
JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4 | JAWT.JAWT_MACOSX_USE_CALAYER);
- } else {
- JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4);
+ return true;
}
+ JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4);
+ return !useOffScreenLayerIfAvailable; // n/a
}
public static boolean isJAWTVersionUsingOffscreenLayer() {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index cc6493313..be47e8939 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -42,6 +42,7 @@ import com.jogamp.common.util.locks.RecursiveLock;
import java.awt.Component;
import java.awt.Window;
+import java.applet.Applet;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
@@ -58,6 +59,7 @@ public abstract class JAWTWindow implements NativeWindow {
// lifetime: forever
protected Component component;
+ protected boolean isApplet;
protected AbstractGraphicsConfiguration config;
// lifetime: valid after lock, forever until invalidate
@@ -75,15 +77,27 @@ public abstract class JAWTWindow implements NativeWindow {
private void init(Component windowObject) throws NativeWindowException {
invalidate();
this.component = windowObject;
+ this.isApplet = false;
+ while(!isApplet && null != windowObject) {
+ isApplet = windowObject instanceof Applet;
+ windowObject = windowObject.getParent();
+ }
+ if(isApplet) {
+ JAWTUtil.setJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true
+ } else {
+ // test
+ JAWTUtil.setJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true
+ }
validateNative();
}
protected abstract void validateNative() throws NativeWindowException;
protected synchronized void invalidate() {
- component = null;
+ invalidateNative();
drawable= 0;
bounds = new Rectangle();
}
+ protected abstract void invalidateNative();
protected final void updateBounds(JAWT_Rectangle jawtBounds) {
bounds.setX(jawtBounds.getX());
@@ -100,12 +114,16 @@ public abstract class JAWTWindow implements NativeWindow {
public final Component getAWTComponent() {
return component;
}
+
+ public final boolean isApplet() {
+ return isApplet;
+ }
//
// SurfaceUpdateListener
//
- public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
// nop
}
@@ -169,15 +187,14 @@ public abstract class JAWTWindow implements NativeWindow {
return surfaceLock.getOwner();
}
- public final boolean surfaceSwap() {
+ public boolean surfaceSwap() {
return false;
}
- public final void surfaceUpdated(Object updater, NativeWindow window, long when) { }
-
- public final long getSurfaceHandle() {
+ public long getSurfaceHandle() {
return drawable;
}
+
public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config;
}
@@ -207,12 +224,13 @@ public abstract class JAWTWindow implements NativeWindow {
//
public synchronized void destroy() {
+ invalidate();
if(null!=component) {
if(component instanceof Window) {
((Window)component).dispose();
}
+ component = null;
}
- invalidate();
}
public final NativeWindow getParent() {
@@ -223,14 +241,6 @@ public abstract class JAWTWindow implements NativeWindow {
return drawable;
}
- public boolean isSetWindowHandleSupported() {
- return false;
- }
- public void setWindowHandle(long handle) {
- throw new java.lang.UnsupportedOperationException();
- }
-
-
public final int getX() {
return component.getX();
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java
index 982b94888..610ce0f15 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java
@@ -61,9 +61,7 @@ public class WindowsJAWTWindow extends JAWTWindow {
protected void validateNative() throws NativeWindowException {
}
- @Override
- protected synchronized void invalidate() {
- super.invalidate();
+ protected void invalidateNative() {
windowHandle = 0;
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
index 2319d6269..562a9339a 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java
@@ -85,6 +85,8 @@ public class X11JAWTWindow extends JAWTWindow {
}
awtDevice.setSubType(NativeWindowFactory.TYPE_X11, displayHandle);
}
+
+ protected void invalidateNative() { }
protected int lockSurfaceImpl() throws NativeWindowException {
int ret = NativeWindow.LOCK_SUCCESS;