summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java40
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java45
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java7
4 files changed, 16 insertions, 104 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index b75d2f927..f5970fad9 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -46,18 +46,18 @@ import java.util.Map;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.OffscreenLayerSurface;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLContextShareSet;
import jogamp.opengl.GLDrawableImpl;
import jogamp.opengl.GLGraphicsConfigurationUtil;
import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType;
-import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.LayeredSurfaceType;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.common.os.Platform;
@@ -407,7 +407,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) MacOSXCGLContext.this.drawable;
final NativeSurface surface = drawable.getNativeSurface();
final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- final boolean isBackingLayerView = LayeredSurfaceType.None != drawable.getLayeredSurfaceType();
+ final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true);
final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor);
if (pixelFormat == 0) {
@@ -416,7 +416,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
config.setChosenPixelFormat(pixelFormat);
if(DEBUG) {
System.err.println("NS create OSX>=lion "+isLionOrLater);
- System.err.println("NS create drawable layeredType: "+drawable.getLayeredSurfaceType()+", backingLayerView "+isBackingLayerView);
+ System.err.println("NS create backingLayerHost: "+backingLayerHost);
System.err.println("NS create share: "+share);
System.err.println("NS create chosenCaps: "+chosenCaps);
System.err.println("NS create pixelFormat: "+toHexString(pixelFormat));
@@ -428,7 +428,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
int[] viewNotReady = new int[1];
// Try to allocate a context with this
ctx = CGL.createContext(share,
- drawable.getNSViewHandle(), isBackingLayerView,
+ drawable.getNSViewHandle(), null!=backingLayerHost,
pixelFormat,
chosenCaps.isBackgroundOpaque(),
viewNotReady, 0);
@@ -459,16 +459,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl
CGL.setContextPBuffer(ctx, drawable.getHandle());
}
//
- // handled layered surface (same path for direct and parented)
+ // handled layered surface
//
- if(isBackingLayerView) {
- final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(surface);
+ if(null != backingLayerHost) {
nsOpenGLLayerPFmt = pixelFormat;
pixelFormat = 0;
- /*
- final long nsView = drawable.getNSViewHandle();
- nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, nsView, fixedCaps.isBackgroundOpaque());
- */
final int texWidth, texHeight;
if(drawable instanceof MacOSXPbufferCGLDrawable) {
final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable;
@@ -482,7 +477,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer));
}
- lsh.attachSurfaceLayer(nsOpenGLLayer);
+ backingLayerHost.attachSurfaceLayer(nsOpenGLLayer);
}
} finally {
if(0!=pixelFormat) {
@@ -495,12 +490,15 @@ public abstract class MacOSXCGLContext extends GLContextImpl
public boolean destroy(long ctx) {
if(0 != nsOpenGLLayer) {
final NativeSurface surface = drawable.getNativeSurface();
- final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(surface);
if (DEBUG) {
System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer));
}
+ final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true);
+ if(null == ols) {
+ throw new InternalError("XXX: "+ols);
+ }
CGL.releaseNSOpenGLLayer(nsOpenGLLayer);
- lsh.detachSurfaceLayer(nsOpenGLLayer);
+ ols.detachSurfaceLayer(nsOpenGLLayer);
CGL.deletePixelFormat(nsOpenGLLayerPFmt);
nsOpenGLLayerPFmt = 0;
nsOpenGLLayer = 0;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
index 7ee0d4fbe..12d480fd1 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
@@ -49,7 +49,6 @@ import javax.media.nativewindow.NativeSurface;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
-import jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow;
import jogamp.opengl.GLDrawableImpl;
import jogamp.opengl.GLDynamicLookupHelper;
@@ -93,29 +92,16 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
this.id = id;
}
}
- public enum LayeredSurfaceType {
- None(0), Direct(1), Parented(2);
-
- public final int id;
-
- LayeredSurfaceType(int id){
- this.id = id;
- }
- }
-
private List<WeakReference<MacOSXCGLContext>> createdContexts = new ArrayList<WeakReference<MacOSXCGLContext>>();
private boolean haveSetOpenGLMode = false;
private GLBackendType openGLMode = GLBackendType.NSOPENGL;
- protected LayeredSurfaceType layeredSurfaceType = LayeredSurfaceType.None;
public MacOSXCGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) {
super(factory, comp, realized);
initOpenGLImpl(getOpenGLMode());
}
- public final LayeredSurfaceType getLayeredSurfaceType() { return layeredSurfaceType; }
-
protected void setRealizedImpl() {
}
@@ -123,32 +109,6 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
return GLBackendType.NSOPENGL == openGLMode ? getHandle() : null;
}
- @Override
- protected void updateHandle() {
- final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(surface);
- if (null != lsh) {
- if(lsh == surface) {
- // direct surface host, eg. AWT GLCanvas
- layeredSurfaceType = LayeredSurfaceType.Direct;
- if (DEBUG) {
- System.err.println("updateHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(lsh.getSurfaceHandle()));
- }
- } else {
- // parent surface host, eg. via native parenting w/ NewtCanvasAWT
- layeredSurfaceType = LayeredSurfaceType.Parented;
- if (DEBUG) {
- System.err.println("updateHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(getHandle()));
- }
- }
- } else {
- layeredSurfaceType = LayeredSurfaceType.None;
- if (DEBUG) {
- System.err.println("updateHandle: layerType " + layeredSurfaceType);
- }
- }
- super.updateHandle();
- }
-
protected void registerContext(MacOSXCGLContext ctx) {
// NOTE: we need to keep track of the created contexts in order to
// implement swapBuffers() because of how Mac OS X implements its
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 3c2b7aed6..30917476e 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -50,7 +50,6 @@ import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
@@ -64,7 +63,6 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import jogamp.nativewindow.WrappedSurface;
-import jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
import jogamp.opengl.GLDrawableFactoryImpl;
import jogamp.opengl.GLDrawableImpl;
@@ -259,38 +257,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
return MacOSXCGLGraphicsConfiguration.getAvailableCapabilities(this, device);
}
- protected static MacOSXJAWTWindow getLayeredSurfaceHost(NativeSurface surface) {
- if(surface instanceof NativeWindow) {
- final NativeWindow nwThis = (NativeWindow) surface;
- if( nwThis instanceof MacOSXJAWTWindow) {
- // direct surface host, eg. via AWT GLCanvas
- final MacOSXJAWTWindow r = (MacOSXJAWTWindow) nwThis;
- return r.isOffscreenLayerSurface() ? r : null;
- } else {
- NativeWindow nwParent = nwThis.getParent();
- if(null != nwParent && nwParent instanceof MacOSXJAWTWindow) {
- final MacOSXJAWTWindow r = (MacOSXJAWTWindow) nwParent;
- return r.isOffscreenLayerSurface() ? r : null;
- }
- }
- }
- return null;
- }
-
protected GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(target);
- if(null != lsh) {
- // layered surface -> PBuffer
- final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- final GLCapabilities chosenCaps = (GLCapabilities) config.getChosenCapabilities().cloneMutable();
- chosenCaps.setOnscreen(false);
- chosenCaps.setPBuffer(true);
- config.setChosenCapabilities(chosenCaps);
- return new MacOSXPbufferCGLDrawable(this, target, false);
- }
return new MacOSXOnscreenCGLDrawable(this, target);
}
@@ -300,21 +270,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
if(!caps.isPBuffer()) {
return new MacOSXOffscreenCGLDrawable(this, target);
}
-
- // PBuffer GLDrawable Creation
- /**
- * FIXME: Think about this ..
- * should not be necessary ? ..
- final List returnList = new ArrayList();
- final GLDrawableFactory factory = this;
- Runnable r = new Runnable() {
- public void run() {
- returnList.add(new MacOSXPbufferCGLDrawable(factory, target));
- }
- };
- maybeDoSingleThreadedWorkaround(r);
- return (GLDrawableImpl) returnList.get(0);
- */
return new MacOSXPbufferCGLDrawable(this, target, true);
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
index de3e90c4c..4fe6fa484 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -74,6 +74,8 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
@Override
protected boolean createImpl() {
boolean res = super.createImpl();
+ lastWidth = -1;
+ lastHeight = -1;
if(res && isNSContext()) {
if(0 != updateHandle) {
throw new InternalError("XXX1");
@@ -83,9 +85,6 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
throw new InternalError("XXX2");
}
}
- updateHandle = 0;
- lastWidth = -1;
- lastHeight = -1;
return res;
}
@@ -98,6 +97,6 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
super.destroyImpl();
}
- private long updateHandle;
+ private long updateHandle = 0;
private int lastWidth, lastHeight;
}