|
From: <ka...@us...> - 2011-11-12 19:01:34
|
Revision: 3691
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3691&view=rev
Author: kappa1
Date: 2011-11-12 19:01:28 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
MacOS: remove the use of 'Blocks' in the Cocoa native code by switching to 'Selectors', should allow natives to be binary compatible with OS X 10.5 now.
Modified Paths:
--------------
trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m
Modified: trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m
===================================================================
--- trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m 2011-11-10 18:46:43 UTC (rev 3690)
+++ trunk/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m 2011-11-12 19:01:28 UTC (rev 3691)
@@ -62,7 +62,22 @@
@end
+// forward declaration
+@interface AttachLayerOnMainThread : NSObject {
+ MacOSXPeerInfo *peer_info;
+ JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi;
+}
+- (void) attachLayer;
+
+- (MacOSXPeerInfo*) peer_info;
+- (JAWT_MacOSXDrawingSurfaceInfo) macosx_dsi;
+
+- (void) setPeer_info: (MacOSXPeerInfo*)input;
+- (void) setMacosx_dsi: (JAWT_MacOSXDrawingSurfaceInfo*)input;
+
+@end
+
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
(JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle, jboolean allowCALayer) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -97,18 +112,15 @@
}
if (macosx_dsi != NULL) {
- [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
- // attach the "root layer" to the AWT Canvas surface layers
- id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)macosx_dsi;//dsi->platformInfo;
- if(surfaceLayers.layer == NULL) {
- PBufferGLLayer *caGLLayer = [[PBufferGLLayer new] autorelease];
- caGLLayer.peer_info = peer_info;
- caGLLayer.asynchronous = YES;
- caGLLayer.needsDisplayOnBoundsChange = YES;
- caGLLayer.opaque = YES;
- surfaceLayers.layer = caGLLayer;
- }
- }];
+
+ AttachLayerOnMainThread *attachLayerOnMainThread = [[AttachLayerOnMainThread new] autorelease];
+ attachLayerOnMainThread.peer_info = peer_info;
+ attachLayerOnMainThread.macosx_dsi = macosx_dsi;
+
+ [JNFRunLoop performOnMainThread:@selector(attachLayer)
+ on:attachLayerOnMainThread
+ withObject:nil
+ waitUntilDone:YES];
}
[pool release];
@@ -122,6 +134,40 @@
[pool release];
}
+// Object class to CALayer on AppKit Thread
+@implementation AttachLayerOnMainThread
+
+- (void) attachLayer {
+ // attach the "root layer" to the AWT Canvas surface layers
+ id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)macosx_dsi;//dsi->platformInfo;
+ if(surfaceLayers.layer == NULL) {
+ PBufferGLLayer *caGLLayer = [[PBufferGLLayer new] autorelease];
+ caGLLayer.peer_info = peer_info;
+ caGLLayer.asynchronous = YES;
+ caGLLayer.needsDisplayOnBoundsChange = YES;
+ caGLLayer.opaque = YES;
+ surfaceLayers.layer = caGLLayer;
+ }
+}
+
+- (MacOSXPeerInfo*) peer_info {
+ return peer_info;
+}
+
+- (JAWT_MacOSXDrawingSurfaceInfo*) macosx_dsi {
+ return macosx_dsi;
+}
+
+- (void) setPeer_info: (MacOSXPeerInfo*)input {
+ peer_info = input;
+}
+
+- (void) setMacosx_dsi: (JAWT_MacOSXDrawingSurfaceInfo*)input {
+ macosx_dsi = input;
+}
+
+@end
+
// rotates a red square when asked to draw
@implementation PBufferGLLayer
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|