Fix Display.setParent() on Java 7 by forcing CALayer usage as

classic NSView method is no long available.
This commit is contained in:
kappaOne 2013-01-31 23:01:19 +00:00
parent 0d25914029
commit b27754089a
2 changed files with 15 additions and 5 deletions

View File

@ -51,9 +51,19 @@ abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
}
protected void initHandle(Canvas component) throws LWJGLException {
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
boolean forceCALayer = true;
String javaVersion = System.getProperty("java.version");
if (javaVersion.startsWith("1.5") || javaVersion.startsWith("1.6")) {
// On Java 7 and newer CALayer mode is the only way to use OpenGL with AWT
// therefore force it on all JVM's except for the older Java 5 and Java 6
// where the older cocoaViewRef NSView method maybe be available.
forceCALayer = false;
}
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), forceCALayer);
}
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle, boolean forceCALayer) throws LWJGLException;
protected void doUnlock() throws LWJGLException {
awt_surface.unlock();

View File

@ -47,15 +47,15 @@
#include "common_tools.h"
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
(JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle) {
(JNIEnv *env, jclass clazz, jobject lock_buffer_handle, jobject peer_info_handle, jboolean forceCALayer) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi = (JAWT_MacOSXDrawingSurfaceInfo *)surface->dsi->platformInfo;
// check for CALayer support
if(surface->awt.version & 0x80000000) { //JAWT_MACOSX_USE_CALAYER) {
// force CALayer usage or check if CALayer is supported (i.e. on Java 5 and Java 6)
if(forceCALayer || (surface->awt.version & 0x80000000)) { //JAWT_MACOSX_USE_CALAYER) {
if (macosx_dsi != NULL) {
if (peer_info->isCALayer) {