summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java6
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m92
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java128
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java28
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m102
5 files changed, 257 insertions, 99 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 8e845e847..b75d2f927 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -477,11 +477,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl
} else {
texWidth = drawable.getWidth();
texHeight = drawable.getHeight();
- }
+ }
nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight);
if (DEBUG) {
System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer));
- }
+ }
lsh.attachSurfaceLayer(nsOpenGLLayer);
}
} finally {
@@ -499,8 +499,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer));
}
- lsh.attachSurfaceLayer(0);
CGL.releaseNSOpenGLLayer(nsOpenGLLayer);
+ lsh.detachSurfaceLayer(nsOpenGLLayer);
CGL.deletePixelFormat(nsOpenGLLayerPFmt);
nsOpenGLLayerPFmt = 0;
nsOpenGLLayer = 0;
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
index ef6d11419..f261e95b2 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
@@ -46,13 +46,15 @@
BOOL shallDraw;
}
-- (id) initWithContext: (NSOpenGLContext*) ctx
+- (id) setupWithContext: (NSOpenGLContext*) ctx
pixelFormat: (NSOpenGLPixelFormat*) pfmt
pbuffer: (NSOpenGLPixelBuffer*) p
opaque: (Bool) opaque
texWidth: (int) texWidth
texHeight: (int) texHeight;
+- (void)deallocTex;
+- (void)disableAnimation;
- (int)getSwapInterval;
- (void)setSwapInterval:(int)interval;
- (void)tick;
@@ -85,15 +87,13 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
@implementation MyNSOpenGLLayer
-- (id) initWithContext: (NSOpenGLContext*) _ctx
+- (id) setupWithContext: (NSOpenGLContext*) _ctx
pixelFormat: (NSOpenGLPixelFormat*) _fmt
pbuffer: (NSOpenGLPixelBuffer*) p
opaque: (Bool) opaque
texWidth: (int) _texWidth
texHeight: (int) _texHeight;
{
- self = [super init];
-
pthread_mutex_init(&renderLock, NULL); // fast non-recursive
pthread_cond_init(&renderSignal, NULL); // no attribute
@@ -152,29 +152,61 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
CGRect lRect = [self frame];
- DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, frame: %lf/%lf %lfx%lf\n",
+ DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, frame: %lf/%lf %lfx%lf (refcnt %d)\n",
self, _ctx, _fmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight,
- lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
+ lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]);
return self;
}
-- (void)dealloc
+- (void)disableAnimation
{
+ DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink);
+ pthread_mutex_lock(&renderLock);
[self setAsynchronous: NO];
+ if(NULL != displayLink) {
#ifdef HAS_CADisplayLink
- [displayLink setPaused: YES];
- [displayLink release];
+ [displayLink setPaused: YES];
+ [displayLink release];
#else
- if(NULL!=displayLink) {
- CVDisplayLinkStop(displayLink);
- CVDisplayLinkRelease(displayLink);
- }
+ if(NULL!=displayLink) {
+ CVDisplayLinkStop(displayLink);
+ CVDisplayLinkRelease(displayLink);
+ }
#endif
- [pbuffer release];
+ displayLink = NULL;
+ }
+ pthread_mutex_unlock(&renderLock);
+}
+
+- (void)deallocTex
+{
+ pthread_mutex_lock(&renderLock);
+ NSOpenGLContext* context = [self openGLContext];
+ DBG_PRINT("MyNSOpenGLLayer::deallocTex %p (refcnt %d) - context %p, pbuffer %p\n", self, (int)[self retainCount], context, pbuffer);
+ if(NULL != pbuffer) {
+ if(NULL!=context) {
+ [context makeCurrentContext];
+ if(0 != textureID) {
+ glDeleteTextures(1, &textureID);
+ textureID = 0;
+ }
+ [context clearDrawable];
+ }
+ [pbuffer release];
+ pbuffer = NULL;
+ }
+ pthread_mutex_unlock(&renderLock);
+}
+
+- (void)dealloc
+{
+ DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]);
+ [self disableAnimation];
+ [self deallocTex];
pthread_cond_destroy(&renderSignal);
pthread_mutex_destroy(&renderLock);
- DBG_PRINT("MyNSOpenGLLayer::dealloc %p\n", self);
[super dealloc];
+ DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self);
}
- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
@@ -183,13 +215,14 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
// assume both methods 'canDrawInOpenGLContext' and 'drawInOpenGLContext'
// are called from the same thread subsequently
pthread_mutex_lock(&renderLock);
- if(NO == shallDraw) {
+ Bool res = NULL != pbuffer && YES == shallDraw;
+ if(!res) {
SYNC_PRINT("<0>");
pthread_mutex_unlock(&renderLock);
} else {
SYNC_PRINT("<");
}
- return shallDraw;
+ return res;
}
- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
@@ -279,6 +312,7 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(textureTarget);
+ glBindTexture(textureTarget, 0);
[super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp];
shallDraw = NO;
@@ -342,7 +376,11 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink,
@end
NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, Bool opaque, int texWidth, int texHeight) {
- return [[MyNSOpenGLLayer alloc] initWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight];
+ // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ?
+ // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO.
+ // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight];
+
+ return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight];
}
void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) {
@@ -403,9 +441,19 @@ void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) {
}
}
-void releaseNSOpenGLLayer(NSOpenGLLayer* l) {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- [l release];
- [pool release];
+void releaseNSOpenGLLayer(NSOpenGLLayer* layer) {
+ MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p (refcnt %d)\n", l, (int)[l retainCount]);
+
+ [l performSelectorOnMainThread:@selector(disableAnimation) withObject:nil waitUntilDone:YES];
+ // [l disableAnimation];
+
+ [l performSelectorOnMainThread:@selector(deallocTex) withObject:nil waitUntilDone:YES];
+ // [l deallocTex];
+
+ [l release];
+ DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p (refcnt %d)\n", l, (int)[l retainCount]);
+ [pool release];
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 71b297791..364b2054d 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -58,7 +58,6 @@ import jogamp.nativewindow.jawt.JAWTUtil;
import jogamp.nativewindow.jawt.JAWTWindow;
import jogamp.nativewindow.jawt.JAWT_DrawingSurface;
import jogamp.nativewindow.jawt.JAWT_DrawingSurfaceInfo;
-import jogamp.nativewindow.jawt.JAWT_Rectangle;
import jogamp.nativewindow.macosx.OSXUtil;
public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
@@ -78,17 +77,47 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
OSXUtil.DestroyNSWindow(drawable);
drawable = 0;
}
- if(0 != surfaceLayerHandle && null!=dsi) {
- OSXUtil.AttachJAWTSurfaceLayer(dsi, 0);
- }
- surfaceLayerHandle = 0;
}
}
public final boolean isOffscreenLayerSurface() {
return isOffscreenLayerSurface;
+ }
+ public void attachSurfaceLayer(final long layerHandle) {
+ if( !isOffscreenLayerSurface() ) {
+ throw new NativeWindowException("Not using CALAYER");
+ }
+ int lockRes = lockSurface();
+ if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
+ throw new NativeWindowException("Could not lock layeredSurfaceHost: "+this);
+ }
+ try {
+ if(DEBUG) {
+ System.err.println("MacOSXJAWTWindow.attachSurfaceLayer(): 0x"+Long.toHexString(layerHandle));
+ }
+ OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle);
+ } finally {
+ unlockSurface();
+ }
}
-
+ public void detachSurfaceLayer(final long layerHandle) {
+ if( !isOffscreenLayerSurface() ) {
+ throw new NativeWindowException("Not using CALAYER");
+ }
+ int lockRes = lockSurface();
+ if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
+ throw new NativeWindowException("Could not lock layeredSurfaceHost: "+this);
+ }
+ try {
+ if(DEBUG) {
+ System.err.println("MacOSXJAWTWindow.detachSurfaceLayer(): 0x"+Long.toHexString(layerHandle));
+ }
+ OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle);
+ } finally {
+ unlockSurface();
+ }
+ }
+
public long getSurfaceHandle() {
return isOffscreenLayerSurface ? surfaceHandle : super.getSurfaceHandle() ;
}
@@ -117,45 +146,6 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
return sscSet ? sscHeight: super.getHeight();
}
- /*
- public long getSurfaceLayer() {
- if( !isLayeredSurface() ) {
- throw new java.lang.UnsupportedOperationException("Not using CALAYER");
- }
- if( !dsLocked ) {
- throw new NativeWindowException("Not locked");
- }
- // return macosxsl.getLayer();
- return getSurfaceLayers().getLayer();
- } */
-
- public void attachSurfaceLayer(final long layerHandle) {
- if( !isOffscreenLayerSurface() ) {
- throw new NativeWindowException("Not using CALAYER");
- }
- int lockRes = lockSurface();
- if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
- throw new NativeWindowException("Could not lock layeredSurfaceHost: "+this);
- }
- try {
- if(DEBUG) {
- System.err.println("MacOSXJAWTWindow.attachSurfaceLayer(): 0x"+Long.toHexString(layerHandle));
- }
- if(!OSXUtil.AttachJAWTSurfaceLayer(dsi, layerHandle)) {
- throw new NativeWindowException("Could not attach JAWT surfaceLayerHandle: "+this);
- }
- surfaceLayerHandle = layerHandle;
- } finally {
- unlockSurface();
- }
- /*
- if( null == macosxsl) {
- throw new NativeWindowException("Not locked and/or SurfaceLayers null");
- }
- macosxsl.setLayer(layerHandle); */
- // getSurfaceLayers().setLayer(layerHandle);
- }
-
protected int lockSurfaceImpl() throws NativeWindowException {
int ret = NativeWindow.LOCK_SURFACE_NOT_READY;
if(null == ds) {
@@ -234,15 +224,24 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
Capabilities caps = (Capabilities) config.getChosenCapabilities().cloneMutable();
caps.setOnscreen(false);
config.setChosenCapabilities(caps);
+ }
+ if(0 == rootSurfaceLayerHandle) {
+ rootSurfaceLayerHandle = OSXUtil.CreateCALayer();
+ if(0 == rootSurfaceLayerHandle) {
+ OSXUtil.DestroyNSWindow(drawable);
+ drawable = 0;
+ unlockSurfaceImpl();
+ throw new NativeWindowException("Could not create root CALayer: "+this);
+ }
+ if(!OSXUtil.AttachJAWTSurfaceLayer(dsi, rootSurfaceLayerHandle)) {
+ OSXUtil.DestroyCALayer(rootSurfaceLayerHandle);
+ rootSurfaceLayerHandle = 0;
+ OSXUtil.DestroyNSWindow(drawable);
+ drawable = 0;
+ unlockSurfaceImpl();
+ throw new NativeWindowException("Could not attach JAWT surfaceLayerHandle: "+this);
+ }
}
- /**
- macosxsl = (JAWT_SurfaceLayers) dsi.platformInfo();
- if (null == macosxsl) {
- unlockSurfaceImpl();
- return NativeWindow.LOCK_SURFACE_NOT_READY;
- } else {
- ret = NativeWindow.LOCK_SUCCESS;
- } */
ret = NativeWindow.LOCK_SUCCESS;
}
@@ -261,31 +260,14 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
}
ds = null;
dsi = null;
- // macosxsl = null;
}
- /**
- protected JAWT_SurfaceLayers getSurfaceLayers() {
- if( !dsLocked || null == dsi ) {
- throw new NativeWindowException("Locked: "+dsLocked+", dsi valid: "+(null!=dsi));
- }
- final JAWT_SurfaceLayers macosxsl = (JAWT_SurfaceLayers) dsi.platformInfo();
- if (null == macosxsl) {
- throw new NativeWindowException("SurfaceLayer null");
- }
- return macosxsl;
- } */
-
private void dumpInfo() {
System.err.println("MaxOSXJAWTWindow: 0x"+Integer.toHexString(this.hashCode())+" - thread: "+Thread.currentThread().getName());
// 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 "+isOffscreenLayerSurface());
- if(null != dsi) {
- JAWT_Rectangle r = dsi.getBounds();
- System.err.println("dsi bounds: "+r.getX()+"/"+r.getY()+" "+r.getWidth()+"x"+r.getHeight());
- }
+ ", isLayeredSurface "+isOffscreenLayerSurface()+", bounds "+bounds);
// Thread.dumpStack();
}
@@ -307,10 +289,10 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
private JAWT_DrawingSurfaceInfo dsi;
private JAWT_MacOSXDrawingSurfaceInfo macosxdsi;
- // private JAWT_SurfaceLayers macosxsl;
private final boolean isOffscreenLayerSurface;
- private long surfaceLayerHandle = 0;
+ private long rootSurfaceLayerHandle = 0; // is autoreleased, once it is attached to the JAWT_SurfaceLayer
+
private long surfaceHandle = 0;
private int sscWidth, sscHeight;
private boolean sscSet = false;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index a07001def..1739288a7 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -51,7 +51,31 @@ public class OSXUtil {
DestroyNSWindow0(nsWindow);
}
+ public static long CreateCALayer() {
+ return CreateCALayer0();
+ }
+ public static void AddCASublayer(long rootCALayer, long subCALayer) {
+ if(0==rootCALayer || 0==subCALayer) {
+ throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer));
+ }
+ AddCASublayer0(rootCALayer, subCALayer);
+ }
+ public static void RemoveCASublayer(long rootCALayer, long subCALayer) {
+ if(0==rootCALayer || 0==subCALayer) {
+ throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer));
+ }
+ RemoveCASublayer0(rootCALayer, subCALayer);
+ }
+ public static void DestroyCALayer(long caLayer) {
+ if(0==caLayer) {
+ throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer));
+ }
+ DestroyCALayer0(caLayer);
+ }
public static boolean AttachJAWTSurfaceLayer(JAWT_DrawingSurfaceInfo dsi, long caLayer) {
+ if(0==caLayer) {
+ throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer));
+ }
return AttachJAWTSurfaceLayer0(dsi.getBuffer(), caLayer);
}
@@ -73,6 +97,10 @@ public class OSXUtil {
private static native void DestroyNSView0(long nsView);
private static native long CreateNSWindow0(int x, int y, int width, int height);
private static native void DestroyNSWindow0(long nsWindow);
+ private static native long CreateCALayer0();
+ private static native void AddCASublayer0(long rootCALayer, long subCALayer);
+ private static native void RemoveCASublayer0(long rootCALayer, long subCALayer);
+ private static native void DestroyCALayer0(long caLayer);
private static native boolean AttachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer);
private static native void RunOnMainThread0(boolean waitUntilDone, Runnable runnable);
private static native boolean IsMainThread0();
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 16a4ed148..7b7897701 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -39,6 +39,15 @@
#include <jawt_md.h>
#import <JavaNativeFoundation.h>
+#define VERBOSE 1
+//
+#ifdef VERBOSE
+ // #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__)
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+ #define DBG_PRINT(...)
+#endif
+
static const char * const ClazzNameRunnable = "java/lang/Runnable";
static jmethodID runnableRunID = NULL;
@@ -224,6 +233,97 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: CreateCALayer0
+ * Signature: (V)J
+ */
+JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0
+ (JNIEnv *env, jclass unused)
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ // CALayer* layer = [[CALayer alloc] init];
+ CALayer* layer = [CALayer layer];
+
+ // initial dummy size !
+ CGRect lRect = [layer frame];
+ lRect.origin.x = 0;
+ lRect.origin.y = 0;
+ lRect.size.width = 32;
+ lRect.size.height = 32;
+ [layer setFrame: lRect];
+ DBG_PRINT("CALayer::CreateCALayer0: %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
+
+ [pool release];
+
+ return (jlong) ((intptr_t) layer);
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: AddCASublayer0
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
+ (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer)
+{
+ JNF_COCOA_ENTER(env);
+ CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer);
+ CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer);
+
+ CGRect lRectRoot = [rootLayer frame];
+ // simple 1:1 layout !
+ [subLayer setFrame:lRectRoot];
+ DBG_PRINT("CALayer::AddCASublayer0.0: %p . %p %lf/%lf %lfx%lf (%lf/%lf %lfx%lf) (refcnt %d)\n",
+ rootLayer, subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]);
+ [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+ [rootLayer addSublayer:subLayer];
+ }];
+ DBG_PRINT("CALayer::AddCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);
+ JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: RemoveCASublayer0
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0
+ (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer)
+{
+ JNF_COCOA_ENTER(env);
+ CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer);
+ CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer);
+
+ DBG_PRINT("CALayer::RemoveCASublayer0.0: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);
+ [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+ [subLayer removeFromSuperlayer];
+ // [[rootLayer sublayers] makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
+ }];
+ DBG_PRINT("CALayer::RemoveCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]);
+ JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: DestroyCALayer0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0
+ (JNIEnv *env, jclass unused, jlong caLayer)
+{
+ JNF_COCOA_ENTER(env);
+ CALayer* layer = (CALayer*) ((intptr_t) caLayer);
+
+ DBG_PRINT("CALayer::DestroyCALayer0.0: %p (refcnt %d)\n", layer, (int)[layer retainCount]);
+ [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+ [layer release]; // performs release!
+ }];
+ DBG_PRINT("CALayer::DestroyCALayer0.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]);
+ JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
* Method: attachJAWTSurfaceLayer
* Signature: (JJ)Z
*/
@@ -239,8 +339,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AttachJAWTSur
CALayer* layer = (CALayer*) (intptr_t) caLayer;
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo;
+ DBG_PRINT("CALayer::attachJAWTSurfaceLayer: %p -> %p\n", surfaceLayers.layer, layer);
surfaceLayers.layer = [layer autorelease];
- // surfaceLayers.layer = layer; // FIXME: JAU
}];
JNF_COCOA_EXIT(env);
return JNI_TRUE;