Limit the use to CALayer only to when using Display.setParent(), an AWTGLCanvas in non fullscreen mode.

This commit is contained in:
kappa1 2011-10-11 22:30:55 +00:00
parent c9cac6406b
commit c5eadd89a0
4 changed files with 59 additions and 52 deletions

View file

@ -79,14 +79,17 @@ final class AWTSurfaceLock {
// http://192.18.37.44/forums/index.php?topic=10572 for a discussion.
// It is only needed on first call, so we avoid it on all subsequent calls
// due to performance..
final Canvas parent = component instanceof AWTGLCanvas ? component : Display.getParent();
// Allow the use of a Core Animation Layer only when using Display.setParent() or AWTGLCanvas and when not in fullscreen
final boolean allowCALayer = (Display.getParent() != null || component instanceof AWTGLCanvas) && !Display.isFullscreen();
if (firstLockSucceeded)
return lockAndInitHandle(lock_buffer, component, parent);
return lockAndInitHandle(lock_buffer, component, allowCALayer);
else
try {
firstLockSucceeded = AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
public Boolean run() throws LWJGLException {
return lockAndInitHandle(lock_buffer, component, parent);
return lockAndInitHandle(lock_buffer, component, allowCALayer);
}
});
return firstLockSucceeded;
@ -95,7 +98,7 @@ final class AWTSurfaceLock {
}
}
private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component, Canvas display_parent) throws LWJGLException;
private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component, boolean allowCALayer) throws LWJGLException;
void unlock() throws LWJGLException {
nUnlock(lock_buffer);

View file

@ -50,9 +50,12 @@ abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
}
protected void initHandle(Canvas component) throws LWJGLException {
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle());
// Allow the use of a Core Animation Layer only when using Display.setParent() or AWTGLCanvas and when not in fullscreen
final boolean allowCALayer = (Display.getParent() != null || component instanceof AWTGLCanvas) && !Display.isFullscreen();
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), allowCALayer);
}
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 allowCALayer) throws LWJGLException;
protected void doUnlock() throws LWJGLException {
awt_surface.unlock();