aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-09 07:42:20 +0100
committerSven Gothel <[email protected]>2011-11-09 07:42:20 +0100
commit46542168d64b37f544f61802693f15b59b224e4e (patch)
tree292a62903a27ef00cef92faca19d323f914bce28 /src/nativewindow/classes/jogamp
parentf51e3dad6c4bd1f6d0001cecf6a0f692400ed602 (diff)
OS X Layered View: Part5 NEWT/AWT Interaction ; Fix NSOpenGLLayer pos ; Cleanup
Better JAWT* name for offscreen layer surface: - MacOSXCGLDrawableFactory, JAWTUtil, JAWTWindow, MacOSXJAWTWindow - FIXME: Need to get rid of the cached JAWT instance, in case we like to have dual usage of offscreenLayerSurface and onscreen. This would be done implicit by using NEWT .. hence low prio. AWTGraphicsConfiguration: - Fix create(): Use capsRequested for AWT aligned caps if capsChosen is null. (was capsChosen .. which is null) - Add updateGraphicsConfiguration() which allows to update the AWTGraphicsConfiguration. NewtFactoryAWT: - Add updateGraphicsConfiguration() .. entrypoint for AWTGraphicsConfiguration.updateGraphicsConfiguration() NSOpenGLLayer Impl: - For 'some reason' the layer's position is initially negative, fix it @ 1st 'draw' - Re-add CVDisplayLink OpenGL setting .. for what it's worth .. I don't know JAWTWindow: - Remove test setting: Only enable offscreenLayerSurface for applets if avail. (New unit test enables it seperatly) NewtCanvasAWT: - If NEWT child is offscreen, attach AWTMouseAdapter and AWTKeyAdapter to route these AWT input events to NEWT. - Don't loose-focus if NEWT child is offscreen. - Impl. NativeSurfaceHolder, NativeWindowHolder - NativeWindow is created at construction and it's GraphicsConfiguration updated at addNotify(..). - At addNotify/reparent: try harder to determine proper NEWT child size: - use preferred size if set - use minimum size if set - subtract insets from container size OffscreenWindow/WindowImpl: - Allow setSize() .. currently NOP for offscreen. - WindowImpl: Commented out recreate case for offscreen-setSize .. TEST: com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT Passed tests: - GLCanvas - NewtCanvasAWT/OffscreenWindow
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java28
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java5
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java24
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java2
4 files changed, 36 insertions, 23 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index a88ca678e..4435c4f8f 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -77,20 +77,36 @@ public class JAWTUtil {
boolean ok;
}
- public static boolean setJAWTVersionFlags(boolean useOffScreenLayerIfAvailable) {
+ /**
+ * Returns true if this platform's JAWT implementation supports
+ * or uses offscreen layer.
+ */
+ public static boolean isOffscreenLayerSupported() {
+ return Platform.OS_TYPE == Platform.OSType.MACOS &&
+ Platform.OS_VERSION_NUMBER.compareTo(JAWT.JAWT_MacOSXCALayerMinVersion) >= 0;
+ }
+
+ /**
+ *
+ * FIXME: Need to get rid of the cached JAWT instance,
+ * in case we like to have dual usage of offscreenLayeredSurface and onscreen.
+ * This would be done implicit by using NEWT .. hence low prio.
+ *
+ * @param useOffscreenLayerIfAvailable
+ * @return
+ */
+ public static boolean setCachedJAWTVersionFlags(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) {
+ if(useOffscreenLayerIfAvailable && isOffscreenLayerSupported()) {
JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4 | JAWT.JAWT_MACOSX_USE_CALAYER);
return true;
}
JAWT.setJAWTVersionFlags(JAWTFactory.JAWT_VERSION_1_4);
- return !useOffScreenLayerIfAvailable; // n/a
+ return !useOffscreenLayerIfAvailable; // n/a
}
- public static boolean isJAWTVersionUsingOffscreenLayer() {
+ public static boolean isCachedJAWTUsingOffscreenLayer() {
return 0 != ( JAWT.getJAWT().getVersionCached() & JAWT.JAWT_MACOSX_USE_CALAYER );
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index 3f10fa983..151099f26 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -98,10 +98,7 @@ public abstract class JAWTWindow implements NativeWindow {
windowObject = windowObject.getParent();
}
if(isApplet) {
- JAWTUtil.setJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true
- } else {
- // test
- JAWTUtil.setJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true
+ JAWTUtil.setCachedJAWTVersionFlags(true); // useOffScreenLayerIfAvailable := true
}
validateNative();
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index b75bb3f4d..5ac42e21b 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -64,7 +64,7 @@ import jogamp.nativewindow.macosx.OSXUtil;
public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
public MacOSXJAWTWindow(Object comp, AbstractGraphicsConfiguration config) {
super(comp, config);
- isOffscreenLayeredSurface = JAWTUtil.isJAWTVersionUsingOffscreenLayer();
+ isOffscreenLayerSurface = JAWTUtil.isCachedJAWTUsingOffscreenLayer();
dumpInfo();
}
@@ -73,22 +73,22 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
protected void invalidateNative() {
surfaceHandle=0;
- if(isOffscreenLayeredSurface && 0 == drawable) {
+ if(isOffscreenLayerSurface && 0 == drawable) {
OSXUtil.DestroyNSWindow(drawable);
drawable = 0;
}
}
- public final boolean isLayeredSurface() {
- return isOffscreenLayeredSurface;
+ public final boolean isOffscreenLayerSurface() {
+ return isOffscreenLayerSurface;
}
public long getSurfaceHandle() {
- return isOffscreenLayeredSurface ? surfaceHandle : super.getSurfaceHandle() ;
+ return isOffscreenLayerSurface ? surfaceHandle : super.getSurfaceHandle() ;
}
public void setSurfaceHandle(long surfaceHandle) {
- if( !isLayeredSurface() ) {
+ if( !isOffscreenLayerSurface() ) {
throw new java.lang.UnsupportedOperationException("Not using CALAYER");
}
if(DEBUG) {
@@ -109,8 +109,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
return getSurfaceLayers().getLayer();
} */
- public void attachSurfaceLayer(long layerHandle) {
- if( !isLayeredSurface() ) {
+ public void attachSurfaceLayer(final long layerHandle) {
+ if( !isOffscreenLayerSurface() ) {
throw new NativeWindowException("Not using CALAYER");
}
int lockRes = lockSurface();
@@ -121,7 +121,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
if(DEBUG) {
System.err.println("MacOSXJAWTWindow.attachSurfaceLayer(): 0x"+Long.toHexString(layerHandle));
}
- OSXUtil.AttachJAWTSurfaceLayer0(dsi, layerHandle);
+ OSXUtil.AttachJAWTSurfaceLayer(dsi, layerHandle);
} finally {
unlockSurface();
}
@@ -179,7 +179,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
dumpInfo();
}
firstLock = false;
- if( !isOffscreenLayeredSurface ) {
+ if( !isOffscreenLayerSurface ) {
macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo();
if (macosxdsi == null) {
unlockSurfaceImpl();
@@ -258,7 +258,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
// System.err.println(this);
System.err.println("JAWT version: 0x"+Integer.toHexString(JAWT.getJAWT().getVersionCached())+
", CA_LAYER: "+ (0!=(JAWT.getJAWT().getVersionCached() & JAWT.JAWT_MACOSX_USE_CALAYER))+
- ", isLayeredSurface "+isLayeredSurface());
+ ", isLayeredSurface "+isOffscreenLayerSurface());
if(null != dsi) {
JAWT_Rectangle r = dsi.getBounds();
System.err.println("dsi bounds: "+r.getX()+"/"+r.getY()+" "+r.getWidth()+"x"+r.getHeight());
@@ -286,7 +286,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
private JAWT_MacOSXDrawingSurfaceInfo macosxdsi;
// private JAWT_SurfaceLayers macosxsl;
- final boolean isOffscreenLayeredSurface;
+ final boolean isOffscreenLayerSurface;
long surfaceHandle = 0;
// Workaround for instance of 4796548
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 79ac24686..a07001def 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -51,7 +51,7 @@ public class OSXUtil {
DestroyNSWindow0(nsWindow);
}
- public static boolean AttachJAWTSurfaceLayer0(JAWT_DrawingSurfaceInfo dsi, long caLayer) {
+ public static boolean AttachJAWTSurfaceLayer(JAWT_DrawingSurfaceInfo dsi, long caLayer) {
return AttachJAWTSurfaceLayer0(dsi.getBuffer(), caLayer);
}