aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
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/nativewindow
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/nativewindow')
-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
4 files changed, 34 insertions, 21 deletions
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;