Linux: moved handle allocations to native

This commit is contained in:
Elias Naur 2005-02-22 13:59:33 +00:00
parent 47814d58f4
commit 9a764b3d33
5 changed files with 61 additions and 15 deletions

View file

@ -43,20 +43,16 @@ import org.lwjgl.BufferUtils;
* @version $Revision$
*/
final class LinuxContextImplementation implements ContextImplementation {
private final static int HANDLE_SIZE = 64;
private static PeerInfo getCurrentPeerInfo() {
return Context.getCurrentContext().getPeerInfo();
}
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE);
LinuxDisplay.lockAWT();
try {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
nCreate(peer_handle, handle, shared_context_handle);
return handle;
return nCreate(peer_handle, shared_context_handle);
} finally {
peer_info.unlock();
}
@ -65,7 +61,7 @@ final class LinuxContextImplementation implements ContextImplementation {
}
}
private static native void nCreate(ByteBuffer peer_handle, ByteBuffer context_handle, ByteBuffer shared_context_handle) throws LWJGLException;
private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
public void swapBuffers() throws LWJGLException {
PeerInfo current_peer_info = getCurrentPeerInfo();

View file

@ -44,9 +44,8 @@ import org.lwjgl.Sys;
* @version $Revision$
*/
abstract class LinuxPeerInfo extends PeerInfo {
private static final int PEER_HANDLE_SIZE = 64;
public LinuxPeerInfo() {
super(BufferUtils.createByteBuffer(PEER_HANDLE_SIZE));
super(createHandle());
}
private static native ByteBuffer createHandle();
}