diff options
author | Sven Gothel <[email protected]> | 2001-07-24 12:07:18 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2001-07-24 12:07:18 +0000 |
commit | 3583101e586a6fe3306f84d4d34ee764596e0632 (patch) | |
tree | d5c228654f882fa0f0c6214e6d4866ce44181b89 /CNativeCode | |
parent | c9eae90cb823d918ecc4bf5afa73ce3a0859d578 (diff) |
optimized context switchingrel-2-8-0-0-prerelease-3
Diffstat (limited to 'CNativeCode')
-rwxr-xr-x | CNativeCode/OpenGL_Win32.c | 26 | ||||
-rwxr-xr-x | CNativeCode/OpenGL_Win32_jawt.c | 69 | ||||
-rw-r--r-- | CNativeCode/OpenGL_X11.c | 26 | ||||
-rw-r--r-- | CNativeCode/OpenGL_X11_jawt.c | 110 | ||||
-rw-r--r-- | CNativeCode/OpenGL_misc.c | 9 |
5 files changed, 205 insertions, 35 deletions
diff --git a/CNativeCode/OpenGL_Win32.c b/CNativeCode/OpenGL_Win32.c index 6213fdd..8e888e3 100755 --- a/CNativeCode/OpenGL_Win32.c +++ b/CNativeCode/OpenGL_Win32.c @@ -66,6 +66,32 @@ Java_gl4java_GLContext_hasJAWTSurfaceChanged( JNIEnv *env, jobject obj, }
JNIEXPORT jboolean JNICALL
+Java_gl4java_GLContext_lockJAWT( JNIEnv *env, jobject obj,
+ jobject canvas,
+ jlong thisWin, jboolean verbose
+ )
+{
+ (void) env;
+ (void) obj;
+ (void) canvas;
+ (void) thisWin;
+ (void) verbose;
+ return JNI_TRUE;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gl4java_GLContext_unlockJAWT( JNIEnv *env, jobject obj,
+ jlong thisWin, jboolean verbose
+ )
+{
+ (void) env;
+ (void) obj;
+ (void) thisWin;
+ (void) verbose;
+ return JNI_TRUE;
+}
+
+JNIEXPORT jboolean JNICALL
Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj,
jobject canvas)
{
diff --git a/CNativeCode/OpenGL_Win32_jawt.c b/CNativeCode/OpenGL_Win32_jawt.c index 5eefec3..2f69ad7 100755 --- a/CNativeCode/OpenGL_Win32_jawt.c +++ b/CNativeCode/OpenGL_Win32_jawt.c @@ -92,6 +92,71 @@ Java_gl4java_GLContext_hasJAWTSurfaceChanged( JNIEnv *env, jobject obj, } JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_lockJAWT( JNIEnv *env, jobject obj, + jobject canvas, + jlong thisWin, jboolean verbose + ) +{ + jboolean ret = JNI_TRUE; + JAWTDataHolder * pData = (JAWTDataHolder *) ( (PointerHolder) thisWin ); + + if(pData==0) + { + fprintf(stderr, "GL4Java ERROR: LockAWT NO JAWT Holder exist ! (pData=%p, thisWin=%lX) ...\n", pData, (long)thisWin); + fflush(stderr); + return JNI_FALSE; + } + + if(jawt_open(env, canvas, pData, verbose)==JNI_FALSE || + pData->result==JNI_FALSE + ) + { + fprintf(stderr,"\nGL4Java ERROR: LockAWT could not open JAWT reference!\n"); + fflush(stderr); + ret=JNI_FALSE; + jawt_close_unlock(env, pData, JNI_FALSE); + return ret; + } + + if(jawt_lock(env, pData, JNI_FALSE, verbose)==JNI_FALSE || + pData->result==JNI_FALSE + ) + { + /* this can happen: + if ( (pJData->lock & JAWT_LOCK_SURFACE_CHANGED) != 0 ) + + In this case, we need a new GLXContext ... + + This has to be queried by the java class, + while using the native method hasJAWTSurfaceChanged ! + */ + if(verbose) + { + fprintf(stderr,"\nGL4Java ERROR: LockAWT could not lock JAWT reference!\n"); + fflush(stderr); + } + ret=JNI_FALSE; + jawt_close_unlock(env, pData, JNI_FALSE); + return ret; + } + return ret; +} + +JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_unlockJAWT( JNIEnv *env, jobject obj, + jlong thisWin, jboolean verbose + ) +{ + jboolean ret = JNI_TRUE; + JAWTDataHolder * pData = (JAWTDataHolder *) ( (PointerHolder) thisWin ); + + jawt_close_unlock(env, pData, verbose); + + return ret; +} + + +JNIEXPORT jboolean JNICALL Java_gl4java_GLContext_openOpenGLNative( JNIEnv *env, jobject obj, jobject canvas) { @@ -489,7 +554,7 @@ Java_gl4java_GLContext_gljFreeNative( JNIEnv *env, jobject obj, } if(pData!=NULL) - jawt_close_unlock(env, pData, verbose); + jawt_close_unlock(env, pData, JNI_FALSE); return ret; } @@ -642,7 +707,7 @@ Java_gl4java_GLContext_gljDestroyNative( JNIEnv *env, jobject obj, gc = 0; thisWin = 0; - jawt_free_close_unlock(env, &pData, verbose); + jawt_free_close_unlock(env, &pData, JNI_FALSE); pData=0; ret=JNI_TRUE; // force .. diff --git a/CNativeCode/OpenGL_X11.c b/CNativeCode/OpenGL_X11.c index 14510ec..f95ee8a 100644 --- a/CNativeCode/OpenGL_X11.c +++ b/CNativeCode/OpenGL_X11.c @@ -102,6 +102,32 @@ Java_gl4java_GLContext_hasJAWTSurfaceChanged( JNIEnv *env, jobject obj, return JNI_FALSE; } +JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_lockJAWT( JNIEnv *env, jobject obj, + jobject canvas, + jlong thisWin, jboolean verbose + ) +{ + (void) env; + (void) obj; + (void) canvas; + (void) thisWin; + (void) verbose; + return JNI_TRUE; +} + +JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_unlockJAWT( JNIEnv *env, jobject obj, + jlong thisWin, jboolean verbose + ) +{ + (void) env; + (void) obj; + (void) thisWin; + (void) verbose; + return JNI_TRUE; +} + /* * OpenGL_GLFrame_openOpenGL * diff --git a/CNativeCode/OpenGL_X11_jawt.c b/CNativeCode/OpenGL_X11_jawt.c index bb91c5c..21231ef 100644 --- a/CNativeCode/OpenGL_X11_jawt.c +++ b/CNativeCode/OpenGL_X11_jawt.c @@ -125,17 +125,6 @@ Java_gl4java_GLContext_useJAWT( JNIEnv *env, jobject obj ) return JNI_TRUE; } -JNIEXPORT jboolean JNICALL -Java_gl4java_GLContext_hasJAWTSurfaceChanged( JNIEnv *env, jobject obj, - jlong thisWin ) -{ - JAWTDataHolder * pData = (JAWTDataHolder *) ( (PointerHolder) thisWin ); - (void)env; - (void)obj; - - return (pData->lock & JAWT_LOCK_SURFACE_CHANGED) != 0 ; -} - /* * OpenGL_GLFrame_openOpenGL * @@ -579,6 +568,82 @@ Java_gl4java_GLContext_gljResizeNative( JNIEnv *env, jobject obj, } JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_hasJAWTSurfaceChanged( JNIEnv *env, jobject obj, + jlong thisWin ) +{ + JAWTDataHolder * pData = (JAWTDataHolder *) ( (PointerHolder) thisWin ); + (void)env; + (void)obj; + + return (pData->lock & JAWT_LOCK_SURFACE_CHANGED) != 0 ; +} + +JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_lockJAWT( JNIEnv *env, jobject obj, + jobject canvas, + jlong thisWin, jboolean verbose + ) +{ + jboolean ret = JNI_TRUE; + JAWTDataHolder * pData = (JAWTDataHolder *) ( (PointerHolder) thisWin ); + + if(pData==0) + { + fprintf(stderr, "GL4Java ERROR: LockAWT NO JAWT Holder exist ! (pData=%p, thisWin=%lX) ...\n", pData, (long)thisWin); + fflush(stderr); + return JNI_FALSE; + } + + if(jawt_open(env, canvas, pData, verbose)==JNI_FALSE || + pData->result==JNI_FALSE + ) + { + fprintf(stderr,"\nGL4Java ERROR: LockAWT could not open JAWT reference!\n"); + fflush(stderr); + ret=JNI_FALSE; + jawt_close_unlock(env, pData, JNI_FALSE); + return ret; + } + + if(jawt_lock(env, pData, JNI_FALSE, verbose)==JNI_FALSE || + pData->result==JNI_FALSE + ) + { + /* this can happen: + if ( (pJData->lock & JAWT_LOCK_SURFACE_CHANGED) != 0 ) + + In this case, we need a new GLXContext ... + + This has to be queried by the java class, + while using the native method hasJAWTSurfaceChanged ! + */ + if(verbose) + { + fprintf(stderr,"\nGL4Java ERROR: LockAWT could not lock JAWT reference!\n"); + fflush(stderr); + } + ret=JNI_FALSE; + jawt_close_unlock(env, pData, JNI_FALSE); + return ret; + } + return ret; +} + +JNIEXPORT jboolean JNICALL +Java_gl4java_GLContext_unlockJAWT( JNIEnv *env, jobject obj, + jlong thisWin, jboolean verbose + ) +{ + jboolean ret = JNI_TRUE; + JAWTDataHolder * pData = (JAWTDataHolder *) ( (PointerHolder) thisWin ); + + jawt_close_unlock(env, pData, verbose); + + return ret; +} + + +JNIEXPORT jboolean JNICALL Java_gl4java_GLContext_gljMakeCurrentNative( JNIEnv *env, jobject obj, jobject canvas, jlong disp, @@ -592,14 +657,14 @@ Java_gl4java_GLContext_gljMakeCurrentNative( JNIEnv *env, jobject obj, if(pData==0) { - fprintf(stderr, "GL4Java ERROR: gljUse NO JAWT Holder exist ! (pData=%p, thisWin=%lX) ...\n", pData, (long)thisWin); + fprintf(stderr, "GL4Java ERROR: MakeCurrent NO JAWT Holder exist ! (pData=%p, thisWin=%lX) ...\n", pData, (long)thisWin); fflush(stderr); return JNI_FALSE; } if(glContext==0) { - fprintf(stderr, "GL4Java ERROR: gljUse NO actual GC was created ...\n"); + fprintf(stderr, "GL4Java ERROR: MakeCurrent NO actual GC was created ...\n"); fflush(stderr); return JNI_FALSE; } @@ -682,26 +747,13 @@ Java_gl4java_GLContext_gljFreeNative( JNIEnv *env, jobject obj, } } - jawt_close_unlock(env, pData, verbose); + if(pData!=NULL) + jawt_close_unlock(env, pData, JNI_FALSE); return ret; } JNIEXPORT jboolean JNICALL -Java_gl4java_GLContext_gljIsContextCurrentNative( JNIEnv *env, jobject obj, - jlong glContext - ) -{ - GLXContext ctx = disp__glXGetCurrentContext(); - - if(ctx==(GLXContext)((PointerHolder)glContext)) - return JNI_TRUE; - - return JNI_FALSE; -} - - -JNIEXPORT jboolean JNICALL Java_gl4java_GLContext_gljDestroyNative( JNIEnv *env, jobject obj, jobject canvas ) { @@ -846,7 +898,7 @@ Java_gl4java_GLContext_gljDestroyNative( JNIEnv *env, jobject obj, } } - jawt_free_close_unlock(env, &pData, verbose); + jawt_free_close_unlock(env, &pData, JNI_FALSE); if(ret==JNI_TRUE) { diff --git a/CNativeCode/OpenGL_misc.c b/CNativeCode/OpenGL_misc.c index fabd968..ff00cce 100644 --- a/CNativeCode/OpenGL_misc.c +++ b/CNativeCode/OpenGL_misc.c @@ -6,6 +6,7 @@ #include <GL/glx.h> #include <dlfcn.h> #include "glxtool.h" + #include <unistd.h> #endif #ifdef _WIN32_ @@ -863,17 +864,17 @@ Java_gl4java_GLContext_gljTestGLProc ( } -JNIEXPORT jint JNICALL +JNIEXPORT jlong JNICALL Java_gl4java_GLContext_gljGetCurrentContext( JNIEnv *env, jobject obj ) { #ifdef _WIN32_ - return (jint) disp__wglGetCurrentContext(); + return (jlong) ((PointerHolder)disp__wglGetCurrentContext()); #else #ifdef _MAC_OS9_ - return (jint) aglGetCurrentContext(); + return (jlong) ((PointerHolder)aglGetCurrentContext()); #else - return (jint) disp__glXGetCurrentContext(); + return (jlong) ((PointerHolder)disp__glXGetCurrentContext()); #endif #endif } |